All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Laszlo Ersek <lersek@redhat.com>
Cc: Matt Fleming <matt@console-pimps.org>,
	edk2-devel@lists.sourceforge.net,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [edk2] SetVirtualAddressMap and NX bit
Date: Thu, 1 Aug 2013 19:27:36 +0200	[thread overview]
Message-ID: <20130801172736.GC7445@pd.tnic> (raw)
In-Reply-To: <51F8FE9C.6070207@redhat.com>

+ Matt.

On Wed, Jul 31, 2013 at 02:10:04PM +0200, Laszlo Ersek wrote:
> Just random ideas...

First of all, thanks for looking. You made me look too and find the fun
:-)

The fact that you guys didn't say "Oh yeah, we do this because... " but
simply shruggingly suggested ideas should've been enough to give me the
hint to look in our own backyard and maybe to permit the possibility of
the kernel doing something funny. And it does, indeed!

And for that you need to look at SetVirtualAddressMap() itself or
rather, how we call it:

phys_efi_set_virtual_address_map
|-> efi_call_phys_prelog
|-> efi_call_phys4(efi_phys.set_virtual_address_map
|-> efi_call_phys_epilog

Now guess what those pre- and epi- things do. Right:

efi_call_phys_prelog does early_code_mapping_set_exec(1) and
efi_call_phys_epilog does early_code_mapping_set_exec(0) and we end up
with that PTE's NX bit set:

before:
> [   47.379000] __lookup_address_in_pgd:         pte: 0x7fb12063 (0xffff88007c823b68)

after:
> [   47.393000] __lookup_address_in_pgd:         pte: 0x800000007fb12163 (0xffff88007c823b68)

What is still missing from the big picture is why the PTE in my
pagetable (not the kernel's pagetable) gets that bit set??

I mean, the EFI code is using pgd_offset_k() which looks at init_mm and
my PGD is a different one. And I guess the explanation for that would
also clarify why this doesn't happen on baremetal so probably it has
something to do with the nested page table thingy.

Oh well...

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

      reply	other threads:[~2013-08-01 23:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20130716151236.GF4402@pd.tnic>
2013-07-31 12:10 ` [Qemu-devel] [edk2] SetVirtualAddressMap and NX bit Laszlo Ersek
2013-08-01 17:27   ` Borislav Petkov [this message]

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=20130801172736.GC7445@pd.tnic \
    --to=bp@alien8.de \
    --cc=edk2-devel@lists.sourceforge.net \
    --cc=lersek@redhat.com \
    --cc=matt@console-pimps.org \
    --cc=qemu-devel@nongnu.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.