summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-11-30 23:09:27 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2022-12-29 15:48:33 -0500
commit2c106f29004d2a6dbdc375cd9c0c8f981f475f47 (patch)
tree5b774ab33f109c776926b0f5a4792190292c4f20 /virt
parente4aa7f88af1a123863530af4a238ce64ec8fad5a (diff)
downloadlinux-2c106f29004d2a6dbdc375cd9c0c8f981f475f47.tar.gz
linux-2c106f29004d2a6dbdc375cd9c0c8f981f475f47.tar.xz
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 <seanjc@google.com> Message-Id: <20221130230934.1014142-44-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2d6203ecab88..0c3b9d6fa1b1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -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))
@@ -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;