lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6zPdN3vCWmm2Irs@google.com>
Date: Wed, 12 Feb 2025 08:42:28 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Jim Mattson <jmattson@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Thomas Gleixner <tglx@...utronix.de>, 
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org, 
	"H . Peter Anvin" <hpa@...or.com>, David Woodhouse <dwmw2@...radead.org>, Paul Durrant <paul@....org>, 
	Gleb Natapov <gleb@...hat.com>, Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>, 
	Suzuki Poulose <suzuki@...ibm.com>, Srivatsa Vaddagiri <vatsa@...ux.vnet.ibm.com>, 
	Jan Kiszka <jan.kiszka@...mens.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] KVM: x86: Introduce kvm_set_mp_state()

On Mon, Jan 13, 2025, Jim Mattson wrote:
> @@ -11288,7 +11287,7 @@ static int __kvm_emulate_halt(struct kvm_vcpu *vcpu, int state, int reason)
>  		if (kvm_vcpu_has_events(vcpu))
>  			vcpu->arch.pv.pv_unhalted = false;
>  		else
> -			vcpu->arch.mp_state = state;
> +			kvm_set_mp_state(vcpu, state);

It wouldn't be appropriate in this patch, but I think it makes sense to invoke
kvm_set_mp_state() instead of open coding the pv.pv_unhalted change.  E.g. if
the vCPU is somehow not already RUNNABLE (which is a bug?), then depending on
when pv_unhalted is set, KVM could either leave the vCPU in the non-RUNNABLE
state (set before __kvm_emulate_halt()), or transition the vCPU to HALTED and
then RUNNABLE (pv_unhalted set after the kvm_vcpu_has_events() check).

Untested, but this?  I'll test and post a patch (assuming it works).

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0aca2a5dac7e..c51499c66cfa 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11292,9 +11292,8 @@ static int __kvm_emulate_halt(struct kvm_vcpu *vcpu, int state, int reason)
        ++vcpu->stat.halt_exits;
        if (lapic_in_kernel(vcpu)) {
                if (kvm_vcpu_has_events(vcpu))
-                       vcpu->arch.pv.pv_unhalted = false;
-               else
-                       kvm_set_mp_state(vcpu, state);
+                       state = KVM_MP_STATE_RUNNABLE;
+               kvm_set_mp_state(vcpu, state);
                return 1;
        } else {
                vcpu->run->exit_reason = reason;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ