Skip to content

Commit 190ecf6

Browse files
sean-jcjfvogel
authored andcommitted
KVM: x86: Revert kvm_x86_ops.mem_enc_ioctl() back to an OPTIONAL hook
Restore KVM's handling of a NULL kvm_x86_ops.mem_enc_ioctl, as the hook is NULL on SVM when CONFIG_KVM_AMD_SEV=n, and TDX will soon follow suit. ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at arch/x86/include/asm/kvm-x86-ops.h:130 kvm_x86_vendor_init+0x178b/0x18e0 Modules linked in: CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.15.0-rc2-dc1aead1a985-sink-vm #2 NONE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:kvm_x86_vendor_init+0x178b/0x18e0 Call Trace: <TASK> svm_init+0x2e/0x60 do_one_initcall+0x56/0x290 kernel_init_freeable+0x192/0x1e0 kernel_init+0x16/0x130 ret_from_fork+0x30/0x50 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end trace 0000000000000000 ]--- Opportunistically drop the superfluous curly braces. Link: https://lore.kernel.org/all/20250318-vverma7-cleanup_x86_ops-v2-4-701e82d6b779@intel.com Fixes: b2aaf38 ("KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctl") Link: https://lore.kernel.org/r/20250502203421.865686-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> (cherry picked from commit f2d7993) Orabug: 38359602 Signed-off-by: Ross Philipson <ross.philipson@oracle.com> Reviewed-by: Liam Merwick <liam.merwick@oracle.com> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
1 parent 59bbcb6 commit 190ecf6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

arch/x86/include/asm/kvm-x86-ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ KVM_X86_OP(leave_smm)
126126
KVM_X86_OP(enable_smi_window)
127127
#endif
128128
KVM_X86_OP_OPTIONAL(dev_get_attr)
129-
KVM_X86_OP(mem_enc_ioctl)
129+
KVM_X86_OP_OPTIONAL(mem_enc_ioctl)
130130
KVM_X86_OP_OPTIONAL(vcpu_mem_enc_ioctl)
131131
KVM_X86_OP_OPTIONAL(mem_enc_register_region)
132132
KVM_X86_OP_OPTIONAL(mem_enc_unregister_region)

arch/x86/kvm/x86.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7321,10 +7321,13 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
73217321
r = READ_ONCE(kvm->arch.default_tsc_khz);
73227322
goto out;
73237323
}
7324-
case KVM_MEMORY_ENCRYPT_OP: {
7324+
case KVM_MEMORY_ENCRYPT_OP:
7325+
r = -ENOTTY;
7326+
if (!kvm_x86_ops.mem_enc_ioctl)
7327+
goto out;
7328+
73257329
r = kvm_x86_call(mem_enc_ioctl)(kvm, argp);
73267330
break;
7327-
}
73287331
case KVM_MEMORY_ENCRYPT_REG_REGION: {
73297332
struct kvm_enc_region region;
73307333

0 commit comments

Comments
 (0)