]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Rename vmcb->nested_ctl to vmcb->misc_ctl
authorSean Christopherson <seanjc@google.com>
Tue, 3 Mar 2026 16:58:06 +0000 (08:58 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 5 Mar 2026 00:09:03 +0000 (16:09 -0800)
The 'nested_ctl' field is misnamed. Although the first bit is for nested
paging, the other defined bits are for SEV/SEV-ES. Other bits in the
same field according to the APM (but not defined by KVM) include "Guest
Mode Execution Trap", "Enable INVLPGB/TLBSYNC", and other control bits
unrelated to 'nested'.

There is nothing common among these bits, so just name the field
misc_ctl. Also rename the flags accordingly.

Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260303003421.2185681-19-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/svm.h
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h
tools/testing/selftests/kvm/include/x86/svm.h
tools/testing/selftests/kvm/lib/x86/svm.c

index edde36097ddc31a32fe1e2491efe46c000970c5e..983db6575141df31491aade7f8ba2870f214f6b4 100644 (file)
@@ -142,7 +142,7 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
        u64 exit_info_2;
        u32 exit_int_info;
        u32 exit_int_info_err;
-       u64 nested_ctl;
+       u64 misc_ctl;
        u64 avic_vapic_bar;
        u64 ghcb_gpa;
        u32 event_inj;
@@ -239,9 +239,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
 #define SVM_IOIO_SIZE_MASK (7 << SVM_IOIO_SIZE_SHIFT)
 #define SVM_IOIO_ASIZE_MASK (7 << SVM_IOIO_ASIZE_SHIFT)
 
-#define SVM_NESTED_CTL_NP_ENABLE       BIT(0)
-#define SVM_NESTED_CTL_SEV_ENABLE      BIT(1)
-#define SVM_NESTED_CTL_SEV_ES_ENABLE   BIT(2)
+#define SVM_MISC_ENABLE_NP             BIT(0)
+#define SVM_MISC_ENABLE_SEV            BIT(1)
+#define SVM_MISC_ENABLE_SEV_ES BIT(2)
 
 
 #define SVM_TSC_RATIO_RSVD     0xffffff0000000000ULL
index 146faa7584a13ece84d5e1139bbaf29569b845e7..789f38c55541a53ae39ddb112323f553f7d59040 100644 (file)
@@ -386,7 +386,7 @@ static bool nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
        if (CC(control->asid == 0))
                return false;
 
-       if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) &&
+       if (CC((control->misc_ctl & SVM_MISC_ENABLE_NP) &&
               !kvm_vcpu_is_legal_gpa(vcpu, control->nested_cr3)))
                return false;
 
@@ -477,10 +477,10 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
        nested_svm_sanitize_intercept(vcpu, to, SKINIT);
        nested_svm_sanitize_intercept(vcpu, to, RDPRU);
 
-       /* Always clear SVM_NESTED_CTL_NP_ENABLE if the guest cannot use NPTs */
-       to->nested_ctl          = from->nested_ctl;
+       /* Always clear SVM_MISC_ENABLE_NP if the guest cannot use NPTs */
+       to->misc_ctl = from->misc_ctl;
        if (!guest_cpu_cap_has(vcpu, X86_FEATURE_NPT))
-               to->nested_ctl &= ~SVM_NESTED_CTL_NP_ENABLE;
+               to->misc_ctl &= ~SVM_MISC_ENABLE_NP;
 
        to->iopm_base_pa        = from->iopm_base_pa;
        to->msrpm_base_pa       = from->msrpm_base_pa;
@@ -823,7 +823,7 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm)
        }
 
        /* Copied from vmcb01.  msrpm_base can be overwritten later.  */
-       vmcb02->control.nested_ctl = vmcb01->control.nested_ctl;
+       vmcb02->control.misc_ctl = vmcb01->control.misc_ctl;
        vmcb02->control.iopm_base_pa = vmcb01->control.iopm_base_pa;
        vmcb02->control.msrpm_base_pa = vmcb01->control.msrpm_base_pa;
        vmcb_mark_dirty(vmcb02, VMCB_PERM_MAP);
@@ -982,7 +982,7 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa,
                                 vmcb12->save.rip,
                                 vmcb12->control.int_ctl,
                                 vmcb12->control.event_inj,
-                                vmcb12->control.nested_ctl,
+                                vmcb12->control.misc_ctl,
                                 vmcb12->control.nested_cr3,
                                 vmcb12->save.cr3,
                                 KVM_ISA_SVM);
@@ -1770,7 +1770,7 @@ static void nested_copy_vmcb_cache_to_control(struct vmcb_control_area *dst,
        dst->exit_info_2          = from->exit_info_2;
        dst->exit_int_info        = from->exit_int_info;
        dst->exit_int_info_err    = from->exit_int_info_err;
-       dst->nested_ctl           = from->nested_ctl;
+       dst->misc_ctl             = from->misc_ctl;
        dst->event_inj            = from->event_inj;
        dst->event_inj_err        = from->event_inj_err;
        dst->next_rip             = from->next_rip;
index fea4a65758ad803cf8c683311562716bc8cb4e8d..a0f1ce2b9a7bc620f222cfedddcd1cf1de2ae400 100644 (file)
@@ -4599,7 +4599,7 @@ static void sev_es_init_vmcb(struct vcpu_svm *svm, bool init_event)
        struct kvm_sev_info *sev = to_kvm_sev_info(svm->vcpu.kvm);
        struct vmcb *vmcb = svm->vmcb01.ptr;
 
-       svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ES_ENABLE;
+       svm->vmcb->control.misc_ctl |= SVM_MISC_ENABLE_SEV_ES;
 
        /*
         * An SEV-ES guest requires a VMSA area that is a separate from the
@@ -4670,7 +4670,7 @@ void sev_init_vmcb(struct vcpu_svm *svm, bool init_event)
 {
        struct kvm_vcpu *vcpu = &svm->vcpu;
 
-       svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ENABLE;
+       svm->vmcb->control.misc_ctl |= SVM_MISC_ENABLE_SEV;
        clr_exception_intercept(svm, UD_VECTOR);
 
        /*
index 62501c12011248c802923ae4e901e811c19cd0fa..c626cbacaf4aa56d7d3cb95cba8126e840cdadcd 100644 (file)
@@ -1186,7 +1186,7 @@ static void init_vmcb(struct kvm_vcpu *vcpu, bool init_event)
 
        if (npt_enabled) {
                /* Setup VMCB for Nested Paging */
-               control->nested_ctl |= SVM_NESTED_CTL_NP_ENABLE;
+               control->misc_ctl |= SVM_MISC_ENABLE_NP;
                svm_clr_intercept(svm, INTERCEPT_INVLPG);
                clr_exception_intercept(svm, PF_VECTOR);
                svm_clr_intercept(svm, INTERCEPT_CR3_READ);
@@ -3417,7 +3417,7 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
        pr_err("%-20s%016llx\n", "exit_info2:", control->exit_info_2);
        pr_err("%-20s%08x\n", "exit_int_info:", control->exit_int_info);
        pr_err("%-20s%08x\n", "exit_int_info_err:", control->exit_int_info_err);
-       pr_err("%-20s%lld\n", "nested_ctl:", control->nested_ctl);
+       pr_err("%-20s%lld\n", "misc_ctl:", control->misc_ctl);
        pr_err("%-20s%016llx\n", "nested_cr3:", control->nested_cr3);
        pr_err("%-20s%016llx\n", "avic_vapic_bar:", control->avic_vapic_bar);
        pr_err("%-20s%016llx\n", "ghcb:", control->ghcb_gpa);
index 6c3b3fae91ec14920a55ec44207cb9c220ead90c..ab7eebd3fcff75701571a776b1024694e9c11d58 100644 (file)
@@ -167,7 +167,7 @@ struct vmcb_ctrl_area_cached {
        u64 exit_info_2;
        u32 exit_int_info;
        u32 exit_int_info_err;
-       u64 nested_ctl;
+       u64 misc_ctl;
        u32 event_inj;
        u32 event_inj_err;
        u64 next_rip;
@@ -593,7 +593,7 @@ static inline bool gif_set(struct vcpu_svm *svm)
 
 static inline bool nested_npt_enabled(struct vcpu_svm *svm)
 {
-       return svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE;
+       return svm->nested.ctl.misc_ctl & SVM_MISC_ENABLE_NP;
 }
 
 static inline bool nested_vnmi_enabled(struct vcpu_svm *svm)
index 10b30b38bb3fdecc60c58aed7ae4fe05ea828f95..d81d8a9f5bfb6e8ea575b92564663e15271a989b 100644 (file)
@@ -97,7 +97,7 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
        u64 exit_info_2;
        u32 exit_int_info;
        u32 exit_int_info_err;
-       u64 nested_ctl;
+       u64 misc_ctl;
        u64 avic_vapic_bar;
        u8 reserved_4[8];
        u32 event_inj;
@@ -175,8 +175,8 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
 #define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL
 #define SVM_VM_CR_SVM_DIS_MASK  0x0010ULL
 
-#define SVM_NESTED_CTL_NP_ENABLE       BIT(0)
-#define SVM_NESTED_CTL_SEV_ENABLE      BIT(1)
+#define SVM_MISC_ENABLE_NP             BIT(0)
+#define SVM_MISC_ENABLE_SEV            BIT(1)
 
 struct __attribute__ ((__packed__)) vmcb_seg {
        u16 selector;
index 2e5c480c9afd481077c0f12db42e577f9fc54736..eb20b00112c76909098136462f4ea624b3d81bcb 100644 (file)
@@ -126,7 +126,7 @@ void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_r
        guest_regs.rdi = (u64)svm;
 
        if (svm->ncr3_gpa) {
-               ctrl->nested_ctl |= SVM_NESTED_CTL_NP_ENABLE;
+               ctrl->misc_ctl |= SVM_MISC_ENABLE_NP;
                ctrl->nested_cr3 = svm->ncr3_gpa;
        }
 }