From nobody Thu Apr 2 04:55:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 169C0364936; Tue, 3 Mar 2026 00:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772498079; cv=none; b=RS3kVfqjuuNo2nvl71Ol01j5ZZ1hoOSFWsTJnr38kA2JnOmazjROocrz9Fwn4YkozMR1MKrd6LgJh8qDdQJHhbAOW2I0/Qv5cNYXn1LFV89RDGOXVxBaJmpWMgbFEbA/yz+nNCWxzswUjqp78wN0TGuk1sofLT12DZkIb8X+R0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772498079; c=relaxed/simple; bh=4qw1TlrWpsmd//UxHFjs6jBS8JsBWnD5WW9FNAzJsgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C5FyhVsj2aCLIy3pjExaM+Wg5LjikMW7r3g67CkfG4TzkMjJvlhk1N3e0yXAkoW2GQtRyp5zd01HBjpgVJZaH7++uREPQ5fov30No44aWdEVKsK/d2KEkkbvF+W2uGHEcPzmalW7SPpDZu3bDqnGCRvf0ia2v43ZE6EnOG7Dsfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EZ3eUU/M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EZ3eUU/M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1714C2BC9E; Tue, 3 Mar 2026 00:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772498078; bh=4qw1TlrWpsmd//UxHFjs6jBS8JsBWnD5WW9FNAzJsgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZ3eUU/M+8DJ1gBgZryyGM3bxUWed/MEbQHBL7jF3FZdHDHTYLv1GanJ+rDX7uxtW 33Vvap3oGcr3hvPq6REwrQkOOIB08CfFez/ym+86TtiZE6Z12FHL7NRqy9Q/eEAC6Y +rJ+qFV0dbKyd48e0VGTItDAZkAkA9yoBjKUmFrf+MsW4tXFwLVxWGc7Q7FYmFhtdV SDROuRAHRo5u2Ubk3epiMjdHRELlqP1EfHzPs+z95upNide8zqO9VYxudg1mmH9Pce w/a/TvHgrFa7hVg32aiuAGY42Ra9BnLmfCLy6Fme4PCqmd3ukUhnAnXgLLHkyCwwJC /s5TyiedC0VBg== From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [PATCH v7 18/26] KVM: SVM: Rename vmcb->nested_ctl to vmcb->misc_ctl Date: Tue, 3 Mar 2026 00:34:12 +0000 Message-ID: <20260303003421.2185681-19-yosry@kernel.org> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog In-Reply-To: <20260303003421.2185681-1-yosry@kernel.org> References: <20260303003421.2185681-1-yosry@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- arch/x86/include/asm/svm.h | 8 ++++---- arch/x86/kvm/svm/nested.c | 14 +++++++------- arch/x86/kvm/svm/sev.c | 4 ++-- arch/x86/kvm/svm/svm.c | 4 ++-- arch/x86/kvm/svm/svm.h | 4 ++-- tools/testing/selftests/kvm/include/x86/svm.h | 6 +++--- tools/testing/selftests/kvm/lib/x86/svm.c | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index edde36097ddc3..983db6575141d 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -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) =20 -#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) =20 =20 #define SVM_TSC_RATIO_RSVD 0xffffff0000000000ULL diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 15f483fac28a0..2f84fca3df85a 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -396,7 +396,7 @@ static bool nested_vmcb_check_controls(struct kvm_vcpu = *vcpu, if (CC(control->asid =3D=3D 0)) return false; =20 - if (control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) { + if (control->misc_ctl & SVM_MISC_ENABLE_NP) { if (CC(!kvm_vcpu_is_legal_gpa(vcpu, control->nested_cr3))) return false; } @@ -488,10 +488,10 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_v= cpu *vcpu, nested_svm_sanitize_intercept(vcpu, to, SKINIT); nested_svm_sanitize_intercept(vcpu, to, RDPRU); =20 - /* Always clear SVM_NESTED_CTL_NP_ENABLE if the guest cannot use NPTs */ - to->nested_ctl =3D from->nested_ctl; + /* Always clear SVM_MISC_ENABLE_NP if the guest cannot use NPTs */ + to->misc_ctl =3D from->misc_ctl; if (!guest_cpu_cap_has(vcpu, X86_FEATURE_NPT)) - to->nested_ctl &=3D ~SVM_NESTED_CTL_NP_ENABLE; + to->misc_ctl &=3D ~SVM_MISC_ENABLE_NP; =20 to->iopm_base_pa =3D from->iopm_base_pa; to->msrpm_base_pa =3D from->msrpm_base_pa; @@ -835,7 +835,7 @@ static void nested_vmcb02_prepare_control(struct vcpu_s= vm *svm, } =20 /* Copied from vmcb01. msrpm_base can be overwritten later. */ - vmcb02->control.nested_ctl =3D vmcb01->control.nested_ctl; + vmcb02->control.misc_ctl =3D vmcb01->control.misc_ctl; vmcb02->control.iopm_base_pa =3D vmcb01->control.iopm_base_pa; vmcb02->control.msrpm_base_pa =3D vmcb01->control.msrpm_base_pa; vmcb_mark_dirty(vmcb02, VMCB_PERM_MAP); @@ -995,7 +995,7 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmc= b12_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); @@ -1785,7 +1785,7 @@ static void nested_copy_vmcb_cache_to_control(struct = vmcb_control_area *dst, dst->exit_info_2 =3D from->exit_info_2; dst->exit_int_info =3D from->exit_int_info; dst->exit_int_info_err =3D from->exit_int_info_err; - dst->nested_ctl =3D from->nested_ctl; + dst->misc_ctl =3D from->misc_ctl; dst->event_inj =3D from->event_inj; dst->event_inj_err =3D from->event_inj_err; dst->next_rip =3D from->next_rip; diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index ea515cf411686..0ed9cfed1cbcc 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4599,7 +4599,7 @@ static void sev_es_init_vmcb(struct vcpu_svm *svm, bo= ol init_event) struct kvm_sev_info *sev =3D to_kvm_sev_info(svm->vcpu.kvm); struct vmcb *vmcb =3D svm->vmcb01.ptr; =20 - svm->vmcb->control.nested_ctl |=3D SVM_NESTED_CTL_SEV_ES_ENABLE; + svm->vmcb->control.misc_ctl |=3D SVM_MISC_ENABLE_SEV_ES; =20 /* * 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_ev= ent) { struct kvm_vcpu *vcpu =3D &svm->vcpu; =20 - svm->vmcb->control.nested_ctl |=3D SVM_NESTED_CTL_SEV_ENABLE; + svm->vmcb->control.misc_ctl |=3D SVM_MISC_ENABLE_SEV; clr_exception_intercept(svm, UD_VECTOR); =20 /* diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 1b31b033d79b0..7bc8b72fe5ad8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1152,7 +1152,7 @@ static void init_vmcb(struct kvm_vcpu *vcpu, bool ini= t_event) =20 if (npt_enabled) { /* Setup VMCB for Nested Paging */ - control->nested_ctl |=3D SVM_NESTED_CTL_NP_ENABLE; + control->misc_ctl |=3D SVM_MISC_ENABLE_NP; svm_clr_intercept(svm, INTERCEPT_INVLPG); clr_exception_intercept(svm, PF_VECTOR); svm_clr_intercept(svm, INTERCEPT_CR3_READ); @@ -3362,7 +3362,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); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 0a5d5a4453b7e..f66e5c8565aad 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -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; @@ -579,7 +579,7 @@ static inline bool gif_set(struct vcpu_svm *svm) =20 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; } =20 static inline bool nested_vnmi_enabled(struct vcpu_svm *svm) diff --git a/tools/testing/selftests/kvm/include/x86/svm.h b/tools/testing/= selftests/kvm/include/x86/svm.h index 10b30b38bb3fd..d81d8a9f5bfb6 100644 --- a/tools/testing/selftests/kvm/include/x86/svm.h +++ b/tools/testing/selftests/kvm/include/x86/svm.h @@ -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 =20 -#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) =20 struct __attribute__ ((__packed__)) vmcb_seg { u16 selector; diff --git a/tools/testing/selftests/kvm/lib/x86/svm.c b/tools/testing/self= tests/kvm/lib/x86/svm.c index 2e5c480c9afd4..eb20b00112c76 100644 --- a/tools/testing/selftests/kvm/lib/x86/svm.c +++ b/tools/testing/selftests/kvm/lib/x86/svm.c @@ -126,7 +126,7 @@ void generic_svm_setup(struct svm_test_data *svm, void = *guest_rip, void *guest_r guest_regs.rdi =3D (u64)svm; =20 if (svm->ncr3_gpa) { - ctrl->nested_ctl |=3D SVM_NESTED_CTL_NP_ENABLE; + ctrl->misc_ctl |=3D SVM_MISC_ENABLE_NP; ctrl->nested_cr3 =3D svm->ncr3_gpa; } } --=20 2.53.0.473.g4a7958ca14-goog