All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled
@ 2015-10-13 19:42 Sai Praneeth Prakhya
       [not found] ` <1444765377-29303-1-git-send-email-sai.praneeth.prakhya-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Sai Praneeth Prakhya @ 2015-10-13 19:42 UTC (permalink / raw)
  To: linux-efi
  Cc: matt.fleming, bp, linux-kernel, Sai Praneeth, Ricardo Neri,
	Glenn P Williamson, Ravi Shankar

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

When CONFIG_DEBUG_VIRTUAL is turned on, all accesses to __pa(address)
are monitored to see whether address falls in direct mapping or kernel
mapping, if it does not kernel panics. During 1:1 mapping of EFI runtime
services we access addresses which are below 4G and hence when passed as
arguments to __pa() kernel panics as reported by Dave Hansen here
https://lkml.org/lkml/2015/1/27/742. 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 direct kernel mappings and not 1:1 mappings.

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

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 727158cb3b3c..3a603830503a 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -648,9 +648,11 @@ __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)) {
+		if (pfn_range_is_mapped(PFN_DOWN(__pa(address)),
+					PFN_DOWN(__pa(address)) + 1))
+			split_page_count(level);
+	}
 
 	/*
 	 * Install the new, split up pagetable.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [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
  0 siblings, 1 reply; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2015-10-25 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 19:42 [PATCH] x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled Sai Praneeth Prakhya
     [not found] ` <1444765377-29303-1-git-send-email-sai.praneeth.prakhya-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-10-14 14:41   ` Borislav Petkov
2015-10-14 14:41     ` Borislav Petkov
  -- strict thread matches above, loose matches on Subject: below --
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

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.