[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/svm: Use flush-by-asid when available
commit 64b1da5a2fcf37e3542c277fde194ff3e8bba2d2 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Tue Feb 12 18:37:04 2019 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Thu May 7 13:50:38 2020 +0100 x86/svm: Use flush-by-asid when available AMD Fam15h processors introduced the flush-by-asid feature, for more fine grain flushing purposes. Flushing everything including ASID 0 (i.e. Xen context) is an an unnecesserily large hammer, and never necessary in the context of guest TLBs needing invalidating. When available, use TLB_CTRL_FLUSH_ASID in preference to TLB_CTRL_FLUSH_ALL. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/svm/asid.c | 9 ++++++--- xen/include/asm-x86/hvm/svm/svm.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/svm/asid.c b/xen/arch/x86/hvm/svm/asid.c index 9be90058c7..ab06dd3f3a 100644 --- a/xen/arch/x86/hvm/svm/asid.c +++ b/xen/arch/x86/hvm/svm/asid.c @@ -18,6 +18,7 @@ #include <asm/amd.h> #include <asm/hvm/nestedhvm.h> #include <asm/hvm/svm/asid.h> +#include <asm/hvm/svm/svm.h> void svm_asid_init(const struct cpuinfo_x86 *c) { @@ -47,15 +48,17 @@ void svm_asid_handle_vmrun(void) if ( p_asid->asid == 0 ) { vmcb_set_guest_asid(vmcb, 1); - /* TODO: investigate using TLB_CTRL_FLUSH_ASID here instead. */ - vmcb->tlb_control = TLB_CTRL_FLUSH_ALL; + vmcb->tlb_control = + cpu_has_svm_flushbyasid ? TLB_CTRL_FLUSH_ASID : TLB_CTRL_FLUSH_ALL; return; } if ( vmcb_get_guest_asid(vmcb) != p_asid->asid ) vmcb_set_guest_asid(vmcb, p_asid->asid); - vmcb->tlb_control = need_flush ? TLB_CTRL_FLUSH_ALL : TLB_CTRL_NO_FLUSH; + vmcb->tlb_control = + !need_flush ? TLB_CTRL_NO_FLUSH : + cpu_has_svm_flushbyasid ? TLB_CTRL_FLUSH_ASID : TLB_CTRL_FLUSH_ALL; } /* diff --git a/xen/include/asm-x86/hvm/svm/svm.h b/xen/include/asm-x86/hvm/svm/svm.h index 16a994ec74..cd71402cbb 100644 --- a/xen/include/asm-x86/hvm/svm/svm.h +++ b/xen/include/asm-x86/hvm/svm/svm.h @@ -79,6 +79,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_svm_flushbyasid cpu_has_svm_feature(SVM_FEATURE_FLUSHBYASID) #define cpu_has_svm_decode cpu_has_svm_feature(SVM_FEATURE_DECODEASSISTS) #define cpu_has_svm_vgif cpu_has_svm_feature(SVM_FEATURE_VGIF) #define cpu_has_pause_filter cpu_has_svm_feature(SVM_FEATURE_PAUSEFILTER) -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |