public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Isaku Yamahata <yamahata@valinux.co.jp>
Subject: [PATCH 22 of 24] xen: fold xen_sysexit into xen_iret
Date: Wed, 02 Apr 2008 10:54:11 -0700	[thread overview]
Message-ID: <2f18411ec7d823edca3b.1207158851@localhost> (raw)
In-Reply-To: <patchbomb.1207158829@localhost>

xen_sysexit and xen_iret were doing essentially the same thing.  Rather
than having a separate implementation for xen_sysexit, we can just strip
the stack back to an iret frame and jump into xen_iret.  This removes
a lot of code and complexity - specifically, another critical region.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/kernel/entry_32.S |    9 -----
 arch/x86/xen/xen-asm.S     |   70 ++++++++------------------------------------
 2 files changed, 15 insertions(+), 64 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1044,15 +1044,8 @@
 
 	jmp  xen_iret_crit_fixup
 
-1:	cmpl $xen_sysexit_start_crit,%eax
-	jb   2f
-	cmpl $xen_sysexit_end_crit,%eax
-	jae  2f
-
-	jmp xen_sysexit_crit_fixup
-
 ENTRY(xen_do_upcall)
-2:	mov %esp, %eax
+1:	mov %esp, %eax
 	call xen_evtchn_do_upcall
 	jmp  ret_from_intr
 	CFI_ENDPROC
diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
--- a/arch/x86/xen/xen-asm.S
+++ b/arch/x86/xen/xen-asm.S
@@ -106,6 +106,20 @@
 	ret
 	ENDPROC(xen_restore_fl_direct)
 	RELOC(xen_restore_fl_direct, 2b+1)
+
+/*
+	We can't use sysexit directly, because we're not running in ring0.
+	But we can easily fake it up using iret.  Assuming xen_sysexit
+	is jumped to with a standard stack frame, we can just strip it
+	back to a standard iret frame and use iret.
+ */
+ENTRY(xen_sysexit)
+	movl PT_EAX(%esp), %eax			/* Shouldn't be necessary? */
+	orl $X86_EFLAGS_IF, PT_EFLAGS(%esp)
+	lea PT_EIP(%esp), %esp
+
+	jmp xen_iret
+ENDPROC(xen_sysexit)
 
 /*
 	This is run where a normal iret would be run, with the same stack setup:
@@ -276,62 +290,6 @@
 2:	jmp xen_do_upcall
 
 
-ENTRY(xen_sysexit)
-	/* Store vcpu_info pointer for easy access.  Do it this
-	   way to avoid having to reload %fs */
-#ifdef CONFIG_SMP
-	GET_THREAD_INFO(%eax)
-	movl TI_cpu(%eax),%eax
-	movl __per_cpu_offset(,%eax,4),%eax
-	mov per_cpu__xen_vcpu(%eax),%eax
-#else
-	movl per_cpu__xen_vcpu, %eax
-#endif
-
-	/* We can't actually use sysexit in a pv guest,
-	   so fake it up with iret */
-	pushl $__USER_DS		/* user stack segment */
-	pushl %ecx			/* user esp */
-	pushl PT_EFLAGS+2*4(%esp)	/* user eflags */
-	pushl $__USER_CS		/* user code segment */
-	pushl %edx			/* user eip */
-
-xen_sysexit_start_crit:
-	/* Unmask events... */
-	movb $0, XEN_vcpu_info_mask(%eax)
-	/* ...and test for pending.
-	   There's a preempt window here, but it doesn't
-	   matter because we're within the critical section. */
-	testb $0xff, XEN_vcpu_info_pending(%eax)
-
-	/* If there's something pending, mask events again so we
-	   can directly inject it back into the kernel. */
-	jnz   1f
-
-	movl PT_EAX+5*4(%esp),%eax
-2:	iret
-1:	movb $1, XEN_vcpu_info_mask(%eax)
-xen_sysexit_end_crit:
-	addl $5*4, %esp		/* remove iret frame */
-	/* no need to re-save regs, but need to restore kernel %fs */
-	mov $__KERNEL_PERCPU, %eax
-	mov %eax, %fs
-	jmp xen_do_upcall
-.section __ex_table,"a"
-	.align 4
-	.long 2b,iret_exc
-.previous
-
-	.globl xen_sysexit_start_crit, xen_sysexit_end_crit
-/*
-	sysexit fixup is easy, since the old frame is still sitting there
-	on the stack.  We just need to remove the new recursive
-	interrupt and return.
- */
-ENTRY(xen_sysexit_crit_fixup)
-	addl $PT_OLDESP+5*4, %esp		/* remove frame+iret */
-	jmp xen_do_upcall
-
 /*
 	Force an event check by making a hypercall,
 	but preserve regs before making the call.



  parent reply	other threads:[~2008-04-02 18:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-02 17:53 [PATCH 00 of 24] More Xen updates Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 01 of 24] xen: add missing __HYPERVISOR_arch_[0-7] definisions which ia64 needs Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 02 of 24] xen: add missing VIRQ_ARCH_[0-7] definitions which ia64/xen needs Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 03 of 24] xen: add missing definitions for xen grant table " Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 04 of 24] xen: add missing definitions in include/xen/interface/vcpu.h " Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 05 of 24] xen: move features.c from arch/x86/xen/features.c to drivers/xen Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 06 of 24] xen: Move events.c to drivers/xen for IA64/Xen support Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 07 of 24] Xen: Make events.c portable for ia64/xen support Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 08 of 24] Re: [PATCH 08/12] xen: add resend_irq_on_evtchn() definition into events.c Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 09 of 24] xen: make include/xen/page.h portable moving those definitions under asm dir Jeremy Fitzhardinge
2008-04-02 17:53 ` [PATCH 10 of 24] xen: replace callers of alloc_vm_area()/free_vm_area() with xen_ prefixed one Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 11 of 24] xen: make grant table arch portable Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 12 of 24] xen: import arch generic part of xencomm Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 13 of 24] [PATCH] xen: Make xen-blkfront write its protocol ABI to xenstore Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 14 of 24] xen/blkfront: use bdget_disk Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 15 of 24] xen blkfront: Delay wait for block devices until after the disk is added Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 16 of 24] xen: Module autoprobing support for frontend drivers Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 17 of 24] xen: Add compatibility aliases " Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 18 of 24] xen pvfb: Para-virtual framebuffer, keyboard and pointer driver Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 19 of 24] x86: fix build problem in pud_populate without CONFIG_PARAVIRT Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 20 of 24] xen: disable preemption during tlb flush Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 21 of 24] xen: allow set_pte_at on init_mm to be lockless Jeremy Fitzhardinge
2008-04-02 17:54 ` Jeremy Fitzhardinge [this message]
2008-04-02 17:54 ` [PATCH 23 of 24] xen: allow compilation with non-flat memory Jeremy Fitzhardinge
2008-04-02 17:54 ` [PATCH 24 of 24] xen: add balloon driver Jeremy Fitzhardinge
2008-04-07  8:51   ` Isaku Yamahata
2008-04-07 19:01     ` Jeremy Fitzhardinge
2008-04-04  8:10 ` [PATCH 00 of 24] More Xen updates Ingo Molnar
2008-04-04  9:33   ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f18411ec7d823edca3b.1207158851@localhost \
    --to=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=yamahata@valinux.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox