Skip to content

Commit 2c106f2

Browse files
sean-jcbonzini
authored andcommitted
KVM: Ensure CPU is stable during low level hardware enable/disable
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent e4aa7f8 commit 2c106f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

virt/kvm/kvm_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5097,7 +5097,7 @@ static struct miscdevice kvm_dev = {
50975097

50985098
static void hardware_enable_nolock(void *junk)
50995099
{
5100-
int cpu = raw_smp_processor_id();
5100+
int cpu = smp_processor_id();
51015101
int r;
51025102

51035103
if (cpumask_test_cpu(cpu, cpus_hardware_enabled))
@@ -5139,7 +5139,7 @@ static int kvm_online_cpu(unsigned int cpu)
51395139

51405140
static void hardware_disable_nolock(void *junk)
51415141
{
5142-
int cpu = raw_smp_processor_id();
5142+
int cpu = smp_processor_id();
51435143

51445144
if (!cpumask_test_cpu(cpu, cpus_hardware_enabled))
51455145
return;

0 commit comments

Comments
 (0)