From: Amit Shah <[email protected]> Newer AMD CPUs have the ERAPS (Enhanced Return Address Predictor Security) cpuid bit. When this bit is available, the size of the RSB is indicated in EBX bits 16:23 of the same function. Allow the guest to use these features when kvm is enabled and are available on the host.
Documentation for the ERAPS feature may be found in the AMD64 Architecture Programmer's Manual (APM) Volume 2, Rev 3.45, July 2026, section 15.37.2 "ERAPS Virtualization", available here: Link: https://docs.amd.com/v/u/en-US/24593_3.45_APM_Vol2_PUB Signed-off-by: Amit Shah <[email protected]> Co-developed-by: Ben Cheatham <[email protected]> Signed-off-by: Ben Cheatham <[email protected]> --- target/i386/cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3ece2e8b279f..8805657f01de 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -9300,7 +9300,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, case 0x80000021: *eax = *ebx = *ecx = *edx = 0; *eax = env->features[FEAT_8000_0021_EAX]; - *ebx = env->features[FEAT_8000_0021_EBX]; + + if (kvm_enabled() && (*eax & CPUID_8000_0021_EAX_ERAPS)) { + *ebx |= + kvm_arch_get_supported_cpuid(cs->kvm_state, index, count, R_EBX) & + CPUID_8000_0021_EBX_RAPSIZE; + } + *ecx = env->features[FEAT_8000_0021_ECX]; break; case 0x80000022: -- 2.53.0
