From e81b2403d9c981d6e17e4cc9fc38bf5d5b0c2055 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 24 Dec 2015 23:14:23 +0000 Subject: [PATCH] Factor low level difference between PV and HVM into macros to reduce code duplication when further entry/exit paths are added. Signed-off-by: Andrew Cooper --- arch/x86/entry_32.S | 18 +++++++++++------- arch/x86/entry_64.S | 33 ++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/arch/x86/entry_32.S b/arch/x86/entry_32.S index 7d3a1ad..a22bce2 100644 --- a/arch/x86/entry_32.S +++ b/arch/x86/entry_32.S @@ -22,6 +22,16 @@ containing the entry vector. */ +.macro env_IRET /* Environment specific version of `iret`. */ +#if defined(CONFIG_ENV_pv) + + jmp HYPERCALL_iret /* PV guests use the 'iret' hypercall. */ + +#else + iret /* HVM guests use a real 'iret' instruction. */ +#endif +.endm + .macro exception_entry sym vec ENTRY(entry_\sym) @@ -69,10 +79,4 @@ handle_exception: RESTORE_ALL add $8, %esp /* Pop error_code/entry_vector. */ -#if defined(CONFIG_ENV_pv) - - jmp HYPERCALL_iret /* PV guests use the 'iret' hypercall. */ - -#else - iret /* HVM guests use a real 'iret' instruction. */ -#endif + env_IRET diff --git a/arch/x86/entry_64.S b/arch/x86/entry_64.S index dbfbb96..a0fb058 100644 --- a/arch/x86/entry_64.S +++ b/arch/x86/entry_64.S @@ -27,15 +27,29 @@ metadata. Currently just the entry vector. */ -.macro exception_entry sym vec - -ENTRY(entry_\sym) - +.macro env_ADJUST_FRAME /* Environment specific exception entry. */ #if defined(CONFIG_ENV_pv64) - /* Restore results of Xen SYSRET'ing to this point. */ + /* Restore results of Xen SYSRET'ing to this point. */ pop %rcx pop %r11 #endif +.endm + +.macro env_IRETQ /* Environment specific version of `iretq`. */ +#if defined(CONFIG_ENV_pv64) + + push $0 /* Indicate that this isn't a SYSRET'able */ + jmp HYPERCALL_iret /* situation, and use the 'iret' hypercall. */ + +#else + iretq /* HVM guests use a real 'iretq' instruction. */ +#endif +.endm + +.macro exception_entry sym vec + +ENTRY(entry_\sym) + env_ADJUST_FRAME .if !((1 << \vec) & X86_EXC_HAVE_EC) /* Push dummy error code (if needed) to align stack. */ @@ -79,11 +93,4 @@ handle_exception: RESTORE_ALL add $8, %rsp /* Pop error_code/entry_vector. */ -#if defined(CONFIG_ENV_pv) - - push $0 /* Indicate that this isn't a SYSRET'able */ - jmp HYPERCALL_iret /* situation, and use the 'iret' hypercall. */ - -#else - iretq /* HVM guests use a real 'iret' instruction. */ -#endif + env_IRETQ -- 2.39.5