qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
Date: Tue, 20 Aug 2019 18:23:06 -0300

On Mon, Aug 19, 2019 at 06:09:24PM +0800, Bingsong Si wrote:
> This reverts commit de2e68c902f7b6e438b0fa3cfedd74a06a20704f.
> 
> Initial value of env->xcr0 == 0, then CPUID(EAX=0xd,ECX=0).EBX == 0, after kvm
> upstream commit 412a3c41, It is ok.
> On host before commit 412a3c41, some legacy guest, i.e. CentOS 6, get
> xstate_size == 0, will crash the guest.
> 
> Signed-off-by: Bingsong Si <address@hidden>

cpu_x86_cpuid() is also used by TCG, and needs to return the
correct data depending on xcr0.  If you want to work around a KVM
bug by ignoring xcr0, it needs to be conditional on
kvm_enabled().

But even if we you make this conditional on kvm_enabled(), I
don't understand why QEMU would need a workaround for a KVM bug
that was fixed more than 4 years ago.

> ---
>  target/i386/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index ff65e11008..69562e21ed 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -4416,7 +4416,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, 
> uint32_t count,
>              *ecx = xsave_area_size(x86_cpu_xsave_components(cpu));
>              *eax = env->features[FEAT_XSAVE_COMP_LO];
>              *edx = env->features[FEAT_XSAVE_COMP_HI];
> -            *ebx = xsave_area_size(env->xcr0);
> +            *ebx = *ecx;
>          } else if (count == 1) {
>              *eax = env->features[FEAT_XSAVE];
>          } else if (count < ARRAY_SIZE(x86_ext_save_areas)) {
> -- 
> 2.22.0
> 
> 

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]