Re: [PATCH V6 6/8] x86/entry: Convert SWAPGS to swapgs and remove the definition of SWAPGS

From: Juergen Gross
Date: Mon May 02 2022 - 08:18:46 EST


On 29.04.22 11:56, Borislav Petkov wrote:
On Thu, Apr 21, 2022 at 10:10:53PM +0800, Lai Jiangshan wrote:
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 4fdb007cddbd..c5aeb0819707 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -50,7 +50,7 @@ SYM_CODE_START(entry_SYSENTER_compat)
UNWIND_HINT_EMPTY
ENDBR
/* Interrupts are off on entry. */
- SWAPGS
+ swapgs
pushq %rax
SWITCH_TO_KERNEL_CR3 scratch_reg=%rax

I'm not sure about this: why can't XENPV do a 32-bit syscall through the vdso?

The syscall will land in the hypervisor, which then will activate
the related registered callback (xen_sysenter_target).

Also, looking at this, Jürgen, it looks kinda spaghetti to me:

entry_SYSENTER_compat

...

/* XEN PV guests always use IRET path */
ALTERNATIVE "testl %eax, %eax; jz swapgs_restore_regs_and_return_to_usermode", \
"jmp swapgs_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV


then at that swapgs_restore_regs_and_return_to_usermode label:

#ifdef CONFIG_XEN_PV
ALTERNATIVE "", "jmp xenpv_restore_regs_and_return_to_usermode", X86_FEATURE_XENPV
#endif


Can we simply jump directly to xenpv_restore_regs_and_return_to_usermode
from entry_SYSENTER_compat or is that CONFIG_DEBUG_ENTRY chunk there
needed?

I wouldn't insist on the CONFIG_DEBUG_ENTRY chunk.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature