All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Aqib Faruqui <aqibaf@amazon.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	kvm@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,  nh-open-source@amazon.com
Subject: Re: [PATCH 1/1] KVM: selftests: Fix force_emulation_prefix parameter type mismatch
Date: Fri, 29 Aug 2025 07:18:43 -0700	[thread overview]
Message-ID: <aLG2qpCCfjESLZFF@google.com> (raw)
In-Reply-To: <20250829141233.58081-1-aqibaf@amazon.com>

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);

      reply	other threads:[~2025-08-29 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aLG2qpCCfjESLZFF@google.com \
    --to=seanjc@google.com \
    --cc=aqibaf@amazon.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.