Skip to contentSkip to conversation

EFI changes for v4.4

GIT PULL New Matt Fleming 2 participants 3 messages Oct 25, 2015 – Oct 27, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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/[email protected]

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(-)
#1 lore raw

PATCH 1/1 x86/efi: Fix kernel panic when CONFIG_DEBUG_VIRTUAL is enabled

From: Sai Praneeth <[email protected]>

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/[email protected].

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.

---
 arch/x86/mm/pageattr.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/mm/pageattr.c +6 -3
index 727158cb3b3c..9abe0c9b1098 100644
@@ -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.
Signature · 1 line
2.6.0
#2 lore raw
In reply to Matt Fleming
Quoted 31 lines · Matt Fleming

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/[email protected]

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

Quoted 6 lines

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