HVM x86 deprivileged mode operations
v2 cover HVM x86 deprivileged mode operations
Hi all,
I have made requested changes and reworked the patch series based on the comments recieved. Thank you to all of the contributors to those discussions! The next step will be to provide an example of usage of this system which will follow in another patch.
The main changes from v1 are:
- No longer copying the privileged Xen stack but instead change the interrupt/exception, syscall and sysenter pointers to be below the current execution point.
- AMD SVM support
- Stop IST copying onto the privileged stack
- Watchdog timer to kill a long running deprivileged domain
- Support for crashing a domain whilst performing a deprivileged operation
- .text section is now aliased
- Assembly updates
- Updated deprivileged context switching code to fix bugs
- Moved processor-specific code to processor-specific files
- Reduction of user stack sizes
- Updates to interfaces and an is_hvm_deprivileged_mode() style test
- Small bug fixes
- Revised performance tests
Many thanks in advance,
Ben
The aim of this work is to create a proof-of-concept to establish if it is feasible to move certain Xen operations into a deprivileged context to mitigate the impact of a bug or compromise in such areas. An example would be x86_emulate or virtual device emulation which is not done in QEMU for performance reasons.
Performance testing
-------------------
Performance testing indicates that the overhead for this deprivileged mode depend heavily upon the processor. This overhead is the cost of moving into deprivileged mode and then fully back out of deprivileged mode. The conclusions are that the overheads are not negligible and that operations using this mechanism would benefit from being long running or be high risk components. It will need to be evaluated on a case-by-case basis.
I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python script within the HVM guest using time.time() and running Debian Jessie. Each write was trapped to cause a vmexit and the time for each write was calculated. The port operation is bypassed so that no portio is actually performed. Thus, the differences in the measurements below can be taken as the pure overhead. These experiments were repeated. Note that only the host and this HVM guest were running (both Debian Jessie) during the experiments.
Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.
5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.
So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.
So approximately 178% overhead.
RFC PATCH v2 1/4 HVM x86 deprivileged mode: Create deprivileged page tables
The paging structure mappings for the deprivileged mode are added to the monitor page table for HVM guests for HAP and shadow table paging. The entries are generated by walking the page tables and mapping in new pages. Access bits are flipped as needed.
The page entries are generated for deprivileged .text, .data and a stack. The .text section is only allocated once at HVM domain initialisation and then we alias it from then onwards. The data section is copied from sections allocated by the linker. The mappings are setup in an unused portion of the Xen virtual address space. The pages are mapped in as user mode accessible, with NX bits set for the data and stack regions and the code region is set to be executable and read-only.
The needed pages are allocated on the paging heap and are deallocated when those heap pages are deallocated (on domain destruction).
Changes since v1
----------------
* .text section is now aliased when needed
* Reduced user stack size to two pages
* Changed allocator used for pages
* Changed types to using __hvm_$foo[] for linker variables
* Moved some #define's to page.h
* Small bug fix: Testing global bit on L3 not relevant
--- xen/arch/x86/hvm/Makefile | 1 + xen/arch/x86/hvm/deprivileged.c | 514 +++++++++++++++++++++++++++++++++++++ xen/arch/x86/mm/hap/hap.c | 8 + xen/arch/x86/mm/shadow/multi.c | 8 + xen/arch/x86/xen.lds.S | 19 ++ xen/include/asm-x86/config.h | 29 ++- xen/include/asm-x86/x86_64/page.h | 15 ++ xen/include/xen/hvm/deprivileged.h | 90 +++++++ xen/include/xen/sched.h | 4 + 9 files changed, 681 insertions(+), 7 deletions(-) create mode 100644 xen/arch/x86/hvm/deprivileged.c create mode 100644 xen/include/xen/hvm/deprivileged.h
xen/arch/x86/hvm/Makefile +1 -0
@@ -2,6 +2,7 @@ subdir-y += svm subdir-y += vmx obj-y += asid.o +obj-y += deprivileged.o obj-y += emulate.o obj-y += event.o obj-y += hpet.o
xen/arch/x86/hvm/deprivileged.c new file +514 -0
514 lines not on this page · raw message
xen/arch/x86/mm/hap/hap.c +8 -0
@@ -42,6 +42,7 @@#include <asm/hvm/nestedhvm.h> #include "private.h" +#include <xen/hvm/deprivileged.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef mfn_to_page
@@ -401,6 +402,9 @@ static void hap_install_xen_entries_in_l4(struct vcpu *v, mfn_t l4mfn) &idle_pg_table[ROOT_PAGETABLE_FIRST_XEN_SLOT ], ROOT_PAGETABLE_XEN_SLOTS * sizeof(l4_pgentry_t)); +/* Initialise the HVM deprivileged mode feature */ +hvm_deprivileged_init (d, l4e); +/* Install the per-domain mappings for this domain */ l4e[l4_table_offset (PERDOMAIN_VIRT_START )] = l4e_from_pfn(mfn_x(page_to_mfn(d->arch.perdomain_l3_pg)),
@@ -439,6 +443,10 @@ static void hap_destroy_monitor_table(struct vcpu* v, mfn_t mmfn)/* Put the memory back in the pool */ hap_free (d, mmfn); + +/* Destroy the HVM tables */ +ASSERT (paging_locked_by_me (d)); +hvm_deprivileged_destroy (d); }/************************************************/
xen/arch/x86/mm/shadow/multi.c +8 -0
@@ -38,6 +38,7 @@#include <asm/mtrr.h> #include <asm/guest_pt.h> #include <public/sched.h> +#include <xen/hvm/deprivileged.h> #include "private.h" #include "types.h"
@@ -1429,6 +1430,13 @@ void sh_install_xen_entries_in_l4(struct domain *d, mfn_t gl4mfn, mfn_t sl4mfn) &idle_pg_table[ROOT_PAGETABLE_FIRST_XEN_SLOT ], slots * sizeof(l4_pgentry_t)); +/* +* Initialise the HVM deprivileged mode feature. +* The shadow_l4e_t is a typedef for l4_pgentry_t as are all of the +* paging structure so this method will work for the shadow table as well. +*/ +hvm_deprivileged_init (d, (l4_pgentry_t *)sl4e); +/* Install the per-domain mappings for this domain */ sl4e[shadow_l4_table_offset (PERDOMAIN_VIRT_START )] = shadow_l4e_from_mfn(page_to_mfn(d->arch.perdomain_l3_pg),
xen/arch/x86/xen.lds.S +19 -0
@@ -50,6 +50,25 @@ SECTIONS _etext = .; /* End of text section */ } :text = 0x9090 + /* HVM deprivileged mode segments + * Used to map the ring3 static data and .text + */ + + . = ALIGN(PAGE_SIZE); + .hvm_deprivileged_text : { + __hvm_deprivileged_text_start = . ; + *(.hvm_deprivileged_enhancement.text) + __hvm_deprivileged_text_end = . ; + } : text + + . = ALIGN(PAGE_SIZE); + .hvm_deprivileged_data : { + __hvm_deprivileged_data_start = . ; + *(.hvm_deprivileged_enhancement.data) + __hvm_deprivileged_data_end = . ; + } : text + + . = ALIGN(PAGE_SIZE); .rodata : { /* Bug frames table */ . = ALIGN(4);
xen/include/asm-x86/config.h +22 -7
@@ -183,10 +183,12 @@ extern unsigned char boot_edid_info[128];#endif * 0xffff880000000000 - 0xffffffffffffffff [120TB, PML4:272-511] * PV: Guest-defined use. - * 0xffff880000000000 - 0xffffff7fffffffff [119.5TB, PML4:272-510] + * 0xffff880000000000 - 0xffffff0000000000 [119TB, PML4:272-509] * HVM/idle: continuation of 1:1 mapping + * 0xffffff0000000000 - 0xfffff7ffffffffff [512GB, 2^39 bytes PML4:510] + * HVM: HVM deprivileged mode .text segment * 0xffffff8000000000 - 0xffffffffffffffff [512GB, 2^39 bytes PML4:511] - * HVM/idle: unused + * HVM: HVM deprivileged mode data and stack segments * * Compatibility guest area layout: * 0x0000000000000000 - 0x00000000f57fffff [3928MB, PML4:0]
@@ -201,7 +203,6 @@ extern unsigned char boot_edid_info[128];* Reserved for future use. */ -#define ROOT_PAGETABLE_FIRST_XEN_SLOT 256#define ROOT_PAGETABLE_LAST_XEN_SLOT 271#define ROOT_PAGETABLE_XEN_SLOTS \
@@ -270,16 +271,30 @@ extern unsigned char boot_edid_info[128];#define FRAMETABLE_VIRT_START (FRAMETABLE_VIRT_END - FRAMETABLE_SIZE)#ifndef CONFIG_BIGMEM -/* Slot 262-271/510: A direct 1:1 mapping of all of physical memory. */ +/* Slot 262-271/509: A direct 1:1 mapping of all of physical memory. */ #define DIRECTMAP_VIRT_START (PML4_ADDR(262)) -#define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 262)) +#define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (510 - 262))#else -/* Slot 265-271/510: A direct 1:1 mapping of all of physical memory. */ +/* Slot 265-271/509: A direct 1:1 mapping of all of physical memory. */ #define DIRECTMAP_VIRT_START (PML4_ADDR(265)) -#define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (511 - 265)) +#define DIRECTMAP_SIZE (PML4_ENTRY_BYTES * (510 - 265))#endif #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE) +/* +* Slots 510-511: HVM deprivileged mode +* The virtual addresses where the .text, .data and stack should be +* placed. +* We put the .text section in 510 by itself so that, we can easily create an +* alias of it. This is because we use the same mfn for a page entry when +* aliasign it and so, if we put the data and text in with the .text at PML4 +* level then, they would conflict with the other address spaces which is not +* correct. +*/ +#define HVM_DEPRIVILEGED_TEXT_ADDR (PML4_ADDR(510)) +#define HVM_DEPRIVILEGED_DATA_ADDR (PML4_ADDR(511) + 0xa000000) +#define HVM_DEPRIVILEGED_STACK_ADDR (PML4_ADDR(511) + 0xc000000) +#ifndef __ASSEMBLY__/* This is not a fixed value, just a lower limit. */
xen/include/asm-x86/x86_64/page.h +15 -0
@@ -22,6 +22,21 @@#define __PAGE_OFFSET DIRECTMAP_VIRT_START#define __XEN_VIRT_START XEN_VIRT_START +/* The sizes of the pages */ +#define PAGESIZE_1GB (1ul << L3_PAGETABLE_SHIFT) +#define PAGESIZE_2MB (1ul << L2_PAGETABLE_SHIFT) +#define PAGESIZE_4KB (1ul << L1_PAGETABLE_SHIFT) + +/* +* The size in bytes that a single L(1,2,3,4} entry covers. +* There are 512 (left shift by 9) entries in each page-structure. +*/ +#define L4_PAGE_RANGE (PAGESIZE_1GB << 9) +#define L3_PAGE_RANGE (PAGESIZE_2MB << 9) +#define L2_PAGE_RANGE (PAGESIZE_4KB << 9) +#define L1_PAGE_RANGE (PAGESIZE_4KB ) + +/* These are architectural limits. Current CPUs support only 40-bit phys. */ #define PADDR_BITS 52#define VADDR_BITS 48
xen/include/xen/hvm/deprivileged.h new file +90 -0
90 lines not on this page · raw message
xen/include/xen/sched.h +4 -0
@@ -462,6 +462,10 @@ struct domain/* vNUMA topology accesses are protected by rwlock. */ rwlock_t vnuma_rwlock;struct vnuma_info *vnuma; + +/* HVM deprivileged mode data */ +int hvm_depriv_valid_l4e_code; +l4_pgentry_t hvm_depriv_l4e_code; };struct domain_setup_info
Signature · 1 line
2.1.4
RFC PATCH v2 2/4 HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode
In reply to Ben CatterallThe process to switch into and out of deprivileged mode can be likened to setjmp/longjmp.
Xen is non-preemptive and taking an interrupt/exception, SYSCALL, SYSENTER, NMI or any IST will currently clobber the Xen privileged stack. We need this stack to be preserved so that after executing deprivileged mode, we can return to our previous privileged execution point. This allows us to unwind the stack, cleaning up memory allocations.
To enter deprivileged mode, we move the interrupt/exception rsp, SYSENTER rsp and SYSCALL rsp to point to lower down Xen's privileged stack to prevent them from clobbering it. The IST NMI and DF handlers used to copy themselves onto the privileged stack. This is no longer the case, they now leave themselves on their predefined stacks.
This means that we can continue execution from that point. This is similar behaviour to a context switch.
To exit deprivileged mode, we restore the original interrupt/exception rsp, SYSENTER rsp and SYSCALL rsp. We can then continue execution from where we left off, which will unwind the stack and free up resources. This method means that we do not need to change any other code paths and its invocation will be transparent to callers. This should allow the feature to be more easily deployed to different parts of Xen.
The switch to and from deprivileged mode is performed using sysret and syscall respectively.
Changed since v1
----------------
* Added support for AMD SVM
* Moved to the new stack approach
* IST handlers no longer copy themselves
* Updated context switching code to perform a full context-switch. This means that depriv mode will execute with host register states not (partial) guest register state. This allows for crashing the domain (later patch) whilst in depriv mode, alleviates potential security vulnerabilities and is necessaryto work around the AMD TR issue.
* Moved processor-specific code to processor-specific files.
* Changed call/jmp pair in deprivileged_asm.S to call/ret pair to not confuse processor branch predictors.
--- xen/arch/x86/domain.c | 12 +++ xen/arch/x86/hvm/Makefile | 1 + xen/arch/x86/hvm/deprivileged.c | 103 ++++++++++++++++++++++ xen/arch/x86/hvm/deprivileged_asm.S | 167 ++++++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/svm/svm.c | 130 +++++++++++++++++++++++++++- xen/arch/x86/hvm/vmx/vmx.c | 118 +++++++++++++++++++++++++ xen/arch/x86/mm/hap/hap.c | 2 +- xen/arch/x86/x86_64/asm-offsets.c | 5 ++ xen/arch/x86/x86_64/entry.S | 38 ++++++-- xen/arch/x86/x86_64/traps.c | 13 ++- xen/include/asm-x86/current.h | 2 + xen/include/asm-x86/hvm/svm/svm.h | 13 +++ xen/include/asm-x86/hvm/vcpu.h | 15 ++++ xen/include/asm-x86/hvm/vmx/vmx.h | 2 + xen/include/asm-x86/processor.h | 2 + xen/include/asm-x86/system.h | 3 + xen/include/xen/hvm/deprivileged.h | 45 ++++++++++ xen/include/xen/sched.h | 18 +++- 18 files changed, 674 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/hvm/deprivileged_asm.S
xen/arch/x86/domain.c +12 -0
@@ -62,6 +62,7 @@#include <xen/iommu.h> #include <compat/vcpu.h> #include <asm/psr.h> +#include <xen/hvm/deprivileged.h> DEFINE_PER_CPU(struct vcpu *, curr_vcpu); DEFINE_PER_CPU(unsigned long, cr4);
@@ -446,6 +447,12 @@ int vcpu_initialise(struct vcpu *v)if (has_hvm_container_domain (d) ) { rc =hvm_vcpu_initialise (v); + +/* Initialise HVM deprivileged mode */ +printk ("HVM initialising deprivileged mode ..." ); +hvm_deprivileged_prepare_vcpu (v); +printk ("Done.\n" ); + goto done; }
@@ -523,7 +530,12 @@ void vcpu_destroy(struct vcpu *v)vcpu_destroy_fpu (v);if (has_hvm_container_vcpu (v) ) + { +/* Destroy the deprivileged mode on this vcpu */ +hvm_deprivileged_destroy_vcpu (v); +hvm_vcpu_destroy (v); + }else xfree (v->arch.pv_vcpu.trap_ctxt); }
xen/arch/x86/hvm/Makefile +1 -0
@@ -3,6 +3,7 @@ subdir-y += vmx obj-y += asid.o obj-y += deprivileged.o +obj-y += deprivileged_asm.o obj-y += emulate.o obj-y += event.o obj-y += hpet.o
xen/arch/x86/hvm/deprivileged.c +103 -0
106 lines not on this page · raw message
xen/arch/x86/hvm/deprivileged_asm.S new file +167 -0
167 lines not on this page · raw message
xen/arch/x86/hvm/svm/svm.c +129 -1
166 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vmx.c +118 -0
154 lines not on this page · raw message
xen/arch/x86/mm/hap/hap.c +1 -1
@@ -40,7 +40,7 @@#include <asm/domain.h> #include <xen/numa.h> #include <asm/hvm/nestedhvm.h> - +#include <asm/hvm/vmx/vmx.h> #include "private.h" #include <xen/hvm/deprivileged.h>
xen/arch/x86/x86_64/asm-offsets.c +5 -0
@@ -115,6 +115,11 @@ void __dummy__(void) OFFSET(VCPU_nsvm_hap_enabled, struct vcpu, arch.hvm_vcpu.nvcpu.u.nsvm.ns_hap_enabled);BLANK (); + OFFSET(VCPU_depriv_rsp, struct vcpu, arch.hvm_vcpu.depriv_rsp); + OFFSET(VCPU_depriv_user_mode, struct vcpu, arch.hvm_vcpu.depriv_user_mode); + OFFSET(VCPU_depriv_destroy, struct vcpu, arch.hvm_vcpu.depriv_destroy); +BLANK (); + OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);BLANK ();
xen/arch/x86/x86_64/entry.S +29 -9
@@ -102,6 +102,18 @@ restore_all_xen: RESTORE_ALL adj=8 iretq + +/* Returning from user mode */ +ENTRY(handle_hvm_user_mode) + + call hvm_deprivileged_handle_user_mode + + /* fallthrough */ +hvm_depriv_mode: + + /* Go back into user mode */ + jmp restore_all_guest + /* * When entering SYSCALL from kernel mode: * %rax = hypercall vector
@@ -128,6 +140,11 @@ ENTRY(lstar_enter) pushq $0 SAVE_VOLATILE TRAP_syscall GET_CURRENT(%rbx) + + /* Were we in Xen's ring 3? */ + cmpq $1, VCPU_depriv_user_mode(%rbx) + je handle_hvm_user_mode + testb $TF_kernel_mode,VCPU_thread_flags(%rbx) jz switch_to_kernel
@@ -487,6 +504,10 @@ ENTRY(common_interrupt) /* No special register assumptions. */ ENTRY(ret_from_intr) GET_CURRENT(%rbx) + + /* If we are in Xen's user mode */ + cmpq $1,VCPU_depriv_user_mode(%rbx) + je hvm_depriv_mode testb $3,UREGS_cs(%rsp) jz restore_all_xen movq VCPU_domain(%rbx),%rax
@@ -509,6 +530,10 @@ handle_exception_saved: GET_CURRENT(%rbx) PERFC_INCR(exceptions, %rax, %rbx) callq *(%rdx,%rax,8) + + /* If we are in Xen's user mode */ + cmpq $1, VCPU_depriv_user_mode(%rbx) + je hvm_depriv_mode testb $3,UREGS_cs(%rsp) jz restore_all_xen leaq VCPU_trap_bounce(%rbx),%rdx
@@ -636,15 +661,7 @@ ENTRY(nmi) movl $TRAP_nmi,4(%rsp) handle_ist_exception: SAVE_ALL CLAC - testb $3,UREGS_cs(%rsp) - jz 1f - /* Interrupted guest context. Copy the context to stack bottom. */ - GET_CPUINFO_FIELD(guest_cpu_user_regs,%rdi) - movq %rsp,%rsi - movl $UREGS_kernel_sizeof/8,%ecx - movq %rdi,%rsp - rep movsq -1: movq %rsp,%rdi + movq %rsp,%rdi movzbl UREGS_entry_vector(%rsp),%eax leaq exception_table(%rip),%rdx callq *(%rdx,%rax,8)
@@ -664,6 +681,9 @@ handle_ist_exception: movl $EVENT_CHECK_VECTOR,%edi call send_IPI_self 1: movq VCPU_domain(%rbx),%rax + /* This also handles Xen ring3 return for us. + * So, there is no need to explicitly do a user mode check. + */ cmpb $0,DOMAIN_is_32bit_pv(%rax) je restore_all_guest jmp compat_restore_all_guest
xen/arch/x86/x86_64/traps.c +10 -3
@@ -24,6 +24,7 @@#include <asm/hvm/hvm.h> #include <asm/hvm/support.h> #include <public/callback.h> +#include <asm/hvm/svm/svm.h> static void print_xen_info (void )
@@ -337,7 +338,7 @@ unsigned long do_iret(void)return 0 ; } -static unsigned int write_stub_trampoline ( +unsigned int write_stub_trampoline (unsigned char *stub,unsigned long stub_va,unsigned long stack_bottom,unsigned long target_va) {
@@ -368,8 +369,6 @@ static unsigned int write_stub_trampoline( } DEFINE_PER_CPU(struct stubs, stubs); -void lstar_enter (void ); -void cstar_enter (void );void __devinit subarch_percpu_traps_init (void ) {
@@ -385,6 +384,14 @@ void __devinit subarch_percpu_traps_init(void)/* Trampoline for SYSCALL entry from 64-bit mode. */ wrmsrl (MSR_LSTAR , stub_va); + +/* +* HVM deprivileged mode on AMD. The writes for MSR_{L}STAR +* are not trapped so we need to keep a copy of the host's msrs +*/ +svm_depriv_write_msr_star ((unsigned long )((FLAT_RING3_CS32 <<16 ) | __HYPERVISOR_CS) <<32 ); +svm_depriv_write_msr_lstar (stub_va); + offset =write_stub_trampoline (stub_page + (stub_va & ~PAGE_MASK ), stub_va, stack_bottom, (unsigned long )lstar_enter);
xen/include/asm-x86/current.h +2 -0
@@ -23,6 +23,8 @@* 2 - MCE IST stack * 1 - NMI IST stack * 0 - Double Fault IST stack +* +* NOTE: This layout changes slightly in HVM deprivileged mode. */ /*
xen/include/asm-x86/hvm/svm/svm.h +13 -0
@@ -110,4 +110,17 @@ extern void svm_host_osvw_init(void);#define _NPT_PFEC_in_gpt 33#define NPT_PFEC_in_gpt (1UL<<_NPT_PFEC_in_gpt) +/* +* HVM deprivileged mode svm cache of host MSR_{L}STARs +* The svm mode does not trap guest writes to these so we +* need to preserve them. +*/ +DECLARE_PER_CPU (u64, svm_depriv_msr_lstar); +DECLARE_PER_CPU (u64, svm_depriv_msr_star); + +unsigned long svm_depriv_read_msr_star (void ); +void svm_depriv_write_msr_star (unsigned long star); +unsigned long svm_depriv_read_msr_lstar (void ); +void svm_depriv_write_msr_lstar (unsigned long lstar); +#endif /* __ASM_X86_HVM_SVM_H__ */
xen/include/asm-x86/hvm/vcpu.h +15 -0
@@ -202,6 +202,21 @@ struct hvm_vcpu {void (*fpu_exception_callback)(void *,struct cpu_user_regs *);void *fpu_exception_callback_arg; +/* Context switching for HVM deprivileged mode */ +void (*depriv_ctxt_switch_to)(struct vcpu *v); +void (*depriv_ctxt_switch_from)(struct vcpu *v); +void (*depriv_setup_stacks)(unsigned long stack_ptr); +void (*depriv_restore_stacks)(void ); + +/* HVM deprivileged mode state */ +struct segment_register depriv_tr; +unsigned long depriv_rsp;/* rsp of our stack to restore our data to */ +unsigned long depriv_user_mode;/* Are we in user mode */ +unsigned long depriv_efer; +unsigned long depriv_tss_rsp0; +unsigned long depriv_destroy; +unsigned long depriv_watchdog_count; +/* Pending hw/sw interrupt (.vector = -1 means nothing pending). */ struct hvm_trap inject_trap;
xen/include/asm-x86/hvm/vmx/vmx.h +2 -0
@@ -565,4 +565,6 @@ typedef struct { u16 eptp_index; } ve_info_t; +struct vmx_msr_state *get_host_msr_state (void ); +#endif /* __ASM_X86_HVM_VMX_VMX_H__ */
xen/include/asm-x86/processor.h +2 -0
@@ -547,6 +547,8 @@ void sysenter_entry(void);void sysenter_eflags_saved (void );void compat_hypercall (void );void int80_direct_trap (void ); +void lstar_enter (void ); +void cstar_enter (void );#define STUBS_PER_PAGE (PAGE_SIZE / STUB_BUF_SIZE)
xen/include/asm-x86/system.h +3 -0
@@ -240,5 +240,8 @@ void init_idt_traps(void);void load_system_tables (void );void percpu_traps_init (void );void subarch_percpu_traps_init (void ); +unsigned int write_stub_trampoline ( +unsigned char *stub,unsigned long stub_va, +unsigned long stack_bottom,unsigned long target_va);#endif
xen/include/xen/hvm/deprivileged.h +45 -0
65 lines not on this page · raw message
xen/include/xen/sched.h +17 -1
@@ -137,7 +137,7 @@ void evtchn_destroy_final(struct domain *d); /* from complete_domain_destroy */struct waitqueue_vcpu ; -struct vcpu +struct vcpu {int vcpu_id;
@@ -158,6 +158,22 @@ struct vcpuvoid *sched_priv;/* scheduler-specific data */ +/* HVM deprivileged mode state */ +void *stack;/* Location of stack to save data onto */ +unsigned long rsp;/* rsp of our stack to restore our data to */ +unsigned long user_mode;/* Are we (possibly moving into) in user mode? */ + +/* The mstar of the processor that we are currently executing on. +* we need to save this because Xen does lazy saving of these. +*/ +unsigned long int msr_lstar;/* lstar */ +unsigned long int msr_star; + +/* Debug info */ +unsigned long int old_rsp; +unsigned long int old_processor; +unsigned long int old_msr_lstar; +unsigned long int old_msr_star;struct vcpu_runstate_info runstate;#ifndef CONFIG_COMPAT # define runstate_guest (v) ((v)->runstate_guest)
Signature · 1 line
2.1.4
RFC PATCH v2 3/4 HVM x86 deprivileged mode: Trap handlers for deprivileged mode
In reply to Ben CatterallAdded trap handlers to catch exceptions such as a page fault, general protection fault, etc. These handlers will crash the domain as such exceptions would indicate that either there is a bug in deprivileged mode or it has been compromised by an attacker.
On calling a domain_crash() whilst in deprivileged mode, we need to restore the host's context so that we do not have guest-defined registers and values in use after this point due to lazy loading of these values in the SVM and VMX implementations.
Changed since v1
----------------
* Changed to domain_crash(), domain_crash_synchronous was used previously.
* Updated to perform a HVM context switch on crashing a domain
* Updated hvm_deprivileged_check_trap() to return a testable error code and return based on this.
--- xen/arch/x86/hvm/deprivileged.c | 54 ++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 48 +++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/traps.c | 1 - xen/include/xen/hvm/deprivileged.h | 23 ++++++++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/deprivileged.c +54 -0
@@ -615,3 +615,57 @@ void hvm_deprivileged_finish_user_mode(void)hvm_deprivileged_finish_user_mode_asm (); } + +/* Check if we are in deprivileged mode */ +int is_hvm_deprivileged_vcpu (void ) +{ +struct vcpu *v =get_current (); + +if (is_hvm_vcpu (v) && (v->arch.hvm_vcpu.depriv_user_mode) ) +return 1 ; + +return 0 ; +} + +/* +* Crash the domain. This should not be called if there are any memory +* allocations which will be freed by code following its invocation in the +* current execution context (current stack). This is because it causes a +* permanent 'context switch' and the current stack will be cloberred so +* any allocations made which are not freed by other paths will leak. +* This function should only be used after deprivileged mode has been +* successfully switched into, otherwise, the normal domain_crash function +* should be used. +* +* The domain which is crashed is that of the current vcpu. +* +* To crash the domain, we need to return to our privileged stack as we may have +* memory allocations which need to be cleaned up. Then, after we have returned +* to this stack, we can then crash the domain. We set a flag which we check +* when returning. +*/ +void hvm_deprivileged_crash_domain (const char *reason) +{ +struct vcpu *vcpu =get_current (); + + vcpu->arch.hvm_vcpu.depriv_destroy =1 ; + +printk (XENLOG_ERR "HVM Deprivileged Mode: Crashing domain. Reason: %s\n" , + reason); + +/* +* Restore the processor's state. We need to do the privileged return +* path to undo any allocations that got us to this state +*/ +hvm_deprivileged_finish_user_mode (); +/* DOES NOT RETURN */ +} + +/* Handle a trap event */ +int hvm_deprivileged_check_trap (const char * func_name) +{ +if (is_hvm_deprivileged_vcpu () ) +hvm_deprivileged_crash_domain (func_name); + +return 0 ; +}
xen/arch/x86/traps.c +48 -0
105 lines not on this page · raw message
xen/arch/x86/x86_64/traps.c +0 -1
@@ -26,7 +26,6 @@#include <public/callback.h> #include <asm/hvm/svm/svm.h> -static void print_xen_info (void ) {char taint_str[TAINT_STRING_MAX_LEN ];
xen/include/xen/hvm/deprivileged.h +23 -0
@@ -106,9 +106,32 @@ void hvm_deprivileged_setup_stacks(unsigned long stack_ptr);/* Use to restore the stacks for deprivileged mode */ void hvm_deprivileged_restore_stacks (void ); +/* Check if we are in deprivileged mode */ +int is_hvm_deprivileged_vcpu (void ); +/* The ring 3 code */ void hvm_deprivileged_ring3 (void ); +/* +* Crash the domain. This should not be called if there are any memory +* allocations which will be freed by code following its invocation in the +* current execution context (current stack). This is because it causes a +* permanent 'context switch' and the current stack will be cloberred so +* any allocations made which are not freed by other paths will leak. +* This function should only be used after deprivileged mode has been +* successfully switched into, otherwise, the normal domain_crash function +* should be used. +* +* The domain which is crashed is that of the current vcpu. +*/ +void hvm_deprivileged_crash_domain (const char *reason); + +/* +* Call when inside a trap that should cause a domain crash if in user mode +* e.g. an invalid_op is trapped whilst in user mode. +*/ +int hvm_deprivileged_check_trap (const char * func_name); +/* The segments where the user mode .text and .data are stored */ extern unsigned long __hvm_deprivileged_text_start[];extern unsigned long __hvm_deprivileged_text_end[];
Signature · 1 line
2.1.4
RFC PATCH v2 4/4 HVM x86 deprivileged mode: Watchdog for DoS prevention
In reply to Ben CatterallA watchdog timer is used to prevent the deprivileged mode running for too long, aimed at handling a bug or attempted DoS. If the watchdog has occurred more than once whilst we have been in the same deprivileged mode context, then we crash the domain. This can be adjusted for longer running times in future.
--- xen/arch/x86/hvm/deprivileged.c | 17 +++++++++++++---- xen/arch/x86/nmi.c | 17 +++++++++++++++++ xen/include/xen/hvm/deprivileged.h | 1 + 3 files changed, 31 insertions(+), 4 deletions(-)
xen/arch/x86/hvm/deprivileged.c +13 -4
@@ -4,10 +4,11 @@*/ #include <xen/lib.h> #include <xen/mm.h> +#include <xen/sched.h> #include <xen/domain_page.h> #include <xen/config.h> #include <xen/types.h> -#include <xen/sched.h> +#include <xen/watchdog.h> #include <asm/paging.h> #include <xen/compiler.h> #include <asm/hap.h>
@@ -17,6 +18,7 @@#include <xen/domain_page.h> #include <asm/hvm/vmx/vmx.h> #include <xen/hvm/deprivileged.h> +#include <xen/shutdown.h> void hvm_deprivileged_init (struct domain *d,l4_pgentry_t *l4t_base) {
@@ -219,7 +221,6 @@ int hvm_deprivileged_map_l4(struct domain *d,* we preserve the access bits of any supervisor entries that are * used in the leaf case. */ - l3t_base =map_l3t_from_l4e (l4t_base[i]); hvm_deprivileged_map_l3(d, l3t_base, src_start, dst_start,
@@ -309,7 +310,6 @@ int hvm_deprivileged_map_l3(struct domain *d,* we preserve the access bits of any supervisor entries that are * used in the leaf case. */ - l2t_base =map_l2t_from_l3e (l3t_base[i]); hvm_deprivileged_map_l2(d, l2t_base, src_start, dst_start,
@@ -389,7 +389,6 @@ int hvm_deprivileged_map_l2(struct domain *d, {panic ("HVM: L2 Leaf page is already mapped\n" ); } -/* * We can try recursing on this and see if where we want to put our * new pages is empty.
@@ -552,6 +551,16 @@ void hvm_deprivileged_user_mode(void) vcpu->arch.hvm_vcpu.depriv_user_mode =0 ; vcpu->arch.hvm_vcpu.depriv_rsp =0 ; + vcpu->arch.hvm_vcpu.depriv_watchdog_count =0 ; + +/* +* If we need to crash the domain at this point. We will return up the call +* stack, undoing any allocations and then the event testers in the exit +* assembly stubs will test for the SOFTIRQ_TIMER event generated by a +* domain_crash and will crash the domain for us. +*/ +if ( vcpu->arch.hvm_vcpu.depriv_destroy ) +domain_crash (vcpu->domain); }/*
xen/arch/x86/nmi.c +17 -0
@@ -26,6 +26,7 @@#include <xen/smp.h> #include <xen/keyhandler.h> #include <xen/cpu.h> +#include <xen/hvm/deprivileged.h> #include <asm/current.h> #include <asm/mc146818rtc.h> #include <asm/msr.h>
@@ -463,9 +464,25 @@ int __init watchdog_setup(void)/* Returns false if this was not a watchdog NMI, true otherwise */ bool_t nmi_watchdog_tick (const struct cpu_user_regs *regs) { +struct vcpu *vcpu = current;bool_t watchdog_tick =1 ;unsigned int sum =this_cpu (nmi_timer_ticks); +/* +* If the domain has been running in deprivileged mode for two watchdog +* ticks, then we kill it to prevent a DoS. We use two ticks as a coarse +* measure as this ensures that at least a full watchdog tick duration has +* occurred. This means that we do not need to track entry time and do +* time calculations. +*/ +if (is_hvm_deprivileged_vcpu () ) + { +if ( vcpu->arch.hvm_vcpu.depriv_watchdog_count ) +hvm_deprivileged_crash_domain ("HVM Deprivileged domain: Domain exceeded running time." ); +else + vcpu->arch.hvm_vcpu.depriv_watchdog_count =1 ; + } +if ( (this_cpu (last_irq_sums) == sum) &&watchdog_enabled () ) {/*
xen/include/xen/hvm/deprivileged.h +1 -0
@@ -74,6 +74,7 @@ int hvm_deprivileged_map_l1(struct domain *d,unsigned int l1_flags, unsigned int op); +/* Used to allocate a page for the deprivileged mode */ struct page_info *hvm_deprivileged_alloc_page (struct domain *d);
Signature · 1 line
2.1.4
Quoted 11 lines · Ben Catterall
Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
Quoted 8 lines
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.So approximately 178% overhead.
How does this compare to the overhead of passing the I/O through to qemu?
David
Quoted 19 lines · David Vrabel
Quoted 18 lines · Ben Catterall
Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.
Quoted 4 lines
Quoted 1 line
So approximately 178% overhead.
How does this compare to the overhead of passing the I/O through to qemu?
So, passing this portio op through to QEMU takes roughly 20e-6 seconds. However, I don't know if the emulator would have gone and prodded a physical port as port of that which could skew the result. I'll look into this and get back if I find anything to clarify this.
Ben
Quoted 2 lines
David
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 03.09.15 at 18:01, <[email protected]> wrote:
I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python script
within the HVM guest usingtime.time()and running Debian Jessie. Each write was
trapped to cause a vmexit and the time for each write was calculated. The port
operation is bypassed so that no portio is actually performed. Thus, the differences in the measurements below can be taken as the pure overhead. These
experiments were repeated. Note that only the host and this HVM guest were running (both Debian Jessie) during the experiments.Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.
Quoted 1 line
So approximately 178% overhead.
Just like said for v1: Determining a percentage of overhead is pretty meaningless when the actual operation (the I/O port access) can take significantly varying amount of time depending on which I/O port is being accessed. In particular, considering the built in devices emulation of which you want to move out, the majority shouldn't actually be doing any accesses to ports or MMIO, but just act on RAM. Which hence may take quite a bit less than the roughly 1.5us you use as the base line, in turn likely resulting in quite a bit higher relative overhead.
That said - even the 350% you determined above look prohibitive to me.
Jan
Quoted 44 lines · Jan Beulich
Quoted 42 lines
Quoted 2 lines
Quoted 2 lines · On 03.09.15 at 18:01, <[email protected]> wrote:
I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python
script
within the HVM guest usingtime.time()and running Debian Jessie. Each write
was
trapped to cause a vmexit and the time for each write was calculated. The
port
operation is bypassed so that no portio is actually performed. Thus, the
differences in the measurements below can be taken as the pure overhead.
These
experiments were repeated. Note that only the host and this HVM guest were
running (both Debian Jessie) during the experiments.Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry
and
exit from deprvileged mode.Quoted 1 line
So approximately 178% overhead.
Quoted 9 lines
Just like said for v1: Determining a percentage of overhead is pretty meaningless when the actual operation (the I/O port access) can take significantly varying amount of time depending on which I/O port is being accessed. In particular, considering the built in devices emulation of which you want to move out, the majority shouldn't actually be doing any accesses to ports or MMIO, but just act on RAM. Which hence may take quite a bit less than the roughly 1.5us you use as the base line, in turn likely resulting in quite a bit higher relative overhead.
Ben says "no port io is actually performed", so I think the 1.5us is purely the overhead of emulating an I/O access as a NOP.
Quoted 6 lines
That said - even the 350% you determined above look prohibitive to me.
Jan
Quoted 56 lines
Quoted 1 line
Quoted 1 line · On 04.09.15 at 11:16, <[email protected]> wrote:
Quoted 44 lines · Jan Beulich
Quoted 42 lines
Quoted 2 lines
Quoted 2 lines · On 03.09.15 at 18:01, <[email protected]> wrote:
I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python
script
within the HVM guest usingtime.time()and running Debian Jessie. Each write
was
trapped to cause a vmexit and the time for each write was calculated. The
port
operation is bypassed so that no portio is actually performed. Thus, the
differences in the measurements below can be taken as the pure overhead.
These
experiments were repeated. Note that only the host and this HVM guest were
running (both Debian Jessie) during the experiments.Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry
and
exit from deprvileged mode.Quoted 1 line
So approximately 178% overhead.
Quoted 9 lines
Just like said for v1: Determining a percentage of overhead is pretty meaningless when the actual operation (the I/O port access) can take significantly varying amount of time depending on which I/O port is being accessed. In particular, considering the built in devices emulation of which you want to move out, the majority shouldn't actually be doing any accesses to ports or MMIO, but just act on RAM. Which hence may take quite a bit less than the roughly 1.5us you use as the base line, in turn likely resulting in quite a bit higher relative overhead.
Quoted 2 lines
Ben says "no port io is actually performed", so I think the 1.5us is purely the overhead of emulating an I/O access as a NOP.
Oh, I see - I didn't pay close enough attention and judged only from "I performed 100000 writes to a single I/O port ...". I'm sorry.
Otoh - 1.5us seems quite a long time if there's no actual port access...
Jan
Il 03/09/2015 18:01, Ben Catterall ha scritto:
Quoted 24 lines
Hi all,
I have made requested changes and reworked the patch series based on the comments recieved. Thank you to all of the contributors to those discussions! The next step will be to provide an example of usage of this system which will follow in another patch.
The main changes from v1 are:
- No longer copying the privileged Xen stack but instead change the interrupt/exception, syscall and sysenter pointers to be below the current execution point.
- AMD SVM support
- Stop IST copying onto the privileged stack
- Watchdog timer to kill a long running deprivileged domain
- Support for crashing a domain whilst performing a deprivileged operation
- .text section is now aliased
- Assembly updates
- Updated deprivileged context switching code to fix bugs
- Moved processor-specific code to processor-specific files
- Reduction of user stack sizes
- Updates to interfaces and anis_hvm_deprivileged_mode()style test
- Small bug fixes
- Revised performance tests
Quoted 7 lines
Many thanks in advance,
BenThe aim of this work is to create a proof-of-concept to establish if it is feasible to move certain Xen operations into a deprivileged context to mitigate the impact of a bug or compromise in such areas. An example would be
x86_emulateor virtual device emulation which is not done in QEMU for performance reasons.
Sorry for my stupid questions:
Is there a test with benchmark using qemu instead for know how is different? Qemu seems that emulate also some istructions cases that xen hypervisor doesn't for now, or I'm wrong?
Is there any possible hardware technology or set of instructions for improve the operations also deprivileged or transition from Xen is obliged to control even mappings memory access?
Is there any possible future hardware technology or set of instructions for take needed informations from hypervisor for executing directly all needed checks, them if ok and any possible exceptions/protections or delegate this to xen for each instruction with a tremendous impact on the efficiency can not be improved? If I said only absurd things because of my knowledge too low about sorry for having wasted your time.
Thanks for any reply and sorry for my bad english.
Quoted 45 lines
Performance testing
-------------------
Performance testing indicates that the overhead for this deprivileged mode depend heavily upon the processor. This overhead is the cost of moving into deprivileged mode and then fully back out of deprivileged mode. The conclusions are that the overheads are not negligible and that operations using this mechanism would benefit from being long running or be high risk components. It will need to be evaluated on a case-by-case basis.I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python script within the HVM guest using
time.time()and running Debian Jessie. Each write was trapped to cause a vmexit and the time for each write was calculated. The port operation is bypassed so that no portio is actually performed. Thus, the differences in the measurements below can be taken as the pure overhead. These experiments were repeated. Note that only the host and this HVM guest were running (both Debian Jessie) during the experiments.Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.So approximately 178% overhead.
Signed-off-by Ben Catterall <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Fabio,
On 04/09/15 11:46, Fabio Fantoni wrote:
[snip]
Quoted 6 lines
Sorry for my stupid questions:
Is there a test with benchmark using qemu instead for know how is different? Qemu seems that emulate also some istructions cases that xen hypervisor doesn't for now, or I'm wrong?
So, QEMU emulates devices for HVM guests. Now, letting the portio operation through to QEMU to emulate takes about 20e-6 seconds. But, that includes the time QEMU takes to actually emulate the port operation so is not the 'pure' overhead. I need to do more detailed analysis to get that figure.
Quoted 3 lines
Is there any possible hardware technology or set of instructions for improve the operations also deprivileged or transition from Xen is obliged to control even mappings memory access?
We're using sysret and syscall already to do the transition which are the fast system call operations. I don't have actual benchmark values for their execution time though. We map the depriv code, stack and data sections into the monitor table when initialising the HVM guest (user mode mapping) so Xen doesn't need to worry about those mappings whilst executing a depriv operation.
Quoted 5 lines
Is there any possible future hardware technology or set of instructions for take needed informations from hypervisor for executing directly all needed checks, them if ok and any possible exceptions/protections or delegate this to xen for each instruction with a tremendous impact on the efficiency can not be improved?
I'm not quite sure what you're asking here, sorry! Are you asking if we can take an HVM guest instruction, analyse it to determine if it's safe to execute and then execute it rather than emulating it? If so:
QEMU handles device emulation and this is deliberately not done in Xen to reduce the attack surface of the hypervisor and keep it minimal. We do need to analyse instructions at some points (x86 emulate) but this is error prone (there's a paper or two on exploits of this feature). This is one of the reasons for considering a depriv mode in the first pace, by moving such code into a deprivileged area, we can prevent a bug in this code from leading to hypervisor compromise. I'm not aware of any future hardware or set of instructions but that doesn't mean there aren't/won't be!
Quoted 4 lines
If I said only absurd things because of my knowledge too low about sorry for having wasted your time.
Thanks for any reply and sorry for my bad english.
np, I hope I've understood correctly!
Quoted 59 lines
Quoted 58 lines
Performance testing
-------------------
Performance testing indicates that the overhead for this deprivileged mode
depend heavily upon the processor. This overhead is the cost of moving into
deprivileged mode and then fully back out of deprivileged mode. The conclusions
are that the overheads are not negligible and that operations using this mechanism would benefit from being long running or be high risk components. It
will need to be evaluated on a case-by-case basis.I performed 100000 writes to a single I/O port on an Intel 2.2GHz Xeon E5-2407 0 processor and an AMD Opteron 2376. This was done from a python script
within the HVM guest usingtime.time()and running Debian Jessie. Each write was
trapped to cause a vmexit and the time for each write was calculated. The port
operation is bypassed so that no portio is actually performed. Thus, the differences in the measurements below can be taken as the pure overhead. These
experiments were repeated. Note that only the host and this HVM guest were
running (both Debian Jessie) during the experiments.Intel Intel 2.2GHz Xeon E5-2407 0 processor:
--------------------------------------------
1.55e-06 seconds was the average time for performing the write without the
deprivileged code running.5.75e-06 seconds was the average time for performing the write with the
deprivileged code running.So approximately 351% overhead
AMD Opteron 2376:
-----------------
1.74e-06 seconds was the average time for performing the write without the
deprivileged code running.
3.10e-06 seconds was the average time for performing the write with an entry and
exit from deprvileged mode.So approximately 178% overhead.
Signed-off-by Ben Catterall <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel