From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Stephen Tweedie <sct@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Mark McLoughlin <markmc@redhat.com>,
x86@kernel.org
Subject: [PATCH 27 of 55] xen64: add hypervisor callbacks for events, etc
Date: Tue, 08 Jul 2008 15:06:49 -0700 [thread overview]
Message-ID: <43817046e3f319aeec96.1215554809@localhost> (raw)
In-Reply-To: <patchbomb.1215554782@localhost>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
arch/x86/kernel/entry_64.S | 98 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1312,3 +1312,101 @@
sysret
CFI_ENDPROC
ENDPROC(ignore_sysret)
+
+#ifdef CONFIG_XEN
+ENTRY(xen_hypervisor_callback)
+ zeroentry xen_do_hypervisor_callback
+END(xen_hypervisor_callback)
+
+/*
+# A note on the "critical region" in our callback handler.
+# We want to avoid stacking callback handlers due to events occurring
+# during handling of the last event. To do this, we keep events disabled
+# until we've done all processing. HOWEVER, we must enable events before
+# popping the stack frame (can't be done atomically) and so it would still
+# be possible to get enough handler activations to overflow the stack.
+# Although unlikely, bugs of that kind are hard to track down, so we'd
+# like to avoid the possibility.
+# So, on entry to the handler we detect whether we interrupted an
+# existing activation in its critical region -- if so, we pop the current
+# activation and restart the handler using the previous one.
+*/
+ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
+ CFI_STARTPROC
+/* Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
+ see the correct pointer to the pt_regs */
+ movq %rdi, %rsp # we don't return, adjust the stack frame
+ CFI_ENDPROC
+ CFI_DEFAULT_STACK
+11: incl %gs:pda_irqcount
+ movq %rsp,%rbp
+ CFI_DEF_CFA_REGISTER rbp
+ cmovzq %gs:pda_irqstackptr,%rsp
+ pushq %rbp # backlink for old unwinder
+ call xen_evtchn_do_upcall
+ popq %rsp
+ CFI_DEF_CFA_REGISTER rsp
+ decl %gs:pda_irqcount
+ jmp error_exit
+ CFI_ENDPROC
+END(do_hypervisor_callback)
+
+/*
+# Hypervisor uses this for application faults while it executes.
+# We get here for two reasons:
+# 1. Fault while reloading DS, ES, FS or GS
+# 2. Fault while executing IRET
+# Category 1 we do not need to fix up as Xen has already reloaded all segment
+# registers that could be reloaded and zeroed the others.
+# Category 2 we fix up by killing the current process. We cannot use the
+# normal Linux return path in this case because if we use the IRET hypercall
+# to pop the stack frame we end up in an infinite loop of failsafe callbacks.
+# We distinguish between categories by comparing each saved segment register
+# with its current contents: any discrepancy means we in category 1.
+*/
+ENTRY(xen_failsafe_callback)
+#if 1
+ ud2a
+#else
+ _frame (RIP-0x30)
+ CFI_REL_OFFSET rcx, 0
+ CFI_REL_OFFSET r11, 8
+ movw %ds,%cx
+ cmpw %cx,0x10(%rsp)
+ CFI_REMEMBER_STATE
+ jne 1f
+ movw %es,%cx
+ cmpw %cx,0x18(%rsp)
+ jne 1f
+ movw %fs,%cx
+ cmpw %cx,0x20(%rsp)
+ jne 1f
+ movw %gs,%cx
+ cmpw %cx,0x28(%rsp)
+ jne 1f
+ /* All segments match their saved values => Category 2 (Bad IRET). */
+ movq (%rsp),%rcx
+ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
+ CFI_RESTORE r11
+ addq $0x30,%rsp
+ CFI_ADJUST_CFA_OFFSET -0x30
+ movq $11,%rdi /* SIGSEGV */
+ jmp do_exit
+ CFI_RESTORE_STATE
+1: /* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
+ movq (%rsp),%rcx
+ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
+ CFI_RESTORE r11
+ addq $0x30,%rsp
+ CFI_ADJUST_CFA_OFFSET -0x30
+ pushq $0
+ CFI_ADJUST_CFA_OFFSET 8
+ SAVE_ALL
+ jmp error_exit
+ CFI_ENDPROC
+#endif
+END(xen_failsafe_callback)
+
+#endif /* CONFIG_XEN */
next prev parent reply other threads:[~2008-07-08 23:20 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-08 22:06 [PATCH 00 of 55] xen64: implement 64-bit Xen support Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 01 of 55] x86/paravirt: Call paravirt_pagetable_setup_{start, done} Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 02 of 55] pvops-64: call paravirt_post_allocator_init() on setup_arch() Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 03 of 55] x86_64: there's no need to preallocate level1_fixmap_pgt Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 04 of 55] x86: clean up formatting of __switch_to Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 05 of 55] x86: use __page_aligned_data/bss Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 06 of 55] x86_64: adjust exception frame in ia32entry Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 07 of 55] x86_64: unstatic get_local_pda Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 08 of 55] xen: print backtrace on multicall failure Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 09 of 55] xen-netfront: fix xennet_release_tx_bufs() Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 10 of 55] xen: add xen_arch_resume()/xen_timer_resume hook for ia64 support Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 11 of 55] xen: define set_pte from the outset Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 12 of 55] xen64: define asm/xen/interface for 64-bit Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 13 of 55] xen: make ELF notes work for 32 and 64 bit Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 14 of 55] xen: fix 64-bit hypercall variants Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 15 of 55] xen64: fix calls into hypercall page Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 16 of 55] xen64: add extra pv_mmu_ops Jeremy Fitzhardinge
2008-07-09 7:55 ` Mark McLoughlin
2008-07-09 8:02 ` Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 17 of 55] xen64: random ifdefs to mask out 32-bit only code Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 18 of 55] xen64: get active_mm from the pda Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 19 of 55] xen: move smp setup into smp.c Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 20 of 55] x86_64: add workaround for no %gs-based percpu Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 21 of 55] xen64: smp.c compile hacking Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 22 of 55] xen64: add xen-head code to head_64.S Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 23 of 55] xen64: add asm-offsets Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 24 of 55] xen64: add 64-bit assembler Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 25 of 55] xen64: use set_fixmap for shared_info structure Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 26 of 55] xen: cpu_detect is 32-bit only Jeremy Fitzhardinge
2008-07-08 22:06 ` Jeremy Fitzhardinge [this message]
2008-07-08 22:06 ` [PATCH 28 of 55] xen64: early mapping setup Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 29 of 55] xen64: 64-bit starts using set_pte from very early Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 30 of 55] xen64: map an initial chunk of physical memory Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 31 of 55] xen32: create initial mappings like 64-bit Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 32 of 55] xen: fix truncation of machine address Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 33 of 55] xen64: use arbitrary_virt_to_machine for xen_set_pmd Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 34 of 55] xen: set num_processors Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 35 of 55] xen64: defer setting pagetable alloc/release ops Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 36 of 55] xen: use set_pte_vaddr Jeremy Fitzhardinge
2008-07-08 22:06 ` [PATCH 37 of 55] xen64: xen_write_idt_entry() and cvt_gate_to_trap() Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 38 of 55] xen64: deal with extra words Xen pushes onto exception frames Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 39 of 55] xen64: add pvop for swapgs Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 40 of 55] xen64: register callbacks in arch-independent way Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 41 of 55] xen64: add identity irq->vector map Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 42 of 55] Xen64: HYPERVISOR_set_segment_base() implementation Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 43 of 55] xen64: implement xen_load_gs_index() Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 44 of 55] xen: rework pgd_walk to deal with 32/64 bit Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 45 of 55] xen: make sure the kernel command line is right Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 46 of 55] xen: enable PM_SLEEP for CONFIG_XEN Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 47 of 55] xen64: implement failsafe callback Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 48 of 55] xen64: Clear %fs on xen_load_tls() Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 49 of 55] xen64: implement 64-bit update_descriptor Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 50 of 55] xen64: save lots of registers Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 51 of 55] xen64: allocate and manage user pagetables Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 52 of 55] xen64: set up syscall and sysenter entrypoints for 64-bit Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 53 of 55] xen64: set up userspace syscall patch Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 54 of 55] xen: implement Xen write_msr operation Jeremy Fitzhardinge
2008-07-08 22:07 ` [PATCH 55 of 55] xen: update Kconfig to allow 64-bit Xen Jeremy Fitzhardinge
2008-07-09 11:12 ` [PATCH 00 of 55] xen64: implement 64-bit Xen support Ingo Molnar
2008-07-09 11:16 ` [patch] power, xen64: fix PM_SLEEP build dependencies (was: Re: [PATCH 00 of 55] xen64: implement 64-bit Xen support) Ingo Molnar
2008-07-09 19:47 ` Ingo Molnar
2008-07-09 19:52 ` Ingo Molnar
2008-07-09 19:59 ` Rafael J. Wysocki
2008-07-09 20:02 ` Rafael J. Wysocki
2008-07-09 20:04 ` Ingo Molnar
2008-07-09 20:17 ` [patch] power, xen64: fix PM_SLEEP build dependencies Jeremy Fitzhardinge
2008-07-09 20:17 ` [patch] power, xen64: fix PM_SLEEP build dependencies (was: Re: [PATCH 00 of 55] xen64: implement 64-bit Xen support) Rafael J. Wysocki
2008-07-09 20:23 ` [patch] power, xen64: fix PM_SLEEP build dependencies Jeremy Fitzhardinge
2008-07-09 20:26 ` Ingo Molnar
2008-07-09 20:33 ` Rafael J. Wysocki
2008-07-09 20:39 ` Jeremy Fitzhardinge
2008-07-09 20:42 ` Ingo Molnar
2008-07-09 20:53 ` Rafael J. Wysocki
2008-07-09 20:23 ` [patch] power, xen64: fix PM_SLEEP build dependencies (was: Re: [PATCH 00 of 55] xen64: implement 64-bit Xen support) Ingo Molnar
2008-07-09 20:40 ` [patch] power, xen64: fix PM_SLEEP build dependencies Jeremy Fitzhardinge
2008-07-09 11:21 ` [patch] xen64: fix !HVC_XEN build dependency (was: Re: [PATCH 00 of 55] xen64: implement 64-bit Xen support) Ingo Molnar
2008-07-09 16:07 ` [patch] xen64: fix !HVC_XEN build dependency Jeremy Fitzhardinge
2008-07-09 11:47 ` [patch] xen64: fix build error on 32-bit + !HIGHMEM (was: Re: [PATCH 00 of 55] xen64: implement 64-bit Xen support) Ingo Molnar
2008-07-09 16:07 ` [patch] xen64: fix build error on 32-bit + !HIGHMEM Jeremy Fitzhardinge
2008-07-09 16:12 ` [PATCH 00 of 55] xen64: implement 64-bit Xen support 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=43817046e3f319aeec96.1215554809@localhost \
--to=jeremy@goop.org \
--cc=ehabkost@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markmc@redhat.com \
--cc=mingo@elte.hu \
--cc=sct@redhat.com \
--cc=x86@kernel.org \
/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