kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: "Moger, Babu" <Babu.Moger@amd.com>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>, "hpa@zytor.com" <hpa@zytor.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"rkrcmar@redhat.com" <rkrcmar@redhat.com>,
	"sean.j.christopherson@intel.com"
	<sean.j.christopherson@intel.com>,
	"vkuznets@redhat.com" <vkuznets@redhat.com>,
	"wanpengli@tencent.com" <wanpengli@tencent.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"luto@kernel.org" <luto@kernel.org>,
	"zohar@linux.ibm.com" <zohar@linux.ibm.com>,
	"yamada.masahiro@socionext.com" <yamada.masahiro@socionext.com>,
	"nayna@linux.ibm.com" <nayna@linux.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 1/4] kvm: x86: Dont set UMIP feature bit unconditionally
Date: Fri, 1 Nov 2019 12:42:55 -0700	[thread overview]
Message-ID: <CALMp9eSnB+=0MYBkkyAfw1WK+ZmYFqpd7EDToFRmnbE+g3MEvQ@mail.gmail.com> (raw)
In-Reply-To: <a5466e76-3a7b-2de7-ceb9-3d41bf5e4f4d@amd.com>

On Fri, Nov 1, 2019 at 12:39 PM Moger, Babu <Babu.Moger@amd.com> wrote:
>
>
>
> On 11/1/19 1:35 PM, Jim Mattson wrote:
> > On Fri, Nov 1, 2019 at 10:33 AM Moger, Babu <Babu.Moger@amd.com> wrote:
> >>
> >> The UMIP (User-Mode Instruction Prevention) feature bit should be
> >> set if the emulation (kvm_x86_ops->umip_emulated) is supported
> >> which is done already.
> >>
> >> Remove the unconditional setting of this bit.
> >>
> >> Fixes: ae3e61e1c28338d0 ("KVM: x86: add support for UMIP")
> >>
> >> Signed-off-by: Babu Moger <babu.moger@amd.com>
> >> ---
> >>  arch/x86/kvm/cpuid.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> >> index f68c0c753c38..5b81ba5ad428 100644
> >> --- a/arch/x86/kvm/cpuid.c
> >> +++ b/arch/x86/kvm/cpuid.c
> >> @@ -364,7 +364,7 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
> >>         /* cpuid 7.0.ecx*/
> >>         const u32 kvm_cpuid_7_0_ecx_x86_features =
> >>                 F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ | F(RDPID) |
> >> -               F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) |
> >> +               F(AVX512_VPOPCNTDQ) | F(AVX512_VBMI2) | F(GFNI) |
> >>                 F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) |
> >>                 F(CLDEMOTE) | F(MOVDIRI) | F(MOVDIR64B) | 0 /*WAITPKG*/;
> >>
> >
> > This isn't unconditional. This is masked by the features on the boot
> > CPU. Since UMIP can be virtualized (without emulation) on CPUs that
> > support UMIP, you should leave this alone.
> >
>
> There is some inconstancy here.
>
> static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32
>
> unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0;
> ...
>
> case 7: {
>              ..
>             entry->ecx |= f_umip;
>             ..
>         }
>
> and
> static bool svm_umip_emulated(void)
> {
>         return false;
> }
>
> static inline bool vmx_umip_emulated(void)
> {
>         return vmcs_config.cpu_based_2nd_exec_ctrl &
>                 SECONDARY_EXEC_DESC;
> }
>
>
> It appears that intention was to enable the UMIP if SVM or VMX support
> umip emulation. But that is not how it is working now. Now it is enabled
> if boot CPU supports UMIP.

No. The code enumerates UMIP in the guest if *either* it can be
virtualized (i.e. the host supports it natively), *or* it can be
emulated.

  reply	other threads:[~2019-11-01 19:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 17:33 [PATCH 0/4] Emulate and enable UMIP feature on AMD Moger, Babu
2019-11-01 17:33 ` [PATCH 1/4] kvm: x86: Dont set UMIP feature bit unconditionally Moger, Babu
2019-11-01 18:35   ` Jim Mattson
2019-11-01 19:39     ` Moger, Babu
2019-11-01 19:42       ` Jim Mattson [this message]
2019-11-01 17:33 ` [PATCH 2/4] kvm: svm: Enable UMIP feature on AMD Moger, Babu
2019-11-01 18:24   ` Andy Lutomirski
2019-11-01 18:38     ` Moger, Babu
2019-11-01 19:09       ` Andy Lutomirski
2019-11-01 18:29   ` Jim Mattson
2019-11-01 19:20     ` Moger, Babu
2019-11-01 19:24       ` Andy Lutomirski
2019-11-01 20:04         ` Moger, Babu
2019-11-01 20:08           ` Jim Mattson
2019-11-02 19:23             ` Moger, Babu
2019-11-03 11:45               ` Borislav Petkov
2019-11-04 18:46                 ` Moger, Babu
2019-11-04 11:54   ` Paolo Bonzini
2019-11-04 18:45     ` Moger, Babu
2019-11-01 17:33 ` [PATCH 3/4] kvm: svm: Emulate UMIP instructions on non SEV guest Moger, Babu
2019-11-01 17:34 ` [PATCH 4/4] x86/Kconfig: Rename UMIP config parameter Moger, Babu

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='CALMp9eSnB+=0MYBkkyAfw1WK+ZmYFqpd7EDToFRmnbE+g3MEvQ@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=Babu.Moger@amd.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nayna@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    --cc=zohar@linux.ibm.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).