Fwd: Need Help regarding Reading and Writting to a file from kernel function file

Saket Sinha saket.sinha89 at gmail.com
Tue Sep 24 05:51:57 EDT 2019


Hi,

I am sorry but I am really tempted to share -
https://www.linuxjournal.com/article/8110

But as suggested, you should never try this.

Regards,
Saket Sinha

On Tue, Sep 24, 2019 at 10:50 AM Valdis Klētnieks
<valdis.kletnieks at vt.edu> wrote:
>
> On Tue, 24 Sep 2019 16:10:07 +0900, Sahibzada Irfanullah said:
>
> > subject line. The problem is:  I am trying to write/read page faulted
> > physical addresses to a file in a kernel (v5.3-1) function, i.e.,
> > handle_ept_violation() which is present in vmx.c. I have followed this
> > <https://stackoverflow.com/questions/1184274/read-write-files-within-a-linux-kernel-module>,
>
> Just because somebody on stackoverflow gave a guide doesn't mean it's
> a good idea.
>
> What problem are you trying to solve here?  Are you trying to write the faulted
> pages themselves to a file?  In that case, just creating the file, using something like
> 'dd if=/dev/zero of=/your/file/here bs=1M count=4096' and then using mkswap
> and swapon will probably work much better.
>
> If you're trying to produce a trace of what pages are being faulted, you can
> probably do a better job by using 'perf' to produce trace events with a lot of
> added data for you, or use debugfs or netlink and a userspace program to read
> the data and write it to disk from userspace.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list