lkml.org 
[lkml]   [2022]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] KVM: x86: Return emulator error if RDMSR/WRMSR emulation failed
Date
The return value of emulator_{get|set}_mst_with_filter()
is confused, since msr access error and emulator error
are mixed. Although, KVM_MSR_RET_* doesn't conflict with
X86EMUL_IO_NEEDED at present, it is better to convert
msr access error to emulator error if error value is
needed.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
arch/x86/kvm/x86.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5366f884e9a7..8df89b9c212f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7908,11 +7908,12 @@ static int emulator_get_msr_with_filter(struct x86_emulate_ctxt *ctxt,
int r;

r = kvm_get_msr_with_filter(vcpu, msr_index, pdata);
-
- if (r && kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_RDMSR, 0,
- complete_emulated_rdmsr, r)) {
- /* Bounce to user space */
- return X86EMUL_IO_NEEDED;
+ if (r) {
+ if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_RDMSR, 0,
+ complete_emulated_rdmsr, r))
+ r = X86EMUL_IO_NEEDED;
+ else
+ r = X86EMUL_UNHANDLEABLE;
}

return r;
@@ -7925,11 +7926,12 @@ static int emulator_set_msr_with_filter(struct x86_emulate_ctxt *ctxt,
int r;

r = kvm_set_msr_with_filter(vcpu, msr_index, data);
-
- if (r && kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_WRMSR, data,
- complete_emulated_msr_access, r)) {
- /* Bounce to user space */
- return X86EMUL_IO_NEEDED;
+ if (r > 0) {
+ if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_WRMSR, data,
+ complete_emulated_msr_access, r))
+ r = X86EMUL_IO_NEEDED;
+ else
+ r = X86EMUL_UNHANDLEABLE;
}

return r;
--
2.31.1
\
 
 \ /
  Last update: 2022-07-28 10:25    [W:0.089 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site