x86: Misc enumeration improvements
cover x86: Misc enumeration improvements
Patch 1 noticed because xen-cpuid currently says:
[13] 0x00000007:2.edx intel-psfd <1> <2> <4> mcdt-no
when dumping the static known-feature bitmap. In some copious free time, we should have a unit test that catches this.
Patch 2 when double checking that the enumeration hole was in fact correct.
We should offer DDP-CTRL to guests, but I'm not sure when it is appearing in hardware, and it's not massively urgent - the DDP behaviour is mostly sane (having been designed in a post-spectre world) and this is a just-in-case control.
Andrew Cooper (2):
x86/spec-ctrl: Add BHI controls to userspace components x86/spec-ctrl: Enumerations for DDP controls
tools/libs/light/libxl_cpuid.c | 4 ++++ tools/misc/xen-cpuid.c | 6 +++--- xen/arch/x86/include/asm/msr-index.h | 1 + xen/include/public/arch-x86/cpufeatureset.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/2 x86/spec-ctrl: Add BHI controls to userspace components
This was an oversight when adding the Xen parts.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- tools/libs/light/libxl_cpuid.c | 3 +++ tools/misc/xen-cpuid.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-)
tools/libs/light/libxl_cpuid.c +3 -0
@@ -240,6 +240,9 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"cet-sss", 0x00000007, 1, CPUID_REG_EDX, 18, 1}, {"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1}, + {"ipred-ctrl", 0x00000007, 2, CPUID_REG_EDX, 1, 1}, + {"rrsba-ctrl", 0x00000007, 2, CPUID_REG_EDX, 2, 1}, + {"bhi-ctrl", 0x00000007, 2, CPUID_REG_EDX, 4, 1}, {"mcdt-no", 0x00000007, 2, CPUID_REG_EDX, 5, 1}, {"lahfsahf", 0x80000001, NA, CPUID_REG_ECX, 0, 1},
tools/misc/xen-cpuid.c +3 -3
@@ -215,9 +215,9 @@ static const char *const str_7d1[32] =static const char *const str_7d2[32 ] = { - [0 ] ="intel-psfd" , - -/* 4 */ [5 ] ="mcdt-no" , + [0 ] ="intel-psfd" , [1 ] ="ipred-ctrl" , + [2 ] ="rrsba-ctrl" , + [4 ] ="bhi-ctrl" , [5 ] ="mcdt-no" , }; static const struct {
Signature · 1 line
2.30.2
Re: [PATCH 1/2] x86/spec-ctrl: Add BHI controls to userspace components
Quoted 4 lines · Andrew Cooper
This was an oversight when adding the Xen parts.
Fixes cea9ae062295 ("x86/spec-ctrl: Enumeration for new Intel BHI controls")Signed-off-by Andrew Cooper <[email protected]>
PATCH 2/2 x86/spec-ctrl: Enumerations for DDP controls
In reply to Andrew Cooper---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 2 +- xen/arch/x86/include/asm/msr-index.h | 1 + xen/include/public/arch-x86/cpufeatureset.h | 1 + 4 files changed, 4 insertions(+), 1 deletion(-)
tools/libs/light/libxl_cpuid.c +1 -0
@@ -242,6 +242,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1}, {"ipred-ctrl", 0x00000007, 2, CPUID_REG_EDX, 1, 1}, {"rrsba-ctrl", 0x00000007, 2, CPUID_REG_EDX, 2, 1}, + {"ddp-ctrl", 0x00000007, 2, CPUID_REG_EDX, 3, 1}, {"bhi-ctrl", 0x00000007, 2, CPUID_REG_EDX, 4, 1}, {"mcdt-no", 0x00000007, 2, CPUID_REG_EDX, 5, 1},
tools/misc/xen-cpuid.c +1 -1
@@ -216,7 +216,7 @@ static const char *const str_7d1[32] =static const char *const str_7d2[32 ] = { [0 ] ="intel-psfd" , [1 ] ="ipred-ctrl" , - [2 ] ="rrsba-ctrl" , + [2 ] ="rrsba-ctrl" , [3 ] ="ddp-ctrl" , [4 ] ="bhi-ctrl" , [5 ] ="mcdt-no" , };
xen/arch/x86/include/asm/msr-index.h +1 -0
@@ -41,6 +41,7 @@#define SPEC_CTRL_RRSBA_DIS_U (_AC(1, ULL) << 5)#define SPEC_CTRL_RRSBA_DIS_S (_AC(1, ULL) << 6)#define SPEC_CTRL_PSFD (_AC(1, ULL) << 7) +#define SPEC_CTRL_DDPU_D (_AC(1, ULL) << 8)#define SPEC_CTRL_BHI_DIS_S (_AC(1, ULL) << 10)#define MSR_PRED_CMD 0x00000049
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -295,6 +295,7 @@ XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ XEN_CPUFEATURE(IPRED_CTRL, 13*32+ 1) /* MSR_SPEC_CTRL.IPRED_DIS_* */ XEN_CPUFEATURE(RRSBA_CTRL, 13*32+ 2) /* MSR_SPEC_CTRL.RRSBA_DIS_* */ XEN_CPUFEATURE(BHI_CTRL, 13*32+ 4) /* MSR_SPEC_CTRL.BHI_DIS_S */ +XEN_CPUFEATURE(DDP_CTRL, 13*32+ 3) /* MSR_SPEC_CTRL.DDPU_U */XEN_CPUFEATURE (MCDT_NO ,13 *32 +5 )/*A MCDT_NO */ /* Intel-defined CPU features, CPUID level 0x00000007:1.ecx, word 14 */
Signature · 1 line
2.30.2
Re: [PATCH 2/2] x86/spec-ctrl: Enumerations for DDP controls
Quoted 3 lines · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>
In the cover letter you mention that we should enable use of this by guests. Perhaps also mention this here?
xen/arch/x86/include/asm/msr-index.h line 44
Quoted 7 lines
xen/arch/x86/include/asm/msr-index.h +1
-0@@ -41,6 +41,7 @@#define SPEC_CTRL_RRSBA_DIS_U (_AC(1, ULL) << 5)#define SPEC_CTRL_RRSBA_DIS_S (_AC(1, ULL) << 6)#define SPEC_CTRL_PSFD (_AC(1, ULL) << 7) +#define SPEC_CTRL_DDPU_D (_AC(1, ULL) << 8)
The doc calls this DDPD_U - typo, or do you happen to know that the doc has it the wrong way round (and is going to be fixed)?
xen/include/public/arch-x86/cpufeatureset.h XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ · line 299
Quoted 8 lines
xen/include/public/arch-x86/cpufeatureset.h +1
-0@@ -295,6 +295,7 @@ XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ XEN_CPUFEATURE(IPRED_CTRL, 13*32+ 1) /* MSR_SPEC_CTRL.IPRED_DIS_* */ XEN_CPUFEATURE(RRSBA_CTRL, 13*32+ 2) /* MSR_SPEC_CTRL.RRSBA_DIS_* */ XEN_CPUFEATURE(BHI_CTRL, 13*32+ 4) /* MSR_SPEC_CTRL.BHI_DIS_S */ +XEN_CPUFEATURE(DDP_CTRL, 13*32+ 3) /* MSR_SPEC_CTRL.DDPU_U */XEN_CPUFEATURE (MCDT_NO ,13 *32 +5 )/*A MCDT_NO */
Looks like an off-by-1 in where you add the new line.
Suitably adjusted
Jan
Re: [PATCH 2/2] x86/spec-ctrl: Enumerations for DDP controls
Quoted 11 lines · Jan Beulich
xen/arch/x86/include/asm/msr-index.h line 44
Quoted 7 lines · Andrew Cooper
xen/arch/x86/include/asm/msr-index.h +1
-0@@ -41,6 +41,7 @@#define SPEC_CTRL_RRSBA_DIS_U (_AC(1, ULL) << 5)#define SPEC_CTRL_RRSBA_DIS_S (_AC(1, ULL) << 6)#define SPEC_CTRL_PSFD (_AC(1, ULL) << 7) +#define SPEC_CTRL_DDPU_D (_AC(1, ULL) << 8)The doc calls this
DDPD_U- typo, or do you happen to know that the doc has it the wrong way round (and is going to be fixed)?
Actually ...
Quoted 7 lines
xen/include/public/arch-x86/cpufeatureset.h XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ · line 298
Quoted 7 lines
xen/include/public/arch-x86/cpufeatureset.h +1
-0@@ -295,6 +295,7 @@ XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ XEN_CPUFEATURE(IPRED_CTRL, 13*32+ 1) /* MSR_SPEC_CTRL.IPRED_DIS_* */ XEN_CPUFEATURE(RRSBA_CTRL, 13*32+ 2) /* MSR_SPEC_CTRL.RRSBA_DIS_* */ XEN_CPUFEATURE(BHI_CTRL, 13*32+ 4) /* MSR_SPEC_CTRL.BHI_DIS_S */ +XEN_CPUFEATURE (DDP_CTRL ,13 *32 +3 )/* MSR_SPEC_CTRL.DDPU_U */
... here you have even two 'U' in the comment, when one of them wants to be 'D'.
Jan
Re: [PATCH 2/2] x86/spec-ctrl: Enumerations for DDP controls
Quoted 13 lines · Jan Beulich
Quoted 10 lines · Jan Beulich
xen/arch/x86/include/asm/msr-index.h line 44
Quoted 7 lines · Andrew Cooper
xen/arch/x86/include/asm/msr-index.h +1
-0@@ -41,6 +41,7 @@#define SPEC_CTRL_RRSBA_DIS_U (_AC(1, ULL) << 5)#define SPEC_CTRL_RRSBA_DIS_S (_AC(1, ULL) << 6)#define SPEC_CTRL_PSFD (_AC(1, ULL) << 7) +#define SPEC_CTRL_DDPU_D (_AC(1, ULL) << 8)The doc calls this
DDPD_U- typo, or do you happen to know that the doc has it the wrong way round (and is going to be fixed)?Actually ...
Quoted 9 lines
Quoted 7 lines
xen/include/public/arch-x86/cpufeatureset.h XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ · line 298
Quoted 7 lines
xen/include/public/arch-x86/cpufeatureset.h +1
-0@@ -295,6 +295,7 @@ XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ XEN_CPUFEATURE(IPRED_CTRL, 13*32+ 1) /* MSR_SPEC_CTRL.IPRED_DIS_* */ XEN_CPUFEATURE(RRSBA_CTRL, 13*32+ 2) /* MSR_SPEC_CTRL.RRSBA_DIS_* */ XEN_CPUFEATURE(BHI_CTRL, 13*32+ 4) /* MSR_SPEC_CTRL.BHI_DIS_S */ +XEN_CPUFEATURE (DDP_CTRL ,13 *32 +3 )/* MSR_SPEC_CTRL.DDPU_U */ ... here you have even two 'U' in the comment, when one of them wants to be 'D'.
Yeah, I've messed this up. It's supposed to be consistent with the public document (which I ought to have checked was consistent with the non-public reference that I was using...)
I'll fix up and repost.
~Andrew
PATCH v2 2/2 x86/spec-ctrl: Enumerations for DDP controls
In reply to Andrew CooperWe should offer DDP-CTRL to guests, but I'm not sure when it is appearing in hardware, and it's not massively urgent - the DDP behaviour is mostly sane (having been designed in a post-spectre world) and this is a just-in-case control.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
v2:
* Use DDP_DIS_U for consistency with the other bit names.
* Fix ordering/typos, expand commit message.
--- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 2 +- xen/arch/x86/include/asm/msr-index.h | 1 + xen/include/public/arch-x86/cpufeatureset.h | 1 + 4 files changed, 4 insertions(+), 1 deletion(-)
tools/libs/light/libxl_cpuid.c +1 -0
@@ -242,6 +242,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) {"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1}, {"ipred-ctrl", 0x00000007, 2, CPUID_REG_EDX, 1, 1}, {"rrsba-ctrl", 0x00000007, 2, CPUID_REG_EDX, 2, 1}, + {"ddp-ctrl", 0x00000007, 2, CPUID_REG_EDX, 3, 1}, {"bhi-ctrl", 0x00000007, 2, CPUID_REG_EDX, 4, 1}, {"mcdt-no", 0x00000007, 2, CPUID_REG_EDX, 5, 1},
tools/misc/xen-cpuid.c +1 -1
@@ -216,7 +216,7 @@ static const char *const str_7d1[32] =static const char *const str_7d2[32 ] = { [0 ] ="intel-psfd" , [1 ] ="ipred-ctrl" , - [2 ] ="rrsba-ctrl" , + [2 ] ="rrsba-ctrl" , [3 ] ="ddp-ctrl" , [4 ] ="bhi-ctrl" , [5 ] ="mcdt-no" , };
xen/arch/x86/include/asm/msr-index.h +1 -0
@@ -41,6 +41,7 @@#define SPEC_CTRL_RRSBA_DIS_U (_AC(1, ULL) << 5)#define SPEC_CTRL_RRSBA_DIS_S (_AC(1, ULL) << 6)#define SPEC_CTRL_PSFD (_AC(1, ULL) << 7) +#define SPEC_CTRL_DDP_DIS_U (_AC(1, ULL) << 8)#define SPEC_CTRL_BHI_DIS_S (_AC(1, ULL) << 10)#define MSR_PRED_CMD 0x00000049
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -294,6 +294,7 @@ XEN_CPUFEATURE(INTEL_PPIN, 12*32+ 0) /* Protected Processor Inventory XEN_CPUFEATURE(INTEL_PSFD, 13*32+ 0) /*A MSR_SPEC_CTRL.PSFD */ XEN_CPUFEATURE(IPRED_CTRL, 13*32+ 1) /* MSR_SPEC_CTRL.IPRED_DIS_* */ XEN_CPUFEATURE(RRSBA_CTRL, 13*32+ 2) /* MSR_SPEC_CTRL.RRSBA_DIS_* */ +XEN_CPUFEATURE(DDP_CTRL, 13*32+ 3) /* MSR_SPEC_CTRL.DDP_DIS_U */ XEN_CPUFEATURE(BHI_CTRL, 13*32+ 4) /* MSR_SPEC_CTRL.BHI_DIS_S */XEN_CPUFEATURE (MCDT_NO ,13 *32 +5 )/*A MCDT_NO */
Signature · 1 line
2.30.2