From patchwork Mon Oct 9 20:36:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 731031 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1410615wrw; Mon, 9 Oct 2023 13:40:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaKpzj23WJT0zRrFjR99GCdgKPzOmdwWfYic2kFXxLvpwEM2Uky1Osqz5lTFWIEdfqGwkW X-Received: by 2002:a25:3742:0:b0:d9a:4a5f:415d with SMTP id e63-20020a253742000000b00d9a4a5f415dmr925226yba.0.1696884052797; Mon, 09 Oct 2023 13:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696884052; cv=none; d=google.com; s=arc-20160816; b=IbkWy4626luoivxLBWBPxsVd+h9pIjiSL6GOegProJrgpt0+nYDiwduONHAfQp8U75 6CskPCHh9wut2HTJSNKmHrP4m7fZ19NN07NViSh6Aw0bYG/X+C1j3/Ypt/o8Nn9WM57z cHyg2oh7CxkdVxdisMlfs/rcluGhwl8gi9BDBT1rBcyZWQqkqzSfuAryIJsA3dASxYyY I4S/DvdvmSIFQYVJXfkPGZUirBZOOyXg/tvP4yDX/t6tkTRS3OONaC/t38vOgcv60Bdm ZXTDXxY8HhQnO2LARyly2QzUWF8smUx4Qa953bX0GsSzmfUMnnnz0xwLwO4862DgA8nq VSRQ== 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=S5c/gGY1ZDidgBor0t8oCdB+qtcSNNvEAxG9XR5j2dDC3wnHflDI6Nw3/qjDCm1W5l TxA2Kv0R+wFEzkpanJldcvCOoijwjp/42xlRXkVv3g9ngMps0cVBQKpJo59YHhNZ1NKE 0ScZDnQjt5zOuiLF3purEqyJOihAB7edHf4jHoErDYBw3YLO2LqG575lu7lrKYbN9fZR Q9TU71NmCTaWPpxaadocQvf+u8B6Uuk2f3ba57gURrLQoXF9N/sQFzL/dYMW5wz0R/dQ nghS8LwDiF1uvFyWXdaC59rpzUnCZkO1UG6cM7+r6rbQrWZ1UeNpaJVTWLdxZeZForVy KU4w== 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 u23-20020a0cb417000000b0064f68c194a6si6590221qve.73.2023.10.09.13.40.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2023 13:40: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 1qpx3R-0003kS-31; Mon, 09 Oct 2023 16:40: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 1qpx3O-0003aU-2r; Mon, 09 Oct 2023 16:40:38 -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 1qpx3M-0007Xg-E1; Mon, 09 Oct 2023 16:40:37 -0400 Received: from lhrpeml500001.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4S49rk07wSz67hvQ; Tue, 10 Oct 2023 04:40:06 +0800 (CST) Received: from A190218597.china.huawei.com (10.126.175.116) 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 21:40:03 +0100 To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 10/10] target/arm/kvm: Write CPU state back to KVM on reset Date: Mon, 9 Oct 2023 21:36:01 +0100 Message-ID: <20231009203601.17584-11-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20231009203601.17584-1-salil.mehta@huawei.com> References: <20231009203601.17584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.175.116] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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; } /*