From patchwork Fri Sep 29 12:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 727626 Delivered-To: patch@linaro.org Received: by 2002:a5d:60c8:0:b0:31d:da82:a3b4 with SMTP id x8csp423755wrt; Fri, 29 Sep 2023 05:48:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdNAMbrvlDMmHnWbggHwXJmGvxDSw6Pv35bgLq20deqtc3YfrZnRTd0PduasW/u1nYlwqR X-Received: by 2002:a05:622a:1704:b0:412:1e51:8fef with SMTP id h4-20020a05622a170400b004121e518fefmr4829483qtk.30.1695991732154; Fri, 29 Sep 2023 05:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695991732; cv=none; d=google.com; s=arc-20160816; b=OM+phOIxNOBsdbWyKJPZs24UAK2DjIPgyLWLx/CkvAN+U6RMeu/P5K2Xk8ckMkWapY qOhT/yKMs2S1vNLWiKGoSOIJ9NHuut4TALHjAfnWIwIQSy/y2+32W+63eT2cP4AEQkor qwejt57soMXlMJ+hBzQo1K0ZBFvovGB5Ej3y5vBlYRwfiMEtJkV7KF133pnaKkZDjmTm FknGdyySiC2WKN9hdN4cNeAeyt7fXrcM0YfpB58M751vAxxCmBkuk3UsQcauGI/7ty2X uBPGgE5EEqgCmk/5cD0aWLRfm9xZ9yhKOC78ET7I3zlRw0Rg68y9z49pbOBTWBh2NdlT CODw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to; bh=qBZ+VJ4nD5t8FtSMNqtXM9UlIS+kq7AqXPDwpJl0Tk8=; fh=I+6CS2uJqPEgP3gz8gmk6tLbm1jsmO9tblK+QTjWHxs=; b=Yr8T7WnGttswwML/7xqkAPbAE9UAvZxxHgL7gsiDdb3xjB8mTABNVzn5S4o+zNc8JI HeoIASKaR8/V5MF59Z1hQZxDA/VoV9rpGkzUKTCYvcaF15jcC46I22yndkeQZ6wQYW9E 4TRdlv8oi3Iz0tRvaxsoYjL5lWW/7QPoY8WpglLoB/s9N1a+gcVCeQGqgib90cgz0dII oaJtuqLWpivLbpxXka6iFBl5P0ZjMfMnqxtGWA70sAarZ3aW611IWbygSp+FU+G1b20O bN3ORq51Ts7lhVMiyU/UCZS0DW+LuSIHZaZxTPI/CC4vJzUC5sybXMu9xcZHOCExe145 DHvg== 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 c18-20020a05622a025200b0041962bf168esi2012460qtx.418.2023.09.29.05.48.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Sep 2023 05:48:52 -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 1qmCvB-0003JI-Im; Fri, 29 Sep 2023 08:48:41 -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 1qmCuF-000305-O3; Fri, 29 Sep 2023 08:47:48 -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 1qmCtz-0007Ku-E7; Fri, 29 Sep 2023 08:47:43 -0400 Received: from lhrpeml500001.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RxqpJ1yBxz67yyF; Fri, 29 Sep 2023 20:46:00 +0800 (CST) Received: from A190218597.china.huawei.com (10.48.156.153) 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; Fri, 29 Sep 2023 13:47:05 +0100 To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH 9/9] target/arm/kvm: Write CPU state back to KVM on reset Date: Fri, 29 Sep 2023 13:43:04 +0100 Message-ID: <20230929124304.13672-10-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20230929124304.13672-1-salil.mehta@huawei.com> References: <20230929124304.13672-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.156.153] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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 --- 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; } /*