kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kvm <kvm@vger.kernel.org>
Subject: Re: [RFC PATCH 4/4] KVM: vmx: add support for emulating UMIP
Date: Mon, 1 Aug 2016 17:01:44 +0200	[thread overview]
Message-ID: <a627b86b-162c-ac17-37d9-28a49e3d5fab@redhat.com> (raw)
In-Reply-To: <CANRm+Cz-OMvheOCzhc0Hf7B2kDrAedv3NOnEqPEG8K_S5WvjSg@mail.gmail.com>



On 31/07/2016 04:32, Wanpeng Li wrote:
> 2016-07-14 16:09 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>:
> [...]
>>
>> This is not necessary because this is how KVM computes
>> CPUID[EAX=7,EBX=0].ECX:
>>
>>         unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0;
>>         ...
>>         const u32 kvm_cpuid_7_0_ecx_x86_features = F(PKU) | F(UMIP);
>>         ...
>>         // Mask userspace-provided value against supported features
>>         entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
>>         // Mask userspace-provided value against host features
>>         cpuid_mask(&entry->ecx, CPUID_7_ECX);
>>         // Finally add emulated features
>>         entry->ecx |= f_umip;
> 
> I think you mean:
> 
> - entry->ecx  ->  userspace-provided value
> - kvm_cpuid_7_0_ecx_x86_features  ->  supported features
> - CPUID_7_ECX  ->  host features
> 
> However, entry->ecx is returned by cpuid instruction
> (do_cpuid_1_ent()), so why it is a userspace-provided value?

You're right, it's this:

         // Mask host processor value against supported features
         entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
         // Mask host processor value further, e.g. to drop
	 // features that the host kernel has blacklisted.
         cpuid_mask(&entry->ecx, CPUID_7_ECX);
         // Finally add emulated features
         entry->ecx |= f_umip;

The idea is the same. :)

On the other hand, it is true that in many cases of the "switch
(function)" the call to do_cpuid_1_ent is unnecessary, and instead of
cpuid_mask you could just access boot_cpu_data.x86_capability[wordnum].

Paolo

  reply	other threads:[~2016-08-01 15:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12 19:20 [RFC PATCH 0/4] KVM: Emulate UMIP (or almost do so) Paolo Bonzini
2016-07-12 19:20 ` [RFC PATCH 1/4] x86: add UMIP feature and CR4 bit Paolo Bonzini
2016-07-12 19:20 ` [RFC PATCH 2/4] KVM: x86: emulate sldt and str Paolo Bonzini
2016-07-12 19:20 ` [RFC PATCH 3/4] KVM: x86: add support for emulating UMIP Paolo Bonzini
2016-07-13 20:03   ` Radim Krčmář
2016-07-14  7:00     ` Paolo Bonzini
2016-07-14 12:24       ` Radim Krčmář
2016-07-12 19:20 ` [RFC PATCH 4/4] KVM: vmx: " Paolo Bonzini
2016-07-13  9:21   ` Yang Zhang
2016-07-13  9:35     ` Paolo Bonzini
2016-07-13  9:54       ` Yang Zhang
2016-07-13  9:35     ` Paolo Bonzini
2016-07-13 10:02       ` Yang Zhang
2016-07-13 10:21         ` Paolo Bonzini
2016-07-13 20:30   ` Radim Krčmář
2016-07-14  8:09     ` Paolo Bonzini
2016-07-14 12:36       ` Radim Krčmář
2016-07-14 12:54         ` Paolo Bonzini
2016-07-31  2:32       ` Wanpeng Li
2016-08-01 15:01         ` Paolo Bonzini [this message]
2016-08-02  1:05           ` Wanpeng Li
2016-07-13  8:29 ` [RFC PATCH 0/4] KVM: Emulate UMIP (or almost do so) Yang Zhang
2016-07-13  9:34   ` Paolo Bonzini
2016-12-13  4:03 ` Li, Liang Z
2016-12-13 11:03   ` Paolo Bonzini
2017-03-01  9:04     ` Yu Zhang
2017-03-06 21:07       ` Paolo Bonzini
2017-03-10  8:02       ` Yu Zhang
2017-03-10  8:36         ` Paolo Bonzini
2017-03-10  9:31           ` Yu Zhang
2017-03-10 11:28             ` Yu Zhang
2017-03-10 15:00             ` Paolo Bonzini

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=a627b86b-162c-ac17-37d9-28a49e3d5fab@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    /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).