stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <matt@codeblueprint.co.uk>
To: Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H . Peter Anvin" <hpa@zytor.com>
Cc: Toshi Kani <toshi.kani@hp.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
	stable@vger.kernel.org, Dave Hansen <dave.hansen@intel.com>
Subject: [PATCH 1/6] x86/efi: PFN_ALIGN() _text and _end when calculating number of pages
Date: Mon, 23 Nov 2015 13:33:09 +0000	[thread overview]
Message-ID: <1448285594-17617-2-git-send-email-matt@codeblueprint.co.uk> (raw)
In-Reply-To: <1448285594-17617-1-git-send-email-matt@codeblueprint.co.uk>

While _text is currently aligned to PAGE_SIZE in the vmlinux linker
script because it's based on CONFIG_PHYSICAL_ALIGN, it's always better
to be explicit about these things to be sure no alignment bugs are
lurking. There's no analogous enforcement for _end.

Dave provided an example of why the 'npages' calculation is wrong,

 "Just for fun, imagine that _end=0xfff and _text=0x1001.  npages
  would be 0."

Use PFN_ALIGN() to be sure the calculation is correctly aligned to
PAGE_SIZE.

Reported-by: Dave Hansen <dave.hansen@intel.com>
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/x86/platform/efi/efi_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index a0ac0f9c307f..3a90eb72d153 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -183,7 +183,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 	efi_scratch.phys_stack = virt_to_phys(page_address(page));
 	efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
 
-	npages = (_end - _text) >> PAGE_SHIFT;
+	npages = (PFN_ALIGN(_end) - PFN_ALIGN(_text)) >> PAGE_SHIFT;
 	text = __pa(_text);
 
 	if (kernel_map_pages_in_pgd(pgd, text >> PAGE_SHIFT, text, npages, 0)) {
-- 
2.6.2


  reply	other threads:[~2015-11-23 13:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 13:33 [GIT PULL v3 0/6] EFI page table isolation Matt Fleming
2015-11-23 13:33 ` Matt Fleming [this message]
2015-11-24  8:23   ` [PATCH 1/6] x86/efi: PFN_ALIGN() _text and _end when calculating number of pages Ingo Molnar
2015-11-24 10:55     ` Matt Fleming
2015-11-26 11:13       ` Ingo Molnar
2015-11-27 21:05         ` Matt Fleming

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=1448285594-17617-2-git-send-email-matt@codeblueprint.co.uk \
    --to=matt@codeblueprint.co.uk \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=toshi.kani@hp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).