linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] EFI changes for v4.4
@ 2015-10-25 10:49 Matt Fleming
  2015-10-25 10:49 ` [PATCH] x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled Matt Fleming
       [not found] ` <1445770144-22280-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Fleming @ 2015-10-25 10:49 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Matt Fleming, linux-kernel, linux-efi, Borislav Petkov,
	Dave Hansen, Glenn P Williamson, Ravi Shankar, Ricardo Neri,
	Sai Praneeth Prakhya

Folks, please pull the following bugfix from Sai which prevents a
kernel panic when booting an EFI machine with CONFIG_DEBUG_VIRTUAL
enabled.

This bug was reported last year by Dave Hansen,

  https://lkml.kernel.org/r/5462999A.7090706@intel.com

and since nobody else has reported it, and given that it's only
triggerable with a debug config option, I figured this should be
targeted at v4.4.

The following changes since commit 0f96a99dab366333439e110d6ad253bc7c557c09:

  efi: Add "efi_fake_mem" boot option (2015-10-12 14:20:09 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-next

for you to fetch changes up to 2c66e24d75d424919c42288b418d2e593fa818b1:

  x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled (2015-10-25 10:22:25 +0000)

----------------------------------------------------------------
 * Fix a kernel panic by not passing EFI virtual mapping addresses to
   __pa() in the x86 pageattr code. Since these virtual addreses are
  not part of the direct mapping or kernel text mapping, passing them
  to __pa() will trigger a BUG_ON() when CONFIG_DEBUG_VIRTUAL is
  enabled - Sai Praneeth Prakhya

----------------------------------------------------------------
Sai Praneeth (1):
      x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled

 arch/x86/mm/pageattr.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled
  2015-10-25 10:49 [GIT PULL] EFI changes for v4.4 Matt Fleming
@ 2015-10-25 10:49 ` Matt Fleming
       [not found] ` <1445770144-22280-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Fleming @ 2015-10-25 10:49 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Sai Praneeth, linux-kernel, linux-efi, Ricardo Neri,
	Glenn P Williamson, Ravi Shankar, Matt Fleming, Borislav Petkov,
	Dave Hansen

From: Sai Praneeth <sai.praneeth.prakhya@intel.com>

When CONFIG_DEBUG_VIRTUAL is enabled, all accesses to __pa(address) are
monitored to see whether address falls in direct mapping or kernel text
mapping (see Documentation/x86/x86_64/mm.txt for details), if it does
not, the kernel panics. During 1:1 mapping of EFI runtime services we access
virtual addresses which are == physical addresses, thus the 1:1 mapping
and these addresses do not fall in either of the above two regions and
hence when passed as arguments to __pa() kernel panics as reported by
Dave Hansen here https://lkml.kernel.org/r/5462999A.7090706@intel.com.

So, before calling __pa() virtual addresses should be validated which
results in skipping call to split_page_count() and that should be fine
because it is used to keep track of everything *but* 1:1 mappings.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Reported-by: Dave Hansen <dave.hansen@intel.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Ricardo Neri <ricardo.neri@intel.com>
Cc: Glenn P Williamson <glenn.p.williamson@intel.com>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/x86/mm/pageattr.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 727158cb3b3c..9abe0c9b1098 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -648,9 +648,12 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address,
 	for (i = 0; i < PTRS_PER_PTE; i++, pfn += pfninc)
 		set_pte(&pbase[i], pfn_pte(pfn, canon_pgprot(ref_prot)));
 
-	if (pfn_range_is_mapped(PFN_DOWN(__pa(address)),
-				PFN_DOWN(__pa(address)) + 1))
-		split_page_count(level);
+	if (virt_addr_valid(address)) {
+		unsigned long pfn = PFN_DOWN(__pa(address));
+
+		if (pfn_range_is_mapped(pfn, pfn + 1))
+			split_page_count(level);
+	}
 
 	/*
 	 * Install the new, split up pagetable.
-- 
2.6.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [GIT PULL] EFI changes for v4.4
       [not found] ` <1445770144-22280-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
@ 2015-10-27 17:41   ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2015-10-27 17:41 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Thomas Gleixner, H . Peter Anvin,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Borislav Petkov, Dave Hansen,
	Glenn P Williamson, Ravi Shankar, Ricardo Neri,
	Sai Praneeth Prakhya


* Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> wrote:

> Folks, please pull the following bugfix from Sai which prevents a
> kernel panic when booting an EFI machine with CONFIG_DEBUG_VIRTUAL
> enabled.
> 
> This bug was reported last year by Dave Hansen,
> 
>   https://lkml.kernel.org/r/5462999A.7090706-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
> 
> and since nobody else has reported it, and given that it's only
> triggerable with a debug config option, I figured this should be
> targeted at v4.4.
> 
> The following changes since commit 0f96a99dab366333439e110d6ad253bc7c557c09:
> 
>   efi: Add "efi_fake_mem" boot option (2015-10-12 14:20:09 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-next
> 
> for you to fetch changes up to 2c66e24d75d424919c42288b418d2e593fa818b1:
> 
>   x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled (2015-10-25 10:22:25 +0000)
> 
> ----------------------------------------------------------------
>  * Fix a kernel panic by not passing EFI virtual mapping addresses to
>    __pa() in the x86 pageattr code. Since these virtual addreses are
>   not part of the direct mapping or kernel text mapping, passing them
>   to __pa() will trigger a BUG_ON() when CONFIG_DEBUG_VIRTUAL is
>   enabled - Sai Praneeth Prakhya
> 
> ----------------------------------------------------------------
> Sai Praneeth (1):
>       x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled
> 
>  arch/x86/mm/pageattr.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Pulled, thanks Matt!

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-27 17:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-25 10:49 [GIT PULL] EFI changes for v4.4 Matt Fleming
2015-10-25 10:49 ` [PATCH] x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled Matt Fleming
     [not found] ` <1445770144-22280-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-10-27 17:41   ` [GIT PULL] EFI changes for v4.4 Ingo Molnar

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).