qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
@ 2019-08-19 10:09 Bingsong Si
  2019-08-19 14:34 ` Dr. David Alan Gilbert
  2019-08-20 21:23 ` Eduardo Habkost
  0 siblings, 2 replies; 7+ messages in thread
From: Bingsong Si @ 2019-08-19 10:09 UTC (permalink / raw)
  To: qemu-devel

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 <owen.si@ucloud.cn>
---
 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-19 10:09 [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)" Bingsong Si
@ 2019-08-19 14:34 ` Dr. David Alan Gilbert
  2019-08-20 21:23 ` Eduardo Habkost
  1 sibling, 0 replies; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2019-08-19 14:34 UTC (permalink / raw)
  To: Bingsong Si, ehabkost; +Cc: qemu-devel

Copying in Eduardo.

* Bingsong Si (owen.si@ucloud.cn) 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 <owen.si@ucloud.cn>
> ---
>  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
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-19 10:09 [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)" Bingsong Si
  2019-08-19 14:34 ` Dr. David Alan Gilbert
@ 2019-08-20 21:23 ` Eduardo Habkost
  2019-08-21  3:04   ` owen.si
  1 sibling, 1 reply; 7+ messages in thread
From: Eduardo Habkost @ 2019-08-20 21:23 UTC (permalink / raw)
  To: Bingsong Si; +Cc: qemu-devel

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 <owen.si@ucloud.cn>

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-20 21:23 ` Eduardo Habkost
@ 2019-08-21  3:04   ` owen.si
  2019-08-21 11:19     ` Eduardo Habkost
  0 siblings, 1 reply; 7+ messages in thread
From: owen.si @ 2019-08-21  3:04 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel

Thanks for you reply, we have some hosts running with legacy kernel, difficult to upgrade, and i want to run the latest qemu.
Does QEMU support running with legacy kernel(kvm) in design?



owen.si@ucloud.cn
 
From: Eduardo Habkost
Date: 2019-08-21 05:23
To: Bingsong Si
CC: qemu-devel
Subject: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
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 <owen.si@ucloud.cn>
 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-21  3:04   ` owen.si
@ 2019-08-21 11:19     ` Eduardo Habkost
  2019-08-21 11:54       ` owen.si
  0 siblings, 1 reply; 7+ messages in thread
From: Eduardo Habkost @ 2019-08-21 11:19 UTC (permalink / raw)
  To: owen.si; +Cc: qemu-devel

On Wed, Aug 21, 2019 at 11:04:46AM +0800, owen.si@ucloud.cn wrote:
> Thanks for you reply, we have some hosts running with legacy kernel, difficult to upgrade, and i want to run the latest qemu.
> Does QEMU support running with legacy kernel(kvm) in design?

For KVM, QEMU requires Linux 4.5 or newer.  See "System
requirements" / "KVM kernel module" section on qemu-doc.  We also
aim to support the latest version of Linux distributions with
long term support (e.g. RHEL, Debian, Ubuntu LTS, SLES).

Do you have more details on the kernel you are using?  Is it
built and distributed by a third party?


> 
> 
> 
> owen.si@ucloud.cn
>  
> From: Eduardo Habkost
> Date: 2019-08-21 05:23
> To: Bingsong Si
> CC: qemu-devel
> Subject: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
> 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 <owen.si@ucloud.cn>
>  
> 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

-- 
Eduardo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-21 11:19     ` Eduardo Habkost
@ 2019-08-21 11:54       ` owen.si
  2019-08-21 20:45         ` Eduardo Habkost
  0 siblings, 1 reply; 7+ messages in thread
From: owen.si @ 2019-08-21 11:54 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel

It is CentOS 6.3 with kernel version 2.6.32-279. Actually all CentOS 6 releases have this issue.



owen.si@ucloud.cn
 
From: Eduardo Habkost
Date: 2019-08-21 19:19
To: owen.si@ucloud.cn
CC: qemu-devel
Subject: Re: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
On Wed, Aug 21, 2019 at 11:04:46AM +0800, owen.si@ucloud.cn wrote:
> Thanks for you reply, we have some hosts running with legacy kernel, difficult to upgrade, and i want to run the latest qemu.
> Does QEMU support running with legacy kernel(kvm) in design?
 
For KVM, QEMU requires Linux 4.5 or newer.  See "System
requirements" / "KVM kernel module" section on qemu-doc.  We also
aim to support the latest version of Linux distributions with
long term support (e.g. RHEL, Debian, Ubuntu LTS, SLES).
 
Do you have more details on the kernel you are using?  Is it
built and distributed by a third party?
 
 
> 
> 
> 
> owen.si@ucloud.cn
>  
> From: Eduardo Habkost
> Date: 2019-08-21 05:23
> To: Bingsong Si
> CC: qemu-devel
> Subject: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
> 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 <owen.si@ucloud.cn>
>  
> 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
 
-- 
Eduardo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
  2019-08-21 11:54       ` owen.si
@ 2019-08-21 20:45         ` Eduardo Habkost
  0 siblings, 0 replies; 7+ messages in thread
From: Eduardo Habkost @ 2019-08-21 20:45 UTC (permalink / raw)
  To: owen.si; +Cc: qemu-devel

On Wed, Aug 21, 2019 at 07:54:17PM +0800, owen.si@ucloud.cn wrote:
> It is CentOS 6.3 with kernel version 2.6.32-279. Actually all CentOS 6 releases have this issue.

We stopped supporting CentOS 6 in July 2016 (2 years after CentOS
7 was released).  Be aware that even if we work around that
specific bug, there are no guarantees that QEMU will still build
on a CentOS 6 host in the future.

That said, I probably wouldn't reject a patch that works around
that CentOS 6 bug, if it's conditional on kvm_enabled() and has a
comment explaining why the workaround exists.

> 
> 
> 
> owen.si@ucloud.cn
>  
> From: Eduardo Habkost
> Date: 2019-08-21 19:19
> To: owen.si@ucloud.cn
> CC: qemu-devel
> Subject: Re: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
> On Wed, Aug 21, 2019 at 11:04:46AM +0800, owen.si@ucloud.cn wrote:
> > Thanks for you reply, we have some hosts running with legacy kernel, difficult to upgrade, and i want to run the latest qemu.
> > Does QEMU support running with legacy kernel(kvm) in design?
>  
> For KVM, QEMU requires Linux 4.5 or newer.  See "System
> requirements" / "KVM kernel module" section on qemu-doc.  We also
> aim to support the latest version of Linux distributions with
> long term support (e.g. RHEL, Debian, Ubuntu LTS, SLES).
>  
> Do you have more details on the kernel you are using?  Is it
> built and distributed by a third party?
>  
>  
> > 
> > 
> > 
> > owen.si@ucloud.cn
> >  
> > From: Eduardo Habkost
> > Date: 2019-08-21 05:23
> > To: Bingsong Si
> > CC: qemu-devel
> > Subject: Re: [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)"
> > 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 <owen.si@ucloud.cn>
> >  
> > 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
>  
> -- 
> Eduardo

-- 
Eduardo


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-21 21:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 10:09 [Qemu-devel] [PATCH] Revert "i386: correct cpu_x86_cpuid(0xd)" Bingsong Si
2019-08-19 14:34 ` Dr. David Alan Gilbert
2019-08-20 21:23 ` Eduardo Habkost
2019-08-21  3:04   ` owen.si
2019-08-21 11:19     ` Eduardo Habkost
2019-08-21 11:54       ` owen.si
2019-08-21 20:45         ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).