VMX: further code generation improvements
cover VMX: further code generation improvements
1: also use proper instruction mnemonic for VMREAD 2: drop memory barriers from vmread/vmwrite wrappers
PATCH 1/2 VMX: also use proper instruction mnemonic for VMREAD
... when assembler supports it, following commit cfd54835 ("VMX: use proper instruction mnemonics if assembler supports them"). This merely got split off from the earlier change becase of the significant number of call sites needing to be changed.
xen/arch/x86/hvm/vmx/intr.c +32 -8
@@ -76,7 +76,9 @@ static void enable_intr_window(struct vcif (unlikely (tb_init_done) ) { -unsigned int intr =__vmread (VM_ENTRY_INTR_INFO ); +unsigned long intr; + +__vmread (VM_ENTRY_INTR_INFO , &intr);HVMTRACE_3D (INTR_WINDOW , intack.vector, intack.source, (intr &INTR_INFO_VALID_MASK ) ? intr &0xff :-1 ); }
@@ -92,7 +94,9 @@ static void enable_intr_window(struct vc* we may immediately vmexit and hance make no progress! * (see SDM 3B 21.3, "Other Causes of VM Exits"). */ -u32 intr_shadow =__vmread (GUEST_INTERRUPTIBILITY_INFO ); +unsigned long intr_shadow; + +__vmread (GUEST_INTERRUPTIBILITY_INFO , &intr_shadow);if ( intr_shadow &VMX_INTR_SHADOW_STI ) {/* Having both STI-blocking and MOV-SS-blocking fails vmentry. */
@@ -151,9 +155,16 @@ enum hvm_intblk nvmx_intr_blocked(structif (nestedhvm_vcpu_in_guestmode (v) ) {if ( nvcpu->nv_vmexit_pending || - nvcpu->nv_vmswitch_in_progress || - (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) ) + nvcpu->nv_vmswitch_in_progress ) r = hvm_intblk_rflags_ie; +else + { +unsigned long intr_info; + +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) + r = hvm_intblk_rflags_ie; + } }else if ( nvcpu->nv_vmentry_pending ) r = hvm_intblk_rflags_ie;
@@ -228,6 +239,8 @@ void vmx_intr_assist(void) pt_vector =pt_update_irq (v); do { + unsigned long intr_info; + intack = hvm_vcpu_has_pending_irq(v); if ( likely(intack.source == hvm_intsrc_none) ) goto out;
@@ -247,7 +260,8 @@ void vmx_intr_assist(void) goto out; } -if (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) { if ( (intack.source == hvm_intsrc_pic) || (intack.source == hvm_intsrc_nmi) ||
@@ -262,12 +276,21 @@ void vmx_intr_assist(void)ASSERT (intack.source == hvm_intsrc_lapic); tpr_threshold = intack.vector >>4 ; goto out; - }else if ( (intblk != hvm_intblk_none) || - (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) ) + } +else if ( intblk != hvm_intblk_none ) {enable_intr_window (v, intack); goto out; } +else + { +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) + { +enable_intr_window (v, intack); + goto out; + } + } intack =hvm_vcpu_ack_pending_irq (v, intack); }while ( intack.source == hvm_intsrc_none );
@@ -284,7 +307,7 @@ void vmx_intr_assist(void) intack.source != hvm_intsrc_pic && intack.source != hvm_intsrc_vector ) { -unsigned long status =__vmread (GUEST_INTR_STATUS ); +unsigned long status;unsigned int i, n;/*
@@ -296,6 +319,7 @@ void vmx_intr_assist(void)vmx_set_eoi_exit_bitmap (v, pt_vector);/* we need update the RVI field */ +__vmread (GUEST_INTR_STATUS , &status); status &= ~VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; status |=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK & intack.vector;
xen/arch/x86/hvm/vmx/realmode.c +4 -3
@@ -104,7 +104,6 @@ static void realmode_deliver_exception(static void realmode_emulate_one (struct hvm_emulate_ctxt *hvmemul_ctxt) {struct vcpu *curr = current; -uint32_t intr_info;int rc;perfc_incr (realmode_emulations);
@@ -121,7 +120,9 @@ static void realmode_emulate_one(struct {if ( !hvmemul_ctxt->exn_pending ) { - intr_info =__vmread (VM_ENTRY_INTR_INFO ); +unsigned long intr_info; + +__vmread (VM_ENTRY_INTR_INFO , &intr_info);__vmwrite (VM_ENTRY_INTR_INFO ,0 );if ( !(intr_info &INTR_INFO_VALID_MASK ) ) {
@@ -177,7 +178,7 @@ void vmx_realmode(struct cpu_user_regs *unsigned int emulations =0 ;/* Get-and-clear VM_ENTRY_INTR_INFO. */ - intr_info =__vmread (VM_ENTRY_INTR_INFO ); +__vmread (VM_ENTRY_INTR_INFO , &intr_info);if ( intr_info &INTR_INFO_VALID_MASK )__vmwrite (VM_ENTRY_INTR_INFO ,0 );
xen/arch/x86/hvm/vmx/vmcs.c +7 -3
@@ -815,7 +815,7 @@ u64 virtual_vmcs_vmread(void *vvmcs, u32u64 res;virtual_vmcs_enter (vvmcs); - res =__vmread (vmcs_encoding); +__vmread (vmcs_encoding, &res);virtual_vmcs_exit (vvmcs);return res;
@@ -1216,14 +1216,18 @@ void vmx_destroy_vmcs(struct vcpu *v)void vm_launch_fail (void ) { -unsigned long error =__vmread (VM_INSTRUCTION_ERROR ); +unsigned long error; + +__vmread (VM_INSTRUCTION_ERROR , &error);printk ("<vm_launch_fail> error code %lx\n" , error);domain_crash_synchronous (); }void vm_resume_fail (void ) { -unsigned long error =__vmread (VM_INSTRUCTION_ERROR ); +unsigned long error; + +__vmread (VM_INSTRUCTION_ERROR , &error);printk ("<vm_resume_fail> error code %lx\n" , error);domain_crash_synchronous (); }
xen/arch/x86/hvm/vmx/vmx.c +152 -110
591 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vpmu_core2.c +1 -1
@@ -743,7 +743,7 @@ static int core2_vpmu_do_interrupt(strucelse {/* No PMC overflow but perhaps a Trace Message interrupt. */ - msr_content =__vmread (GUEST_IA32_DEBUGCTL ); +__vmread (GUEST_IA32_DEBUGCTL , &msr_content);if ( !(msr_content &IA32_DEBUGCTLMSR_TR ) )return 0 ; }
xen/arch/x86/hvm/vmx/vvmx.c +37 -23
164 lines not on this page · raw message
xen/include/asm-x86/hvm/vmx/vmx.h +13 -8
@@ -322,21 +322,26 @@ static inline void __vmpclear(u64 addr) : "memory"); } -static inline unsigned long __vmread (unsigned long field) +static inline void __vmread (unsigned long field,unsigned long *value) { -unsigned long ecx; - - asm volatile ( VMREAD_OPCODE - MODRM_EAX_ECX + asmvolatile ( +#ifdef HAVE_GAS_VMX + "vmread %1, %0\n\t" +#else + VMREAD_OPCODE MODRM_EAX_ECX +#endif/* CF==1 or ZF==1 --> crash (ud2) */ UNLIKELY_START(be, vmread)"\tud2\n" UNLIKELY_END_SECTION - :"=c" (ecx) +#ifdef HAVE_GAS_VMX + :"=rm" (*value) + :"r" (field) +#else + : "=c" (*value) : "a" (field) +#endif : "memory"); - -return ecx; }static inline void __vmwrite (unsigned long field,unsigned long value)
VMX: also use proper instruction mnemonic for VMREAD
... when assembler supports it, following commit cfd54835 ("VMX: use proper instruction mnemonics if assembler supports them"). This merely got split off from the earlier change becase of the significant number of call sites needing to be changed.
xen/arch/x86/hvm/vmx/intr.c +32 -8
@@ -76,7 +76,9 @@ static void enable_intr_window(struct vcif (unlikely (tb_init_done) ) { -unsigned int intr =__vmread (VM_ENTRY_INTR_INFO ); +unsigned long intr; + +__vmread (VM_ENTRY_INTR_INFO , &intr);HVMTRACE_3D (INTR_WINDOW , intack.vector, intack.source, (intr &INTR_INFO_VALID_MASK ) ? intr &0xff :-1 ); }
@@ -92,7 +94,9 @@ static void enable_intr_window(struct vc* we may immediately vmexit and hance make no progress! * (see SDM 3B 21.3, "Other Causes of VM Exits"). */ -u32 intr_shadow =__vmread (GUEST_INTERRUPTIBILITY_INFO ); +unsigned long intr_shadow; + +__vmread (GUEST_INTERRUPTIBILITY_INFO , &intr_shadow);if ( intr_shadow &VMX_INTR_SHADOW_STI ) {/* Having both STI-blocking and MOV-SS-blocking fails vmentry. */
@@ -151,9 +155,16 @@ enum hvm_intblk nvmx_intr_blocked(structif (nestedhvm_vcpu_in_guestmode (v) ) {if ( nvcpu->nv_vmexit_pending || - nvcpu->nv_vmswitch_in_progress || - (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) ) + nvcpu->nv_vmswitch_in_progress ) r = hvm_intblk_rflags_ie; +else + { +unsigned long intr_info; + +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) + r = hvm_intblk_rflags_ie; + } }else if ( nvcpu->nv_vmentry_pending ) r = hvm_intblk_rflags_ie;
@@ -228,6 +239,8 @@ void vmx_intr_assist(void) pt_vector =pt_update_irq (v); do { + unsigned long intr_info; + intack = hvm_vcpu_has_pending_irq(v); if ( likely(intack.source == hvm_intsrc_none) ) goto out;
@@ -247,7 +260,8 @@ void vmx_intr_assist(void) goto out; } -if (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) { if ( (intack.source == hvm_intsrc_pic) || (intack.source == hvm_intsrc_nmi) ||
@@ -262,12 +276,21 @@ void vmx_intr_assist(void)ASSERT (intack.source == hvm_intsrc_lapic); tpr_threshold = intack.vector >>4 ; goto out; - }else if ( (intblk != hvm_intblk_none) || - (__vmread (VM_ENTRY_INTR_INFO ) &INTR_INFO_VALID_MASK ) ) + } +else if ( intblk != hvm_intblk_none ) {enable_intr_window (v, intack); goto out; } +else + { +__vmread (VM_ENTRY_INTR_INFO , &intr_info); +if ( intr_info &INTR_INFO_VALID_MASK ) + { +enable_intr_window (v, intack); + goto out; + } + } intack =hvm_vcpu_ack_pending_irq (v, intack); }while ( intack.source == hvm_intsrc_none );
@@ -284,7 +307,7 @@ void vmx_intr_assist(void) intack.source != hvm_intsrc_pic && intack.source != hvm_intsrc_vector ) { -unsigned long status =__vmread (GUEST_INTR_STATUS ); +unsigned long status;unsigned int i, n;/*
@@ -296,6 +319,7 @@ void vmx_intr_assist(void)vmx_set_eoi_exit_bitmap (v, pt_vector);/* we need update the RVI field */ +__vmread (GUEST_INTR_STATUS , &status); status &= ~VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; status |=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK & intack.vector;
xen/arch/x86/hvm/vmx/realmode.c +4 -3
@@ -104,7 +104,6 @@ static void realmode_deliver_exception(static void realmode_emulate_one (struct hvm_emulate_ctxt *hvmemul_ctxt) {struct vcpu *curr = current; -uint32_t intr_info;int rc;perfc_incr (realmode_emulations);
@@ -121,7 +120,9 @@ static void realmode_emulate_one(struct {if ( !hvmemul_ctxt->exn_pending ) { - intr_info =__vmread (VM_ENTRY_INTR_INFO ); +unsigned long intr_info; + +__vmread (VM_ENTRY_INTR_INFO , &intr_info);__vmwrite (VM_ENTRY_INTR_INFO ,0 );if ( !(intr_info &INTR_INFO_VALID_MASK ) ) {
@@ -177,7 +178,7 @@ void vmx_realmode(struct cpu_user_regs *unsigned int emulations =0 ;/* Get-and-clear VM_ENTRY_INTR_INFO. */ - intr_info =__vmread (VM_ENTRY_INTR_INFO ); +__vmread (VM_ENTRY_INTR_INFO , &intr_info);if ( intr_info &INTR_INFO_VALID_MASK )__vmwrite (VM_ENTRY_INTR_INFO ,0 );
xen/arch/x86/hvm/vmx/vmcs.c +7 -3
@@ -815,7 +815,7 @@ u64 virtual_vmcs_vmread(void *vvmcs, u32u64 res;virtual_vmcs_enter (vvmcs); - res =__vmread (vmcs_encoding); +__vmread (vmcs_encoding, &res);virtual_vmcs_exit (vvmcs);return res;
@@ -1216,14 +1216,18 @@ void vmx_destroy_vmcs(struct vcpu *v)void vm_launch_fail (void ) { -unsigned long error =__vmread (VM_INSTRUCTION_ERROR ); +unsigned long error; + +__vmread (VM_INSTRUCTION_ERROR , &error);printk ("<vm_launch_fail> error code %lx\n" , error);domain_crash_synchronous (); }void vm_resume_fail (void ) { -unsigned long error =__vmread (VM_INSTRUCTION_ERROR ); +unsigned long error; + +__vmread (VM_INSTRUCTION_ERROR , &error);printk ("<vm_resume_fail> error code %lx\n" , error);domain_crash_synchronous (); }
xen/arch/x86/hvm/vmx/vmx.c +152 -110
591 lines not on this page · raw message
xen/arch/x86/hvm/vmx/vpmu_core2.c +1 -1
@@ -743,7 +743,7 @@ static int core2_vpmu_do_interrupt(strucelse {/* No PMC overflow but perhaps a Trace Message interrupt. */ - msr_content =__vmread (GUEST_IA32_DEBUGCTL ); +__vmread (GUEST_IA32_DEBUGCTL , &msr_content);if ( !(msr_content &IA32_DEBUGCTLMSR_TR ) )return 0 ; }
xen/arch/x86/hvm/vmx/vvmx.c +37 -23
164 lines not on this page · raw message
xen/include/asm-x86/hvm/vmx/vmx.h +13 -8
@@ -322,21 +322,26 @@ static inline void __vmpclear(u64 addr) : "memory"); } -static inline unsigned long __vmread (unsigned long field) +static inline void __vmread (unsigned long field,unsigned long *value) { -unsigned long ecx; - - asm volatile ( VMREAD_OPCODE - MODRM_EAX_ECX + asmvolatile ( +#ifdef HAVE_GAS_VMX + "vmread %1, %0\n\t" +#else + VMREAD_OPCODE MODRM_EAX_ECX +#endif/* CF==1 or ZF==1 --> crash (ud2) */ UNLIKELY_START(be, vmread)"\tud2\n" UNLIKELY_END_SECTION - :"=c" (ecx) +#ifdef HAVE_GAS_VMX + :"=rm" (*value) + :"r" (field) +#else + : "=c" (*value) : "a" (field) +#endif : "memory"); - -return ecx; }static inline void __vmwrite (unsigned long field,unsigned long value)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 89 lines · Jan Beulich
vmx_vmcs_enter(v); switch ( seg ) { case x86_seg_cs:xen/arch/x86/hvm/vmx/vmx.c +32
-34- reg->sel =__vmread (GUEST_CS_SELECTOR ); - reg->limit =__vmread (GUEST_CS_LIMIT ); - reg->base =__vmread (GUEST_CS_BASE ); - attr =__vmread (GUEST_CS_AR_BYTES ); +__vmread (GUEST_CS_SELECTOR , &sel); +__vmread (GUEST_CS_LIMIT , &limit); +__vmread (GUEST_CS_BASE , ®->base); +__vmread (GUEST_CS_AR_BYTES , &attr);break ;case x86_seg_ds: - reg->sel =__vmread (GUEST_DS_SELECTOR ); - reg->limit =__vmread (GUEST_DS_LIMIT ); - reg->base =__vmread (GUEST_DS_BASE ); - attr =__vmread (GUEST_DS_AR_BYTES ); +__vmread (GUEST_DS_SELECTOR , &sel); +__vmread (GUEST_DS_LIMIT , &limit); +__vmread (GUEST_DS_BASE , ®->base); +__vmread (GUEST_DS_AR_BYTES , &attr);break ;case x86_seg_es: - reg->sel =__vmread (GUEST_ES_SELECTOR ); - reg->limit =__vmread (GUEST_ES_LIMIT ); - reg->base =__vmread (GUEST_ES_BASE ); - attr =__vmread (GUEST_ES_AR_BYTES ); +__vmread (GUEST_ES_SELECTOR , &sel); +__vmread (GUEST_ES_LIMIT , &limit); +__vmread (GUEST_ES_BASE , ®->base); +__vmread (GUEST_ES_AR_BYTES , &attr);break ;case x86_seg_fs: - reg->sel =__vmread (GUEST_FS_SELECTOR ); - reg->limit =__vmread (GUEST_FS_LIMIT ); - reg->base =__vmread (GUEST_FS_BASE ); - attr =__vmread (GUEST_FS_AR_BYTES ); +__vmread (GUEST_FS_SELECTOR , &sel); +__vmread (GUEST_FS_LIMIT , &limit); +__vmread (GUEST_FS_BASE , ®->base); +__vmread (GUEST_FS_AR_BYTES , &attr);break ;case x86_seg_gs: - reg->sel =__vmread (GUEST_GS_SELECTOR ); - reg->limit =__vmread (GUEST_GS_LIMIT ); - reg->base =__vmread (GUEST_GS_BASE ); - attr =__vmread (GUEST_GS_AR_BYTES ); +__vmread (GUEST_GS_SELECTOR , &sel); +__vmread (GUEST_GS_LIMIT , &limit); +__vmread (GUEST_GS_BASE , ®->base); +__vmread (GUEST_GS_AR_BYTES , &attr);break ;case x86_seg_ss: - reg->sel =__vmread (GUEST_SS_SELECTOR ); - reg->limit =__vmread (GUEST_SS_LIMIT ); - reg->base =__vmread (GUEST_SS_BASE ); - attr =__vmread (GUEST_SS_AR_BYTES ); +__vmread (GUEST_SS_SELECTOR , &sel); +__vmread (GUEST_SS_LIMIT , &limit); +__vmread (GUEST_SS_BASE , ®->base); +__vmread (GUEST_SS_AR_BYTES , &attr);break ;case x86_seg_tr: - reg->sel =__vmread (GUEST_TR_SELECTOR ); - reg->limit =__vmread (GUEST_TR_LIMIT ); - reg->base =__vmread (GUEST_TR_BASE ); - attr =__vmread (GUEST_TR_AR_BYTES ); +__vmread (GUEST_TR_SELECTOR , &sel); +__vmread (GUEST_TR_LIMIT , &limit); +__vmread (GUEST_TR_BASE , ®->base); +__vmread (GUEST_TR_AR_BYTES , &attr);break ;case x86_seg_gdtr: - reg->limit =__vmread (GUEST_GDTR_LIMIT ); - reg->base =__vmread (GUEST_GDTR_BASE ); +__vmread (GUEST_GDTR_LIMIT , &limit); +__vmread (GUEST_GDTR_BASE , ®->base);break ;case x86_seg_idtr: - reg->limit =__vmread (GUEST_IDTR_LIMIT ); - reg->base =__vmread (GUEST_IDTR_BASE ); +__vmread (GUEST_IDTR_LIMIT , &limit); +__vmread (GUEST_IDTR_BASE , ®->base);break ;case x86_seg_ldtr: - reg->sel =__vmread (GUEST_LDTR_SELECTOR ); - reg->limit =__vmread (GUEST_LDTR_LIMIT );
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 736
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +5
-2- reg->base =__vmread (GUEST_LDTR_BASE ); - attr =__vmread (GUEST_LDTR_AR_BYTES ); +__vmread (GUEST_LDTR_SELECTOR , &sel); +__vmread (GUEST_LDTR_LIMIT , &limit); +__vmread (GUEST_LDTR_BASE , ®->base); +__vmread (GUEST_LDTR_AR_BYTES , &attr);break ;default :BUG (); +return ;
This return is dead code.
Otherwise,
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 736
Quoted 13 lines · Jan Beulich
case x86_seg_ldtr:xen/arch/x86/hvm/vmx/vmx.c +5
-4- reg->sel =__vmread (GUEST_LDTR_SELECTOR ); - reg->limit =__vmread (GUEST_LDTR_LIMIT ); - reg->base =__vmread (GUEST_LDTR_BASE ); - attr =__vmread (GUEST_LDTR_AR_BYTES ); +__vmread (GUEST_LDTR_SELECTOR , &sel); +__vmread (GUEST_LDTR_LIMIT , &limit); +__vmread (GUEST_LDTR_BASE , ®->base); +__vmread (GUEST_LDTR_AR_BYTES , &attr);break ;default :BUG (); +return ;
Quoted 1 line
This return is dead code.
But the compiler doesn't know, and hence whines about possibly uninitialized variables if you leave this out.
Jan
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 13 lines · Jan Beulich
case x86_seg_ldtr:xen/arch/x86/hvm/vmx/vmx.c +5
-4- reg->sel =__vmread (GUEST_LDTR_SELECTOR ); - reg->limit =__vmread (GUEST_LDTR_LIMIT ); - reg->base =__vmread (GUEST_LDTR_BASE ); - attr =__vmread (GUEST_LDTR_AR_BYTES ); +__vmread (GUEST_LDTR_SELECTOR , &sel); +__vmread (GUEST_LDTR_LIMIT , &limit); +__vmread (GUEST_LDTR_BASE , ®->base); +__vmread (GUEST_LDTR_AR_BYTES , &attr);break ;default :BUG (); +return ;
Quoted 6 lines
Quoted 1 line
This return is dead code.
But the compiler doesn't know, and hence whines about possibly uninitialized variables if you leave this out.
Jan
Ah ok, in which case it should be kept.
~Andrew
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
In reply to Jan BeulichQuoted 84 lines · Jan Beulich
... when assembler supports it, following commit
cfd54835("VMX: use proper instruction mnemonics if assembler supports them"). This merely got split off from the earlier change becase of the significant number of call sites needing to be changed.Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/vmx/vmx.c +13
-11@@ -163,11 +163,11 @@ long_mode_do_msr_read(unsigned int msr,switch ( msr ) {case MSR_FS_BASE : - *msr_content =__vmread (GUEST_FS_BASE ); +__vmread (GUEST_FS_BASE , msr_content);break ;case MSR_GS_BASE : - *msr_content =__vmread (GUEST_GS_BASE ); +__vmread (GUEST_GS_BASE , msr_content);break ;case MSR_SHADOW_GS_BASE :@@ -348,13 +348,13 @@ void vmx_update_exception_bitmap(structstatic int vmx_guest_x86_mode (struct vcpu *v) { -unsigned int cs_ar_bytes; +unsigned long cs_ar_bytes;if (unlikely (!(v->arch.hvm_vcpu.guest_cr[0 ] &X86_CR0_PE )) )return 0 ;if (unlikely (guest_cpu_user_regs ()->eflags &X86_EFLAGS_VM ) )return 1 ; - cs_ar_bytes =__vmread (GUEST_CS_AR_BYTES ); +__vmread (GUEST_CS_AR_BYTES , &cs_ar_bytes);if (hvm_long_mode_enabled (v) &&likely (cs_ar_bytes &X86_SEG_AR_CS_LM_ACTIVE ) )return 8 ;@@ -377,7 +377,7 @@ static void vmx_save_dr(struct vcpu *v) v->arch.debugreg[3 ] =read_debugreg (3 ); v->arch.debugreg[6 ] =read_debugreg (6 );/* DR7 must be saved as it is used by vmx_restore_dr(). */ - v->arch.debugreg[7 ] =__vmread (GUEST_DR7 ); +__vmread (GUEST_DR7 , &v->arch.debugreg[7 ]); }static void __restore_debug_registers (struct vcpu *v)@@ -410,7 +410,7 @@ static void vmx_restore_dr(struct vcpu *static void vmx_vmcs_save (struct vcpu *v,struct hvm_hw_cpu *c) { -uint32_t ev; +unsigned long ev;vmx_vmcs_enter (v);@@ -421,17 +421,19 @@ static void vmx_vmcs_save(struct vcpu *v c->msr_efer = v->arch.hvm_vcpu.guest_efer; - c->sysenter_cs =__vmread (GUEST_SYSENTER_CS ); - c->sysenter_esp =__vmread (GUEST_SYSENTER_ESP ); - c->sysenter_eip =__vmread (GUEST_SYSENTER_EIP ); +__vmread (GUEST_SYSENTER_CS , &c->sysenter_cs); +__vmread (GUEST_SYSENTER_ESP , &c->sysenter_esp); +__vmread (GUEST_SYSENTER_EIP , &c->sysenter_eip); c->pending_event =0 ; c->error_code =0 ; -if ( ((ev =__vmread (VM_ENTRY_INTR_INFO )) &INTR_INFO_VALID_MASK ) && +__vmread (VM_ENTRY_INTR_INFO , &ev); +if ( (ev &INTR_INFO_VALID_MASK ) &&hvm_event_needs_reinjection ((ev >>8 ) &7 , ev &0xff ) ) { c->pending_event = ev; - c->error_code =__vmread (VM_ENTRY_EXCEPTION_ERROR_CODE ); +__vmread (VM_ENTRY_EXCEPTION_ERROR_CODE , &ev); + c->error_code = ev; }vmx_vmcs_exit (v);
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 672
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -667,74 +669,78 @@ static void vmx_ctxt_switch_to(struct vcvoid vmx_get_segment_register (struct vcpu *v,enum x86_segment seg,struct segment_register *reg) { -uint32_t attr =0 ; +unsigned long attr =0 , sel =0 , limit;
This is a minor thing, but why do you initialize 'attr' and 'sel', but not 'limit'?
Quoted 110 lines
xen/arch/x86/hvm/vmx/vmx.c +40
-36vmx_vmcs_enter (v);switch ( seg ) {case x86_seg_cs: - reg->sel =__vmread (GUEST_CS_SELECTOR ); - reg->limit =__vmread (GUEST_CS_LIMIT ); - reg->base =__vmread (GUEST_CS_BASE ); - attr =__vmread (GUEST_CS_AR_BYTES ); +__vmread (GUEST_CS_SELECTOR , &sel); +__vmread (GUEST_CS_LIMIT , &limit); +__vmread (GUEST_CS_BASE , ®->base); +__vmread (GUEST_CS_AR_BYTES , &attr);break ;case x86_seg_ds: - reg->sel =__vmread (GUEST_DS_SELECTOR ); - reg->limit =__vmread (GUEST_DS_LIMIT ); - reg->base =__vmread (GUEST_DS_BASE ); - attr =__vmread (GUEST_DS_AR_BYTES ); +__vmread (GUEST_DS_SELECTOR , &sel); +__vmread (GUEST_DS_LIMIT , &limit); +__vmread (GUEST_DS_BASE , ®->base); +__vmread (GUEST_DS_AR_BYTES , &attr);break ;case x86_seg_es: - reg->sel =__vmread (GUEST_ES_SELECTOR ); - reg->limit =__vmread (GUEST_ES_LIMIT ); - reg->base =__vmread (GUEST_ES_BASE ); - attr =__vmread (GUEST_ES_AR_BYTES ); +__vmread (GUEST_ES_SELECTOR , &sel); +__vmread (GUEST_ES_LIMIT , &limit); +__vmread (GUEST_ES_BASE , ®->base); +__vmread (GUEST_ES_AR_BYTES , &attr);break ;case x86_seg_fs: - reg->sel =__vmread (GUEST_FS_SELECTOR ); - reg->limit =__vmread (GUEST_FS_LIMIT ); - reg->base =__vmread (GUEST_FS_BASE ); - attr =__vmread (GUEST_FS_AR_BYTES ); +__vmread (GUEST_FS_SELECTOR , &sel); +__vmread (GUEST_FS_LIMIT , &limit); +__vmread (GUEST_FS_BASE , ®->base); +__vmread (GUEST_FS_AR_BYTES , &attr);break ;case x86_seg_gs: - reg->sel =__vmread (GUEST_GS_SELECTOR ); - reg->limit =__vmread (GUEST_GS_LIMIT ); - reg->base =__vmread (GUEST_GS_BASE ); - attr =__vmread (GUEST_GS_AR_BYTES ); +__vmread (GUEST_GS_SELECTOR , &sel); +__vmread (GUEST_GS_LIMIT , &limit); +__vmread (GUEST_GS_BASE , ®->base); +__vmread (GUEST_GS_AR_BYTES , &attr);break ;case x86_seg_ss: - reg->sel =__vmread (GUEST_SS_SELECTOR ); - reg->limit =__vmread (GUEST_SS_LIMIT ); - reg->base =__vmread (GUEST_SS_BASE ); - attr =__vmread (GUEST_SS_AR_BYTES ); +__vmread (GUEST_SS_SELECTOR , &sel); +__vmread (GUEST_SS_LIMIT , &limit); +__vmread (GUEST_SS_BASE , ®->base); +__vmread (GUEST_SS_AR_BYTES , &attr);break ;case x86_seg_tr: - reg->sel =__vmread (GUEST_TR_SELECTOR ); - reg->limit =__vmread (GUEST_TR_LIMIT ); - reg->base =__vmread (GUEST_TR_BASE ); - attr =__vmread (GUEST_TR_AR_BYTES ); +__vmread (GUEST_TR_SELECTOR , &sel); +__vmread (GUEST_TR_LIMIT , &limit); +__vmread (GUEST_TR_BASE , ®->base); +__vmread (GUEST_TR_AR_BYTES , &attr);break ;case x86_seg_gdtr: - reg->limit =__vmread (GUEST_GDTR_LIMIT ); - reg->base =__vmread (GUEST_GDTR_BASE ); +__vmread (GUEST_GDTR_LIMIT , &limit); +__vmread (GUEST_GDTR_BASE , ®->base);break ;case x86_seg_idtr: - reg->limit =__vmread (GUEST_IDTR_LIMIT ); - reg->base =__vmread (GUEST_IDTR_BASE ); +__vmread (GUEST_IDTR_LIMIT , &limit); +__vmread (GUEST_IDTR_BASE , ®->base);break ;case x86_seg_ldtr: - reg->sel =__vmread (GUEST_LDTR_SELECTOR ); - reg->limit =__vmread (GUEST_LDTR_LIMIT ); - reg->base =__vmread (GUEST_LDTR_BASE ); - attr =__vmread (GUEST_LDTR_AR_BYTES ); +__vmread (GUEST_LDTR_SELECTOR , &sel); +__vmread (GUEST_LDTR_LIMIT , &limit); +__vmread (GUEST_LDTR_BASE , ®->base); +__vmread (GUEST_LDTR_AR_BYTES , &attr);break ;default :BUG (); +return ; }vmx_vmcs_exit (v); + reg->sel = sel; + reg->limit = limit; + reg->attr.bytes = (attr &0xff ) | ((attr >>4 ) &0xf00 );/* Unusable flag is folded into Present flag. */ if ( attr & (1u <<16 ) )
Signature · 2 lines
Jun Intel Open Source Technology Center
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 672
Quoted 7 lines
Quoted 1 line · Jun
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -667,74 +669,78 @@ static void vmx_ctxt_switch_to(struct vcvoid vmx_get_segment_register (struct vcpu *v,enum x86_segment seg,struct segment_register *reg) { -uint32_t attr =0 ; +unsigned long attr =0 , sel =0 , limit;This is a minor thing, but why do you initialize 'attr' and 'sel', but not 'limit'?
Because limit gets initialized in all the case statements, but attr and sel don't (for the GDTR and IDTR cases).
Jan
Re: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 12 lines
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 672
Quoted 8 lines · Jan Beulich
Quoted 1 line · Jun
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -667,74 +669,78 @@ static void vmx_ctxt_switch_to(struct vcvoid vmx_get_segment_register (struct vcpu *v,enum x86_segment seg,struct segment_register *reg) { -uint32_t attr =0 ; +unsigned long attr =0 , sel =0 , limit;This is a minor thing, but why do you initialize 'attr' and 'sel', but not 'limit'?
Quoted 2 lines
Because limit gets initialized in all the case statements, but attr and sel don't (for the GDTR and IDTR cases).
Is there anything else with this answered? If not, mind giving your ack?
Jan
Ping: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines · Jan Beulich
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 672
Quoted 8 lines · Jan Beulich
Quoted 1 line · Jun
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -667,74 +669,78 @@ static void vmx_ctxt_switch_to(struct vcvoid vmx_get_segment_register (struct vcpu *v,enum x86_segment seg,struct segment_register *reg) { -uint32_t attr =0 ; +unsigned long attr =0 , sel =0 , limit;This is a minor thing, but why do you initialize 'attr' and 'sel', but not 'limit'?
Quoted 5 lines
Quoted 2 lines
Because limit gets initialized in all the case statements, but attr and sel don't (for the GDTR and IDTR cases).
Is there anything else with this answered? If not, mind giving your ack?
Ping!?
Jan
Nakajima, Jun
Acked-byRe: Ping: [PATCH 1/2] VMX: also use proper instruction mnemonic for VMREAD
Quoted 14 lines · Jan Beulich
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Jan Beulich
Quoted 2 lines · Jan Beulich
Quoted 1 line
On 16.09.13 at 16:38, "Nakajima, Jun" <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 9 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_ctxt_switch_to(struct vc · line 672
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -667,74 +669,78 @@ static void vmx_ctxt_switch_to(struct vcvoid vmx_get_segment_register (struct vcpu *v,enum x86_segment seg,struct segment_register *reg) { -uint32_t attr =0 ; +unsigned long attr =0 , sel =0 , limit;This is a minor thing, but why do you initialize 'attr' and 'sel', but not 'limit'?
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Because limit gets initialized in all the case statements, but attr and sel don't (for the GDTR and IDTR cases).
Ok.
Quoted 5 lines
Quoted 3 lines
Is there anything else with this answered? If not, mind giving your ack?
Signature · 2 lines
Jun Intel Open Source Technology Center
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/2 VMX: drop memory clobbers from vmread/vmwrite wrappers
In reply to Jan BeulichAll effects are properly being described by the asm() constraints.
xen/include/asm-x86/hvm/vmx/vmx.h +6 -9
@@ -336,12 +336,11 @@ static inline void __vmread(unsigned lonUNLIKELY_END_SECTION #ifdef HAVE_GAS_VMX : "=rm" (*value) - : "r" (field) + : "r" (field)); #else : "=c" (*value) - : "a" (field) + : "a" (field)); #endif - : "memory"); } static inline void __vmwrite(unsigned long field, unsigned long value)
@@ -358,11 +357,10 @@ static inline void __vmwrite(unsigned lo UNLIKELY_END_SECTION : #ifdef HAVE_GAS_VMX - : "r" (field) , "rm" (value) + : "r" (field) , "rm" (value));#else - : "a" (field) , "c" (value) + : "a" (field) , "c" (value));#endif - : "memory"); }static inline bool_t __vmread_safe (unsigned long field,unsigned long *value)
@@ -379,12 +377,11 @@ static inline bool_t __vmread_safe(unsig "setnbe %0" #ifdef HAVE_GAS_VMX : "=qm" (okay), "=rm" (*value) - : "r" (field) + : "r" (field));#else : "=qm" (okay), "=c" (*value) - : "a" (field) + : "a" (field));#endif - : "memory");return okay; }
VMX: drop memory clobbers from vmread/vmwrite wrappers
All effects are properly being described by the asm() constraints.
xen/include/asm-x86/hvm/vmx/vmx.h +6 -9
@@ -336,12 +336,11 @@ static inline void __vmread(unsigned lonUNLIKELY_END_SECTION #ifdef HAVE_GAS_VMX : "=rm" (*value) - : "r" (field) + : "r" (field)); #else : "=c" (*value) - : "a" (field) + : "a" (field)); #endif - : "memory"); } static inline void __vmwrite(unsigned long field, unsigned long value)
@@ -358,11 +357,10 @@ static inline void __vmwrite(unsigned lo UNLIKELY_END_SECTION : #ifdef HAVE_GAS_VMX - : "r" (field) , "rm" (value) + : "r" (field) , "rm" (value));#else - : "a" (field) , "c" (value) + : "a" (field) , "c" (value));#endif - : "memory"); }static inline bool_t __vmread_safe (unsigned long field,unsigned long *value)
@@ -379,12 +377,11 @@ static inline bool_t __vmread_safe(unsig "setnbe %0" #ifdef HAVE_GAS_VMX : "=qm" (okay), "=rm" (*value) - : "r" (field) + : "r" (field));#else : "=qm" (okay), "=c" (*value) - : "a" (field) + : "a" (field));#endif - : "memory");return okay; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/2] VMX: drop memory clobbers from vmread/vmwrite wrappers
Quoted 3 lines · Jan Beulich
All effects are properly being described by the
asm()constraints.Signed-off-by Jan Beulich <[email protected]>
Quoted 52 lines
xen/include/asm-x86/hvm/vmx/vmx.h +6
-9@@ -336,12 +336,11 @@ static inline void __vmread(unsigned lonUNLIKELY_END_SECTION #ifdef HAVE_GAS_VMX : "=rm" (*value) - : "r" (field) + : "r" (field)); #else : "=c" (*value) - : "a" (field) + : "a" (field)); #endif - : "memory"); } static inline void __vmwrite(unsigned long field, unsigned long value)@@ -358,11 +357,10 @@ static inline void __vmwrite(unsigned lo UNLIKELY_END_SECTION : #ifdef HAVE_GAS_VMX - : "r" (field) , "rm" (value) + : "r" (field) , "rm" (value));#else - : "a" (field) , "c" (value) + : "a" (field) , "c" (value));#endif - : "memory"); }static inline bool_t __vmread_safe (unsigned long field,unsigned long *value)@@ -379,12 +377,11 @@ static inline bool_t __vmread_safe(unsig "setnbe %0" #ifdef HAVE_GAS_VMX : "=qm" (okay), "=rm" (*value) - : "r" (field) + : "r" (field));#else : "=qm" (okay), "=c" (*value) - : "a" (field) + : "a" (field));#endif - : "memory");return okay; }
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/2] VMX: drop memory clobbers from vmread/vmwrite wrappers
In reply to Jan BeulichQuoted 44 lines · Jan Beulich
All effects are properly being described by the
asm()constraints.Signed-off-by Jan Beulich <[email protected]>xen/include/asm-x86/hvm/vmx/vmx.h +4
-7@@ -336,12 +336,11 @@ static inline void __vmread(unsigned lonUNLIKELY_END_SECTION #ifdef HAVE_GAS_VMX : "=rm" (*value) - : "r" (field) + : "r" (field)); #else : "=c" (*value) - : "a" (field) + : "a" (field)); #endif - : "memory"); } static inline void __vmwrite(unsigned long field, unsigned long value)@@ -358,11 +357,10 @@ static inline void __vmwrite(unsigned lo UNLIKELY_END_SECTION : #ifdef HAVE_GAS_VMX - : "r" (field) , "rm" (value) + : "r" (field) , "rm" (value));#else - : "a" (field) , "c" (value) + : "a" (field) , "c" (value));#endif - : "memory"); }static inline bool_t __vmread_safe (unsigned long field,unsigned long *value)@@ -379,12 +377,11 @@ static inline bool_t __vmread_safe(unsig "setnbe %0" #ifdef HAVE_GAS_VMX : "=qm" (okay), "=rm" (*value) - :"r" (field)
xen/include/asm-x86/hvm/vmx/vmx.h static inline bool_t __vmread_safe(unsig · line 387
Quoted 10 lines
xen/include/asm-x86/hvm/vmx/vmx.h +2
-2+ : "r" (field));#else : "=qm" (okay), "=c" (*value) - : "a" (field) + : "a" (field));#endif - : "memory");return okay; }