* [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch
@ 2025-08-29 14:12 Aqib Faruqui
2025-08-29 14:18 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Aqib Faruqui @ 2025-08-29 14:12 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini, Shuah Khan, kvm,
linux-kselftest, linux-kernel
Cc: nh-open-source, aqibaf
Fix kvm_is_forced_enabled() to use get_kvm_param_bool() instead of
get_kvm_param_integer() when reading the "force_emulation_prefix" kernel
module parameter.
The force_emulation_prefix parameter is a boolean that accepts Y/N
values, but the function was incorrectly trying to parse it as an
integer using strtol().
Signed-off-by: Aqib Faruqui <aqibaf@amazon.com>
---
tools/testing/selftests/kvm/include/x86/processor.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing/selftests/kvm/include/x86/processor.h
index 3f93d1b4f..8edf48b5a 100644
--- a/tools/testing/selftests/kvm/include/x86/processor.h
+++ b/tools/testing/selftests/kvm/include/x86/processor.h
@@ -1323,7 +1323,7 @@ static inline bool kvm_is_pmu_enabled(void)
static inline bool kvm_is_forced_emulation_enabled(void)
{
- return !!get_kvm_param_integer("force_emulation_prefix");
+ return get_kvm_param_bool("force_emulation_prefix");
}
static inline bool kvm_is_unrestricted_guest_enabled(void)
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch
2025-08-29 14:12 [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch Aqib Faruqui
@ 2025-08-29 14:18 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2025-08-29 14:18 UTC (permalink / raw)
To: Aqib Faruqui
Cc: Paolo Bonzini, Shuah Khan, kvm, linux-kselftest, linux-kernel,
nh-open-source
On Fri, Aug 29, 2025, Aqib Faruqui wrote:
> Fix kvm_is_forced_enabled() to use get_kvm_param_bool() instead of
> get_kvm_param_integer() when reading the "force_emulation_prefix" kernel
> module parameter.
>
> The force_emulation_prefix parameter is a boolean that accepts Y/N
> values, but the function was incorrectly trying to parse it as an
> integer using strtol().
Nope, it's been an int since commit:
commit d500e1ed3dc873818277e109ccf6407118669236
Author: Sean Christopherson <seanjc@google.com>
AuthorDate: Tue Aug 30 23:15:51 2022 +0000
Commit: Paolo Bonzini <pbonzini@redhat.com>
CommitDate: Mon Sep 26 12:03:04 2022 -0400
KVM: x86: Allow clearing RFLAGS.RF on forced emulation to test code #DBs
Extend force_emulation_prefix to an 'int' and use bit 1 as a flag to
indicate that KVM should clear RFLAGS.RF before emulating, e.g. to allow
tests to force emulation of code breakpoints in conjunction with MOV/POP
SS blocking, which is impossible without KVM intervention as VMX
unconditionally sets RFLAGS.RF on intercepted #UD.
Make the behavior controllable so that tests can also test RFLAGS.RF=1
(again in conjunction with code #DBs).
Note, clearing RFLAGS.RF won't create an infinite #DB loop as the guest's
IRET from the #DB handler will return to the instruction and not the
prefix, i.e. the restart won't force emulation.
Opportunistically convert the permissions to the preferred octal format.
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220830231614.3580124-5-seanjc@google.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 418a069ab0d7..a7ae08e68582 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -173,8 +173,13 @@ bool __read_mostly enable_vmware_backdoor = false;
module_param(enable_vmware_backdoor, bool, S_IRUGO);
EXPORT_SYMBOL_GPL(enable_vmware_backdoor);
-static bool __read_mostly force_emulation_prefix = false;
-module_param(force_emulation_prefix, bool, S_IRUGO);
+/*
+ * Flags to manipulate forced emulation behavior (any non-zero value will
+ * enable forced emulation).
+ */
+#define KVM_FEP_CLEAR_RFLAGS_RF BIT(1)
+static int __read_mostly force_emulation_prefix;
+module_param(force_emulation_prefix, int, 0444);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-29 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-29 14:12 [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch Aqib Faruqui
2025-08-29 14:18 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).