All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
To: Sahibzada Irfanullah <irfan.gomalian@gmail.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: Fwd: Need Help regarding Reading and Writting to a file from kernel function file
Date: Tue, 24 Sep 2019 04:48:59 -0400	[thread overview]
Message-ID: <233594.1569314939@turing-police> (raw)
In-Reply-To: <CAGaWEbr96h+Bi4qmP-1Wse+wk=r4Us3CeDY3AXO6xR+_QceNKw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1026 bytes --]

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.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2019-09-24  8:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGaWEbomboZ=MCT4GaKj+5tUNDGc5ZknvhLTikCPSWpjY5E7hA@mail.gmail.com>
2019-09-24  7:10 ` Fwd: Need Help regarding Reading and Writting to a file from kernel function file Sahibzada Irfanullah
2019-09-24  7:35   ` Greg KH
2019-09-24  8:48   ` Valdis Klētnieks [this message]
2019-09-24  9:51     ` Saket Sinha
2019-09-24 13:32       ` Greg KH
2019-09-24 10:02     ` Martin Christian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=233594.1569314939@turing-police \
    --to=valdis.kletnieks@vt.edu \
    --cc=irfan.gomalian@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.