x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()
PATCH 1/1 x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()
This line:
val &= ~chickenbit;
ends up truncating val to 32 bits, and turning off various errata workarounds in Zen2 systems.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
The choice is between int or uint64_t. This is one case where the insistence on using unsigned int as a default data type is genuinely unsafe.
--- xen/arch/x86/cpu/amd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/cpu/amd.c +2 -1
@@ -909,8 +909,9 @@ void __init detect_zen2_null_seg_behaviour(void)void amd_check_zenbleed (void ) {const struct cpu_signature *sig = &this_cpu (cpu_sig); -unsigned int good_rev, chickenbit = (1 <<9 ); +unsigned int good_rev;uint64_t val, old_val; +int chickenbit = (1 <<9 );/* * If we're virtualised, we can't do family/model checks safely, and
Signature · 1 line
2.30.2
Quoted 9 lines · Andrew Cooper
This line:
val &= ~chickenbit;ends up truncating val to 32 bits, and turning off various errata workarounds in Zen2 systems.
Fixes f91c5ea97067 ("x86/amd: Mitigations for Zenbleed")Signed-off-by Andrew Cooper <[email protected]>
Quoted 7 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>The choice is between int or
uint64_t. This is one case where the insistence on using unsigned int as a default data type is genuinely unsafe.
It is not. The (unsigned) type should have been wide enough. From a Misra perspective I'm pretty sure we would be better off using uint64_t. But in the interest of getting this in without a lot of discussion I'll leave the decision up to you; either way
Jan
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Andrew Cooper
This line:
val &= ~chickenbit;ends up truncating val to 32 bits, and turning off various errata workarounds in Zen2 systems.
Fixes f91c5ea97067 ("x86/amd: Mitigations for Zenbleed")Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
Quoted 7 lines
Quoted 2 lines
The choice is between int or
uint64_t. This is one case where the insistence on using unsigned int as a default data type is genuinely unsafe.It is not. The (unsigned) type should have been wide enough. From a Misra perspective I'm pretty sure we would be better off using
uint64_t. But in the interest of getting this in without a lot of discussion I'll leave the decision up to you; either wayReviewed-by Jan Beulich <[email protected]>
Roger asked for uint64_t too so I'll go with that. Thanks.
~Andrew