]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SVM: Refactor SVM instruction handling on #GP intercept
authorYosry Ahmed <yosry@kernel.org>
Mon, 16 Mar 2026 20:27:25 +0000 (20:27 +0000)
committerSean Christopherson <seanjc@google.com>
Fri, 3 Apr 2026 23:08:01 +0000 (16:08 -0700)
commit27f70eaa8661c031f6c5efa4d72c7c4544cc41fc
treed6aef390ca010986188d579a0cc630c99d81e13d
parentc85aaff26d55920d783adac431a59ec738a35aef
KVM: SVM: Refactor SVM instruction handling on #GP intercept

Instead of returning an opcode from svm_instr_opcode() and then passing
it to emulate_svm_instr(), which uses it to find the corresponding exit
code and intercept handler, return the exit code directly from
svm_instr_opcode(), and rename it to svm_get_decoded_instr_exit_code().

emulate_svm_instr() boils down to synthesizing a #VMEXIT or calling the
intercept handler, so open-code it in gp_interception(), and use
svm_invoke_exit_handler() to call the intercept handler based on
the exit code. This allows for dropping the SVM_INSTR_* enum, and the
const array mapping its values to exit codes and intercept handlers.

In gp_intercept(), handle SVM instructions and first with an early return,
and invert is_guest_mode() checks, un-indenting the rest of the code.

No functional change intended.

Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260316202732.3164936-3-yosry@kernel.org
[sean: add BUILD_BUG_ON(), tweak formatting/naming]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c