Date: Sun, 7 Apr 2013 10:07:18 +0000 (UTC) From: "Cherry G. Mathew" <cherry@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r249225 - projects/amd64_xen_pv/sys/amd64/xen Message-ID: <201304071007.r37A7IuQ099905@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cherry Date: Sun Apr 7 10:07:18 2013 New Revision: 249225 URL: http://svnweb.freebsd.org/changeset/base/249225 Log: Normalise stackframe exit layout for both errorcode bearing exceptions and others. This makes INTR_EXIT() work as expected. Fixes: Return to guest from events, exceptions and traps. Approved by: gibbs(implicit) Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/exception.S Sun Apr 7 06:47:44 2013 (r249224) +++ projects/amd64_xen_pv/sys/amd64/xen/exception.S Sun Apr 7 10:07:18 2013 (r249225) @@ -105,8 +105,29 @@ #define RESTORE_SEGMENT_REGS \ call restore_segment_regs -/* stackframe management for trap() */ -/* Undo the work of the Xen template code */ +/* stackframe management for trap() + * + * Xen creates a "bounce frame" in the following format: + * { RCX, R11, [DS-GS,] [ERRCODE,] RIP, CS, RFLAGS, RSP, SS } + * + * Erratum: Comments in the Xen sources talk about [CR2] saved on the + * stackframe, but the code for this is not to be found. + * c.f: xen/arch/x86/x86_64/entry.S + * + * [DS-GS,] is only saved for the failsafe callback. + * + * [ERRCODE], is optional, depending on the type of (hardware) exception. + * See: the "AMD64 Architecture Programmer's Manuel, Volume 2: + * System Programming: Section 8.2 for individual error code + * reporting status + * + */ +/* + * Prepare the frame for a non-failsafe entry point. + * We frob the stack so it looks like the native entry point. + * See: "hardware defined" part of x86/frame.h struct trapframe; + */ + #define TRAP_FRAME_PREPARE \ movq (%rsp), %rcx ; \ movq 8(%rsp), %r11 ; \ @@ -130,11 +151,21 @@ TRAP_FRAME_PREPARE ; \ subq $TF_ERR, %rsp +/* + * Setting up the exit stackframe involves resetting the stack layout + * identically to that of an exception without error code. The reason + * for this is that in order to "iret", we make a hypervisor call, and + * this hypervisor call is a syscall which expects an 'error code' on + * the stack. We accomplish this by pushing quadword '0' onto the + * stack in the INTR_EXIT() stub. + * + */ + #define TRAP_FRAME_EXIT_NOERR \ addq $TF_RIP, %rsp #define TRAP_FRAME_EXIT_ERR \ - addq $TF_ERR, %rsp + addq $TF_RIP, %rsp #define TRAP_PROLOGUE(a) \ movl $(a), TF_TRAPNO(%rsp) ; \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304071007.r37A7IuQ099905>