lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210819134328.GD28768@agape.jhs>
Date:   Thu, 19 Aug 2021 15:43:28 +0200
From:   Fabio Aiuto <fabioaiuto83@...il.com>
To:     Joerg Roedel <jroedel@...e.de>
Cc:     Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Hans de Goede <hdegoede@...hat.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: x86/boot/compressed/64: Lenovo Ideapad Miix300 bug report

Hi Joerg,

On Thu, Aug 19, 2021 at 03:33:40PM +0200, Joerg Roedel wrote:
> Hi Fabio,
> 
> thanks for your report!

you are welcome,

> 
> On Thu, Aug 19, 2021 at 02:16:53PM +0200, Fabio Aiuto wrote:
> > I rebuilt a plain v5.13 kernel (no reverts) with that config
> > disabled and everything goes fine.
> 
> Can you please try the attached patch? I think the problem is that the
> 32-bit EFI boot path sets up its own IDT before ExitBootServices() is
> called.

shall I restore back CONFIG_AMD_MEM_ENCRYPT?

thank you,

fabio

> 
> Regards,
> 
> 	Joerg

> diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
> index 95a223b3e56a..99cfd5dea23c 100644
> --- a/arch/x86/boot/compressed/efi_thunk_64.S
> +++ b/arch/x86/boot/compressed/efi_thunk_64.S
> @@ -39,7 +39,7 @@ SYM_FUNC_START(__efi64_thunk)
>  	/*
>  	 * Convert x86-64 ABI params to i386 ABI
>  	 */
> -	subq	$32, %rsp
> +	subq	$64, %rsp
>  	movl	%esi, 0x0(%rsp)
>  	movl	%edx, 0x4(%rsp)
>  	movl	%ecx, 0x8(%rsp)
> @@ -49,14 +49,19 @@ SYM_FUNC_START(__efi64_thunk)
>  	leaq	0x14(%rsp), %rbx
>  	sgdt	(%rbx)
>  
> +	addq	$16, %rbx
> +	sidt	(%rbx)
> +
>  	/*
> -	 * Switch to gdt with 32-bit segments. This is the firmware GDT
> -	 * that was installed when the kernel started executing. This
> -	 * pointer was saved at the EFI stub entry point in head_64.S.
> +	 * Switch to idt and gdt with 32-bit segments. This is the firmware GDT
> +	 * and IDT that was installed when the kernel started executing. The
> +	 * pointers were saved at the EFI stub entry point in head_64.S.
>  	 *
>  	 * Pass the saved DS selector to the 32-bit code, and use far return to
>  	 * restore the saved CS selector.
>  	 */
> +	leaq	efi32_boot_idt(%rip), %rax
> +	lidt	(%rax)
>  	leaq	efi32_boot_gdt(%rip), %rax
>  	lgdt	(%rax)
>  
> @@ -67,7 +72,7 @@ SYM_FUNC_START(__efi64_thunk)
>  	pushq	%rax
>  	lretq
>  
> -1:	addq	$32, %rsp
> +1:	addq	$64, %rsp
>  	movq	%rdi, %rax
>  
>  	pop	%rbx
> @@ -132,6 +137,9 @@ SYM_FUNC_START_LOCAL(efi_enter32)
>  	 */
>  	cli
>  
> +	lidtl	(%ebx)
> +	subl	$16, %ebx
> +
>  	lgdtl	(%ebx)
>  
>  	movl	%cr4, %eax
> @@ -166,6 +174,11 @@ SYM_DATA_START(efi32_boot_gdt)
>  	.quad	0
>  SYM_DATA_END(efi32_boot_gdt)
>  
> +SYM_DATA_START(efi32_boot_idt)
> +	.word	0
> +	.quad	0
> +SYM_DATA_END(efi32_boot_idt)
> +
>  SYM_DATA_START(efi32_boot_cs)
>  	.word	0
>  SYM_DATA_END(efi32_boot_cs)
> diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
> index a2347ded77ea..572c535cf45b 100644
> --- a/arch/x86/boot/compressed/head_64.S
> +++ b/arch/x86/boot/compressed/head_64.S
> @@ -319,6 +319,9 @@ SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL)
>  	movw	%cs, rva(efi32_boot_cs)(%ebp)
>  	movw	%ds, rva(efi32_boot_ds)(%ebp)
>  
> +	/* Store firmware IDT descriptor */
> +	sidtl	rva(efi32_boot_idt)(%ebp)
> +
>  	/* Disable paging */
>  	movl	%cr0, %eax
>  	btrl	$X86_CR0_PG_BIT, %eax

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ