#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)
{
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;
}
/*
#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)