From: Greg Kroah-Hartman Date: Sun, 27 May 2018 13:50:30 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v3.18.111~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eab49e0ff7d4bb0220cb5bd2f63677f5b61f5441;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: kvm-s390-vsie-fix-8k-check-for-the-itdba.patch kvm-vmx-expose-ssbd-properly-to-guests.patch kvm-x86-ia32_arch_capabilities-is-always-supported.patch kvm-x86-update-cpuid-properly-when-cr4.osxave-or-cr4.pke-is-changed.patch --- diff --git a/queue-4.9/kvm-s390-vsie-fix-8k-check-for-the-itdba.patch b/queue-4.9/kvm-s390-vsie-fix-8k-check-for-the-itdba.patch new file mode 100644 index 00000000000..f646e27ac76 --- /dev/null +++ b/queue-4.9/kvm-s390-vsie-fix-8k-check-for-the-itdba.patch @@ -0,0 +1,44 @@ +From f4a551b72358facbbe5714248dff78404272feee Mon Sep 17 00:00:00 2001 +From: David Hildenbrand +Date: Wed, 9 May 2018 16:12:17 +0200 +Subject: KVM: s390: vsie: fix < 8k check for the itdba + +From: David Hildenbrand + +commit f4a551b72358facbbe5714248dff78404272feee upstream. + +By missing an "L", we might detect some addresses to be <8k, +although they are not. + +e.g. for itdba = 100001fff +!(gpa & ~0x1fffU) -> 1 +!(gpa & ~0x1fffUL) -> 0 + +So we would report a SIE validity intercept although everything is fine. + +Fixes: 166ecb3 ("KVM: s390: vsie: support transactional execution") +Reported-by: Dan Carpenter +Reviewed-by: Christian Borntraeger +Reviewed-by: Janosch Frank +Reviewed-by: Cornelia Huck +Signed-off-by: David Hildenbrand +Signed-off-by: Janosch Frank +Cc: stable@vger.kernel.org # v4.8+ +Signed-off-by: Christian Borntraeger +Signed-off-by: Greg Kroah-Hartman + +--- + arch/s390/kvm/vsie.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/s390/kvm/vsie.c ++++ b/arch/s390/kvm/vsie.c +@@ -549,7 +549,7 @@ static int pin_blocks(struct kvm_vcpu *v + + gpa = scb_o->itdba & ~0xffUL; + if (gpa && (scb_s->ecb & 0x10U)) { +- if (!(gpa & ~0x1fffU)) { ++ if (!(gpa & ~0x1fffUL)) { + rc = set_validity_icpt(scb_s, 0x0080U); + goto unpin; + } diff --git a/queue-4.9/kvm-vmx-expose-ssbd-properly-to-guests.patch b/queue-4.9/kvm-vmx-expose-ssbd-properly-to-guests.patch new file mode 100644 index 00000000000..9e2dbec7243 --- /dev/null +++ b/queue-4.9/kvm-vmx-expose-ssbd-properly-to-guests.patch @@ -0,0 +1,42 @@ +From 0aa48468d00959c8a37cd3ac727284f4f7359151 Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Mon, 21 May 2018 17:54:49 -0400 +Subject: KVM/VMX: Expose SSBD properly to guests +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Konrad Rzeszutek Wilk + +commit 0aa48468d00959c8a37cd3ac727284f4f7359151 upstream. + +The X86_FEATURE_SSBD is an synthetic CPU feature - that is +it bit location has no relevance to the real CPUID 0x7.EBX[31] +bit position. For that we need the new CPU feature name. + +Fixes: 52817587e706 ("x86/cpufeatures: Disentangle SSBD enumeration") +Signed-off-by: Konrad Rzeszutek Wilk +Signed-off-by: Thomas Gleixner +Cc: kvm@vger.kernel.org +Cc: "Radim Krčmář" +Cc: stable@vger.kernel.org +Cc: "H. Peter Anvin" +Cc: Paolo Bonzini +Link: https://lkml.kernel.org/r/20180521215449.26423-2-konrad.wilk@oracle.com +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kvm/cpuid.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/x86/kvm/cpuid.c ++++ b/arch/x86/kvm/cpuid.c +@@ -382,7 +382,7 @@ static inline int __do_cpuid_ent(struct + + /* cpuid 7.0.edx*/ + const u32 kvm_cpuid_7_0_edx_x86_features = +- F(SPEC_CTRL) | F(SSBD) | F(ARCH_CAPABILITIES); ++ F(SPEC_CTRL) | F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES); + + /* all calls to cpuid_count() should be made on the same cpu */ + get_cpu(); diff --git a/queue-4.9/kvm-x86-ia32_arch_capabilities-is-always-supported.patch b/queue-4.9/kvm-x86-ia32_arch_capabilities-is-always-supported.patch new file mode 100644 index 00000000000..f27ed99b0af --- /dev/null +++ b/queue-4.9/kvm-x86-ia32_arch_capabilities-is-always-supported.patch @@ -0,0 +1,52 @@ +From 1eaafe91a0df4157521b6417b3dd8430bf5f52f0 Mon Sep 17 00:00:00 2001 +From: Jim Mattson +Date: Wed, 9 May 2018 14:29:35 -0700 +Subject: kvm: x86: IA32_ARCH_CAPABILITIES is always supported +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jim Mattson + +commit 1eaafe91a0df4157521b6417b3dd8430bf5f52f0 upstream. + +If there is a possibility that a VM may migrate to a Skylake host, +then the hypervisor should report IA32_ARCH_CAPABILITIES.RSBA[bit 2] +as being set (future work, of course). This implies that +CPUID.(EAX=7,ECX=0):EDX.ARCH_CAPABILITIES[bit 29] should be +set. Therefore, kvm should report this CPUID bit as being supported +whether or not the host supports it. Userspace is still free to clear +the bit if it chooses. + +For more information on RSBA, see Intel's white paper, "Retpoline: A +Branch Target Injection Mitigation" (Document Number 337131-001), +currently available at https://bugzilla.kernel.org/show_bug.cgi?id=199511. + +Since the IA32_ARCH_CAPABILITIES MSR is emulated in kvm, there is no +dependency on hardware support for this feature. + +Signed-off-by: Jim Mattson +Reviewed-by: Konrad Rzeszutek Wilk +Fixes: 28c1c9fabf48 ("KVM/VMX: Emulate MSR_IA32_ARCH_CAPABILITIES") +Cc: stable@vger.kernel.org +Signed-off-by: Radim Krčmář +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kvm/cpuid.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/arch/x86/kvm/cpuid.c ++++ b/arch/x86/kvm/cpuid.c +@@ -468,6 +468,11 @@ static inline int __do_cpuid_ent(struct + entry->ecx &= ~F(PKU); + entry->edx &= kvm_cpuid_7_0_edx_x86_features; + cpuid_mask(&entry->edx, CPUID_7_EDX); ++ /* ++ * We emulate ARCH_CAPABILITIES in software even ++ * if the host doesn't support it. ++ */ ++ entry->edx |= F(ARCH_CAPABILITIES); + } else { + entry->ebx = 0; + entry->ecx = 0; diff --git a/queue-4.9/kvm-x86-update-cpuid-properly-when-cr4.osxave-or-cr4.pke-is-changed.patch b/queue-4.9/kvm-x86-update-cpuid-properly-when-cr4.osxave-or-cr4.pke-is-changed.patch new file mode 100644 index 00000000000..6f26291f69d --- /dev/null +++ b/queue-4.9/kvm-x86-update-cpuid-properly-when-cr4.osxave-or-cr4.pke-is-changed.patch @@ -0,0 +1,60 @@ +From c4d2188206bafa177ea58e9a25b952baa0bf7712 Mon Sep 17 00:00:00 2001 +From: Wei Huang +Date: Tue, 1 May 2018 09:49:54 -0500 +Subject: KVM: x86: Update cpuid properly when CR4.OSXAVE or CR4.PKE is changed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Wei Huang + +commit c4d2188206bafa177ea58e9a25b952baa0bf7712 upstream. + +The CPUID bits of OSXSAVE (function=0x1) and OSPKE (func=0x7, leaf=0x0) +allows user apps to detect if OS has set CR4.OSXSAVE or CR4.PKE. KVM is +supposed to update these CPUID bits when CR4 is updated. Current KVM +code doesn't handle some special cases when updates come from emulator. +Here is one example: + + Step 1: guest boots + Step 2: guest OS enables XSAVE ==> CR4.OSXSAVE=1 and CPUID.OSXSAVE=1 + Step 3: guest hot reboot ==> QEMU reset CR4 to 0, but CPUID.OSXAVE==1 + Step 4: guest os checks CPUID.OSXAVE, detects 1, then executes xgetbv + +Step 4 above will cause an #UD and guest crash because guest OS hasn't +turned on OSXAVE yet. This patch solves the problem by comparing the the +old_cr4 with cr4. If the related bits have been changed, +kvm_update_cpuid() needs to be called. + +Signed-off-by: Wei Huang +Reviewed-by: Bandan Das +Cc: stable@vger.kernel.org +Signed-off-by: Radim Krčmář +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kvm/x86.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -7258,6 +7258,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct + { + struct msr_data apic_base_msr; + int mmu_reset_needed = 0; ++ int cpuid_update_needed = 0; + int pending_vec, max_bits, idx; + struct desc_ptr dt; + +@@ -7289,8 +7290,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct + vcpu->arch.cr0 = sregs->cr0; + + mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; ++ cpuid_update_needed |= ((kvm_read_cr4(vcpu) ^ sregs->cr4) & ++ (X86_CR4_OSXSAVE | X86_CR4_PKE)); + kvm_x86_ops->set_cr4(vcpu, sregs->cr4); +- if (sregs->cr4 & (X86_CR4_OSXSAVE | X86_CR4_PKE)) ++ if (cpuid_update_needed) + kvm_update_cpuid(vcpu); + + idx = srcu_read_lock(&vcpu->kvm->srcu); diff --git a/queue-4.9/series b/queue-4.9/series index 0659fd885d5..6be50a61a57 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -18,3 +18,7 @@ ipc-shm-fix-shmat-nil-address-after-round-down-when-remapping.patch kasan-fix-memory-hotplug-during-boot.patch kernel-sys.c-fix-potential-spectre-v1-issue.patch kernel-signal.c-avoid-undefined-behaviour-in-kill_something_info.patch +kvm-vmx-expose-ssbd-properly-to-guests.patch +kvm-s390-vsie-fix-8k-check-for-the-itdba.patch +kvm-x86-update-cpuid-properly-when-cr4.osxave-or-cr4.pke-is-changed.patch +kvm-x86-ia32_arch_capabilities-is-always-supported.patch