All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL 0/3] EFI fixes for v5.5
@ 2019-12-24 13:29 Ard Biesheuvel
  2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2019-12-24 13:29 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: Ard Biesheuvel, linux-kernel, Arvind Sankar, Hans de Goede

The following changes since commit a470552ee8965da0fe6fd4df0aa39c4cda652c7c:

  efi: Don't attempt to map RCI2 config table if it doesn't exist (2019-12-10 12:13:02 +0100)

are available in the Git repository at:

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

for you to fetch changes up to 77217fcc8e04f27127b32825376ed508705fd946:

  x86/efistub: disable paging at mixed mode entry (2019-12-23 16:25:21 +0100)

----------------------------------------------------------------
Some more fixes for the EFI subsystem:
- Ensure that the EFI framebuffer earlycon uses WC attributes on x86 (Arvind)
- Another mixed mode fix from Hans, for the RNG code this time.
- Fix mixed mode boot from OVMF, by disabling paging at entry.

----------------------------------------------------------------
Ard Biesheuvel (1):
      x86/efistub: disable paging at mixed mode entry

Arvind Sankar (1):
      efi/earlycon: Fix write-combine mapping on x86

Hans de Goede (1):
      efi/libstub/random: Initialize pointer variables to zero for mixed mode

 arch/x86/boot/compressed/head_64.S    |  5 +++++
 drivers/firmware/efi/earlycon.c       | 16 +++++++---------
 drivers/firmware/efi/libstub/random.c |  6 +++---
 3 files changed, 15 insertions(+), 12 deletions(-)

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

* [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86
  2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
@ 2019-12-24 13:29 ` Ard Biesheuvel
  2019-12-25 10:38   ` [tip: efi/urgent] " tip-bot2 for Arvind Sankar
  2019-12-24 13:29 ` [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode Ard Biesheuvel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2019-12-24 13:29 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: Ard Biesheuvel, linux-kernel, Arvind Sankar, Hans de Goede

From: Arvind Sankar <nivedita@alum.mit.edu>

On x86, until PAT is initialized, WC translates into UC-. Since we
calculate and store pgprot_writecombine(PAGE_KERNEL) when earlycon is
initialized, this means we actually use UC- mappings instead of WC
mappings, which makes scrolling very slow.

Instead store a boolean flag to indicate whether we want to use
writeback or write-combine mappings, and recalculate the actual pgprot_t
we need on every mapping. Once PAT is initialized, we will start using
write-combine mappings, which speeds up the scrolling considerably.

Fixes: 69c1f396f25b ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation")
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/earlycon.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index d4077db6dc97..5d4f84781aa0 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -17,7 +17,7 @@ static const struct console *earlycon_console __initdata;
 static const struct font_desc *font;
 static u32 efi_x, efi_y;
 static u64 fb_base;
-static pgprot_t fb_prot;
+static bool fb_wb;
 static void *efi_fb;
 
 /*
@@ -33,10 +33,8 @@ static int __init efi_earlycon_remap_fb(void)
 	if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED))
 		return 0;
 
-	if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL))
-		efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB);
-	else
-		efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC);
+	efi_fb = memremap(fb_base, screen_info.lfb_size,
+			  fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
 
 	return efi_fb ? 0 : -ENOMEM;
 }
@@ -53,9 +51,12 @@ late_initcall(efi_earlycon_unmap_fb);
 
 static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
 {
+	pgprot_t fb_prot;
+
 	if (efi_fb)
 		return efi_fb + start;
 
+	fb_prot = fb_wb ? PAGE_KERNEL : pgprot_writecombine(PAGE_KERNEL);
 	return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
 }
 
@@ -215,10 +216,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
 	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
 		fb_base |= (u64)screen_info.ext_lfb_base << 32;
 
-	if (opt && !strcmp(opt, "ram"))
-		fb_prot = PAGE_KERNEL;
-	else
-		fb_prot = pgprot_writecombine(PAGE_KERNEL);
+	fb_wb = opt && !strcmp(opt, "ram");
 
 	si = &screen_info;
 	xres = si->lfb_width;
-- 
2.20.1


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

* [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode
  2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
  2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
@ 2019-12-24 13:29 ` Ard Biesheuvel
  2019-12-25 10:38   ` [tip: efi/urgent] " tip-bot2 for Hans de Goede
  2019-12-24 13:29 ` [PATCH 3/3] x86/efistub: disable paging at mixed mode entry Ard Biesheuvel
  2019-12-25  9:50 ` [GIT PULL 0/3] EFI fixes for v5.5 Ingo Molnar
  3 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2019-12-24 13:29 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: Ard Biesheuvel, linux-kernel, Arvind Sankar, Hans de Goede

From: Hans de Goede <hdegoede@redhat.com>

Commit 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the
UEFI RNG table"), causes the drivers/efi/libstub/random.c code to get used
on x86 for the first time.

But this code was not written with EFI mixed mode in mind (running a 64
bit kernel on 32 bit EFI firmware), this causes the kernel to crash during
early boot when running in mixed mode.

The problem is that in mixed mode pointers are 64 bit, but when running on
a 32 bit firmware, EFI calls which return a pointer value by reference only
fill the lower 32 bits of the passed pointer, leaving the upper 32 bits
uninitialized which leads to crashes.

This commit fixes this by initializing pointers which are passed by
reference to EFI calls to NULL before passing them, so that the upper 32
bits are initialized to 0.

Fixes: 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
index 35edd7cfb6a1..97378cf96a2e 100644
--- a/drivers/firmware/efi/libstub/random.c
+++ b/drivers/firmware/efi/libstub/random.c
@@ -33,7 +33,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg,
 {
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_status_t status;
-	struct efi_rng_protocol *rng;
+	struct efi_rng_protocol *rng = NULL;
 
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,
 				(void **)&rng);
@@ -162,8 +162,8 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg)
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
 	efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
-	struct efi_rng_protocol *rng;
-	struct linux_efi_random_seed *seed;
+	struct efi_rng_protocol *rng = NULL;
+	struct linux_efi_random_seed *seed = NULL;
 	efi_status_t status;
 
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,
-- 
2.20.1


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

* [PATCH 3/3] x86/efistub: disable paging at mixed mode entry
  2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
  2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
  2019-12-24 13:29 ` [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode Ard Biesheuvel
@ 2019-12-24 13:29 ` Ard Biesheuvel
  2019-12-25 10:38   ` [tip: efi/urgent] x86/efistub: Disable " tip-bot2 for Ard Biesheuvel
  2019-12-25  9:50 ` [GIT PULL 0/3] EFI fixes for v5.5 Ingo Molnar
  3 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2019-12-24 13:29 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: Ard Biesheuvel, linux-kernel, Arvind Sankar, Hans de Goede

The EFI mixed mode entry code goes through the ordinary startup_32()
routine before jumping into the kernel's EFI boot code in 64-bit
mode. The 32-bit startup code must be entered with paging disabled,
but this is not documented as a requirement for the EFI handover
protocol, and so we should disable paging explicitly when entering
the kernel from 32-bit EFI firmware.

Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/x86/boot/compressed/head_64.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 58a512e33d8d..ee60b81944a7 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -244,6 +244,11 @@ SYM_FUNC_START(efi32_stub_entry)
 	leal	efi32_config(%ebp), %eax
 	movl	%eax, efi_config(%ebp)
 
+	/* Disable paging */
+	movl	%cr0, %eax
+	btrl	$X86_CR0_PG_BIT, %eax
+	movl	%eax, %cr0
+
 	jmp	startup_32
 SYM_FUNC_END(efi32_stub_entry)
 #endif
-- 
2.20.1


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

* Re: [GIT PULL 0/3] EFI fixes for v5.5
  2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2019-12-24 13:29 ` [PATCH 3/3] x86/efistub: disable paging at mixed mode entry Ard Biesheuvel
@ 2019-12-25  9:50 ` Ingo Molnar
  3 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2019-12-25  9:50 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Thomas Gleixner, linux-kernel, Arvind Sankar, Hans de Goede


* Ard Biesheuvel <ardb@kernel.org> wrote:

> The following changes since commit a470552ee8965da0fe6fd4df0aa39c4cda652c7c:
> 
>   efi: Don't attempt to map RCI2 config table if it doesn't exist (2019-12-10 12:13:02 +0100)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent
> 
> for you to fetch changes up to 77217fcc8e04f27127b32825376ed508705fd946:
> 
>   x86/efistub: disable paging at mixed mode entry (2019-12-23 16:25:21 +0100)
> 
> ----------------------------------------------------------------
> Some more fixes for the EFI subsystem:
> - Ensure that the EFI framebuffer earlycon uses WC attributes on x86 (Arvind)
> - Another mixed mode fix from Hans, for the RNG code this time.
> - Fix mixed mode boot from OVMF, by disabling paging at entry.
> 
> ----------------------------------------------------------------
> Ard Biesheuvel (1):
>       x86/efistub: disable paging at mixed mode entry
> 
> Arvind Sankar (1):
>       efi/earlycon: Fix write-combine mapping on x86
> 
> Hans de Goede (1):
>       efi/libstub/random: Initialize pointer variables to zero for mixed mode
> 
>  arch/x86/boot/compressed/head_64.S    |  5 +++++
>  drivers/firmware/efi/earlycon.c       | 16 +++++++---------
>  drivers/firmware/efi/libstub/random.c |  6 +++---
>  3 files changed, 15 insertions(+), 12 deletions(-)

Applied to tip:efi/urgent, thanks Ard!

	Ingo

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

* [tip: efi/urgent] efi/libstub/random: Initialize pointer variables to zero for mixed mode
  2019-12-24 13:29 ` [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode Ard Biesheuvel
@ 2019-12-25 10:38   ` tip-bot2 for Hans de Goede
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Hans de Goede @ 2019-12-25 10:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Hans de Goede, Ard Biesheuvel, Arvind Sankar, Linus Torvalds,
	Peter Zijlstra, Thomas Gleixner, linux-efi, Ingo Molnar, x86,
	LKML

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     818c7ce724770fbcdcd43725c81f2b3535f82b76
Gitweb:        https://git.kernel.org/tip/818c7ce724770fbcdcd43725c81f2b3535f82b76
Author:        Hans de Goede <hdegoede@redhat.com>
AuthorDate:    Tue, 24 Dec 2019 14:29:08 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 25 Dec 2019 10:46:06 +01:00

efi/libstub/random: Initialize pointer variables to zero for mixed mode

Commit:

  0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table")

causes the drivers/efi/libstub/random.c code to get used on x86 for the first time.

But this code was not written with EFI mixed mode in mind (running a 64
bit kernel on 32 bit EFI firmware), this causes the kernel to crash during
early boot when running in mixed mode.

The problem is that in mixed mode pointers are 64 bit, but when running on
a 32 bit firmware, EFI calls which return a pointer value by reference only
fill the lower 32 bits of the passed pointer, leaving the upper 32 bits
uninitialized which leads to crashes.

This commit fixes this by initializing pointers which are passed by
reference to EFI calls to NULL before passing them, so that the upper 32
bits are initialized to 0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Fixes: 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table")
Link: https://lkml.kernel.org/r/20191224132909.102540-3-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/libstub/random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
index 35edd7c..97378cf 100644
--- a/drivers/firmware/efi/libstub/random.c
+++ b/drivers/firmware/efi/libstub/random.c
@@ -33,7 +33,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg,
 {
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_status_t status;
-	struct efi_rng_protocol *rng;
+	struct efi_rng_protocol *rng = NULL;
 
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,
 				(void **)&rng);
@@ -162,8 +162,8 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg)
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
 	efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
-	struct efi_rng_protocol *rng;
-	struct linux_efi_random_seed *seed;
+	struct efi_rng_protocol *rng = NULL;
+	struct linux_efi_random_seed *seed = NULL;
 	efi_status_t status;
 
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,

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

* [tip: efi/urgent] efi/earlycon: Fix write-combine mapping on x86
  2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
@ 2019-12-25 10:38   ` tip-bot2 for Arvind Sankar
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Arvind Sankar @ 2019-12-25 10:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Arvind Sankar, Ard Biesheuvel, Hans de Goede, Linus Torvalds,
	Peter Zijlstra, Thomas Gleixner, linux-efi, Ingo Molnar, x86,
	LKML

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     d92b54570d24d017d2630e314b525ed792f5aa6c
Gitweb:        https://git.kernel.org/tip/d92b54570d24d017d2630e314b525ed792f5aa6c
Author:        Arvind Sankar <nivedita@alum.mit.edu>
AuthorDate:    Tue, 24 Dec 2019 14:29:07 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 25 Dec 2019 10:46:06 +01:00

efi/earlycon: Fix write-combine mapping on x86

On x86, until PAT is initialized, WC translates into UC-. Since we
calculate and store pgprot_writecombine(PAGE_KERNEL) when earlycon is
initialized, this means we actually use UC- mappings instead of WC
mappings, which makes scrolling very slow.

Instead store a boolean flag to indicate whether we want to use
writeback or write-combine mappings, and recalculate the actual pgprot_t
we need on every mapping. Once PAT is initialized, we will start using
write-combine mappings, which speeds up the scrolling considerably.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Fixes: 69c1f396f25b ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation")
Link: https://lkml.kernel.org/r/20191224132909.102540-2-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/earlycon.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index d4077db..5d4f847 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -17,7 +17,7 @@ static const struct console *earlycon_console __initdata;
 static const struct font_desc *font;
 static u32 efi_x, efi_y;
 static u64 fb_base;
-static pgprot_t fb_prot;
+static bool fb_wb;
 static void *efi_fb;
 
 /*
@@ -33,10 +33,8 @@ static int __init efi_earlycon_remap_fb(void)
 	if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED))
 		return 0;
 
-	if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL))
-		efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB);
-	else
-		efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC);
+	efi_fb = memremap(fb_base, screen_info.lfb_size,
+			  fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
 
 	return efi_fb ? 0 : -ENOMEM;
 }
@@ -53,9 +51,12 @@ late_initcall(efi_earlycon_unmap_fb);
 
 static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
 {
+	pgprot_t fb_prot;
+
 	if (efi_fb)
 		return efi_fb + start;
 
+	fb_prot = fb_wb ? PAGE_KERNEL : pgprot_writecombine(PAGE_KERNEL);
 	return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
 }
 
@@ -215,10 +216,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
 	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
 		fb_base |= (u64)screen_info.ext_lfb_base << 32;
 
-	if (opt && !strcmp(opt, "ram"))
-		fb_prot = PAGE_KERNEL;
-	else
-		fb_prot = pgprot_writecombine(PAGE_KERNEL);
+	fb_wb = opt && !strcmp(opt, "ram");
 
 	si = &screen_info;
 	xres = si->lfb_width;

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

* [tip: efi/urgent] x86/efistub: Disable paging at mixed mode entry
  2019-12-24 13:29 ` [PATCH 3/3] x86/efistub: disable paging at mixed mode entry Ard Biesheuvel
@ 2019-12-25 10:38   ` tip-bot2 for Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Ard Biesheuvel @ 2019-12-25 10:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ard Biesheuvel, stable, Arvind Sankar, Hans de Goede,
	Linus Torvalds, Peter Zijlstra, Thomas Gleixner, linux-efi,
	Ingo Molnar, x86, LKML

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     4911ee401b7ceff8f38e0ac597cbf503d71e690c
Gitweb:        https://git.kernel.org/tip/4911ee401b7ceff8f38e0ac597cbf503d71e690c
Author:        Ard Biesheuvel <ardb@kernel.org>
AuthorDate:    Tue, 24 Dec 2019 14:29:09 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 25 Dec 2019 10:46:07 +01:00

x86/efistub: Disable paging at mixed mode entry

The EFI mixed mode entry code goes through the ordinary startup_32()
routine before jumping into the kernel's EFI boot code in 64-bit
mode. The 32-bit startup code must be entered with paging disabled,
but this is not documented as a requirement for the EFI handover
protocol, and so we should disable paging explicitly when entering
the kernel from 32-bit EFI firmware.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: <stable@vger.kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224132909.102540-4-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/boot/compressed/head_64.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 58a512e..ee60b81 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -244,6 +244,11 @@ SYM_FUNC_START(efi32_stub_entry)
 	leal	efi32_config(%ebp), %eax
 	movl	%eax, efi_config(%ebp)
 
+	/* Disable paging */
+	movl	%cr0, %eax
+	btrl	$X86_CR0_PG_BIT, %eax
+	movl	%eax, %cr0
+
 	jmp	startup_32
 SYM_FUNC_END(efi32_stub_entry)
 #endif

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

end of thread, other threads:[~2019-12-25 10:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
2019-12-25 10:38   ` [tip: efi/urgent] " tip-bot2 for Arvind Sankar
2019-12-24 13:29 ` [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode Ard Biesheuvel
2019-12-25 10:38   ` [tip: efi/urgent] " tip-bot2 for Hans de Goede
2019-12-24 13:29 ` [PATCH 3/3] x86/efistub: disable paging at mixed mode entry Ard Biesheuvel
2019-12-25 10:38   ` [tip: efi/urgent] x86/efistub: Disable " tip-bot2 for Ard Biesheuvel
2019-12-25  9:50 ` [GIT PULL 0/3] EFI fixes for v5.5 Ingo Molnar

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.