From patchwork Mon Oct 9 11:28:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 730999 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1156572wrw; Mon, 9 Oct 2023 04:34:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm+EAbmpJ8jKnUXxAt/sM8kqaThQvRAZNB7wOfGJ4YhLvxF2doUR7qS9VPCqeBbozXtNTE X-Received: by 2002:a0c:c98a:0:b0:649:c4f:8d81 with SMTP id b10-20020a0cc98a000000b006490c4f8d81mr13159112qvk.5.1696851242999; Mon, 09 Oct 2023 04:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696851242; cv=none; d=google.com; s=arc-20160816; b=SyPzF+Vsc+ongwmGm+PcYxelZggulgwXYKjJi9jVxJiHmpvZIApzJzs8UTXWIzEVfQ UjP4idnNxhzyqAzEnU8EPO1iTlQGnQzlqWr89fIlvGlOFVoLtCDQi0gOO68jMotDdxLM E57knUs0YeM6l1GIl2N8ahneQWLMGl2IgBipsS5gYlJUBCMI8mbptLNrQ64sWa2ewEPI SnTIx52FNK31wxGPj1YtXdWDQaa46e5hJ4UZ+fhOAnoY9qN+ubWuGeByt5pWBf3QWuNr hzLgwJk7FV5nC/2Q3oF4qUAQ8AP5RKeSuiSI1khiFtIzdAbnrvWFiC8pGM1vksQsGqOy IZMA== 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=qCNh/vOVVjEQnNSeKvwPw4nUeQ5allYWPl1Jwdp4Yyg=; fh=I+6CS2uJqPEgP3gz8gmk6tLbm1jsmO9tblK+QTjWHxs=; b=dsSbV0DwGdldmGuUliOfLDUXNJyVg9CgetkgNmI44SSzPG+x36nNve4vcuLRxrqWOk cRCRYyOsxWuCKwJWK1bZ3pw/1uxxSjwjjcsidVFDwJaQO9cFaQGzc5lz3vyNxBqN77ee sZDt7swkeHoDEpepSA+sBRyKKLuGY+2sNPDlEnEr5cC0ohVyEOSgtynCyxtM7ylQwfeb a2DhywIux9oEbO8IM60PsJCAPOLZ0S/OS2Q8YMuZP+57pIAPv1orivEjTXlKpJuGG0/8 dvvxgEEukKNinMWRLlgsiTkQGNXuUB69FLsTFaTN/SUE/xp6gA69yKhGaE2XkvA8P1fN HQHg== 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 t10-20020a0ca68a000000b00658561d243csi5866565qva.16.2023.10.09.04.34.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2023 04:34:02 -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 1qpoVl-0005X5-7i; Mon, 09 Oct 2023 07:33:24 -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 1qpoV5-0004wu-Lk; Mon, 09 Oct 2023 07:32:39 -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 1qpoV4-00018i-4e; Mon, 09 Oct 2023 07:32:39 -0400 Received: from lhrpeml500001.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4S3xhd5bGDz67cSL; Mon, 9 Oct 2023 19:32:17 +0800 (CST) Received: from A190218597.china.huawei.com (10.48.154.91) 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; Mon, 9 Oct 2023 12:32:16 +0100 To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V3 10/10] target/arm/kvm: Write CPU state back to KVM on reset Date: Mon, 9 Oct 2023 12:28:12 +0100 Message-ID: <20231009112812.10612-11-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20231009112812.10612-1-salil.mehta@huawei.com> References: <20231009112812.10612-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.48.154.91] 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: -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; } /*