proc: added ept_ad flag to /proc/cpuinfo
PATCH 1/1 proc: added ept_ad flag to /proc/cpuinfo
From: Peter Feiner <[email protected]>
The Intel Haswell architecture has an EPT feature whereby the access & dirty bits in EPT entries are updated without taking a guest exit. This patch adds the "ept_ad" flag to /proc/cpuinfo if this feature is available.
--- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/kernel/cpu/intel.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -229,7 +229,7 @@#define X86_FEATURE_VMMCALL ( 8*32+15)/* Prefer VMMCALL to VMCALL */ #define X86_FEATURE_XENPV ( 8*32+16)/* "" Xen paravirtual guest */ - +#define X86_FEATURE_EPT_AD ( 8*32+17)/* Intel Extended Page Table access-dirty bit */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ #define X86_FEATURE_FSGSBASE ( 9*32+ 0)/* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
arch/x86/kernel/cpu/intel.c +9 -1
@@ -465,14 +465,17 @@ static void detect_vmx_virtcap(struct cpuinfo_x86 *c)#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001#define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002#define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020 +#define x86_VMX_FEATURE_EPT_CAP_AD 0x00200000u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2; +u32 msr_vpid_cap, msr_ept_cap;clear_cpu_cap (c,X86_FEATURE_TPR_SHADOW );clear_cpu_cap (c,X86_FEATURE_VNMI );clear_cpu_cap (c,X86_FEATURE_FLEXPRIORITY );clear_cpu_cap (c,X86_FEATURE_EPT );clear_cpu_cap (c,X86_FEATURE_VPID ); +clear_cpu_cap (c,X86_FEATURE_EPT_AD );rdmsr (MSR_IA32_VMX_PROCBASED_CTLS , vmx_msr_low, vmx_msr_high); msr_ctl = vmx_msr_high | vmx_msr_low;
@@ -487,8 +490,13 @@ static void detect_vmx_virtcap(struct cpuinfo_x86 *c)if ((msr_ctl2 &X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC ) && (msr_ctl &X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW ))set_cpu_cap (c,X86_FEATURE_FLEXPRIORITY ); -if (msr_ctl2 &X86_VMX_FEATURE_PROC_CTLS2_EPT ) +if (msr_ctl2 &X86_VMX_FEATURE_PROC_CTLS2_EPT ) {set_cpu_cap (c,X86_FEATURE_EPT ); +rdmsr (MSR_IA32_VMX_EPT_VPID_CAP , + msr_ept_cap, msr_vpid_cap); +if (msr_ept_cap & x86_VMX_FEATURE_EPT_CAP_AD) +set_cpu_cap (c,X86_FEATURE_EPT_AD ); + }if (msr_ctl2 &X86_VMX_FEATURE_PROC_CTLS2_VPID )set_cpu_cap (c,X86_FEATURE_VPID ); }
Signature · 1 line
2.18.0.233.g985f88cf7e-goog
Quoted 1 line · Peter Shier
Subject: [PATCH] proc: added
ept_adflag to/proc/cpuinfo
The 'proc:' prefix is misleading here. x86/cpufeatures is the right choice. The /proc/cpuinfo display is a side effect.
Also please avoid 'added'. Changelogs should be written in imperative mood. Something like this:
x86/cpufeatures: Add EPT_AD feature bit
Quoted 2 lines
The Intel Haswell architecture has an EPT feature whereby the access & dirty bits in EPT entries are updated without taking a guest exit.
Why would this be Haswell specific?
Aside of that I don't see what this has to do with exits. From the SDM:
" * If bit 21 is read as 1, accessed and dirty flags for EPT are
supported (see Section 28.2.4)"
And nothing in 28.2.4 says anything about exits. It's all about whether the feature is supported or not. If it is supported it can be enabled in EPTP.
Quoted 2 lines
This patch adds the "
ept_ad" flag to/proc/cpuinfoif this feature is available.
See Documentation/process/submitting-patches.rst and search for 'This patch'.
The other question is why is this new feature bit not used in the VMX code? It needs to be checked to enable the AD bit in EPTP ....
Thanks,
tglx
Thank you Thomas. Wording issues understood and will post a new patch with updated subject.
Re goals: purpose is to expose feature bit with side effect of "ept_ad" in /proc/cpuinfo and is not necessarily related to VMX code. We are upstreaming some internal patches that we think would be generally useful and I will be careful from now on to remove any wording that is not publicly relevant.
Quoted 38 lines · Thomas Gleixner
Quoted 1 line · Peter Shier
Subject: [PATCH] proc: added
ept_adflag to/proc/cpuinfoThe 'proc:' prefix is misleading here. x86/cpufeatures is the right choice. The
/proc/cpuinfodisplay is a side effect.Also please avoid 'added'. Changelogs should be written in imperative mood. Something like this:
x86/cpufeatures: Add
EPT_ADfeature bitQuoted 2 lines
The Intel Haswell architecture has an EPT feature whereby the access & dirty bits in EPT entries are updated without taking a guest exit.
Why would this be Haswell specific?
Aside of that I don't see what this has to do with exits. From the SDM:
" * If bit 21 is read as 1, accessed and dirty flags for EPT are
supported (see Section 28.2.4)"And nothing in 28.2.4 says anything about exits. It's all about whether the feature is supported or not. If it is supported it can be enabled in EPTP.
Quoted 2 lines
This patch adds the "
ept_ad" flag to/proc/cpuinfoif this feature is available.See
Documentation/process/submitting-patches.rstand search for 'This patch'.The other question is why is this new feature bit not used in the VMX code? It needs to be checked to enable the AD bit in EPTP ....
Thanks,
tglx
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
Quoted 9 lines · Peter Shier
Thank you Thomas. Wording issues understood and will post a new patch with updated subject.
Re goals: purpose is to expose feature bit with side effect of "
ept_ad" in/proc/cpuinfoand is not necessarily related to VMX code.We are upstreaming some internal patches that we think would be generally useful and I will be careful from now on to remove any wording that is not publicly relevant.
Well, it does not matter what your goals are. If you add new functionality and there is an indication that it might be useful in other places, then looking into that is not really optional. Kernel development works because people work together and look over the brim of their own tea cup, otherwise we would end up with a unmaintainable steaming pile of s....
'Not my goal' surely does not qualify as a proper answer to a sensible technical question.
Thanks,
tglx
Thank you Thomas. I missed what I think is your fundamental point regarding duplication created by this patch between CPU feature bits and KVM's consumption of the IA32_VMX_EPT_VPID_CAP MSR.
Should all the features in this MSR be exposed via CPU feature bits and should KVM consume only from there rather than reading the MSR directly? There are 16 feature bits in the MSR per SDM Vol 3d section A.10.
Peter,
Quoted 8 lines · Peter Shier
Thank you Thomas. I missed what I think is your fundamental point regarding duplication created by this patch between CPU feature bits and KVM's consumption of the
IA32_VMX_EPT_VPID_CAPMSR.Should all the features in this MSR be exposed via CPU feature bits and should KVM consume only from there rather than reading the MSR directly? There are 16 feature bits in the MSR per SDM Vol 3d section A.10.
Uuurg. Probably not, unless they are important somehow for similar reasons like the one you are exposing. I assume they are not, so using the MSR and picking all bits directly from there is ok.
But thanks for taking a look as noew we at least know why it doesn't make sense to convert VMX over as it has to read the MSR anyway.
Thanks,
tglx
Paolo Bonzini
maintainerQuoted 6 lines · Peter Shier
Quoted 6 lines
Quoted 3 lines
The Intel Haswell architecture has an EPT feature whereby the access & dirty bits in EPT entries are updated without taking a guest exit.
Why would this be Haswell specific?
Quoted 7 lines
Quoted 7 lines
Aside of that I don't see what this has to do with exits. From the SDM:
" * If bit 21 is read as 1, accessed and dirty flags for EPT are
supported (see Section 28.2.4)"And nothing in 28.2.4 says anything about exits. It's all about whether the feature is supported or not. If it is supported it can be enabled in EPTP.
Right, if it's not supported KVM instead has to use the R/W/X permission bits to emulate accessed and dirty bits, taking an exit on every update.
But then it seems to me that you're more interested in the KVM behavior than the processor behavior, and then the information you need is already in the /sys/modules/kvm_intel/parameters directory. (Most processor features have a parameter so that it's possible to test code paths for old processors). I don't particularly see a need to add them in /proc/cpuinfo.
Paolo
Quoted 9 lines
Thank you Thomas. I missed what I think is your fundamental point regarding duplication created by this patch between CPU feature bits and KVM's consumption of the
IA32_VMX_EPT_VPID_CAPMSR.Should all the features in this MSR be exposed via CPU feature bits and should KVM consume only from there rather than reading the MSR directly? There are 16 feature bits in the MSR per SDM Vol 3d section A.10.