On Tue, 2026-06-30 at 10:33 -0500, Ben Cheatham wrote:
> 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.
> 
> NOTE: The commit description is from a patch made by Amit while the
> actual changes are a subset of that patch, hence my Co-developed-by.
> Amit, let me know if the attribution looks good to you.

Looks good, thanks.  BTW you can move this blurb below the --- lines so
that it doesn't show up in the commit log.


> 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 a85cc67700fa..9342cc3ca4c6 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -9292,7 +9292,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:

Reply via email to