Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d75cd22f authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Ingo Molnar
Browse files

x86/paravirt: split sysret and sysexit



Don't conflate sysret and sysexit; they're different instructions with
different semantics, and may be in use at the same time (at least
within the same kernel, depending on whether its an Intel or AMD
system).

sysexit - just return to userspace, does no register restoration of
    any kind; must explicitly atomically enable interrupts.

sysret - reloads flags from r11, so no need to explicitly enable
    interrupts on 64-bit, responsible for restoring usermode %gs

Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citirx.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent e04e0a63
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ void foo(void)
	OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
	OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable);
	OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
	OFFSET(PV_CPU_irq_enable_syscall_ret, pv_cpu_ops, irq_enable_syscall_ret);
	OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
	OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
#endif

+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ int main(void)
	OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
	OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable);
	OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
	OFFSET(PV_CPU_irq_enable_syscall_ret, pv_cpu_ops, irq_enable_syscall_ret);
	OFFSET(PV_CPU_usersp_sysret, pv_cpu_ops, usersp_sysret);
	OFFSET(PV_CPU_swapgs, pv_cpu_ops, swapgs);
	OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
#endif
+4 −4
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
 * for paravirtualization.  The following will never clobber any registers:
 *   INTERRUPT_RETURN (aka. "iret")
 *   GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
 *   ENABLE_INTERRUPTS_SYSCALL_RET (aka "sti; sysexit").
 *   ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
 *
 * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
 * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
@@ -349,7 +349,7 @@ sysenter_past_esp:
	xorl %ebp,%ebp
	TRACE_IRQS_ON
1:	mov  PT_FS(%esp), %fs
	ENABLE_INTERRUPTS_SYSCALL_RET
	ENABLE_INTERRUPTS_SYSEXIT
	CFI_ENDPROC
.pushsection .fixup,"ax"
2:	movl $0,PT_FS(%esp)
@@ -874,10 +874,10 @@ ENTRY(native_iret)
.previous
END(native_iret)

ENTRY(native_irq_enable_syscall_ret)
ENTRY(native_irq_enable_sysexit)
	sti
	sysexit
END(native_irq_enable_syscall_ret)
END(native_irq_enable_sysexit)
#endif

KPROBE_ENTRY(int3)
+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@
#endif	

#ifdef CONFIG_PARAVIRT
ENTRY(native_irq_enable_syscall_ret)
ENTRY(native_usersp_sysret)
	movq	%gs:pda_oldrsp,%rsp
	swapgs
	sysretq
@@ -275,7 +275,7 @@ sysret_check:
	CFI_REGISTER	rip,rcx
	RESTORE_ARGS 0,-ARG_SKIP,1
	/*CFI_REGISTER	rflags,r11*/
	ENABLE_INTERRUPTS_SYSCALL_RET
	USERSP_SYSRET

	CFI_RESTORE_STATE
	/* Handle reschedules */
+9 −3
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
		/* If the operation is a nop, then nop the callsite */
		ret = paravirt_patch_nop();
	else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
		 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_syscall_ret))
		 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
		 type == PARAVIRT_PATCH(pv_cpu_ops.usersp_sysret))
		/* If operation requires a jmp, then jmp */
		ret = paravirt_patch_jmp(insnbuf, opfunc, addr, len);
	else
@@ -191,7 +192,8 @@ static void native_flush_tlb_single(unsigned long addr)

/* These are in entry.S */
extern void native_iret(void);
extern void native_irq_enable_syscall_ret(void);
extern void native_irq_enable_sysexit(void);
extern void native_usersp_sysret(void);

static int __init print_banner(void)
{
@@ -327,7 +329,11 @@ struct pv_cpu_ops pv_cpu_ops = {
	.write_idt_entry = native_write_idt_entry,
	.load_sp0 = native_load_sp0,

	.irq_enable_syscall_ret = native_irq_enable_syscall_ret,
#ifdef CONFIG_X86_32
	.irq_enable_sysexit = native_irq_enable_sysexit,
#else
	.usersp_sysret = native_usersp_sysret,
#endif
	.iret = native_iret,
	.swapgs = native_swapgs,

Loading