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]
Date: Thu, 25 Jan 2024 13:44:54 +0200
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Andi Kleen <ak@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, 
	Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org, 
	"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org, Kai Huang <kai.huang@...el.com>, 
	Sean Christopherson <seanjc@...gle.com>
Subject: Re: [PATCHv3, RESEND] x86/trampoline: Bypass compat mode in
 trampoline_start64() if not needed

On Thu, Jan 25, 2024 at 01:57:18AM -0800, Andi Kleen wrote:
> > +	/* Paging mode is correct proceed in 64-bit mode */
> > +
> > +	LOCK_AND_LOAD_REALMODE_ESP lock_rip=1
> > +
> > +	movw	$__KERNEL_DS, %dx
> > +	movl	%edx, %ss
> > +	addl	$pa_real_mode_base, %esp
> > +	movl	%edx, %ds
> > +	movl	%edx, %es
> > +	movl	%edx, %fs
> > +	movl	%edx, %gs
> > +
> > +	movl	$pa_trampoline_pgd, %eax
> > +	movq	%rax, %cr3
> > +
> > +	jmpq	*tr_start(%rip)
> 
> Still think we should add a far jump here so that we run on a defined
> code segment. It probably doesn't matter since there are likely no
> IRETs before reloading anyways, but it seems cleaner.

I think it is cleaner to switch to IRET here. Does this work for you?

diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
index 608f108cba7d..14d9c7daf90f 100644
--- a/arch/x86/realmode/rm/trampoline_64.S
+++ b/arch/x86/realmode/rm/trampoline_64.S
@@ -243,7 +243,9 @@ SYM_CODE_START(trampoline_start64)
 	movl	$pa_trampoline_pgd, %eax
 	movq	%rax, %cr3
 
-	jmpq	*tr_start(%rip)
+	pushq	$__KERNEL_CS
+	pushq	tr_start(%rip)
+	lretq
 .L_switch_paging:
 	/*
 	 * To switch between 4- and 5-level paging modes, it is necessary
-- 
  Kiryl Shutsemau / Kirill A. Shutemov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ