On Tue, May 01, 2018 at 08:30:27PM +0200, speck for Thomas Gleixner wrote: > On Tue, 1 May 2018, speck for Konrad Rzeszutek Wilk wrote: > > > > On my Skylake box this does what is expected: > > > > And I don't see the weird issue that Tim reported? > > That depends on your ucode loading mechanism. Oooh . Right, that would explain it: RHEL-64 dmesg | grep micro [ 0.000000] microcode: microcode updated early to revision 0x200004a, date = 2018-03-28 [ 28.499014] microcode: sig=0x50654, pf=0x80, revision=0x200004a [ 28.575504] microcode: Microcode Update Driver: v2.2. > > > RHEL-64 ./test-prctl > > Could you please send that test thing around? It's trivial enough but I'm a > lousy user space programmer and lazy :) It is very umm, crappy but sure - see inline and attached. And it does not do any ASSERTS or such to verify things. And I've no clue why the tabs all changed to spaces. #include #include #define SPEC_CTRL_RDS_SHIFT 2 /* Reduced Data Speculation bit */ /* Per task speculation control */ #define PR_SET_SPECULATION_CTRL 52 #define PR_GET_SPECULATION_CTRL 53 /* Speculation control variants */ # define PR_SPEC_STORE_BYPASS 0 /* Return and control values for PR_SET/GET_SPECULATION_CTRL */ # define PR_SPEC_NOT_AFFECTED 0 # define PR_SPEC_PRCTL (1UL << 0) # define PR_SPEC_ENABLE (1UL << 1) # define PR_SPEC_DISABLE (1UL << 2) void print_bitfields(int r) { if ( r >= 0 ) fprintf(stderr, " r=%s %s %s\n", r & PR_SPEC_PRCTL ? "PR_SPEC_PRCTL" : "", r & PR_SPEC_ENABLE ? "PR_SPEC_ENABLE" : "", r & PR_SPEC_DISABLE ? "PR_SPEC_DISABLE" : ""); } void get_v(void) { int r; r = prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, NULL, NULL,NULL); fprintf(stderr, " PR_GET_SPECULATION_CTRL PR_SPEC_STORE_BYPASS r=%d\n", r); print_bitfields(r); } int main(void) { int r; fprintf(stderr,"Initial state\n"); get_v(); r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, NULL, NULL); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); /* Two DISALBE in a row*/ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, NULL, NULL); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); /* Two enable in a row. */ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_ENABLE, NULL, NULL); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_ENABLE r=%d\n", r); print_bitfields(r); get_v(); r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_ENABLE, NULL, NULL); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_ENABLE r=%d\n", r); print_bitfields(r); get_v(); fprintf(stderr,"\nReal test-case\n"); /* The real normal test-case */ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, NULL, NULL); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); do { } while (1); return 0; } > > Thanks, > > tglx