Message ID | 20230929124304.13672-10-salil.mehta@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add architecture agnostic code to support vCPU Hotplug | expand |
Salil Mehta <salil.mehta@huawei.com> writes: > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > When a KVM vCPU is reset following a PSCI CPU_ON call, its power state > is not synchronized with KVM at the moment. Because the vCPU is not > marked dirty, we miss the call to kvm_arch_put_registers() that writes > to KVM's MP_STATE. Force mp_state synchronization. > > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> > Signed-off-by: Salil Mehta <salil.mehta@huawei.com> Seems reasonable: Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> From: Alex Bennée <alex.bennee@linaro.org> > Sent: Friday, September 29, 2023 3:40 PM > To: Salil Mehta <salil.mehta@huawei.com> > Cc: qemu-devel@nongnu.org; qemu-arm@nongnu.org; maz@kernel.org; jean- > philippe@linaro.org; Jonathan Cameron <jonathan.cameron@huawei.com>; > lpieralisi@kernel.org; peter.maydell@linaro.org; > richard.henderson@linaro.org; imammedo@redhat.com; andrew.jones@linux.dev; > david@redhat.com; philmd@linaro.org; eric.auger@redhat.com; > oliver.upton@linux.dev; pbonzini@redhat.com; mst@redhat.com; > will@kernel.org; gshan@redhat.com; rafael@kernel.org; > linux@armlinux.org.uk; darren@os.amperecomputing.com; > ilkka@os.amperecomputing.com; vishnu@os.amperecomputing.com; > karl.heubaum@oracle.com; miguel.luis@oracle.com; salil.mehta@opnsrc.net; > zhukeqian <zhukeqian1@huawei.com>; wangxiongfeng (C) > <wangxiongfeng2@huawei.com>; wangyanan (Y) <wangyanan55@huawei.com>; > jiakernel2@gmail.com; maobibo@loongson.cn; lixianglai@loongson.cn; Linuxarm > <linuxarm@huawei.com> > Subject: Re: [PATCH 9/9] target/arm/kvm: Write CPU state back to KVM on > reset > > > Salil Mehta <salil.mehta@huawei.com> writes: > > > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > > > When a KVM vCPU is reset following a PSCI CPU_ON call, its power state > > is not synchronized with KVM at the moment. Because the vCPU is not > > marked dirty, we miss the call to kvm_arch_put_registers() that writes > > to KVM's MP_STATE. Force mp_state synchronization. > > > > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> > > Signed-off-by: Salil Mehta <salil.mehta@huawei.com> > > Seems reasonable: > > Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Thanks Salil.
diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b66b936a95..8cb70b9e7c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -642,11 +642,12 @@ void kvm_arm_cpu_post_load(ARMCPU *cpu) void kvm_arm_reset_vcpu(ARMCPU *cpu) { int ret; + CPUState *cs = CPU(cpu); /* Re-init VCPU so that all registers are set to * their respective reset values. */ - ret = kvm_arm_vcpu_init(CPU(cpu)); + ret = kvm_arm_vcpu_init(cs); if (ret < 0) { fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(-ret)); abort(); @@ -663,6 +664,11 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu) * for the same reason we do so in kvm_arch_get_registers(). */ write_list_to_cpustate(cpu); + /* + * Ensure we call kvm_arch_put_registers(). The vCPU isn't marked dirty if + * it was parked in KVM and is now booting from a PSCI CPU_ON call. + */ + cs->vcpu_dirty = true; } /*