]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
KVM: x86: add support for UMIP
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 12 Jul 2016 08:36:41 +0000 (10:36 +0200)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Mon, 19 Mar 2018 23:40:23 +0000 (20:40 -0300)
BugLink: http://bugs.launchpad.net/bugs/1739665
Add the CPUID bits, make the CR4.UMIP bit not reserved anymore, and
add UMIP support for instructions that are already emulated by KVM.

Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit ae3e61e1c28338d077b704505570fa181df1e41f)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index 51679843132829e38ed204eda60d50379a4fabb5..ff79134d1d71afa003403e976095e7c523f441c8 100644 (file)
@@ -86,7 +86,7 @@
                          | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
                          | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \
                          | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \
-                         | X86_CR4_SMAP | X86_CR4_PKE))
+                         | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP))
 
 #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
 
index 4f544f2a7b06b38fb38d22c1bf52bdb847d92bdd..4cb0a380cdc676df0c533bae0598995b1f16f997 100644 (file)
@@ -389,8 +389,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 
        /* cpuid 7.0.ecx*/
        const u32 kvm_cpuid_7_0_ecx_x86_features =
-               F(AVX512VBMI) | F(LA57) | F(PKU) |
-               0 /*OSPKE*/ | F(AVX512_VPOPCNTDQ);
+               F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ |
+               F(AVX512_VPOPCNTDQ) | F(UMIP);
 
        /* cpuid 7.0.edx*/
        const u32 kvm_cpuid_7_0_edx_x86_features =
index 290ecf711aec2d6684fd296d07d7379a88232027..ebdfaa576261a43411561011c0c668b6059a1b24 100644 (file)
@@ -3739,6 +3739,10 @@ static int emulate_store_desc_ptr(struct x86_emulate_ctxt *ctxt,
 {
        struct desc_ptr desc_ptr;
 
+       if ((ctxt->ops->get_cr(ctxt, 4) & X86_CR4_UMIP) &&
+           ctxt->ops->cpl(ctxt) > 0)
+               return emulate_gp(ctxt, 0);
+
        if (ctxt->mode == X86EMUL_MODE_PROT64)
                ctxt->op_bytes = 8;
        get(ctxt, &desc_ptr);
@@ -3798,6 +3802,10 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt)
 
 static int em_smsw(struct x86_emulate_ctxt *ctxt)
 {
+       if ((ctxt->ops->get_cr(ctxt, 4) & X86_CR4_UMIP) &&
+           ctxt->ops->cpl(ctxt) > 0)
+               return emulate_gp(ctxt, 0);
+
        if (ctxt->dst.type == OP_MEM)
                ctxt->dst.bytes = 2;
        ctxt->dst.val = ctxt->ops->get_cr(ctxt, 0);
index 4aba7ee5b53788082ef6e8c3228217e89cc392a3..15ba5b7e905d43986b332a89b135da0950e54f78 100644 (file)
@@ -794,6 +794,9 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
        if (!guest_cpuid_has(vcpu, X86_FEATURE_LA57) && (cr4 & X86_CR4_LA57))
                return 1;
 
+       if (!guest_cpuid_has(vcpu, X86_FEATURE_UMIP) && (cr4 & X86_CR4_UMIP))
+               return 1;
+
        if (is_long_mode(vcpu)) {
                if (!(cr4 & X86_CR4_PAE))
                        return 1;