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 <sea...@google.com>
AuthorDate: Tue Aug 30 23:15:51 2022 +0000
Commit:     Paolo Bonzini <pbonz...@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 <sea...@google.com>
    Link: https://lore.kernel.org/r/20220830231614.3580124-5-sea...@google.com
    Signed-off-by: Paolo Bonzini <pbonz...@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);

Reply via email to