fix(shim-sev): clamp maximum memory allocation if C-bit is set
If the C-bit location is > 47, we don't want to use that.
@@ -111,7 +111,7 @@ impl EnarxAllocator {
const MIN_EXP: u32 = 24; // start with 2^24 = 16 MiB
let c_bit_mask = C_BIT_MASK.load(Ordering::Relaxed);
let target_exp: u32 = if c_bit_mask > 0 {
- msb(c_bit_mask as _).checked_sub(1).unwrap() // don't want to address more than c_bit_mask
+ u32::min(47, msb(c_bit_mask as _).checked_sub(1).unwrap()) // don't want to address more than c_bit_mask
} else {
47 // we want more than 2^47 = 128 TiB
};
