Skip to content

Commit 24975ce

Browse files
committed
Merge tag 'kvm-x86-svm-6.5' of https://github.com/kvm-x86/linux into HEAD
KVM SVM changes for 6.5: - Drop manual TR/TSS load after VM-Exit now that KVM uses VMLOAD for host state - Fix a not-yet-problematic missing call to trace_kvm_exit() for VM-Exits that are handled in the fastpath - Print more descriptive information about the status of SEV and SEV-ES during module load - Assert that misc_cg_set_capacity() doesn't fail to avoid should-be-impossible memory leaks
2 parents bb05b0e + 106ed2c commit 24975ce

3 files changed

Lines changed: 13 additions & 35 deletions

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,10 +2216,7 @@ void __init sev_hardware_setup(void)
22162216
}
22172217

22182218
sev_asid_count = max_sev_asid - min_sev_asid + 1;
2219-
if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))
2220-
goto out;
2221-
2222-
pr_info("SEV supported: %u ASIDs\n", sev_asid_count);
2219+
WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count));
22232220
sev_supported = true;
22242221

22252222
/* SEV-ES support requested? */
@@ -2244,13 +2241,19 @@ void __init sev_hardware_setup(void)
22442241
goto out;
22452242

22462243
sev_es_asid_count = min_sev_asid - 1;
2247-
if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
2248-
goto out;
2249-
2250-
pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count);
2244+
WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count));
22512245
sev_es_supported = true;
22522246

22532247
out:
2248+
if (boot_cpu_has(X86_FEATURE_SEV))
2249+
pr_info("SEV %s (ASIDs %u - %u)\n",
2250+
sev_supported ? "enabled" : "disabled",
2251+
min_sev_asid, max_sev_asid);
2252+
if (boot_cpu_has(X86_FEATURE_SEV_ES))
2253+
pr_info("SEV-ES %s (ASIDs %u - %u)\n",
2254+
sev_es_supported ? "enabled" : "disabled",
2255+
min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
2256+
22542257
sev_enabled = sev_supported;
22552258
sev_es_enabled = sev_es_supported;
22562259
#endif

arch/x86/kvm/svm/svm.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,6 @@ static u8 rsm_ins_bytes[] = "\x0f\xaa";
244244

245245
static unsigned long iopm_base;
246246

247-
struct kvm_ldttss_desc {
248-
u16 limit0;
249-
u16 base0;
250-
unsigned base1:8, type:5, dpl:2, p:1;
251-
unsigned limit1:4, zero0:3, g:1, base2:8;
252-
u32 base3;
253-
u32 zero1;
254-
} __attribute__((packed));
255-
256247
DEFINE_PER_CPU(struct svm_cpu_data, svm_data);
257248

258249
/*
@@ -588,7 +579,6 @@ static int svm_hardware_enable(void)
588579

589580
struct svm_cpu_data *sd;
590581
uint64_t efer;
591-
struct desc_struct *gdt;
592582
int me = raw_smp_processor_id();
593583

594584
rdmsrl(MSR_EFER, efer);
@@ -601,9 +591,6 @@ static int svm_hardware_enable(void)
601591
sd->next_asid = sd->max_asid + 1;
602592
sd->min_asid = max_sev_asid + 1;
603593

604-
gdt = get_current_gdt_rw();
605-
sd->tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS);
606-
607594
wrmsrl(MSR_EFER, efer | EFER_SVME);
608595

609596
wrmsrl(MSR_VM_HSAVE_PA, sd->save_area_pa);
@@ -3419,8 +3406,6 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
34193406
struct kvm_run *kvm_run = vcpu->run;
34203407
u32 exit_code = svm->vmcb->control.exit_code;
34213408

3422-
trace_kvm_exit(vcpu, KVM_ISA_SVM);
3423-
34243409
/* SEV-ES guests must use the CR write traps to track CR registers. */
34253410
if (!sev_es_guest(vcpu->kvm)) {
34263411
if (!svm_is_intercept(svm, INTERCEPT_CR0_WRITE))
@@ -3458,14 +3443,6 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
34583443
return svm_invoke_exit_handler(vcpu, exit_code);
34593444
}
34603445

3461-
static void reload_tss(struct kvm_vcpu *vcpu)
3462-
{
3463-
struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu);
3464-
3465-
sd->tss_desc->type = 9; /* available 32/64-bit TSS */
3466-
load_TR_desc();
3467-
}
3468-
34693446
static void pre_svm_run(struct kvm_vcpu *vcpu)
34703447
{
34713448
struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, vcpu->cpu);
@@ -4100,9 +4077,6 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
41004077

41014078
svm_vcpu_enter_exit(vcpu, spec_ctrl_intercepted);
41024079

4103-
if (!sev_es_guest(vcpu->kvm))
4104-
reload_tss(vcpu);
4105-
41064080
if (!static_cpu_has(X86_FEATURE_V_SPEC_CTRL))
41074081
x86_spec_ctrl_restore_host(svm->virt_spec_ctrl);
41084082

@@ -4157,6 +4131,8 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
41574131
SVM_EXIT_EXCP_BASE + MC_VECTOR))
41584132
svm_handle_mce(vcpu);
41594133

4134+
trace_kvm_exit(vcpu, KVM_ISA_SVM);
4135+
41604136
svm_complete_interrupts(vcpu);
41614137

41624138
if (is_guest_mode(vcpu))

arch/x86/kvm/svm/svm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ struct svm_cpu_data {
303303
u32 max_asid;
304304
u32 next_asid;
305305
u32 min_asid;
306-
struct kvm_ldttss_desc *tss_desc;
307306

308307
struct page *save_area;
309308
unsigned long save_area_pa;

0 commit comments

Comments
 (0)