* FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree
@ 2020-02-09 12:31 gregkh
2020-02-09 19:58 ` Sasha Levin
2020-02-09 20:05 ` Sasha Levin
0 siblings, 2 replies; 3+ messages in thread
From: gregkh @ 2020-02-09 12:31 UTC (permalink / raw)
To: pbonzini, thomas.lendacky; +Cc: stable
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Wed, 4 Dec 2019 15:50:27 +0100
Subject: [PATCH] KVM: x86: use CPUID to locate host page table reserved bits
The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually
true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if
available, it is simplest and works even if memory is not encrypted.
Cc: stable@vger.kernel.org
Reported-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 6f92b40d798c..1e4ee4f8de5f 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -538,16 +538,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes);
static u8 kvm_get_shadow_phys_bits(void)
{
/*
- * boot_cpu_data.x86_phys_bits is reduced when MKTME is detected
- * in CPU detection code, but MKTME treats those reduced bits as
- * 'keyID' thus they are not reserved bits. Therefore for MKTME
- * we should still return physical address bits reported by CPUID.
+ * boot_cpu_data.x86_phys_bits is reduced when MKTME or SME are detected
+ * in CPU detection code, but the processor treats those reduced bits as
+ * 'keyID' thus they are not reserved bits. Therefore KVM needs to look at
+ * the physical address bits reported by CPUID.
*/
- if (!boot_cpu_has(X86_FEATURE_TME) ||
- WARN_ON_ONCE(boot_cpu_data.extended_cpuid_level < 0x80000008))
- return boot_cpu_data.x86_phys_bits;
+ if (likely(boot_cpu_data.extended_cpuid_level >= 0x80000008))
+ return cpuid_eax(0x80000008) & 0xff;
- return cpuid_eax(0x80000008) & 0xff;
+ /*
+ * Quite weird to have VMX or SVM but not MAXPHYADDR; probably a VM with
+ * custom CPUID. Proceed with whatever the kernel found since these features
+ * aren't virtualizable (SME/SEV also require CPUIDs higher than 0x80000008).
+ */
+ return boot_cpu_data.x86_phys_bits;
}
static void kvm_mmu_reset_all_pte_masks(void)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree
2020-02-09 12:31 FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree gregkh
@ 2020-02-09 19:58 ` Sasha Levin
2020-02-09 20:05 ` Sasha Levin
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-02-09 19:58 UTC (permalink / raw)
To: gregkh; +Cc: pbonzini, thomas.lendacky, stable
On Sun, Feb 09, 2020 at 01:31:10PM +0100, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 5.4-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 Mon Sep 17 00:00:00 2001
>From: Paolo Bonzini <pbonzini@redhat.com>
>Date: Wed, 4 Dec 2019 15:50:27 +0100
>Subject: [PATCH] KVM: x86: use CPUID to locate host page table reserved bits
>
>The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually
>true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if
>available, it is simplest and works even if memory is not encrypted.
>
>Cc: stable@vger.kernel.org
>Reported-by: Tom Lendacky <thomas.lendacky@amd.com>
>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
For 5.4 it was just due to a file rename, I've fixed it and queued it
up. 4.19 still needs a backport.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree
2020-02-09 12:31 FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree gregkh
2020-02-09 19:58 ` Sasha Levin
@ 2020-02-09 20:05 ` Sasha Levin
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-02-09 20:05 UTC (permalink / raw)
To: gregkh; +Cc: pbonzini, thomas.lendacky, stable
On Sun, Feb 09, 2020 at 01:31:10PM +0100, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 5.4-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 Mon Sep 17 00:00:00 2001
>From: Paolo Bonzini <pbonzini@redhat.com>
>Date: Wed, 4 Dec 2019 15:50:27 +0100
>Subject: [PATCH] KVM: x86: use CPUID to locate host page table reserved bits
>
>The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually
>true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if
>available, it is simplest and works even if memory is not encrypted.
>
>Cc: stable@vger.kernel.org
>Reported-by: Tom Lendacky <thomas.lendacky@amd.com>
>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
I've fixed it up and queued for 5.4 and 4.19.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-09 20:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-09 12:31 FAILED: patch "[PATCH] KVM: x86: use CPUID to locate host page table reserved bits" failed to apply to 5.4-stable tree gregkh
2020-02-09 19:58 ` Sasha Levin
2020-02-09 20:05 ` Sasha Levin
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).