qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH 2/2] i386/cpu: Mask off unsupported XSAVE components
Date: Thu, 16 Jul 2020 23:28:04 +0800	[thread overview]
Message-ID: <690a1ec5-e32c-7def-da27-16858d110e89@intel.com> (raw)
In-Reply-To: <20200716151431.GK1274972@habkost.net>

On 7/16/2020 11:14 PM, Eduardo Habkost wrote:
> On Thu, Jul 16, 2020 at 04:20:19PM +0800, Xiaoyao Li wrote:
>> When setting up XSAVE components, it needs to mask off those unsupported
>> by KVM.
>>
>> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> 
> We must never disable CPUID features silently based on host
> capabilities, otherwise we can't guarantee guest ABI stability
> when migrating to another host.  Filtering of features should
> involve a call to mark_unavailable_features() (or some equivalent
> mechanism) so we can report the missing features properly through
> QMP.
> 
> Could you explain what's the bug you are trying to fix?  The loop
> at x86_cpu_filter_features() is already supposed to disable
> features unsupported by the host.

Sorry, I forgot x86_cpu_filter_features() totally when code inspection.

>> ---
>>   target/i386/cpu.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>> index f5f11603e805..efc92334b7b1 100644
>> --- a/target/i386/cpu.c
>> +++ b/target/i386/cpu.c
>> @@ -6274,8 +6274,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
>>           }
>>       }
>>   
>> -    env->features[FEAT_XSAVE_COMP_LO] = mask;
>> -    env->features[FEAT_XSAVE_COMP_HI] = mask >> 32;
>> +    env->features[FEAT_XSAVE_COMP_LO] = mask &
>> +        x86_cpu_get_supported_feature_word(FEAT_XSAVE_COMP_LO, cpu->migratable);
>> +    env->features[FEAT_XSAVE_COMP_HI] = (mask >> 32) &
>> +        x86_cpu_get_supported_feature_word(FEAT_XSAVE_COMP_HI, cpu->migratable);
>>   }
>>   
>>   /***** Steps involved on loading and filtering CPUID data
>> -- 
>> 2.18.4
>>
> 



      reply	other threads:[~2020-07-16 15:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  8:20 [PATCH 0/2] Two Fixes for xsave compoent features Xiaoyao Li
2020-07-16  8:20 ` [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO, HI} when XSAVE is not available Xiaoyao Li
2020-07-16 15:15   ` [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO,HI} " Eduardo Habkost
2020-07-16 15:22     ` [PATCH 1/2] i386/cpu: Clear FEAT_XSAVE_COMP_{LO, HI} " Xiaoyao Li
2020-08-18  7:45   ` Paolo Bonzini
2020-07-16  8:20 ` [PATCH 2/2] i386/cpu: Mask off unsupported XSAVE components Xiaoyao Li
2020-07-16 15:14   ` Eduardo Habkost
2020-07-16 15:28     ` Xiaoyao Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=690a1ec5-e32c-7def-da27-16858d110e89@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).