From: Chris Wright <chrisw@sous-sol.org>
To: linux-kernel@vger.kernel.org
Cc: virtualization@lists.osdl.org, xen-devel@lists.xensource.com,
Ian Pratt <ian.pratt@xensource.com>,
Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Subject: [RFC PATCH 11/35] Add support for Xen to entry.S.
Date: Tue, 09 May 2006 00:00:11 -0700 [thread overview]
Message-ID: <20060509085152.524462000@sous-sol.org> (raw)
In-Reply-To: 20060509084945.373541000@sous-sol.org
[-- Attachment #1: i386-entry.S --]
[-- Type: text/plain, Size: 7899 bytes --]
- change cli/sti
- change test for user mode return to work for kernel mode in ring1
- check hypervisor saved event mask on return from exception
- add entry points for the hypervisor upcall handlers
- avoid math emulation check when running on Xen
- add nmi handler for running on Xen
Signed-off-by: Ian Pratt <ian.pratt@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
arch/i386/kernel/entry.S | 137 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 120 insertions(+), 17 deletions(-)
--- linus-2.6.orig/arch/i386/kernel/entry.S
+++ linus-2.6/arch/i386/kernel/entry.S
@@ -75,8 +75,38 @@ DF_MASK = 0x00000400
NT_MASK = 0x00004000
VM_MASK = 0x00020000
+#ifndef CONFIG_XEN
+#define DISABLE_INTERRUPTS cli
+#define ENABLE_INTERRUPTS sti
+#else
+#include <xen/interface/xen.h>
+
+EVENT_MASK = 0x2E
+
+/* Offsets into shared_info_t. */
+#define evtchn_upcall_pending /* 0 */
+#define evtchn_upcall_mask 1
+
+#define sizeof_vcpu_shift 6
+
+#ifdef CONFIG_SMP
+#define GET_VCPU_INFO movl TI_cpu(%ebp),%esi ; \
+ shl $sizeof_vcpu_shift,%esi ; \
+ addl HYPERVISOR_shared_info,%esi
+#else
+#define GET_VCPU_INFO movl HYPERVISOR_shared_info,%esi
+#endif
+
+#define __DISABLE_INTERRUPTS movb $1,evtchn_upcall_mask(%esi)
+#define DISABLE_INTERRUPTS GET_VCPU_INFO ; \
+ __DISABLE_INTERRUPTS
+#define ENABLE_INTERRUPTS GET_VCPU_INFO ; \
+ movb $0,evtchn_upcall_mask(%esi)
+#define __TEST_PENDING testb $0xFF,evtchn_upcall_pending(%esi)
+#endif
+
#ifdef CONFIG_PREEMPT
-#define preempt_stop cli
+#define preempt_stop DISABLE_INTERRUPTS
#else
#define preempt_stop
#define resume_kernel restore_nocheck
@@ -145,10 +175,10 @@ ret_from_intr:
GET_THREAD_INFO(%ebp)
movl EFLAGS(%esp), %eax # mix EFLAGS and CS
movb CS(%esp), %al
- testl $(VM_MASK | 3), %eax
+ testl $(VM_MASK | USER_MODE_MASK), %eax
jz resume_kernel
ENTRY(resume_userspace)
- cli # make sure we don't miss an interrupt
+ DISABLE_INTERRUPTS # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
movl TI_flags(%ebp), %ecx
@@ -159,7 +189,7 @@ ENTRY(resume_userspace)
#ifdef CONFIG_PREEMPT
ENTRY(resume_kernel)
- cli
+ DISABLE_INTERRUPTS
cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
jnz restore_nocheck
need_resched:
@@ -179,7 +209,7 @@ need_resched:
ENTRY(sysenter_entry)
movl TSS_sysenter_esp0(%esp),%esp
sysenter_past_esp:
- sti
+ ENABLE_INTERRUPTS
pushl $(__USER_DS)
pushl %ebp
pushfl
@@ -209,7 +239,7 @@ sysenter_past_esp:
jae syscall_badsys
call *sys_call_table(,%eax,4)
movl %eax,EAX(%esp)
- cli
+ DISABLE_INTERRUPTS
movl TI_flags(%ebp), %ecx
testw $_TIF_ALLWORK_MASK, %cx
jne syscall_exit_work
@@ -217,7 +247,7 @@ sysenter_past_esp:
movl EIP(%esp), %edx
movl OLDESP(%esp), %ecx
xorl %ebp,%ebp
- sti
+ ENABLE_INTERRUPTS
sysexit
@@ -240,7 +270,7 @@ syscall_call:
call *sys_call_table(,%eax,4)
movl %eax,EAX(%esp) # store the return value
syscall_exit:
- cli # make sure we don't miss an interrupt
+ DISABLE_INTERRUPTS # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
movl TI_flags(%ebp), %ecx
@@ -248,6 +278,7 @@ syscall_exit:
jne syscall_exit_work
restore_all:
+#ifndef CONFIG_XEN
movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
# Warning: OLDSS(%esp) contains the wrong/random values if we
# are returning to the kernel.
@@ -258,12 +289,32 @@ restore_all:
cmpl $((4 << 8) | 3), %eax
je ldt_ss # returning to user-space with LDT SS
restore_nocheck:
+#else
+restore_nocheck:
+ movl EFLAGS(%esp), %eax # mix EFLAGS and CS
+ movb CS(%esp), %al
+ andl $(VM_MASK | 3), %eax
+ cmpl $3, %eax
+ jne hypervisor_iret
+ ENABLE_INTERRUPTS
+ __TEST_PENDING
+ jz restore_regs_and_iret
+ __DISABLE_INTERRUPTS
+ jmp do_hypervisor_callback
+hypervisor_iret:
+ RESTORE_REGS
+ addl $4, %esp
+ jmp hypercall_page + (__HYPERVISOR_iret * 32)
+#endif
+restore_regs_and_iret:
RESTORE_REGS
addl $4, %esp
1: iret
.section .fixup,"ax"
iret_exc:
- sti
+#ifndef CONFIG_XEN
+ ENABLE_INTERRUPTS
+#endif
pushl $0 # no error code
pushl $do_iret_error
jmp error_code
@@ -273,6 +324,7 @@ iret_exc:
.long 1b,iret_exc
.previous
+#ifndef CONFIG_XEN
ldt_ss:
larl OLDSS(%esp), %eax
jnz restore_nocheck
@@ -285,7 +337,7 @@ ldt_ss:
* CPUs, which we can try to work around to make
* dosemu and wine happy. */
subl $8, %esp # reserve space for switch16 pointer
- cli
+ DISABLE_INTERRUPTS
movl %esp, %eax
/* Set up the 16bit stack frame with switch32 pointer on top,
* and a switch16 pointer on top of the current frame. */
@@ -297,6 +349,7 @@ ldt_ss:
.align 4
.long 1b,iret_exc
.previous
+#endif
# perform work that needs to be done immediately before resumption
ALIGN
@@ -305,7 +358,7 @@ work_pending:
jz work_notifysig
work_resched:
call schedule
- cli # make sure we don't miss an interrupt
+ DISABLE_INTERRUPTS # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
movl TI_flags(%ebp), %ecx
@@ -357,7 +410,7 @@ syscall_trace_entry:
syscall_exit_work:
testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
jz work_pending
- sti # could let do_syscall_trace() call
+ ENABLE_INTERRUPTS # could let do_syscall_trace() call
# schedule() instead
movl %esp, %eax
movl $1, %edx
@@ -377,6 +430,7 @@ syscall_badsys:
movl $-ENOSYS,EAX(%esp)
jmp resume_userspace
+#ifndef CONFIG_XEN
#define FIXUP_ESPFIX_STACK \
movl %esp, %eax; \
/* switch to 32bit stack using the pointer on top of 16bit stack */ \
@@ -435,6 +489,9 @@ ENTRY(name) \
/* The include is where all of the SMP etc. interrupts come from */
#include "entry_arch.h"
+#else
+#define UNWIND_ESPFIX_STACK
+#endif
ENTRY(divide_error)
pushl $0 # no error code
@@ -466,6 +523,44 @@ error_code:
call *%edi
jmp ret_from_exception
+#ifdef CONFIG_XEN
+ENTRY(hypervisor_callback)
+ pushl %eax
+ SAVE_ALL
+do_hypervisor_callback:
+ push %esp
+ call evtchn_do_upcall
+ add $4,%esp
+ jmp ret_from_intr
+
+# Hypervisor uses this for application faults while it executes.
+ENTRY(failsafe_callback)
+1: popl %ds
+2: popl %es
+3: popl %fs
+4: popl %gs
+ subl $4,%esp
+ SAVE_ALL
+ jmp ret_from_exception
+.section .fixup,"ax"; \
+6: movl $0,(%esp); \
+ jmp 1b; \
+7: movl $0,(%esp); \
+ jmp 2b; \
+8: movl $0,(%esp); \
+ jmp 3b; \
+9: movl $0,(%esp); \
+ jmp 4b; \
+.previous; \
+.section __ex_table,"a";\
+ .align 4; \
+ .long 1b,6b; \
+ .long 2b,7b; \
+ .long 3b,8b; \
+ .long 4b,9b; \
+.previous
+#endif
+
ENTRY(coprocessor_error)
pushl $0
pushl $do_coprocessor_error
@@ -479,17 +574,19 @@ ENTRY(simd_coprocessor_error)
ENTRY(device_not_available)
pushl $-1 # mark this as an int
SAVE_ALL
+#ifndef CONFIG_XEN
movl %cr0, %eax
testl $0x4, %eax # EM (math emulation bit)
- jne device_not_available_emulate
- preempt_stop
- call math_state_restore
- jmp ret_from_exception
-device_not_available_emulate:
+ je device_available_emulate
pushl $0 # temporary storage for ORIG_EIP
call math_emulate
addl $4, %esp
jmp ret_from_exception
+device_available_emulate:
+#endif
+ preempt_stop
+ call math_state_restore
+ jmp ret_from_exception
/*
* Debug traps and NMI can happen at the one SYSENTER instruction
@@ -525,6 +622,8 @@ debug_stack_correct:
call do_debug
jmp ret_from_exception
.previous .text
+
+#ifndef CONFIG_XEN
/*
* NMI is doubly nasty. It can happen _while_ we're handling
* a debug fault, and the debug fault hasn't yet been able to
@@ -595,6 +694,10 @@ nmi_16bit_stack:
.align 4
.long 1b,iret_exc
.previous
+#else
+ENTRY(nmi)
+ jmp restore_all
+#endif
KPROBE_ENTRY(int3)
pushl $-1 # mark this as an int
--
next prev parent reply other threads:[~2006-05-09 8:53 UTC|newest]
Thread overview: 184+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-09 8:49 [RFC PATCH 00/35] Xen i386 paravirtualization support Chris Wright
2006-05-09 7:00 ` [RFC PATCH 01/35] Add XEN config options and disable unsupported config options Chris Wright
2006-05-09 10:05 ` Adrian Bunk
2006-05-09 11:06 ` Ed Tomlinson
2006-05-09 12:45 ` Christian Limpach
2006-05-09 23:23 ` Chris Wright
2006-05-09 14:47 ` Daniel Walker
2006-05-09 15:16 ` Christian Limpach
2006-05-09 16:00 ` Daniel Walker
2006-05-09 23:25 ` Chris Wright
2006-05-09 16:42 ` Andi Kleen
2006-05-10 15:36 ` [Xen-devel] " Alan Cox
2006-05-10 15:48 ` Christian Limpach
2006-05-09 7:00 ` [RFC PATCH 02/35] Makefile support to build Xen subarch Chris Wright
2006-05-09 7:00 ` [RFC PATCH 03/35] Add Xen interface header files Chris Wright
2006-05-09 14:49 ` Martin J. Bligh
2006-05-09 17:54 ` Christian Limpach
2006-05-09 15:15 ` Christoph Hellwig
2006-05-09 19:35 ` Hollis Blanchard
2006-05-09 19:48 ` [Xen-devel] " Anthony Liguori
2006-05-09 22:34 ` Christoph Hellwig
2006-05-09 22:36 ` Ingo Oeser
2006-05-09 16:06 ` Daniel Walker
2006-05-09 16:18 ` Christian Limpach
2006-05-09 16:29 ` Daniel Walker
2006-05-09 7:00 ` [RFC PATCH 04/35] Hypervisor " Chris Wright
2006-05-09 22:43 ` Ingo Oeser
2006-05-09 23:01 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 05/35] Add sync bitops Chris Wright
2006-05-09 22:56 ` Christoph Lameter
2006-05-09 23:04 ` Andi Kleen
2006-05-09 23:07 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 06/35] Add vmlinuz build target Chris Wright
2006-05-09 7:00 ` [RFC PATCH 07/35] Make LOAD_OFFSET defined by subarch Chris Wright
2006-05-10 23:28 ` Zachary Amsden
2006-05-11 7:47 ` [Xen-devel] " Gerd Hoffmann
2006-05-11 8:51 ` Chris Wright
2006-05-11 9:06 ` Gerd Hoffmann
2006-05-11 16:43 ` Christian Limpach
2006-05-12 6:47 ` [Xen-devel] " Jan Beulich
2006-05-12 8:38 ` Christian Limpach
2006-05-09 7:00 ` [RFC PATCH 08/35] Add Xen-specific memory management definitions Chris Wright
2006-05-09 14:49 ` Martin J. Bligh
2006-05-09 17:44 ` Christian Limpach
2006-05-15 6:44 ` Pete Zaitcev
2006-05-15 7:04 ` Keir Fraser
2006-05-15 8:19 ` Christian Limpach
2006-05-17 16:06 ` Pete Zaitcev
2006-05-18 7:42 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 09/35] Change __FIXADDR_TOP to leave room for the hypervisor Chris Wright
2006-05-09 7:00 ` [RFC PATCH 10/35] Add a new head.S start-of-day file for booting on Xen Chris Wright
2006-05-09 7:00 ` Chris Wright [this message]
2006-05-09 16:51 ` [RFC PATCH 11/35] Add support for Xen to entry.S Andi Kleen
2006-05-09 7:00 ` [RFC PATCH 12/35] Add start-of-day setup hooks to subarch Chris Wright
2006-05-09 7:00 ` [RFC PATCH 13/35] Support loading an initrd when running on Xen Chris Wright
2006-05-09 7:00 ` [RFC PATCH 14/35] Subarch support for CPUID instruction Chris Wright
2006-05-09 7:00 ` [RFC PATCH 15/35] subarch support for controlling interrupt delivery Chris Wright
2006-05-09 14:49 ` Martin J. Bligh
2006-05-09 14:55 ` Nick Piggin
2006-05-09 15:51 ` Christian Limpach
2006-05-09 16:02 ` Martin J. Bligh
2006-05-09 16:07 ` Andi Kleen
2006-05-09 16:29 ` Christian Limpach
2006-05-09 16:31 ` Andi Kleen
2006-05-09 20:42 ` Christian Limpach
2006-05-09 21:56 ` Andi Kleen
2006-05-10 10:35 ` Christian Limpach
2006-05-10 10:54 ` Andi Kleen
2006-05-09 21:56 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 16/35] subarch support for interrupt and exception gates Chris Wright
2006-05-09 11:09 ` Andi Kleen
2006-05-09 12:55 ` Christian Limpach
2006-05-13 12:27 ` Andrew Morton
2006-05-15 18:30 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 17/35] Segment register changes for Xen Chris Wright
2006-05-09 7:16 ` Pavel Machek
2006-05-10 20:09 ` Andi Kleen
2006-05-10 20:30 ` Pavel Machek
2006-05-11 10:34 ` Avi Kivity
2006-05-11 10:41 ` Andi Kleen
2006-05-12 0:28 ` [Xen-devel] " Rusty Russell
2006-05-09 16:44 ` Andi Kleen
2006-05-18 20:20 ` Zachary Amsden
2006-05-18 20:41 ` Keir Fraser
2006-05-18 21:26 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 18/35] Support gdt/idt/ldt handling on Xen Chris Wright
2006-05-09 7:21 ` Pavel Machek
2006-05-10 20:23 ` Andi Kleen
2006-05-09 14:49 ` Martin J. Bligh
2006-05-09 18:14 ` Christian Limpach
2006-05-09 18:21 ` Martin Bligh
2006-05-09 7:00 ` [RFC PATCH 19/35] subarch support for control register accesses Chris Wright
2006-05-09 7:00 ` [RFC PATCH 20/35] subarch stack pointer update Chris Wright
2006-05-09 7:00 ` [RFC PATCH 21/35] subarch TLB support Chris Wright
2006-05-09 7:00 ` [RFC PATCH 22/35] subarch suport for idle loop (NO_IDLE_HZ for Xen) Chris Wright
2006-05-09 13:21 ` Andi Kleen
2006-05-09 15:13 ` Christian Limpach
2006-05-09 7:00 ` [RFC PATCH 23/35] Increase x86 interrupt vector range Chris Wright
2006-05-09 7:00 ` [RFC PATCH 24/35] Add support for Xen event channels Chris Wright
2006-05-12 21:41 ` Pavel Machek
2006-05-13 12:27 ` Andrew Morton
2006-05-13 13:02 ` Keir Fraser
2006-05-09 7:00 ` [RFC PATCH 25/35] Add Xen time abstractions Chris Wright
2006-05-09 16:23 ` Daniel Walker
2006-05-09 16:38 ` Christian Limpach
2006-05-09 19:27 ` Adrian Bunk
2006-05-09 21:50 ` Andi Kleen
2006-05-09 23:03 ` Ingo Oeser
2006-05-09 23:09 ` Andi Kleen
2006-05-09 23:13 ` Chris Wright
2006-05-12 21:44 ` Pavel Machek
2006-05-09 7:00 ` [RFC PATCH 26/35] Add Xen subarch reboot support Chris Wright
2006-05-09 17:02 ` Andi Kleen
2006-05-12 21:46 ` Pavel Machek
2006-05-12 21:57 ` Chris Wright
2006-05-09 7:00 ` [RFC PATCH 27/35] Add nosegneg capability to the vsyscall page notes Chris Wright
2006-05-09 7:00 ` [RFC PATCH 28/35] add support for Xen feature queries Chris Wright
2006-05-12 21:56 ` Pavel Machek
2006-05-09 7:00 ` [RFC PATCH 29/35] Add the Xen virtual console driver Chris Wright
2006-05-09 13:26 ` Andi Kleen
2006-05-09 15:03 ` Christian Limpach
2006-05-13 12:27 ` Andrew Morton
2006-05-13 12:51 ` Nick Piggin
2006-05-13 14:29 ` Andrew Morton
2006-05-13 14:43 ` Nick Piggin
2006-05-09 7:00 ` [RFC PATCH 30/35] Add apply_to_page_range() function Chris Wright
2006-05-09 7:00 ` [RFC PATCH 31/35] Add Xen grant table support Chris Wright
2006-05-09 7:00 ` [RFC PATCH 32/35] Add Xen driver utility functions Chris Wright
2006-05-09 19:48 ` Greg KH
2006-05-09 21:50 ` Andi Kleen
2006-05-09 7:00 ` [RFC PATCH 33/35] Add the Xenbus sysfs and virtual device hotplug driver Chris Wright
2006-05-09 16:06 ` Alexey Dobriyan
2006-05-09 16:28 ` Andi Kleen
2006-05-09 19:40 ` Greg KH
2006-05-09 21:53 ` Chris Wright
2006-05-09 22:01 ` Greg KH
2006-05-09 22:50 ` Chris Wright
2006-05-09 23:43 ` Anthony Liguori
2006-05-09 19:49 ` Greg KH
2006-05-09 19:58 ` Chris Wright
2006-05-13 12:28 ` Andrew Morton
2006-05-09 7:00 ` [RFC PATCH 34/35] Add the Xen virtual network device driver Chris Wright
2006-05-09 11:55 ` [Xen-devel] " Herbert Xu
2006-05-09 12:43 ` Christian Limpach
2006-05-09 13:01 ` Herbert Xu
2006-05-09 13:14 ` Andi Kleen
2006-05-09 13:16 ` Christian Limpach
2006-05-09 13:26 ` Herbert Xu
2006-05-09 14:00 ` Christian Limpach
2006-05-09 14:30 ` David Boutcher
2006-05-09 23:35 ` Chris Wright
2006-05-09 11:58 ` Christoph Hellwig
2006-05-09 23:37 ` Chris Wright
2006-05-09 18:56 ` Stephen Hemminger
2006-05-09 23:39 ` Chris Wright
2006-05-09 20:25 ` Stephen Hemminger
2006-05-09 20:26 ` Keir Fraser
2006-05-09 20:39 ` Stephen Hemminger
2006-05-09 20:46 ` Roland Dreier
2006-05-10 18:28 ` Andi Kleen
2006-05-11 0:33 ` Herbert Xu
2006-05-11 7:49 ` Keir Fraser
2006-05-11 8:04 ` Herbert Xu
2006-05-11 9:47 ` Andi Kleen
2006-05-11 16:18 ` Stephen Hemminger
2006-05-11 16:48 ` Rick Jones
2006-05-11 16:55 ` Stephen Hemminger
2006-05-11 17:30 ` Andi Kleen
2006-05-09 20:32 ` Chris Wright
2006-05-09 22:41 ` [Xen-devel] " Herbert Xu
2006-05-09 23:51 ` Chris Wright
2006-05-10 6:36 ` Keir Fraser
2006-05-09 7:00 ` [RFC PATCH 35/35] Add Xen virtual block " Chris Wright
2006-05-09 12:01 ` Christoph Hellwig
2006-05-09 14:49 ` [RFC PATCH 00/35] Xen i386 paravirtualization support Martin J. Bligh
2006-05-09 15:07 ` Christoph Hellwig
2006-05-09 15:12 ` Martin J. Bligh
2006-05-09 15:20 ` Andi Kleen
2006-05-09 15:22 ` Christoph Hellwig
2006-05-09 15:45 ` Pekka Enberg
2006-05-14 1:35 ` Andrew Morton
2006-05-15 21:01 ` Chris Wright
-- strict thread matches above, loose matches on Subject: below --
2006-03-22 6:30 Chris Wright
2006-03-22 6:30 ` [RFC PATCH 11/35] Add support for Xen to entry.S Chris Wright
2006-03-22 13:55 ` Andi Kleen
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=20060509085152.524462000@sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=Christian.Limpach@cl.cam.ac.uk \
--cc=ian.pratt@xensource.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.org \
--cc=xen-devel@lists.xensource.com \
/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