diff -r 940b8760c604 xen/arch/x86/hvm/svm/asid.c --- a/xen/arch/x86/hvm/svm/asid.c Tue Jan 11 14:32:25 2011 +0100 +++ b/xen/arch/x86/hvm/svm/asid.c Tue Jan 11 14:55:24 2011 +0100 @@ -26,12 +26,16 @@ void svm_asid_init(struct cpuinfo_x86 *c void svm_asid_init(struct cpuinfo_x86 *c) { int nasids = 0; + int svm_features = 0; /* Check for erratum #170, and leave ASIDs disabled if it's present. */ if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) ) nasids = cpuid_ebx(0x8000000A); - - hvm_asid_init(nasids, 0); + + /* We can't use cpu_has_flush_by_asid here because svm_feature_flags has + * been initialized yet. Use CPUID to find out instead. */ + svm_features = cpuid_edx(0x8000000A); + hvm_asid_init(nasids, svm_features & (1 << SVM_FEATURE_FLUSHBYASID)); } /* @@ -42,7 +46,7 @@ asmlinkage void svm_asid_handle_vmrun(vo { struct vcpu *curr = current; struct vmcb_struct *vmcb = curr->arch.hvm_svm.vmcb; - bool_t need_flush = !!hvm_asid_handle_vmenter(); + asid_action_t asid_action = hvm_asid_handle_vmenter(); /* ASID 0 indicates that ASIDs are disabled. */ if ( curr->arch.hvm_vcpu.asid == 0 ) @@ -53,7 +57,10 @@ asmlinkage void svm_asid_handle_vmrun(vo } vmcb_set_guest_asid(vmcb, curr->arch.hvm_vcpu.asid); - vmcb->tlb_control = need_flush; + + /* Note: make sure asid_action value returned from hvm_asid_handle_vmenter + * matches SVM's definition here. */ + curr->arch.hvm_svm.vmcb->tlb_control = asid_action; } /* diff -r 940b8760c604 xen/include/asm-x86/hvm/svm/svm.h --- a/xen/include/asm-x86/hvm/svm/svm.h Tue Jan 11 14:32:25 2011 +0100 +++ b/xen/include/asm-x86/hvm/svm/svm.h Tue Jan 11 14:55:24 2011 +0100 @@ -80,6 +80,7 @@ extern u32 svm_feature_flags; #define cpu_has_svm_svml cpu_has_svm_feature(SVM_FEATURE_SVML) #define cpu_has_svm_nrips cpu_has_svm_feature(SVM_FEATURE_NRIPS) #define cpu_has_svm_cleanbits cpu_has_svm_feature(SVM_FEATURE_VMCBCLEAN) +#define cpu_has_flush_by_asid cpu_has_svm_feature(SVM_FEATURE_FLUSHBYASID) #define cpu_has_pause_filter cpu_has_svm_feature(SVM_FEATURE_PAUSEFILTER) #endif /* __ASM_X86_HVM_SVM_H__ */