Skip to content

Commit

Permalink
KVM: Ensure CPU is stable during low level hardware enable/disable
Browse files Browse the repository at this point in the history
Use the non-raw smp_processor_id() in the low hardware enable/disable
helpers as KVM absolutely relies on the CPU being stable, e.g. KVM would
end up with incorrect state if the task were migrated between accessing
cpus_hardware_enabled and actually enabling/disabling hardware.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-44-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
sean-jc authored and bonzini committed Dec 29, 2022
1 parent e4aa7f8 commit 2c106f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5097,7 +5097,7 @@ static struct miscdevice kvm_dev = {

static void hardware_enable_nolock(void *junk)
{
int cpu = raw_smp_processor_id();
int cpu = smp_processor_id();
int r;

if (cpumask_test_cpu(cpu, cpus_hardware_enabled))
Expand Down Expand Up @@ -5139,7 +5139,7 @@ static int kvm_online_cpu(unsigned int cpu)

static void hardware_disable_nolock(void *junk)
{
int cpu = raw_smp_processor_id();
int cpu = smp_processor_id();

if (!cpumask_test_cpu(cpu, cpus_hardware_enabled))
return;
Expand Down

0 comments on commit 2c106f2

Please sign in to comment.