[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/30] ppc/spapr: Use start-powered-off CPUState property
From: |
David Gibson |
Subject: |
[PULL 17/30] ppc/spapr: Use start-powered-off CPUState property |
Date: |
Fri, 4 Sep 2020 13:47:06 +1000 |
From: Thiago Jung Bauermann <bauerman@linux.ibm.com>
PowerPC sPAPR CPUs start in the halted state, and spapr_reset_vcpu()
attempts to implement this by setting CPUState::halted to 1. But that's too
late for the case of hotplugged CPUs in a machine configure with 2 or more
threads per core.
By then, other parts of QEMU have already caused the vCPU to run in an
unitialized state a couple of times. For example, ppc_cpu_reset() calls
ppc_tlb_invalidate_all(), which ends up calling async_run_on_cpu(). This
kicks the new vCPU while it has CPUState::halted = 0, causing QEMU to issue
a KVM_RUN ioctl on the new vCPU before the guest is able to make the
start-cpu RTAS call to initialize its register state.
This problem doesn't seem to cause visible issues for regular guests, but
on a secure guest running under the Ultravisor it does. The Ultravisor
relies on being able to snoop on the start-cpu RTAS call to map vCPUs to
guests, and this issue causes it to see a stray vCPU that doesn't belong to
any guest.
Fix by setting the start-powered-off CPUState property in
spapr_create_vcpu(), which makes cpu_common_reset() initialize
CPUState::halted to 1 at an earlier moment.
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
Message-Id: <20200826055535.951207-4-bauerman@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr_cpu_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index c4f47dcc04..2125fdac34 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -36,11 +36,6 @@ static void spapr_reset_vcpu(PowerPCCPU *cpu)
cpu_reset(cs);
- /* All CPUs start halted. CPU0 is unhalted from the machine level
- * reset code and the rest are explicitly started up by the guest
- * using an RTAS call */
- cs->halted = 1;
-
env->spr[SPR_HIOR] = 0;
lpcr = env->spr[SPR_LPCR];
@@ -274,6 +269,11 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int
i, Error **errp)
cs = CPU(obj);
cpu = POWERPC_CPU(obj);
+ /*
+ * All CPUs start halted. CPU0 is unhalted from the machine level reset
code
+ * and the rest are explicitly started up by the guest using an RTAS call.
+ */
+ cs->start_powered_off = true;
cs->cpu_index = cc->core_id + i;
spapr_set_vcpu_id(cpu, cs->cpu_index, &local_err);
if (local_err) {
--
2.26.2
- [PULL 03/30] spapr: Remove unnecessary DRC type-checker macros, (continued)
- [PULL 03/30] spapr: Remove unnecessary DRC type-checker macros, David Gibson, 2020/09/03
- [PULL 05/30] ppc/pnv: Add a HIOMAP erase command, David Gibson, 2020/09/03
- [PULL 07/30] spapr/xive: Use the xics flag to check for XIVE-only IRQ backends, David Gibson, 2020/09/03
- [PULL 08/30] spapr/xive: Modify kvm_cpu_is_enabled() interface, David Gibson, 2020/09/03
- [PULL 11/30] spapr/xive: Allocate vCPU IPIs from the vCPU contexts, David Gibson, 2020/09/03
- [PULL 10/30] spapr/xive: Allocate IPIs independently from the other sources, David Gibson, 2020/09/03
- [PULL 18/30] ppc/e500: Use start-powered-off CPUState property, David Gibson, 2020/09/03
- [PULL 14/30] ppc/spapr_nvdimm: do not enable support with 'nvdimm=off', David Gibson, 2020/09/03
- [PULL 13/30] spapr, spapr_nvdimm: fold NVDIMM validation in the same place, David Gibson, 2020/09/03
- [PULL 12/30] ppc/spapr_nvdimm: use g_autofree in spapr_nvdimm_validate_opts(), David Gibson, 2020/09/03
- [PULL 17/30] ppc/spapr: Use start-powered-off CPUState property,
David Gibson <=
- [PULL 15/30] target/arm: Move start-powered-off property to generic CPUState, David Gibson, 2020/09/03
- [PULL 19/30] mips/cps: Use start-powered-off CPUState property, David Gibson, 2020/09/03
- [PULL 16/30] target/arm: Move setting of CPU halted state to generic code, David Gibson, 2020/09/03
- [PULL 21/30] sparc/sun4m: Use start-powered-off CPUState property, David Gibson, 2020/09/03
- [PULL 20/30] sparc/sun4m: Don't set cs->halted = 0 in main_cpu_reset(), David Gibson, 2020/09/03
- [PULL 22/30] target/s390x: Use start-powered-off CPUState property, David Gibson, 2020/09/03
- [PULL 23/30] hw/ppc/ppc4xx_pci: Use ARRAY_SIZE() instead of magic value, David Gibson, 2020/09/03
- [PULL 24/30] hw/ppc/ppc4xx_pci: Replace pointless warning by assert(), David Gibson, 2020/09/03
- [PULL 25/30] ppc: introducing spapr_numa.c NUMA code helper, David Gibson, 2020/09/03
- [PULL 26/30] ppc/spapr_nvdimm: turn spapr_dt_nvdimm() static, David Gibson, 2020/09/03