[PATCH v2 1/6] KVM/x86: Change comment before KVM_MSR_RET_* defines
From: Juergen Gross
Date: Thu May 28 2026 - 07:43:38 EST
For MSR emulation return values only 2 special cases have defines,
while the most used values 0 and 1 don't.
Reason seems to be the maze of function calls of MSR emulation
intertwined with the KVM guest exit handlers, which are using the
values 0 and 1 for other purposes. This even led to the comment above
the already existing defines, warning to use the values 0 and 1 (and
negative errno values) in the MSR emulation at all.
Fact is that MSR emulation and exit handlers are in fact rather well
distinct, with only very few exceptions which are handled in a sane
way. Negative errno values and 0 are fine to be used, while the value
"1" is just used for unspecific error cases.
Drop the warning comment part, as it is just plainly wrong.
Replace it with a statement that it is fine to use negative errno
values, 0, and the special MSR emulation return values defined.
Don't mention the value "1", as current cases where MSR emulation is
returning "1" should be modified to return a negative errno value
instead.
No change of functionality intended.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
V2:
- instead of defining new return value macros, adapt the comment
---
arch/x86/kvm/x86.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 38a905fa86de..5ca2f3d44092 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -675,8 +675,8 @@ enum kvm_msr_access {
/*
* Internal error codes that are used to indicate that MSR emulation encountered
* an error that should result in #GP in the guest, unless userspace handles it.
- * Note, '1', '0', and negative numbers are off limits, as they are used by KVM
- * as part of KVM's lightly documented internal KVM_RUN return codes.
+ * Other than these internal error codes negative errno values can be used for
+ * error cases, or 0 for success.
*
* UNSUPPORTED - The MSR isn't supported, either because it is completely
* unknown to KVM, or because the MSR should not exist according
--
2.54.0