[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/2] x86: guard synthetic feature and bug enumerators
On 2025-10-08 01:56, Jan Beulich wrote: On 07.10.2025 21:38, Jason Andryuk wrote:On 2025-10-07 08:22, Jan Beulich wrote:On 30.09.2025 01:36, Jason Andryuk wrote:On 2025-09-25 06:48, Jan Beulich wrote:--- a/xen/arch/x86/include/asm/spec_ctrl.h +++ b/xen/arch/x86/include/asm/spec_ctrl.h @@ -73,7 +73,7 @@ static always_inline void spec_ctrl_new_/* (ab)use alternative_input() to specify clobbers. */alternative_input("", "DO_OVERWRITE_RSB xu=%=", X86_BUG_IBPB_NO_RET, - : "rax", "rcx"); + "i" (0) : "rax", "rcx");"i" (0) is to work around the trailing comma in alternative_input() and does nothing?Yes. If more such "uses" appeared, we may want to introduce some kind of abstraction.Thanks for confirming. Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>Thanks.Though I also wondered if just #define X86_BUG_MAX/X86_SYNTH_MAX combined with a BUILD_BUG_ON might be good enough. Your approach avoids the extra define but is more complicated. Anyway, just a thought.How would that end up simplifying things? IOW what would the BUILD_BUG_ON() look like that you're thinking about? After all X86_{SYNTH,BUG}_MAX aren't meaningfully different from X86_NR_{SYNTH,BUG}. Originally, I was thinking something like XEN_CPUFEATURE(PDX_COMPRESSION, X86_SYNTH(31)) /* PDX compression */ +#define X86_SYNTH_MAX 31 /* Bump when adding flags */ and: BUILD_BUG_ON( ((X86_SYNTH_MAX / 32) + 1) > X86_NR_SYNTH )Not automated, but adding a new flag should make it obvious X86_SYNTH_MAX should increase. But as you point out the redundancy of X86_{SYNTH,BUG}_MAX and X86_NR_{SYNTH,BUG}. But we could re-arrange to make X86_NR_{SYNTH,BUG} calculated from X86_{SYNTH,BUG}_MAX like below. Again, it's not automated, but it should make it harder to miss increasing the value. Regards, Jasondiff --git i/xen/arch/x86/include/asm/cpufeatures.h w/xen/arch/x86/include/asm/cpufeatures.h index 0a98676c16..724eb1599f 100644 --- i/xen/arch/x86/include/asm/cpufeatures.h +++ w/xen/arch/x86/include/asm/cpufeatures.h @@ -7,7 +7,6 @@ #define FSCAPINTS FEATURESET_NR_ENTRIES /* Synthetic words follow the featureset words. */ -#define X86_NR_SYNTH 1 #define X86_SYNTH(x) (FSCAPINTS * 32 + (x)) /* Synthetic features */@@ -43,9 +42,10 @@ XEN_CPUFEATURE(IBPB_ENTRY_PV, X86_SYNTH(28)) /* MSR_PRED_CMD used by Xen for XEN_CPUFEATURE(IBPB_ENTRY_HVM, X86_SYNTH(29)) /* MSR_PRED_CMD used by Xen for HVM */ XEN_CPUFEATURE(USE_VMCALL, X86_SYNTH(30)) /* Use VMCALL instead of VMMCALL */ XEN_CPUFEATURE(PDX_COMPRESSION, X86_SYNTH(31)) /* PDX compression */ +#define X86_SYNTH_MAX 31 /* Bump when adding new flags. */ +#define X86_NR_SYNTH ((X86_SYNTH_MAX / 32) + 1) /* Bug words follow the synthetic words. */ -#define X86_NR_BUG 1 #define X86_BUG(x) ((FSCAPINTS + X86_NR_SYNTH) * 32 + (x))#define X86_BUG_FPU_PTRS X86_BUG( 0) /* (F)X{SAVE,RSTOR} doesn't save/restore FOP/FIP/FDP. */ @@ -62,6 +62,8 @@ XEN_CPUFEATURE(PDX_COMPRESSION, X86_SYNTH(31)) /* PDX compression */ #define X86_SPEC_BHB_TSX X86_BUG(19) /* Use clear_bhb_tsx for BHI mitigation. */ #define X86_SPEC_BHB_LOOPS X86_BUG(20) /* Use clear_bhb_loops for BHI mitigation.*/ #define X86_SPEC_BHB_LOOPS_LONG X86_BUG(21) /* Upgrade clear_bhb_loops to the "long" sequence. */ +#define X86_BUX_MAX 21 /* Bump when adding new flags. */ +#define X86_NR_BUG ((X86_BUG_MAX / 32) + 1) /* Total number of capability words, inc synth and bug words. */#define NCAPINTS (FSCAPINTS + X86_NR_SYNTH + X86_NR_BUG) /* N 32-bit words worth of info */
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |