lkml.org 
[lkml]   [2017]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Part2 PATCH v5 15/31] KVM: SVM: Reserve ASID range for SEV guest
Date
A SEV-enabled guest must use ASIDs from the defined subset, while non-SEV
guests can use the remaining ASID range. The range of allowed SEV guest
ASIDs is [1 - CPUID_8000_001F[ECX][31:0]].

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
---
arch/x86/kvm/svm.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index be2e98c01b22..3244b8f88010 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -323,6 +323,8 @@ enum {

#define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL

+static unsigned int max_sev_asid;
+
static inline void mark_all_dirty(struct vmcb *vmcb)
{
vmcb->control.clean = 0;
@@ -787,7 +789,7 @@ static int svm_hardware_enable(void)
sd->asid_generation = 1;
sd->max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1;
sd->next_asid = sd->max_asid + 1;
- sd->min_asid = 1;
+ sd->min_asid = max_sev_asid + 1;

gdt = get_current_gdt_rw();
sd->tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS);
@@ -1054,6 +1056,15 @@ static int avic_ga_log_notifier(u32 ga_tag)
return 0;
}

+/*
+ * Get maximum number of encrypted guest supported: Fn8001_001F[ECX].
+ * [31:0]: Number of supported guest
+ */
+static __init void sev_hardware_setup(void)
+{
+ max_sev_asid = cpuid_ecx(0x8000001F);
+}
+
static __init int svm_hardware_setup(void)
{
int cpu;
@@ -1084,6 +1095,16 @@ static __init int svm_hardware_setup(void)
kvm_tsc_scaling_ratio_frac_bits = 32;
}

+ if (sev) {
+ if (!boot_cpu_has(X86_FEATURE_SEV) ||
+ !IS_ENABLED(CONFIG_KVM_AMD_SEV)) {
+ sev = false;
+ } else {
+ sev_hardware_setup();
+ pr_info("SEV supported\n");
+ }
+ }
+
if (nested) {
printk(KERN_INFO "kvm: Nested Virtualization enabled\n");
kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
--
2.9.5
\
 
 \ /
  Last update: 2017-10-04 15:15    [W:0.419 / U:8.308 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site