From patchwork Sat Sep 30 00:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 728068 Delivered-To: patch@linaro.org Received: by 2002:a5d:60c8:0:b0:31d:da82:a3b4 with SMTP id x8csp713266wrt; Fri, 29 Sep 2023 17:23:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSZZYQbSyYi8C3ZX8aPFpr5tW0jstA48TS3+IhSePFnCEdZQrw40otFgVKotCOQOdE1MoV X-Received: by 2002:a05:6214:3a81:b0:647:2653:bcc with SMTP id nz1-20020a0562143a8100b0064726530bccmr7506283qvb.13.1696033418751; Fri, 29 Sep 2023 17:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696033418; cv=none; d=google.com; s=arc-20160816; b=yncDDx8GESoxGglr88kbwIVxLxzDWCOi7Q6lmtbLki/Evm3T8EqgEsSpN3MjOARZtb yeHqB15m3yB9wFb6wM0/9OFeEtDNPbcvjzbo7hD2o29NYEaZ3JCzFl/3mYzd8BNd9p8V gZHToMzp6tZpLZM7vHTmH2386pp/ohMbggWLvci8SwE/XaKKlf1II+84R7NiAcLJtLrQ sfFXO62Fww5T1Z9kkQE3ss6GgJhOA7NhdQ4gfDPSCici1+nM/lRZZGBXH9DDtI+u+IJd 4nZ7XOHLCZJ3G18lzIJ0oXNNXbpgVD/klNA4GlrcSprczETTmc97ReAr1qlqL7vZUSul 909Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:from:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to; bh=H8XDUKELtAzks0OFZ7mZ4L9TtQOEGmt5380nszY8DRk=; fh=I+6CS2uJqPEgP3gz8gmk6tLbm1jsmO9tblK+QTjWHxs=; b=05WCji2q6YMYXDrMx/sJiezxZeImQs0BDITX1Bmh+mg+2Fgsea4UBvPpvTI0zI1kWB 9RlI6Vo0v4rtuMg/MF8vgTb2OxMQC4DcZDZX6Xx3YHWj1kBlV3XqQ79PqU/kbD8ZxB7s PQdT8SdMsDKbhJQYXBW31w2mUPuVuhcE4RL+rs87bYUnoEbtBqy21Xnk86j4RHoksqqp gfqe7s8PlNFvaEBrg8TyETv1ewWK1g9k3ZulnWmUd/t+r58jAXWIDW91+Tm8Kq1u+QyR Znf0fV5IfbhiQ/y2DH/4VQAIdi8CKggfCIhpBWNJt/w+IjltJK+GwLsKlmohNU0v4MsC U7AA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p8-20020a0cf548000000b00655dadf3eaasi4865073qvm.141.2023.09.29.17.23.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Sep 2023 17:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nongnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmNlZ-0003dL-VL; Fri, 29 Sep 2023 20:23:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmNlX-0003cf-98; Fri, 29 Sep 2023 20:23:27 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmNlV-0001lZ-Qh; Fri, 29 Sep 2023 20:23:27 -0400 Received: from lhrpeml500001.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Ry7FK2cPhz6K5rX; Sat, 30 Sep 2023 08:21:57 +0800 (CST) Received: from A190218597.china.huawei.com (10.195.35.96) by lhrpeml500001.china.huawei.com (7.191.163.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 30 Sep 2023 01:23:03 +0100 To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V2 10/10] target/arm/kvm: Write CPU state back to KVM on reset Date: Sat, 30 Sep 2023 01:19:33 +0100 Message-ID: <20230930001933.2660-11-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20230930001933.2660-1-salil.mehta@huawei.com> References: <20230930001933.2660-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.195.35.96] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhrpeml500001.china.huawei.com (7.191.163.213) X-CFilter-Loop: Reflected Received-SPF: pass client-ip=185.176.79.56; envelope-from=salil.mehta@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Salil Mehta X-Patchwork-Original-From: Salil Mehta via From: Salil Mehta Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jean-Philippe Brucker 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 Signed-off-by: Salil Mehta Reviewed-by: Alex Bennée Reviewed-by: Gavin Shan --- target/arm/kvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } /*