]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: Ensure CPU is stable during low level hardware enable/disable
authorSean Christopherson <seanjc@google.com>
Wed, 30 Nov 2022 23:09:27 +0000 (23:09 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 13 Jan 2023 15:47:29 +0000 (10:47 -0500)
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>
virt/kvm/kvm_main.c

index 4bf49a4954e0dcc47d1d3f7d5674b672d7b4071d..a5ee54e993d1c35182c9c6a9a28c78ae2801a2f5 100644 (file)
@@ -5065,7 +5065,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))
@@ -5107,7 +5107,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;