[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH for-next v3 17/22] x86/traps: move hypercall_page_initialise_ring3_kernel
And export it via pv/domain.h. No functional change. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/arch/x86/pv/traps.c | 36 ++++++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/traps.c | 37 +------------------------------------ xen/include/asm-x86/pv/domain.h | 5 +++++ 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 7cdec77618..4f52d3e4d3 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -580,6 +580,42 @@ long do_set_callbacks(unsigned long event_address, return 0; } +void hypercall_page_initialise_ring3_kernel(void *hypercall_page) +{ + char *p; + int i; + + /* Fill in all the transfer points with template machine code. */ + for ( i = 0; i < (PAGE_SIZE / 32); i++ ) + { + if ( i == __HYPERVISOR_iret ) + continue; + + p = (char *)(hypercall_page + (i * 32)); + *(u8 *)(p+ 0) = 0x51; /* push %rcx */ + *(u16 *)(p+ 1) = 0x5341; /* push %r11 */ + *(u8 *)(p+ 3) = 0xb8; /* mov $<i>,%eax */ + *(u32 *)(p+ 4) = i; + *(u16 *)(p+ 8) = 0x050f; /* syscall */ + *(u16 *)(p+10) = 0x5b41; /* pop %r11 */ + *(u8 *)(p+12) = 0x59; /* pop %rcx */ + *(u8 *)(p+13) = 0xc3; /* ret */ + } + + /* + * HYPERVISOR_iret is special because it doesn't return and expects a + * special stack frame. Guests jump at this transfer point instead of + * calling it. + */ + p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32)); + *(u8 *)(p+ 0) = 0x51; /* push %rcx */ + *(u16 *)(p+ 1) = 0x5341; /* push %r11 */ + *(u8 *)(p+ 3) = 0x50; /* push %rax */ + *(u8 *)(p+ 4) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ + *(u32 *)(p+ 5) = __HYPERVISOR_iret; + *(u16 *)(p+ 9) = 0x050f; /* syscall */ +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index db2037509e..7a4dd4458e 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -23,6 +23,7 @@ #include <asm/shared.h> #include <asm/hvm/hvm.h> #include <asm/hvm/support.h> +#include <asm/pv/domain.h> static void print_xen_info(void) { @@ -334,42 +335,6 @@ void subarch_percpu_traps_init(void) wrmsrl(MSR_SYSCALL_MASK, XEN_SYSCALL_MASK); } -static void hypercall_page_initialise_ring3_kernel(void *hypercall_page) -{ - char *p; - int i; - - /* Fill in all the transfer points with template machine code. */ - for ( i = 0; i < (PAGE_SIZE / 32); i++ ) - { - if ( i == __HYPERVISOR_iret ) - continue; - - p = (char *)(hypercall_page + (i * 32)); - *(u8 *)(p+ 0) = 0x51; /* push %rcx */ - *(u16 *)(p+ 1) = 0x5341; /* push %r11 */ - *(u8 *)(p+ 3) = 0xb8; /* mov $<i>,%eax */ - *(u32 *)(p+ 4) = i; - *(u16 *)(p+ 8) = 0x050f; /* syscall */ - *(u16 *)(p+10) = 0x5b41; /* pop %r11 */ - *(u8 *)(p+12) = 0x59; /* pop %rcx */ - *(u8 *)(p+13) = 0xc3; /* ret */ - } - - /* - * HYPERVISOR_iret is special because it doesn't return and expects a - * special stack frame. Guests jump at this transfer point instead of - * calling it. - */ - p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32)); - *(u8 *)(p+ 0) = 0x51; /* push %rcx */ - *(u16 *)(p+ 1) = 0x5341; /* push %r11 */ - *(u8 *)(p+ 3) = 0x50; /* push %rax */ - *(u8 *)(p+ 4) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ - *(u32 *)(p+ 5) = __HYPERVISOR_iret; - *(u16 *)(p+ 9) = 0x050f; /* syscall */ -} - #include "compat/traps.c" void hypercall_page_initialise(struct domain *d, void *hypercall_page) diff --git a/xen/include/asm-x86/pv/domain.h b/xen/include/asm-x86/pv/domain.h index acdf140fbd..dfa60b080c 100644 --- a/xen/include/asm-x86/pv/domain.h +++ b/xen/include/asm-x86/pv/domain.h @@ -29,6 +29,8 @@ void pv_domain_destroy(struct domain *d); int pv_domain_initialise(struct domain *d, unsigned int domcr_flags, struct xen_arch_domainconfig *config); +void hypercall_page_initialise_ring3_kernel(void *hypercall_page); + #else /* !CONFIG_PV */ #include <xen/errno.h> @@ -42,6 +44,9 @@ static inline int pv_domain_initialise(struct domain *d, { return -EOPNOTSUPP; } + +void hypercall_page_initialise_ring3_kernel(void *hypercall_page) {} + #endif /* CONFIG_PV */ void paravirt_ctxt_switch_from(struct vcpu *v); -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |