From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433105; cv=none; d=zohomail.com; s=zohoarc; b=WL7Yz3F3Yb1NKpO8tQltCEsDpI+PCLziVhrvHf7I+J9zkoYsKP3xSfXp5sX6htrQlkp/g/jZ7G2zEB9L8ZYnPZiFyzprHyZ3VV8evfe5C80Mg3TLbDKiT/gJ4HBp0ZvFKvJn53kFu+wXfj3C9MJ0FNswrmg8HpR828JQ8OeiLgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433105; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A8CijVa+e1oWr2EV0tfoz247smmQS3FwcjTPUtBwtaM=; b=arCtBOvkikhTvOfhXhSY/whmZ46l5nR6M4G/D+1eMAx2TRJHjygP6d+yQ714ercc2woxvpe2+NbdaC8U6vwcx7V9/YgbC6F1aoYIK22NAUP2m/RB2FIPhumo/RLJfMX/3Nyl5YT9FnG8Vg+X8c1PzpRTl/OpZFIaXtLNih+7i0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433105664532.0126055852667; Fri, 1 Dec 2023 04:18:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92Sb-0005hu-KI; Fri, 01 Dec 2023 07:17:34 -0500 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 1r92S0-0005X7-JP; Fri, 01 Dec 2023 07:16:57 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92Rw-0006Jk-6k; Fri, 01 Dec 2023 07:16:56 -0500 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6cdfee14c24so509154b3a.2; Fri, 01 Dec 2023 04:16:50 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433009; x=1702037809; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A8CijVa+e1oWr2EV0tfoz247smmQS3FwcjTPUtBwtaM=; b=VozzuXtkI1YjeyyePe5HJjW15Law2Pn/CWvtH6bTmF85MXkcMZ85R5IiBvpYvYJX2f SiSoOlls9yto2UBJvItjK1xKiiJfdwhSlEaHlIrSTqiv2XAXbuey7FRz9dcqAoI5LPKe nckkIqnTGdLtXfrbAFlDZZTUJ+oABfMJDHrWm5W7cdr1aw8e6XEx7TtfA6AsmUXTfpH7 fa0lSz0O8DJJtatyKkkZ4/FwxYOiVBL5WpZgpp1S2LRgvVSbQXGs21HVhMiVADRR+512 vQ71mUaEH87+CZF9So43GRvG+1KhLyELEgvmJpXjVPCSY78oECQH0vJ67Vqn7/sfhJY+ sQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433009; x=1702037809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A8CijVa+e1oWr2EV0tfoz247smmQS3FwcjTPUtBwtaM=; b=epAJJR8WlKJVH23aGJvgQ2nT+gOjdxmPkg5qMlCIMQFoSIqZjL0Tc6YXOPdi+O/Mc0 FORQJysb2nxbKxWeHQE8DKiDC6odFJYfDVg0/QuViprTm3UKkIS2YwdNjQQcaBrXxHGt 1UhshEHg3MNEX8NZhxYcA3eWmOl3Wpde2lqyGrcLDq0lcRKVcj138Vv0+8/LrmTsnw4u w2oOjdZV70qRogpMi3wZJvgMs5wcECsetzd+aUJ7k1Ln/8cgGqVcrjyZMNDLTH/LjObj 0s0r1m+XqgWKKI0SCSiEpNx+jBOxeNWPWLRkSMULIAUGIvp6/1oEdKjvVHwh/P2Rj187 +6ig== X-Gm-Message-State: AOJu0YyBFPMH2CG6Hx47iNvPJLXdbA+6oYfd/rbA4Eyj+a6o8EBpk+oU fQ0FQgHUVj8rVfQryfgJqxWRysoDfv0= X-Google-Smtp-Source: AGHT+IGyuVrLHwn2M1CI4eUZBlG+fbN+lDo48FBbf6XiOWJHpfMKdiREhwPfRVIeChlUeEZYL7CoAQ== X-Received: by 2002:a05:6a00:4c81:b0:6cd:f209:80cf with SMTP id eb1-20020a056a004c8100b006cdf20980cfmr4749092pfb.4.1701433008991; Fri, 01 Dec 2023 04:16:48 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v3 1/8] target/ppc: Rename TBL to TB on 64-bit Date: Fri, 1 Dec 2023 22:16:29 +1000 Message-ID: <20231201121636.142694-2-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433107214000007 From the earliest PowerPC ISA, TBR (later SPR) 268 has been called TB and accessed with mftb instruction. The problem is that TB is the name of the 64-bit register, and 32-bit implementations can only read the lower half with one instruction, so 268 has also been called TBL and it does only read TBL on 32-bit. Change SPR 268 to be called TB on 64-bit implementations. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/helper_regs.c | 4 ++++ target/ppc/ppc-qmp-cmds.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index f380342d4d..8c00ed8c06 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -460,7 +460,11 @@ void register_generic_sprs(PowerPCCPU *cpu) } =20 /* Time base */ +#if defined(TARGET_PPC64) + spr_register(env, SPR_VTBL, "TB", +#else spr_register(env, SPR_VTBL, "TBL", +#endif &spr_read_tbl, SPR_NOACCESS, &spr_read_tbl, SPR_NOACCESS, 0x00000000); diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c index f9acc21056..ffaff59e78 100644 --- a/target/ppc/ppc-qmp-cmds.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -103,7 +103,11 @@ const MonitorDef monitor_defs[] =3D { { "xer", 0, &monitor_get_xer }, { "msr", offsetof(CPUPPCState, msr) }, { "tbu", 0, &monitor_get_tbu, }, +#if defined(TARGET_PPC64) + { "tb", 0, &monitor_get_tbl, }, +#else { "tbl", 0, &monitor_get_tbl, }, +#endif { NULL }, }; =20 --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433078; cv=none; d=zohomail.com; s=zohoarc; b=gK6UlbMgIhRFMvm5i8o5qhyIsb1YSyYkvK9JQLCelWbIXCBrB8kjTPC4T44DtzXjW9BEPw+ODY7QZ46zn64V5FX/MFLBm6Z6GII5U8pJa9tvvLtvWZ7TT32Ffss1fwxl926tVXeCQx2zgyPuFraXbnonr781VT0fqagJr7iAG+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433078; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H6qL3e2JNWPt6jmOYzh7bH11qo1VaaEllPBpgKTuMG8=; b=inrt7HmE5LLw+mXODPhRb79ggEiMjVDlecDiuTwmrh2y9rIwsPj8IoZMLfkZpeJJLSwCVcGa+T0n1g7P1BA4aaJHYvVRDsBfGyQZPmKhpC10CgdvY4xcP54xT7tZQYGyZ2dHevXKJqwVDlg1lzwxLB9bijyocC8G4L0fKb36OVY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170143307830478.96797378330223; Fri, 1 Dec 2023 04:17:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92ST-0005dg-4M; Fri, 01 Dec 2023 07:17:26 -0500 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 1r92S0-0005XA-Vz; Fri, 01 Dec 2023 07:16:58 -0500 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92Ry-0006Ka-EH; Fri, 01 Dec 2023 07:16:56 -0500 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6cdde2aeb64so1947002b3a.2; Fri, 01 Dec 2023 04:16:53 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433012; x=1702037812; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H6qL3e2JNWPt6jmOYzh7bH11qo1VaaEllPBpgKTuMG8=; b=YqkrxlpBWX4lBZrwF3uDWfJB7hLTRT85XCrfGo6dhsxBSYxsZUeZFlUJQ+pbHZ4IR5 oS7lQEGpOKr/Kk5/vvQeLlF5qHWXsGeNfzxzrYjouo40qLvAzLQIvD7nYLuHL1Meow4v D5nUmQan95y0h+BLIhD/ZTMTRHVr9K/rXmIxCyP6AIdBEkmLY5uW5ZRX9npnFavw6W31 vXswi2sMh1P/H8T+Xt/hrsIsvNh2DM7qd2USVZJmaRQ8Vb6QhQTYwR/vOBLWP4PTXCf8 M1+ne4WcuF3k3twOxro5cBVHqKUwrwyk3AcJnzzapSaaYPy5QZkzVqtxMIg6x9gAgrur HJqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433012; x=1702037812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H6qL3e2JNWPt6jmOYzh7bH11qo1VaaEllPBpgKTuMG8=; b=ctF3EEcujKCt1gxKyXPDgu4QW6pISMlmW6Eug5RL60t+Vj4VDy0Auhe++iCkNWsjuk n721EFuAqrIE88bHSuC8jUT+fEHFoXRSkg+vZ/90xEhFPccQkzr2nXvRE5Beu5LoNxEc WbrYSw7dq5QQpI3Lop1b5qRG7f//vIQR1s9Fy6O5S1ozwDM15WTIzXYs4r4KGG51Bvfz OEHukL3GYG15ASPkFelXldGU5c4p7wiCkG02qx3agtzTxw262wFqDaV68npxq7dgJphx ect4m3XwCYaWii/YzyWrtFNuhTSLKKiCLhxQShruPPu0WE/mHSivjjTpuTdqpFVzZDWt MoIw== X-Gm-Message-State: AOJu0Yx6OoYhH8kDUfJo+3ApypZmy3v4GSgCRrgl+zn/olsnV5XXaQIA YiV8NlVex4DPayLMnPm99Sq5eSh+o/I= X-Google-Smtp-Source: AGHT+IHJqtLmYVIPl5s7Z5YaVW7h1U1YyHI9mltDPcf/r/wsFCEOW89nU4yzyGgxK8krtvjpflwOkA== X-Received: by 2002:a05:6a20:5483:b0:187:604a:3add with SMTP id i3-20020a056a20548300b00187604a3addmr32192655pzk.24.1701433012343; Fri, 01 Dec 2023 04:16:52 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 2/8] target/ppc: Improve timebase register defines naming Date: Fri, 1 Dec 2023 22:16:30 +1000 Message-ID: <20231201121636.142694-3-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433079183000001 The timebase in ppc started out with the mftb instruction which is like mfspr but addressed timebase registers (TBRs) rather than SPRs. These instructions could be used to read TB and TBU at 268 and 269. Timebase could be written via the TBL and TBU SPRs at 284 and 285. The ISA changed around v2.03 to bring TB and TBU reads into the SPR space at 268 and 269 (access via mftb TBR-space is still supported but will be phased out). Later, VTB was added which is an entirely different register. The SPR number defines in QEMU are understandably inconsistently named. Change SPR 268, 269, 284, 285 to TBL, TBU, WR_TBL, WR_TBU, respectively. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 8 ++++---- target/ppc/helper_regs.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index f8101ffa29..848e583c2d 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1750,8 +1750,8 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_USPRG5 (0x105) #define SPR_USPRG6 (0x106) #define SPR_USPRG7 (0x107) -#define SPR_VTBL (0x10C) -#define SPR_VTBU (0x10D) +#define SPR_TBL (0x10C) +#define SPR_TBU (0x10D) #define SPR_SPRG0 (0x110) #define SPR_SPRG1 (0x111) #define SPR_SPRG2 (0x112) @@ -1764,8 +1764,8 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_SPRG7 (0x117) #define SPR_ASR (0x118) #define SPR_EAR (0x11A) -#define SPR_TBL (0x11C) -#define SPR_TBU (0x11D) +#define SPR_WR_TBL (0x11C) +#define SPR_WR_TBU (0x11D) #define SPR_TBU40 (0x11E) #define SPR_SVR (0x11E) #define SPR_BOOKE_PIR (0x11E) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 8c00ed8c06..6f190ab13b 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -461,22 +461,22 @@ void register_generic_sprs(PowerPCCPU *cpu) =20 /* Time base */ #if defined(TARGET_PPC64) - spr_register(env, SPR_VTBL, "TB", + spr_register(env, SPR_TBL, "TB", #else - spr_register(env, SPR_VTBL, "TBL", + spr_register(env, SPR_TBL, "TBL", #endif &spr_read_tbl, SPR_NOACCESS, &spr_read_tbl, SPR_NOACCESS, 0x00000000); - spr_register(env, SPR_TBL, "TBL", + spr_register(env, SPR_WR_TBL, "TBL", &spr_read_tbl, SPR_NOACCESS, &spr_read_tbl, &spr_write_tbl, 0x00000000); - spr_register(env, SPR_VTBU, "TBU", + spr_register(env, SPR_TBU, "TBU", &spr_read_tbu, SPR_NOACCESS, &spr_read_tbu, SPR_NOACCESS, 0x00000000); - spr_register(env, SPR_TBU, "TBU", + spr_register(env, SPR_WR_TBU, "TBU", &spr_read_tbu, SPR_NOACCESS, &spr_read_tbu, &spr_write_tbu, 0x00000000); --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433144; cv=none; d=zohomail.com; s=zohoarc; b=KBhpNBGkU2Xe8GPZrxQfIzoHn4WpLBN5yEqNQcltI8A8tfLgXETD/+QhbCzYPH7zRdnCjda5buqmmulVIj4p7n1iiIdkQnehQomCX+Ime/k/lt8TYVlvRZOAsrRnJ2VG9G1AwSAJmSvWt9PkmWtZPqU2Tj2XQ1oq73r1cLiAsoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433144; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3eBHorYzeWRYIe6CR3hkTCvrYn8Bc1IR+gf3wCmm4l0=; b=IUU4U59IsE+BOM8pcQ63Lsy7NpOgDqrfPJWQC9OCRGqqOZ1RmwD3+JrhM8BfVyK8mpTKWKqjnJpiprISbU3EDRwElKT2OG9GOlMJ478UQDCuPkwNiIIXGGmDaTYdJLC6jcYNNpfZHJP6SoNSicZ1pSD6DKHURf/b5gN3+OpUIj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433144622170.70713599597036; Fri, 1 Dec 2023 04:19:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92Ss-0005or-Dx; Fri, 01 Dec 2023 07:17:51 -0500 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 1r92S5-0005Xb-30; Fri, 01 Dec 2023 07:17:03 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92S3-0006La-3g; Fri, 01 Dec 2023 07:17:00 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6cdd584591eso2009535b3a.2; Fri, 01 Dec 2023 04:16:58 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433017; x=1702037817; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3eBHorYzeWRYIe6CR3hkTCvrYn8Bc1IR+gf3wCmm4l0=; b=Us/UG5BMRR5cxfy3IE5VLN+fe+hI42UxfibKBrXdcAmK/czfxTifr4jBaMfKNFw1zq l3n7fnbVvQhVAYCxRw8nv6MLCHAgHNc2b2gDuhotrYYEF0uKaNWynOb4pkvRFfBM9np8 iZU2R0UFHjYVaJrgXnf/D4+mXNChiiqWiqqt/ri5abK77jPUPWYpJNcpeYRwzpha5XzY Np54HsrAX4VJwmZdsNQucbaM5eILQ13OMFS5D7km06pWeoLUx12pSdsZ8IaMEeg6Wjcn LnJUHQcW1qwXkMq3q+CsOP/zbxeZgZ+YPsyV5cwkvRFKcOGiHLkHQSxYq1pb8bRBPUMS m4bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433017; x=1702037817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3eBHorYzeWRYIe6CR3hkTCvrYn8Bc1IR+gf3wCmm4l0=; b=sM5hdyGcbaHTr6QXmIKOhgynnztGMmtOE61NU56jj9wg/6JRVzUuT+50ons2otoi8J yQNm3lNFuV6fz2tbwfLYnGM724YVeDntg1mnTZDrJ/IoH51TI+I6FOyjrNajENNlsXeQ VDf0+SUKZaUSW0Mjm14cipZnuKIw92RLOJVbqAh1lneU8Zzqq1d18G0/sNoJ6uuiARiS FkRzU6ZU3j5/gGWrtU1fDSWLy2TNBBEhYbIQBDrUP3LRucMzjVDWz5Bm3oID4FzS+7mJ FfbLmNraUKZsVEO+1aJ3wpIDWgiPrN8w8ArJwZpuq4Ms/13b9FSLLC/xCG5V7dy3gKEl oaVQ== X-Gm-Message-State: AOJu0Yz+NPVDffkQIncJ6Rw1L4JhhaJOBjURdy4ybVFY4o7vkG9wZ3QD vggZ4gahhGT0UPyfW3Q5suyV7pT1+p4= X-Google-Smtp-Source: AGHT+IG71d2Q4UtgNWy945gm3jCSHZYQgluMi4wbw1w3b7bIRi024NtYZq5ekvoAA+TCAMWtoyT4oQ== X-Received: by 2002:aa7:981d:0:b0:6cd:f399:be00 with SMTP id e29-20020aa7981d000000b006cdf399be00mr3703834pfl.28.1701433015828; Fri, 01 Dec 2023 04:16:55 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 3/8] target/ppc: Fix move-to timebase SPR access permissions Date: Fri, 1 Dec 2023 22:16:31 +1000 Message-ID: <20231201121636.142694-4-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=npiggin@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433145377000003 The move-to timebase registers TBU and TBL can not be read, and they can not be written in supervisor mode on hypervisor-capable CPUs. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/helper_regs.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 6f190ab13b..f1493ddca0 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -468,18 +468,33 @@ void register_generic_sprs(PowerPCCPU *cpu) &spr_read_tbl, SPR_NOACCESS, &spr_read_tbl, SPR_NOACCESS, 0x00000000); - spr_register(env, SPR_WR_TBL, "TBL", - &spr_read_tbl, SPR_NOACCESS, - &spr_read_tbl, &spr_write_tbl, - 0x00000000); spr_register(env, SPR_TBU, "TBU", &spr_read_tbu, SPR_NOACCESS, &spr_read_tbu, SPR_NOACCESS, 0x00000000); - spr_register(env, SPR_WR_TBU, "TBU", - &spr_read_tbu, SPR_NOACCESS, - &spr_read_tbu, &spr_write_tbu, - 0x00000000); +#ifndef CONFIG_USER_ONLY + if (env->has_hv_mode) { + spr_register_hv(env, SPR_WR_TBL, "TBL", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, &spr_write_tbl, + 0x00000000); + spr_register_hv(env, SPR_WR_TBU, "TBU", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, &spr_write_tbu, + 0x00000000); + } else { + spr_register(env, SPR_WR_TBL, "TBL", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, &spr_write_tbl, + 0x00000000); + spr_register(env, SPR_WR_TBU, "TBU", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, &spr_write_tbu, + 0x00000000); + } +#endif } =20 void register_non_embedded_sprs(CPUPPCState *env) --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433144; cv=none; d=zohomail.com; s=zohoarc; b=Yq+fjuMwPDTKRg35HiKEnRaJw0Aue8qcqwYmOV+NJNyCOvgYr5e48aYIf4ww+2MjDaup27VOGV4wMSf5ir5RVuK6OU+c62Ia7ZHk+I9ud99ZQRDzcVkJvEtFHKGObkeKijn6DwONKqYTz4VFamp/H0poYGlfTeYegUAxkRnzblw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433144; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pCnRGS5HPdnNI9SGD5Wcso4HL/SplUlvD0sVKolReIU=; b=DXoPGg9IflNqWg+FN48A09KjYPkxlGQ0kjspC3s/OHQqZh8W4Ez3YZZH8NVsIH7LhfP32gostXGTnNLvaLZuJq6xkUSGu98u/t/oI4359T/jM4a7zmo/vbKkcBssENVdkKBLqDgAumfF7w90hawQvDEoRx1/N6UeCtsiJsMBVBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433144443126.43555774734125; Fri, 1 Dec 2023 04:19:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92T9-00064A-8q; Fri, 01 Dec 2023 07:18:07 -0500 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 1r92S8-0005Xo-S3; Fri, 01 Dec 2023 07:17:05 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92S5-0006MJ-VM; Fri, 01 Dec 2023 07:17:04 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6cb749044a2so2055810b3a.0; Fri, 01 Dec 2023 04:17:00 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433019; x=1702037819; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pCnRGS5HPdnNI9SGD5Wcso4HL/SplUlvD0sVKolReIU=; b=RpdslPZRbH72Kf8k6HSD4FN46bwuDFxpXvNomC9qQ/MhPHM+fmN63emI7H5LpzmDKy 8bz4qbMM2GuQs7ScoDxl4Drf2G1nyVPsR/NdMZTvZn3piyiCn8w4a42OjBBWCcm1PZtA Edsek1EL/d8sN2TlQ8a93fKLMkjvKF/spiEXuqh5fpThrSitvNOKcs/SR/BpIQ5miDuy g4RsoQZd2Pk/IpMdPiJO481M4Lkuu2poq9f8dlQrLyi9RvUk9imOIQpYMMaQ8TRpqK2E ydh0epEJ3u1U5SFaLJmOJpH34DYLcScCGPdbCMmarkAvv6C8LAUEfJW4qdD6XWtMMc8p Ialw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433019; x=1702037819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pCnRGS5HPdnNI9SGD5Wcso4HL/SplUlvD0sVKolReIU=; b=rOVdFOaHVP7Oa2EW4t/05tmC7qpjGDOOrkDBpBFtEthB0ZwLZK+YqH/epZtfyk0UZg U/UCM5mYbJzz2ZlHMLE8QtTLYD/VUzZnedTKNBfYtzwsB2kBUtOECrMrqyHEEgUVjr9P 3ui12X0wwyl4CcKflDfnxAQ0eq/uSzVt/i0QDBF+9CGOtR1zqunDfeUuuSpskO6G+Wkh jhqyf3NVSTtXY1cxD2g7mOirUF7Wy2JFZVSGcdcHMhANRLeN9nJftt4ity5uds2K8mT9 4DF0loH+EcA0Ur2R9h2OGxLSyvvilEIbSKtRuEgB6cbdOAvIBhADB5a6ACw501KSfGAE xS3w== X-Gm-Message-State: AOJu0YzHlsJac/wFgUL9mFQWFCvbS4ITQJP0GkiO98t2Oie/zKQ3Jg+B gwfv6+r3hmVHA7nN402tVuG5rt/gwT8= X-Google-Smtp-Source: AGHT+IFbwy2TE+9jOjrwKFBvdh424nf4oEm0/DH4POWpHciyLWopu/tw6vq+VTVelVFFvy2CnowHaA== X-Received: by 2002:a05:6a20:13c8:b0:18b:c96b:a433 with SMTP id ho8-20020a056a2013c800b0018bc96ba433mr22847228pzc.56.1701433019467; Fri, 01 Dec 2023 04:16:59 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 4/8] pnv/chiptod: Add POWER9/10 chiptod model Date: Fri, 1 Dec 2023 22:16:32 +1000 Message-ID: <20231201121636.142694-5-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=npiggin@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433145425000004 The ChipTOD (for Time-Of-Day) is a chip pervasive facility in IBM POWER (powernv) processors that keeps a time of day clock. In particular for this model are facilities that initialise and start the time of day clock, and that synchronise that clock to cores on the chip, and to other chips. In this way, all cores on all chips can synchronise timebase (TB). This model implements functionality sufficient to run the skiboot chiptod synchronisation procedure (with the following core timebase state machine implementation). It does not modify the TB in the cores where the real hardware would, because the QEMU ppc timebase implementation is always synchronised acros all cores. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv_chiptod.h | 49 ++++ include/hw/ppc/pnv_xscom.h | 9 + hw/ppc/pnv_chiptod.c | 454 +++++++++++++++++++++++++++++++++++ hw/ppc/meson.build | 1 + hw/ppc/trace-events | 4 + 5 files changed, 517 insertions(+) create mode 100644 include/hw/ppc/pnv_chiptod.h create mode 100644 hw/ppc/pnv_chiptod.c diff --git a/include/hw/ppc/pnv_chiptod.h b/include/hw/ppc/pnv_chiptod.h new file mode 100644 index 0000000000..ca770525d9 --- /dev/null +++ b/include/hw/ppc/pnv_chiptod.h @@ -0,0 +1,49 @@ +/* + * QEMU PowerPC PowerNV Emulation of some CHIPTOD behaviour + * + * Copyright (c) 2022-2023, IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PPC_PNV_CHIPTOD_H +#define PPC_PNV_CHIPTOD_H + +#include "qom/object.h" + +#define TYPE_PNV_CHIPTOD "pnv-chiptod" +OBJECT_DECLARE_TYPE(PnvChipTOD, PnvChipTODClass, PNV_CHIPTOD) +#define TYPE_PNV9_CHIPTOD TYPE_PNV_CHIPTOD "-POWER9" +DECLARE_INSTANCE_CHECKER(PnvChipTOD, PNV9_CHIPTOD, TYPE_PNV9_CHIPTOD) +#define TYPE_PNV10_CHIPTOD TYPE_PNV_CHIPTOD "-POWER10" +DECLARE_INSTANCE_CHECKER(PnvChipTOD, PNV10_CHIPTOD, TYPE_PNV10_CHIPTOD) + +enum tod_state { + tod_error =3D 0, + tod_not_set =3D 7, + tod_running =3D 2, + tod_stopped =3D 1, +}; + +struct PnvChipTOD { + DeviceState xd; + + PnvChip *chip; + MemoryRegion xscom_regs; + + bool primary; + bool secondary; + enum tod_state tod_state; + uint64_t tod_error; + uint64_t pss_mss_ctrl_reg; +}; + +struct PnvChipTODClass { + DeviceClass parent_class; + + void (*broadcast_ttype)(PnvChipTOD *sender, uint32_t trigger); + + int xscom_size; +}; + +#endif /* PPC_PNV_CHIPTOD_H */ diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h index f5becbab41..6aa3ac745d 100644 --- a/include/hw/ppc/pnv_xscom.h +++ b/include/hw/ppc/pnv_xscom.h @@ -64,6 +64,9 @@ struct PnvXScomInterfaceClass { #define PNV_XSCOM_PSIHB_BASE 0x2010900 #define PNV_XSCOM_PSIHB_SIZE 0x20 =20 +#define PNV_XSCOM_CHIPTOD_BASE 0x0040000 +#define PNV_XSCOM_CHIPTOD_SIZE 0x31 + #define PNV_XSCOM_OCC_BASE 0x0066000 #define PNV_XSCOM_OCC_SIZE 0x6000 =20 @@ -93,6 +96,9 @@ struct PnvXScomInterfaceClass { #define PNV9_XSCOM_I2CM_BASE 0xa0000 #define PNV9_XSCOM_I2CM_SIZE 0x1000 =20 +#define PNV9_XSCOM_CHIPTOD_BASE PNV_XSCOM_CHIPTOD_BASE +#define PNV9_XSCOM_CHIPTOD_SIZE PNV_XSCOM_CHIPTOD_SIZE + #define PNV9_XSCOM_OCC_BASE PNV_XSCOM_OCC_BASE #define PNV9_XSCOM_OCC_SIZE 0x8000 =20 @@ -155,6 +161,9 @@ struct PnvXScomInterfaceClass { #define PNV10_XSCOM_I2CM_BASE PNV9_XSCOM_I2CM_BASE #define PNV10_XSCOM_I2CM_SIZE PNV9_XSCOM_I2CM_SIZE =20 +#define PNV10_XSCOM_CHIPTOD_BASE PNV9_XSCOM_CHIPTOD_BASE +#define PNV10_XSCOM_CHIPTOD_SIZE PNV9_XSCOM_CHIPTOD_SIZE + #define PNV10_XSCOM_OCC_BASE PNV9_XSCOM_OCC_BASE #define PNV10_XSCOM_OCC_SIZE PNV9_XSCOM_OCC_SIZE =20 diff --git a/hw/ppc/pnv_chiptod.c b/hw/ppc/pnv_chiptod.c new file mode 100644 index 0000000000..6ac3eac9d0 --- /dev/null +++ b/hw/ppc/pnv_chiptod.c @@ -0,0 +1,454 @@ +/* + * QEMU PowerPC PowerNV Emulation of some ChipTOD behaviour + * + * Copyright (c) 2022-2023, IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * ChipTOD (aka TOD) is a facility implemented in the nest / pervasive. The + * purpose is to keep time-of-day across chips and cores. + * + * There is a master chip TOD, which sends signals to slave chip TODs to + * keep them synchronized. There are two sets of configuration registers + * called primary and secondary, which can be used fail over. + * + * The chip TOD also distributes synchronisation signals to the timebase + * facility in each of the cores on the chip. In particular there is a + * feature that can move the TOD value in the ChipTOD to and from the TB. + * + * Initialisation typically brings all ChipTOD into sync (see tod_state), + * and then brings each core TB into sync with the ChipTODs (see timebase + * state and TFMR). This model is a very basic simulation of the init sequ= ence + * performed by skiboot. + */ + +#include "qemu/osdep.h" +#include "sysemu/reset.h" +#include "target/ppc/cpu.h" +#include "qapi/error.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "hw/ppc/fdt.h" +#include "hw/ppc/ppc.h" +#include "hw/ppc/pnv.h" +#include "hw/ppc/pnv_chip.h" +#include "hw/ppc/pnv_core.h" +#include "hw/ppc/pnv_xscom.h" +#include "hw/ppc/pnv_chiptod.h" +#include "trace.h" + +#include + +/* TOD chip XSCOM addresses */ +#define TOD_M_PATH_CTRL_REG 0x00000000 /* Master Path ctrl reg= */ +#define TOD_PRI_PORT_0_CTRL_REG 0x00000001 /* Primary port0 ctrl r= eg */ +#define TOD_PRI_PORT_1_CTRL_REG 0x00000002 /* Primary port1 ctrl r= eg */ +#define TOD_SEC_PORT_0_CTRL_REG 0x00000003 /* Secondary p0 ctrl re= g */ +#define TOD_SEC_PORT_1_CTRL_REG 0x00000004 /* Secondary p1 ctrl re= g */ +#define TOD_S_PATH_CTRL_REG 0x00000005 /* Slave Path ctrl reg = */ +#define TOD_I_PATH_CTRL_REG 0x00000006 /* Internal Path ctrl r= eg */ + +/* -- TOD primary/secondary master/slave control register -- */ +#define TOD_PSS_MSS_CTRL_REG 0x00000007 + +/* -- TOD primary/secondary master/slave status register -- */ +#define TOD_PSS_MSS_STATUS_REG 0x00000008 + +/* TOD chip XSCOM addresses */ +#define TOD_CHIP_CTRL_REG 0x00000010 /* Chip control reg */ + +#define TOD_TX_TTYPE_0_REG 0x00000011 +#define TOD_TX_TTYPE_1_REG 0x00000012 /* PSS switch reg */ +#define TOD_TX_TTYPE_2_REG 0x00000013 /* Enable step checkers= */ +#define TOD_TX_TTYPE_3_REG 0x00000014 /* Request TOD reg */ +#define TOD_TX_TTYPE_4_REG 0x00000015 /* Send TOD reg */ +#define TOD_TX_TTYPE_5_REG 0x00000016 /* Invalidate TOD reg */ + +#define TOD_MOVE_TOD_TO_TB_REG 0x00000017 +#define TOD_LOAD_TOD_MOD_REG 0x00000018 +#define TOD_LOAD_TOD_REG 0x00000021 +#define TOD_START_TOD_REG 0x00000022 +#define TOD_FSM_REG 0x00000024 + +#define TOD_TX_TTYPE_CTRL_REG 0x00000027 /* TX TTYPE Control reg= */ +#define TOD_TX_TTYPE_PIB_SLAVE_ADDR PPC_BITMASK(26, 31) + +/* -- TOD Error interrupt register -- */ +#define TOD_ERROR_REG 0x00000030 + +/* PC unit PIB address which recieves the timebase transfer from TOD */ +#define PC_TOD 0x4A3 + +/* + * The TOD FSM: + * - The reset state is 0 error. + * - A hardware error detected will transition to state 0 from any state. + * - LOAD_TOD_MOD and TTYPE5 will transition to state 7 from any state. + * + * | state | action | new | + * |------------+------------------------------+-----| + * | 0 error | LOAD_TOD_MOD | 7 | + * | 0 error | Recv TTYPE5 (invalidate TOD) | 7 | + * | 7 not_set | LOAD_TOD (bit-63 =3D 0) | 2 | + * | 7 not_set | LOAD_TOD (bit-63 =3D 1) | 1 | + * | 7 not_set | Recv TTYPE4 (send TOD) | 2 | + * | 2 running | | | + * | 1 stopped | START_TOD | 2 | + * + * Note the hardware has additional states but they relate to the sending + * and receiving and waiting on synchronisation signals between chips and + * are not described or modeled here. + */ + +static uint64_t pnv_chiptod_xscom_read(void *opaque, hwaddr addr, + unsigned size) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(opaque); + uint32_t offset =3D addr >> 3; + uint64_t val =3D 0; + + switch (offset) { + case TOD_PSS_MSS_STATUS_REG: + /* + * ChipTOD does not support configurations other than primary + * master, does not support errors, etc. + */ + val |=3D PPC_BITMASK(6, 10); /* STEP checker validity */ + val |=3D PPC_BIT(12); /* Primary config master path select */ + if (chiptod->tod_state =3D=3D tod_running) { + val |=3D PPC_BIT(20); /* Is running */ + } + val |=3D PPC_BIT(21); /* Is using primary config */ + val |=3D PPC_BIT(26); /* Is using master path select */ + + if (chiptod->primary) { + val |=3D PPC_BIT(23); /* Is active master */ + } else if (chiptod->secondary) { + val |=3D PPC_BIT(24); /* Is backup master */ + } else { + val |=3D PPC_BIT(25); /* Is slave (should backup master set th= is?) */ + } + break; + case TOD_PSS_MSS_CTRL_REG: + val =3D chiptod->pss_mss_ctrl_reg; + break; + case TOD_TX_TTYPE_CTRL_REG: + val =3D 0; + break; + case TOD_ERROR_REG: + val =3D chiptod->tod_error; + break; + case TOD_FSM_REG: + if (chiptod->tod_state =3D=3D tod_running) { + val |=3D PPC_BIT(4); + } + break; + default: + qemu_log_mask(LOG_UNIMP, "pnv_chiptod: unimplemented register: Ox%" + HWADDR_PRIx "\n", addr >> 3); + } + + trace_pnv_chiptod_xscom_read(addr >> 3, val); + + return val; +} + +static void chiptod_receive_ttype(PnvChipTOD *chiptod, uint32_t trigger) +{ + switch (trigger) { + case TOD_TX_TTYPE_4_REG: + if (chiptod->tod_state !=3D tod_not_set) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: received TTYPE4 i= n " + " state %d, should be in 7 (TOD_NOT_SET)\n", + chiptod->tod_state); + } else { + chiptod->tod_state =3D tod_running; + } + break; + case TOD_TX_TTYPE_5_REG: + /* Works from any state */ + chiptod->tod_state =3D tod_not_set; + break; + default: + qemu_log_mask(LOG_UNIMP, "pnv_chiptod: received unimplemented " + " TTYPE %u\n", trigger); + break; + } +} + +static void chiptod_power9_broadcast_ttype(PnvChipTOD *sender, + uint32_t trigger) +{ + PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); + int i; + + for (i =3D 0; i < pnv->num_chips; i++) { + Pnv9Chip *chip9 =3D PNV9_CHIP(pnv->chips[i]); + PnvChipTOD *chiptod =3D &chip9->chiptod; + + if (chiptod !=3D sender) { + chiptod_receive_ttype(chiptod, trigger); + } + } +} + +static void chiptod_power10_broadcast_ttype(PnvChipTOD *sender, + uint32_t trigger) +{ + PnvMachineState *pnv =3D PNV_MACHINE(qdev_get_machine()); + int i; + + for (i =3D 0; i < pnv->num_chips; i++) { + Pnv10Chip *chip10 =3D PNV10_CHIP(pnv->chips[i]); + PnvChipTOD *chiptod =3D &chip10->chiptod; + + if (chiptod !=3D sender) { + chiptod_receive_ttype(chiptod, trigger); + } + } +} + +static void pnv_chiptod_xscom_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(opaque); + PnvChipTODClass *pctc =3D PNV_CHIPTOD_GET_CLASS(chiptod); + uint32_t offset =3D addr >> 3; + + trace_pnv_chiptod_xscom_write(addr >> 3, val); + + switch (offset) { + case TOD_PSS_MSS_CTRL_REG: + /* Is this correct? */ + if (chiptod->primary) { + val |=3D PPC_BIT(1); /* TOD is master */ + } else { + val &=3D ~PPC_BIT(1); + } + val |=3D PPC_BIT(2); /* Drawer is master (don't simulate multi-dra= wer) */ + chiptod->pss_mss_ctrl_reg =3D val & PPC_BITMASK(0, 31); + break; + + case TOD_ERROR_REG: + chiptod->tod_error &=3D ~val; + break; + case TOD_LOAD_TOD_MOD_REG: + if (!(val & PPC_BIT(0))) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" + " TOD_LOAD_TOD_MOD_REG with bad val 0x%" PRIx64"= \n", + val); + } else { + chiptod->tod_state =3D tod_not_set; + } + break; + case TOD_LOAD_TOD_REG: + if (chiptod->tod_state !=3D tod_not_set) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: LOAD_TOG_REG in " + " state %d, should be in 7 (TOD_NOT_SET)\n", + chiptod->tod_state); + } else { + if (val & PPC_BIT(63)) { + chiptod->tod_state =3D tod_stopped; + } else { + chiptod->tod_state =3D tod_running; + } + } + break; + case TOD_START_TOD_REG: + if (chiptod->tod_state !=3D tod_stopped) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: LOAD_TOG_REG in " + " state %d, should be in 1 (TOD_STOPPED)\n", + chiptod->tod_state); + } else { + chiptod->tod_state =3D tod_running; + } + break; + case TOD_TX_TTYPE_4_REG: + case TOD_TX_TTYPE_5_REG: + pctc->broadcast_ttype(chiptod, offset); + break; + default: + qemu_log_mask(LOG_UNIMP, "pnv_chiptod: unimplemented register: Ox%" + HWADDR_PRIx "\n", addr >> 3); + } +} + +static const MemoryRegionOps pnv_chiptod_xscom_ops =3D { + .read =3D pnv_chiptod_xscom_read, + .write =3D pnv_chiptod_xscom_write, + .valid.min_access_size =3D 8, + .valid.max_access_size =3D 8, + .impl.min_access_size =3D 8, + .impl.max_access_size =3D 8, + .endianness =3D DEVICE_BIG_ENDIAN, +}; + +static int pnv_chiptod_dt_xscom(PnvXScomInterface *dev, void *fdt, + int xscom_offset, + const char compat[], size_t compat_size) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(dev); + g_autofree char *name =3D NULL; + int offset; + uint32_t chiptod_pcba =3D PNV9_XSCOM_CHIPTOD_BASE; + uint32_t reg[] =3D { + cpu_to_be32(chiptod_pcba), + cpu_to_be32(PNV9_XSCOM_CHIPTOD_SIZE) + }; + + name =3D g_strdup_printf("chiptod@%x", chiptod_pcba); + offset =3D fdt_add_subnode(fdt, xscom_offset, name); + _FDT(offset); + + if (chiptod->primary) { + _FDT((fdt_setprop(fdt, offset, "primary", NULL, 0))); + } else if (chiptod->secondary) { + _FDT((fdt_setprop(fdt, offset, "secondary", NULL, 0))); + } + + _FDT((fdt_setprop(fdt, offset, "reg", reg, sizeof(reg)))); + _FDT((fdt_setprop(fdt, offset, "compatible", compat, compat_size))); + return 0; +} + +static int pnv_chiptod_power9_dt_xscom(PnvXScomInterface *dev, void *fdt, + int xscom_offset) +{ + const char compat[] =3D "ibm,power-chiptod\0ibm,power9-chiptod"; + + return pnv_chiptod_dt_xscom(dev, fdt, xscom_offset, compat, sizeof(com= pat)); +} + +static Property pnv_chiptod_properties[] =3D { + DEFINE_PROP_BOOL("primary", PnvChipTOD, primary, false), + DEFINE_PROP_BOOL("secondary", PnvChipTOD, secondary, false), + DEFINE_PROP_LINK("chip", PnvChipTOD , chip, TYPE_PNV_CHIP, PnvChip *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void pnv_chiptod_power9_class_init(ObjectClass *klass, void *data) +{ + PnvChipTODClass *pctc =3D PNV_CHIPTOD_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + PnvXScomInterfaceClass *xdc =3D PNV_XSCOM_INTERFACE_CLASS(klass); + + dc->desc =3D "PowerNV ChipTOD Controller (POWER9)"; + device_class_set_props(dc, pnv_chiptod_properties); + + xdc->dt_xscom =3D pnv_chiptod_power9_dt_xscom; + + pctc->broadcast_ttype =3D chiptod_power9_broadcast_ttype; + + pctc->xscom_size =3D PNV_XSCOM_CHIPTOD_SIZE; +} + +static const TypeInfo pnv_chiptod_power9_type_info =3D { + .name =3D TYPE_PNV9_CHIPTOD, + .parent =3D TYPE_PNV_CHIPTOD, + .instance_size =3D sizeof(PnvChipTOD), + .class_init =3D pnv_chiptod_power9_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_PNV_XSCOM_INTERFACE }, + { } + } +}; + +static int pnv_chiptod_power10_dt_xscom(PnvXScomInterface *dev, void *fdt, + int xscom_offset) +{ + const char compat[] =3D "ibm,power-chiptod\0ibm,power10-chiptod"; + + return pnv_chiptod_dt_xscom(dev, fdt, xscom_offset, compat, sizeof(com= pat)); +} + +static void pnv_chiptod_power10_class_init(ObjectClass *klass, void *data) +{ + PnvChipTODClass *pctc =3D PNV_CHIPTOD_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + PnvXScomInterfaceClass *xdc =3D PNV_XSCOM_INTERFACE_CLASS(klass); + + dc->desc =3D "PowerNV ChipTOD Controller (POWER10)"; + device_class_set_props(dc, pnv_chiptod_properties); + + xdc->dt_xscom =3D pnv_chiptod_power10_dt_xscom; + + pctc->broadcast_ttype =3D chiptod_power10_broadcast_ttype; + + pctc->xscom_size =3D PNV_XSCOM_CHIPTOD_SIZE; +} + +static const TypeInfo pnv_chiptod_power10_type_info =3D { + .name =3D TYPE_PNV10_CHIPTOD, + .parent =3D TYPE_PNV_CHIPTOD, + .instance_size =3D sizeof(PnvChipTOD), + .class_init =3D pnv_chiptod_power10_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_PNV_XSCOM_INTERFACE }, + { } + } +}; + +static void pnv_chiptod_reset(void *dev) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(dev); + + chiptod->pss_mss_ctrl_reg =3D 0; + if (chiptod->primary) { + chiptod->pss_mss_ctrl_reg |=3D PPC_BIT(1); /* TOD is master */ + } + /* Drawer is master (we do not simulate multi-drawer) */ + chiptod->pss_mss_ctrl_reg |=3D PPC_BIT(2); + + chiptod->tod_error =3D 0; + chiptod->tod_state =3D tod_error; +} + +static void pnv_chiptod_realize(DeviceState *dev, Error **errp) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(dev); + PnvChipTODClass *pctc =3D PNV_CHIPTOD_GET_CLASS(chiptod); + + /* XScom regions for ChipTOD registers */ + pnv_xscom_region_init(&chiptod->xscom_regs, OBJECT(dev), + &pnv_chiptod_xscom_ops, chiptod, "xscom-chiptod", + pctc->xscom_size); + + qemu_register_reset(pnv_chiptod_reset, chiptod); +} + +static void pnv_chiptod_unrealize(DeviceState *dev) +{ + PnvChipTOD *chiptod =3D PNV_CHIPTOD(dev); + + qemu_unregister_reset(pnv_chiptod_reset, chiptod); +} + +static void pnv_chiptod_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D pnv_chiptod_realize; + dc->unrealize =3D pnv_chiptod_unrealize; + dc->desc =3D "PowerNV ChipTOD Controller"; + dc->user_creatable =3D false; +} + +static const TypeInfo pnv_chiptod_type_info =3D { + .name =3D TYPE_PNV_CHIPTOD, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(PnvChipTOD), + .class_init =3D pnv_chiptod_class_init, + .class_size =3D sizeof(PnvChipTODClass), + .abstract =3D true, +}; + +static void pnv_chiptod_register_types(void) +{ + type_register_static(&pnv_chiptod_type_info); + type_register_static(&pnv_chiptod_power9_type_info); + type_register_static(&pnv_chiptod_power10_type_info); +} + +type_init(pnv_chiptod_register_types); diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build index ea44856d43..b1f4e65d24 100644 --- a/hw/ppc/meson.build +++ b/hw/ppc/meson.build @@ -46,6 +46,7 @@ ppc_ss.add(when: 'CONFIG_POWERNV', if_true: files( 'pnv_i2c.c', 'pnv_lpc.c', 'pnv_psi.c', + 'pnv_chiptod.c', 'pnv_occ.c', 'pnv_sbe.c', 'pnv_bmc.c', diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index f670e8906c..57c4f265ef 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -95,6 +95,10 @@ vof_write(uint32_t ih, unsigned cb, const char *msg) "ih= =3D0x%x [%u] \"%s\"" vof_avail(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"P= RIx64" size=3D0x%"PRIx64 vof_claimed(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%= "PRIx64" size=3D0x%"PRIx64 =20 +# pnv_chiptod.c +pnv_chiptod_xscom_read(uint64_t addr, uint64_t val) "addr 0x%" PRIx64 " va= l 0x%" PRIx64 +pnv_chiptod_xscom_write(uint64_t addr, uint64_t val) "addr 0x%" PRIx64 " v= al 0x%" PRIx64 + # pnv_sbe.c pnv_sbe_xscom_ctrl_read(uint64_t addr, uint64_t val) "addr 0x%" PRIx64 " v= al 0x%" PRIx64 pnv_sbe_xscom_ctrl_write(uint64_t addr, uint64_t val) "addr 0x%" PRIx64 " = val 0x%" PRIx64 --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433118; cv=none; d=zohomail.com; s=zohoarc; b=VKzWebuF7klsUkdSLVGEU0EfbRh/Co0QNJXCzXaeiH8miBMwJq6VpzSjAVeFSVr6+D6AiEieQzccSrjHeFqK9odTLRsL9kvQKrgBHYnPsw4qhG4cjRbZuvH+gjPo1+pZe4KE1zDn5jbxODArddlFgdnJks4IMHUZ67N9SX7XBfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433118; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qtHGRZF6+qlNeXTS0wG4HtUh3/2nP9FjM8yjvGmOaek=; b=WsRRftBjhlpn5sar+xiZdoxaTcSl60Zudo5Lb6olqBOKFW5AvCCgiqoWJgnSzI73vnN8ohsIfWAu7+OvAGl8OSIiKMINzO80W3+YHW61UjQUy4Msfs93yFYhgOH9yLtvhMcsUKKkaEScjyREOp83FGVuLdRKdz7T97jUgxRMKEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433118197181.62001674586497; Fri, 1 Dec 2023 04:18:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92T9-00065O-D6; Fri, 01 Dec 2023 07:18:07 -0500 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 1r92SB-0005Yi-9H; Fri, 01 Dec 2023 07:17:11 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92S9-0006Mx-6u; Fri, 01 Dec 2023 07:17:07 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cddc59e731so1864034b3a.1; Fri, 01 Dec 2023 04:17:04 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433023; x=1702037823; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qtHGRZF6+qlNeXTS0wG4HtUh3/2nP9FjM8yjvGmOaek=; b=iGba2KdnO2dGI+u4O/WFHeqQWT12kp3a/1G9xPWNOfeUe+u5ab0TvfHPw7ohE026+J Jj7pr8T9Ym8CBO8+85XxI5sdd7NaKUUa5LaO45jeDPn9sGVWM9ZB11f1ef3p5KEaJbDE vbEwzXlJ7Nmza0P5oa2B7KmiXNgf8GLW+MzDkhMv2zg3EooiqZWBAyz/Ztc2AiIz4HAg JlcvpC0BeJLzxy2+R3Bv6rXqp/0VY/YoaxDBaH6psHc9ffItr6zASPhNs6MnuhEBwxi6 CEpQn68qyRMZ6LlKHGg7GOlM3cRH7oTRh0NV3oa6t7Pm6oy3x9hON5y6rThPKJpjJ/gQ pO2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433023; x=1702037823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qtHGRZF6+qlNeXTS0wG4HtUh3/2nP9FjM8yjvGmOaek=; b=usoAHoFT3Zsx5PA8vKfj+IsvjJex8xppW2PYEtfaIgtfYqo+9d1OBPxY1dMqihc8tn fs9NLfYo+221sYe8N8drZx7O1bwx8MadjTE9vXHh8BLBMp6dnJlSC5BPjPOLkE7LZmA2 u3duC2IXPJDjDFl5fW9lEdRSImG2fcbwCV8iThovBQCvuGANbEYJuLA3T9BdtSEKW2SJ AWw5ytu7iStqM6fPU8+8lDyVQtQx7A33o8GjyhmaRHyyFdMa8gAsgDZhwGEP6cpl8chE eJprQZUK2Eth3I++oiEg5Y4u2GF+ZRkXnHdUo64jy54gXFd0Fxl279yTVAAUAvpUeR3g ExsA== X-Gm-Message-State: AOJu0YzdfPR33WnfJofDWPI0mI8E00zmmuTZTTwTQLv06rBa5hGuo+Zk vidff10L06d1avT9f3vdFbS00bsSYH8= X-Google-Smtp-Source: AGHT+IHi+6v8ZS1UcqqB4TX3k8mfteN4NzDffpSWzINYpG8XU8QuREfc7oEDtpE5t7Or5X0pUKPrNA== X-Received: by 2002:a05:6a00:e17:b0:6cb:8beb:15dc with SMTP id bq23-20020a056a000e1700b006cb8beb15dcmr24344059pfb.30.1701433022767; Fri, 01 Dec 2023 04:17:02 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 5/8] ppc/pnv: Wire ChipTOD model to powernv9 and powernv10 machines Date: Fri, 1 Dec 2023 22:16:33 +1000 Message-ID: <20231201121636.142694-6-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433119281000003 Wire the ChipTOD model to powernv9 and powernv10 machines. Suggested-by-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- include/hw/ppc/pnv_chip.h | 3 +++ hw/ppc/pnv.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/hw/ppc/pnv_chip.h b/include/hw/ppc/pnv_chip.h index 0ab5c42308..bfc4772cf3 100644 --- a/include/hw/ppc/pnv_chip.h +++ b/include/hw/ppc/pnv_chip.h @@ -2,6 +2,7 @@ #define PPC_PNV_CHIP_H =20 #include "hw/pci-host/pnv_phb4.h" +#include "hw/ppc/pnv_chiptod.h" #include "hw/ppc/pnv_core.h" #include "hw/ppc/pnv_homer.h" #include "hw/ppc/pnv_lpc.h" @@ -78,6 +79,7 @@ struct Pnv9Chip { PnvXive xive; Pnv9Psi psi; PnvLpcController lpc; + PnvChipTOD chiptod; PnvOCC occ; PnvSBE sbe; PnvHomer homer; @@ -110,6 +112,7 @@ struct Pnv10Chip { PnvXive2 xive; Pnv9Psi psi; PnvLpcController lpc; + PnvChipTOD chiptod; PnvOCC occ; PnvSBE sbe; PnvHomer homer; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index b949398689..d38888cb76 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1419,6 +1419,8 @@ static void pnv_chip_power9_instance_init(Object *obj) =20 object_initialize_child(obj, "lpc", &chip9->lpc, TYPE_PNV9_LPC); =20 + object_initialize_child(obj, "chiptod", &chip9->chiptod, TYPE_PNV9_CHI= PTOD); + object_initialize_child(obj, "occ", &chip9->occ, TYPE_PNV9_OCC); =20 object_initialize_child(obj, "sbe", &chip9->sbe, TYPE_PNV9_SBE); @@ -1565,6 +1567,19 @@ static void pnv_chip_power9_realize(DeviceState *dev= , Error **errp) chip->dt_isa_nodename =3D g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0= ", (uint64_t) PNV9_LPCM_BASE(chip= )); =20 + /* ChipTOD */ + object_property_set_bool(OBJECT(&chip9->chiptod), "primary", + chip->chip_id =3D=3D 0, &error_abort); + object_property_set_bool(OBJECT(&chip9->chiptod), "secondary", + chip->chip_id =3D=3D 1, &error_abort); + object_property_set_link(OBJECT(&chip9->chiptod), "chip", OBJECT(chip), + &error_abort); + if (!qdev_realize(DEVICE(&chip9->chiptod), NULL, errp)) { + return; + } + pnv_xscom_add_subregion(chip, PNV9_XSCOM_CHIPTOD_BASE, + &chip9->chiptod.xscom_regs); + /* Create the simplified OCC model */ if (!qdev_realize(DEVICE(&chip9->occ), NULL, errp)) { return; @@ -1677,6 +1692,8 @@ static void pnv_chip_power10_instance_init(Object *ob= j) "xive-fabric"); object_initialize_child(obj, "psi", &chip10->psi, TYPE_PNV10_PSI); object_initialize_child(obj, "lpc", &chip10->lpc, TYPE_PNV10_LPC); + object_initialize_child(obj, "chiptod", &chip10->chiptod, + TYPE_PNV10_CHIPTOD); object_initialize_child(obj, "occ", &chip10->occ, TYPE_PNV10_OCC); object_initialize_child(obj, "sbe", &chip10->sbe, TYPE_PNV10_SBE); object_initialize_child(obj, "homer", &chip10->homer, TYPE_PNV10_HOMER= ); @@ -1810,6 +1827,19 @@ static void pnv_chip_power10_realize(DeviceState *de= v, Error **errp) chip->dt_isa_nodename =3D g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0= ", (uint64_t) PNV10_LPCM_BASE(chi= p)); =20 + /* ChipTOD */ + object_property_set_bool(OBJECT(&chip10->chiptod), "primary", + chip->chip_id =3D=3D 0, &error_abort); + object_property_set_bool(OBJECT(&chip10->chiptod), "secondary", + chip->chip_id =3D=3D 1, &error_abort); + object_property_set_link(OBJECT(&chip10->chiptod), "chip", OBJECT(chip= ), + &error_abort); + if (!qdev_realize(DEVICE(&chip10->chiptod), NULL, errp)) { + return; + } + pnv_xscom_add_subregion(chip, PNV10_XSCOM_CHIPTOD_BASE, + &chip10->chiptod.xscom_regs); + /* Create the simplified OCC model */ if (!qdev_realize(DEVICE(&chip10->occ), NULL, errp)) { return; --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433103; cv=none; d=zohomail.com; s=zohoarc; b=ioUUIdnsg4967c7m45gbO28k5GfE/L6DHPoGj9PeZ206GfFGDmtbg2DRk0znZSVPPWeDsW3la/MCU9rRt0uba2l4+/8xJ6kthwdJBTC8bDUJLxmu+fivZ4AbssxmtRNz24Mg9kv51qvqRKz9YH8roPSt+YNyFXRxq6jaq3FjJyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433103; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p4v8ZIiGztILWDGHIIVOnHmTEak2FIEKJKdyszNhPIU=; b=hdUlCu7T3bgx+brApUUXpaweXmieHOx7KRYeKMTGZFMNBSBfBl0lUVLQQRJCjVvJWmTS87hBrIuKCoaCyLaKeSTCE8yY26ty7fVwZEO0XT5aQOHVEFTSZJxnpiNWmoQUc6I1d++XAZ/AQrnlVY3aBMhtvpr/H9MBJYloSG4RhxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433103482412.13773777623396; Fri, 1 Dec 2023 04:18:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92Sx-0005vT-8O; Fri, 01 Dec 2023 07:17:56 -0500 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 1r92SE-0005ZE-L4; Fri, 01 Dec 2023 07:17:14 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92SC-0006Nq-Ez; Fri, 01 Dec 2023 07:17:10 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6cdfb72172aso751125b3a.1; Fri, 01 Dec 2023 04:17:07 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433026; x=1702037826; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p4v8ZIiGztILWDGHIIVOnHmTEak2FIEKJKdyszNhPIU=; b=R1McLk9P68JNwhiJiBLlUWhPKvatzbajFsmUIaSBDj0exdSjC36dmy87TW7ux2SMUe RM3L5/HzEPVce6kQt251xJX6WiHo8yAOtHO+ocdnwGnjAH0KmzkRUXSGTr9yIhB69uhV 3WufkoaUVKFCgzoRr23P+OgX/L42iIVVisKNNWE358sEry5lsIlyKbDtr+X76rjcUVRc 03tz4hcYo9K9yOLI2CIr1y7GIHcXckk11S3Wa/IXOehryXGG/elO7bbEkMCW6kcZRvvF YznwhpNETIZENUjdgXcR6cWcji4I0wMtWZ0/C4iVqMOg0fiViknAkztbTFRipB8s4NU5 KH5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433026; x=1702037826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p4v8ZIiGztILWDGHIIVOnHmTEak2FIEKJKdyszNhPIU=; b=bIvowglfi2Qc9FCj1pExZZFw/Up3dSUtA41sNQVe8kHQ/IQ7RnvnuGg9Sji/9sX5Sc 5m/ohy5iDA4HJfJ78mGZtsHaesG5mnBx5ZRG2AJejkF/1OilPLLi7V/V+Xf75uPNXwu4 YTSizXYjHpmpS2J+ZHHY+bAcoI54S7oZR4nr0BvECIkKttqwB1waFd0Uu5CExKCyiMJh oXtD/MnkaHAuOkSKpllcpsegPARuBerBeESe9pr9v7+57q0PVCuvzmkPgE0Nnyym4RHO yqZ90m9Jmve9/npD76pA8zRq8FI0Kvng81GZjvrmZ5mtFcz3nmQV4+xqJghaFUIVHavh 4Jfw== X-Gm-Message-State: AOJu0YyqYfE7mGo2JiXYvPbmi8Fnt5j1/wdLC7E4/4L2c4VEEDV9iBIq 484lkv48yQ3tb4eTf9VvATqC4+vgvQA= X-Google-Smtp-Source: AGHT+IHIpGZOZR3E+bfYYPa/jUHGenIF/DQ06giS1trvR7eaP8zohhPsi6+EtPo/5nEdztYTyZqCUQ== X-Received: by 2002:a05:6a21:3989:b0:186:ae16:103 with SMTP id ad9-20020a056a21398900b00186ae160103mr25397758pzc.30.1701433026230; Fri, 01 Dec 2023 04:17:06 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 6/8] pnv/chiptod: Implement the ChipTOD to Core transfer Date: Fri, 1 Dec 2023 22:16:34 +1000 Message-ID: <20231201121636.142694-7-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=npiggin@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433105265000003 One of the functions of the ChipTOD is to transfer TOD to the Core (aka PC - Pervasive Core) timebase facility. The ChipTOD can be programmed with a target address to send the TOD value to. The hardware implementation seems to perform this by sending the TOD value to a SCOM address. This implementation grabs the core directly and manipulates the timebase facility state in the core. This is a hack, but it works enough for now. A better implementation would implement the transfer to the PnvCore xscom register and drive the timebase state machine from there. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- include/hw/ppc/pnv.h | 2 + include/hw/ppc/pnv_chiptod.h | 4 ++ target/ppc/cpu.h | 13 ++++ hw/ppc/pnv.c | 15 ++++ hw/ppc/pnv_chiptod.c | 132 +++++++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 7e5fef7c43..005048d207 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -28,6 +28,7 @@ =20 #define TYPE_PNV_CHIP "pnv-chip" =20 +typedef struct PnvCore PnvCore; typedef struct PnvChip PnvChip; typedef struct Pnv8Chip Pnv8Chip; typedef struct Pnv9Chip Pnv9Chip; @@ -56,6 +57,7 @@ DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER9, DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER10, TYPE_PNV_CHIP_POWER10) =20 +PnvCore *pnv_chip_find_core(PnvChip *chip, uint32_t core_id); PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir); =20 typedef struct PnvPHB PnvPHB; diff --git a/include/hw/ppc/pnv_chiptod.h b/include/hw/ppc/pnv_chiptod.h index ca770525d9..fde569bcbf 100644 --- a/include/hw/ppc/pnv_chiptod.h +++ b/include/hw/ppc/pnv_chiptod.h @@ -25,6 +25,8 @@ enum tod_state { tod_stopped =3D 1, }; =20 +typedef struct PnvCore PnvCore; + struct PnvChipTOD { DeviceState xd; =20 @@ -36,12 +38,14 @@ struct PnvChipTOD { enum tod_state tod_state; uint64_t tod_error; uint64_t pss_mss_ctrl_reg; + PnvCore *slave_pc_target; }; =20 struct PnvChipTODClass { DeviceClass parent_class; =20 void (*broadcast_ttype)(PnvChipTOD *sender, uint32_t trigger); + PnvCore *(*tx_ttype_target)(PnvChipTOD *chiptod, uint64_t val); =20 int xscom_size; }; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 848e583c2d..87a6b720f4 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1183,6 +1183,13 @@ DEXCR_ASPECT(SRAPD, 4) DEXCR_ASPECT(NPHIE, 5) DEXCR_ASPECT(PHIE, 6) =20 +/*************************************************************************= ****/ +/* PowerNV ChipTOD and TimeBase State Machine */ +struct pnv_tod_tbst { + int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ + int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ +}; + /*************************************************************************= ****/ /* The whole PowerPC CPU context */ =20 @@ -1258,6 +1265,12 @@ struct CPUArchState { uint32_t tlb_need_flush; /* Delayed flush needed */ #define TLB_NEED_LOCAL_FLUSH 0x1 #define TLB_NEED_GLOBAL_FLUSH 0x2 + +#if defined (TARGET_PPC64) + /* PowerNV chiptod / timebase facility state. */ + /* Would be nice to put these into PnvCore */ + struct pnv_tod_tbst pnv_tod_tbst; +#endif #endif =20 /* Other registers */ diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d38888cb76..0ddc0008f5 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2065,6 +2065,21 @@ static void pnv_chip_class_init(ObjectClass *klass, = void *data) dc->desc =3D "PowerNV Chip"; } =20 +PnvCore *pnv_chip_find_core(PnvChip *chip, uint32_t core_id) +{ + int i; + + for (i =3D 0; i < chip->nr_cores; i++) { + PnvCore *pc =3D chip->cores[i]; + CPUCore *cc =3D CPU_CORE(pc); + + if (cc->core_id =3D=3D core_id) { + return pc; + } + } + return NULL; +} + PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir) { int i, j; diff --git a/hw/ppc/pnv_chiptod.c b/hw/ppc/pnv_chiptod.c index 6ac3eac9d0..3831a72101 100644 --- a/hw/ppc/pnv_chiptod.c +++ b/hw/ppc/pnv_chiptod.c @@ -210,6 +210,79 @@ static void chiptod_power10_broadcast_ttype(PnvChipTOD= *sender, } } =20 +static PnvCore *pnv_chip_get_core_by_xscom_base(PnvChip *chip, + uint32_t xscom_base) +{ + PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); + int i; + + for (i =3D 0; i < chip->nr_cores; i++) { + PnvCore *pc =3D chip->cores[i]; + CPUCore *cc =3D CPU_CORE(pc); + int core_hwid =3D cc->core_id; + + if (pcc->xscom_core_base(chip, core_hwid) =3D=3D xscom_base) { + return pc; + } + } + return NULL; +} + +static PnvCore *chiptod_power9_tx_ttype_target(PnvChipTOD *chiptod, + uint64_t val) +{ + /* + * skiboot uses Core ID for P9, though SCOM should work too. + */ + if (val & PPC_BIT(35)) { /* SCOM addressing */ + uint32_t addr =3D val >> 32; + uint32_t reg =3D addr & 0xfff; + + if (reg !=3D PC_TOD) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: SCOM addressing: " + "unimplemented slave register 0x%" PRIx32 "\n", = reg); + return NULL; + } + + return pnv_chip_get_core_by_xscom_base(chiptod->chip, addr & ~0xff= f); + + } else { /* Core ID addressing */ + uint32_t core_id =3D GETFIELD(TOD_TX_TTYPE_PIB_SLAVE_ADDR, val) & = 0x1f; + return pnv_chip_find_core(chiptod->chip, core_id); + } +} + +static PnvCore *chiptod_power10_tx_ttype_target(PnvChipTOD *chiptod, + uint64_t val) +{ + /* + * skiboot uses SCOM for P10 because Core ID was unable to be made to + * work correctly. For this reason only SCOM addressing is implemented. + */ + if (val & PPC_BIT(35)) { /* SCOM addressing */ + uint32_t addr =3D val >> 32; + uint32_t reg =3D addr & 0xfff; + + if (reg !=3D PC_TOD) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: SCOM addressing: " + "unimplemented slave register 0x%" PRIx32 "\n", = reg); + return NULL; + } + + /* + * This may not deal with P10 big-core addressing at the moment. + * The big-core code in skiboot syncs small cores, but it targets + * the even PIR (first small-core) when syncing second small-core. + */ + return pnv_chip_get_core_by_xscom_base(chiptod->chip, addr & ~0xff= f); + + } else { /* Core ID addressing */ + qemu_log_mask(LOG_UNIMP, "pnv_chiptod: TX TTYPE Core ID " + "addressing is not implemented for POWER10\n"); + return NULL; + } +} + static void pnv_chiptod_xscom_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { @@ -231,6 +304,22 @@ static void pnv_chiptod_xscom_write(void *opaque, hwad= dr addr, chiptod->pss_mss_ctrl_reg =3D val & PPC_BITMASK(0, 31); break; =20 + case TOD_TX_TTYPE_CTRL_REG: + /* + * This register sets the target of the TOD value transfer initiat= ed + * by TOD_MOVE_TOD_TO_TB. The TOD is able to send the address to + * any target register, though in practice only the PC TOD register + * should be used. ChipTOD has a "SCOM addressing" mode which fully + * specifies the SCOM address, and a core-ID mode which uses the + * core ID to target the PC TOD for a given core. + */ + chiptod->slave_pc_target =3D pctc->tx_ttype_target(chiptod, val); + if (!chiptod->slave_pc_target) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" + " TOD_TX_TTYPE_CTRL_REG val 0x%" PRIx64 + " invalid slave address\n", val); + } + break; case TOD_ERROR_REG: chiptod->tod_error &=3D ~val; break; @@ -256,6 +345,47 @@ static void pnv_chiptod_xscom_write(void *opaque, hwad= dr addr, } } break; + + case TOD_MOVE_TOD_TO_TB_REG: + /* + * XXX: it should be a cleaner model to have this drive a SCOM + * transaction to the target address, and implement the state mach= ine + * in the PnvCore. For now, this hack makes things work. + */ + if (chiptod->tod_state !=3D tod_running) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" + " TOD_MOVE_TOD_TO_TB_REG in bad state %d\n", + chiptod->tod_state); + } else if (!(val & PPC_BIT(0))) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" + " TOD_MOVE_TOD_TO_TB_REG with bad val 0x%" PRIx6= 4"\n", + val); + } else if (chiptod->slave_pc_target =3D=3D NULL) { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write reg" + " TOD_MOVE_TOD_TO_TB_REG with no slave target\n"= ); + } else { + PowerPCCPU *cpu =3D chiptod->slave_pc_target->threads[0]; + CPUPPCState *env =3D &cpu->env; + + /* + * Moving TOD to TB will set the TB of all threads in a + * core, so skiboot only does this once per thread0, so + * that is where we keep the timebase state machine. + * + * It is likely possible for TBST to be driven from other + * threads in the core, but for now we only implement it for + * thread 0. + */ + + if (env->pnv_tod_tbst.tb_ready_for_tod) { + env->pnv_tod_tbst.tod_sent_to_tb =3D 1; + } else { + qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: xscom write r= eg" + " TOD_MOVE_TOD_TO_TB_REG with TB not ready t= o" + " receive TOD\n"); + } + } + break; case TOD_START_TOD_REG: if (chiptod->tod_state !=3D tod_stopped) { qemu_log_mask(LOG_GUEST_ERROR, "pnv_chiptod: LOAD_TOG_REG in " @@ -340,6 +470,7 @@ static void pnv_chiptod_power9_class_init(ObjectClass *= klass, void *data) xdc->dt_xscom =3D pnv_chiptod_power9_dt_xscom; =20 pctc->broadcast_ttype =3D chiptod_power9_broadcast_ttype; + pctc->tx_ttype_target =3D chiptod_power9_tx_ttype_target; =20 pctc->xscom_size =3D PNV_XSCOM_CHIPTOD_SIZE; } @@ -375,6 +506,7 @@ static void pnv_chiptod_power10_class_init(ObjectClass = *klass, void *data) xdc->dt_xscom =3D pnv_chiptod_power10_dt_xscom; =20 pctc->broadcast_ttype =3D chiptod_power10_broadcast_ttype; + pctc->tx_ttype_target =3D chiptod_power10_tx_ttype_target; =20 pctc->xscom_size =3D PNV_XSCOM_CHIPTOD_SIZE; } --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433170; cv=none; d=zohomail.com; s=zohoarc; b=h/xqT/WV42X+GtdaG9I/UnRx5uXbEAQ6cEhHcI8F8u2yrlOlRWXeEA8ixKkk5Rhd2twe1dVJo9f7CNFJ32M9UHY9PN9j3Akm+5MXhOqm7YOfIEAh6YNQophY5pOQj4cf2uURKV+gYHEoZq7a2LEVBMds7LR5VANklzWfNrcgc/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433170; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d4fmWfFJUU2wqj42pGTu3PZsHuJqb1f7yCNTxZGW2ZY=; b=et/3c98kuG++oCYiVFTmy8vJJqUtgtLXDZgEj4otO5uTXwC1H+MOan/l74T8FvIaEagYcMIkn2AkBUzI8ijmtQuzZ4/QY46IfaMYXRPQgD297ic8/kniU0uQLxwJNocm8ThNLhrlVd5yRkBjxdkdsDZVdSCmLvvmz/9mNLp4G6Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433170548598.1604555168093; Fri, 1 Dec 2023 04:19:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92TA-00069m-NP; Fri, 01 Dec 2023 07:18:08 -0500 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 1r92SJ-0005aq-FL; Fri, 01 Dec 2023 07:17:16 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92SH-0006Oc-0z; Fri, 01 Dec 2023 07:17:14 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cdde2aeb64so1947257b3a.2; Fri, 01 Dec 2023 04:17:11 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:17:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433029; x=1702037829; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d4fmWfFJUU2wqj42pGTu3PZsHuJqb1f7yCNTxZGW2ZY=; b=l8uZFrifZ13qKFlCSYFaOGvLerlFUnK394lqefMMYKAqw1AC7zaAeYZyvuc3AIKdbn yJluQvvu56evuw2iKWngjLGqrDzfbtEmT176A/XR+t4qtryVS+CpoEMzOPwJDR4LR1bq QSPO9P3ZO60PrXAA3WLRE08J54oBwCkue791wy8eYUeg47qctcvoC7bBjsdLp9LQOX8I ZWgjjIYWQsmP1lBvNQwkG3+rrPm+kJeBEQ4grIdCOmyLWksSBAas/WNHtm+P9lzondQ6 UFBU5zDmHocA+IBiLhTH6eFdlRqUGMhqSTK5NI+FE/SU7nOMndvplL2XkJxDadm9+1QT l1bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433029; x=1702037829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d4fmWfFJUU2wqj42pGTu3PZsHuJqb1f7yCNTxZGW2ZY=; b=IctJbagmWhGsiv6ZS6qlR+i+veFYktnzAzbiUcWncXUrvvrs/jzeBxnw4/cZHW+cI4 1hGvruOeNoQ3YyXXVqjf3i9Jc487Rz18PAlPXSCvFLr5NX17fkemwaAMacjXkhehvbp6 VfDFpmUcoJ6s2Da6DowEwqvXDEJgWWt7aYqCz8rjnuN3GjsC2SDOKS8+vqiCfIibedbe 0/OzjBDtJ6yXzpv8tXjJxRMoDyd2rwqGwG8EnDL2p3AYgKwaGdonR1uQKcrQqaTPcs7q Ds7CWsEZdZ+9K9XM5bOEjTOd4Tv92J4DteFmdFLAvH3pJf1WjJUkVmnsO0hLWtRKLog4 OJxQ== X-Gm-Message-State: AOJu0Yys0e/DcQZ610Qd8vOho7qqwjLLRICODDacN62f6qWrouxMVCqS NiTvUzCpjeooIWPdSBkO4ttkBWcDQso= X-Google-Smtp-Source: AGHT+IFZr5qtokxwhWbi7ijlEuXaCzSKNOQfJ80WZ94pnq8wuPycCyRol4geeC1ebSMWliVMc3Q/VA== X-Received: by 2002:a05:6a00:8ce:b0:6c3:1b7d:ecee with SMTP id s14-20020a056a0008ce00b006c31b7deceemr32551023pfu.15.1701433029617; Fri, 01 Dec 2023 04:17:09 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 7/8] target/ppc: Implement core timebase state machine and TFMR Date: Fri, 1 Dec 2023 22:16:35 +1000 Message-ID: <20231201121636.142694-8-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433171478000001 This implements the core timebase state machine, which is the core side of the time-of-day system in POWER processors. This facility is operated by control fields in the TFMR register, which also contains status fields. The core timebase interacts with the chiptod hardware, primarily to receive TOD updates, to synchronise timebase with other cores. This model does not actually update TB values with TOD or updates received from the chiptod, as timebases are always synchronised. It does step through the states required to perform the update. There are several asynchronous state transitions. These are modelled using using mfTFMR to drive state changes, because it is expected that firmware poll the register to wait for those states. This is good enough to test basic firmware behaviour without adding real timers. The values chosen are arbitrary. Acked-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- target/ppc/cpu.h | 36 ++++++ target/ppc/timebase_helper.c | 210 ++++++++++++++++++++++++++++++++++- 2 files changed, 243 insertions(+), 3 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 87a6b720f4..ebc663b914 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1188,6 +1188,14 @@ DEXCR_ASPECT(PHIE, 6) struct pnv_tod_tbst { int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ + + /* + * "Timers" for async TBST events are simulated by mfTFAC because TFAC + * is polled for such events. These are just used to ensure firmware + * performs the polling at least a few times. + */ + int tb_state_timer; + int tb_sync_pulse_timer; }; =20 /*************************************************************************= ****/ @@ -2661,6 +2669,34 @@ enum { HMER_XSCOM_STATUS_MASK =3D PPC_BITMASK(21, 23), }; =20 +/* TFMR */ +enum { + TFMR_CONTROL_MASK =3D PPC_BITMASK(0, 24), + TFMR_MASK_HMI =3D PPC_BIT(10), + TFMR_TB_ECLIPZ =3D PPC_BIT(14), + TFMR_LOAD_TOD_MOD =3D PPC_BIT(16), + TFMR_MOVE_CHIP_TOD_TO_TB =3D PPC_BIT(18), + TFMR_CLEAR_TB_ERRORS =3D PPC_BIT(24), + TFMR_STATUS_MASK =3D PPC_BITMASK(25, 63), + TFMR_TBST_ENCODED =3D PPC_BITMASK(28, 31), /* TBST =3D TB St= ate */ + TFMR_TBST_LAST =3D PPC_BITMASK(32, 35), /* Previous TBST = */ + TFMR_TB_ENABLED =3D PPC_BIT(40), + TFMR_TB_VALID =3D PPC_BIT(41), + TFMR_TB_SYNC_OCCURED =3D PPC_BIT(42), + TFMR_FIRMWARE_CONTROL_ERROR =3D PPC_BIT(46), +}; + +/* TFMR TBST (Time Base State Machine). */ +enum { + TBST_RESET =3D 0x0, + TBST_SEND_TOD_MOD =3D 0x1, + TBST_NOT_SET =3D 0x2, + TBST_SYNC_WAIT =3D 0x6, + TBST_GET_TOD =3D 0x7, + TBST_TB_RUNNING =3D 0x8, + TBST_TB_ERROR =3D 0x9, +}; + /*************************************************************************= ****/ =20 #define is_isa300(ctx) (!!(ctx->insns_flags2 & PPC2_ISA300)) diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index 08a6b47ee0..bc1d54a427 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" +#include "hw/ppc/ppc.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "qemu/log.h" @@ -145,15 +146,218 @@ void helper_store_booke_tsr(CPUPPCState *env, target= _ulong val) } =20 #if defined(TARGET_PPC64) -/* POWER processor Timebase Facility */ +/* + * POWER processor Timebase Facility + */ + +/* + * The TBST is the timebase state machine, which is a per-core machine that + * is used to synchronize the core TB with the ChipTOD. States 3,4,5 are + * not used in POWER8/9/10. + * + * The state machine gets driven by writes to TFMR SPR from the core, and + * by signals from the ChipTOD. The state machine table for common + * transitions is as follows (according to hardware specs, not necessarily + * this implementation): + * + * | Cur | Event | New | + * +----------------+----------------------------------+-----+ + * | 0 RESET | TFMR |=3D LOAD_TOD_MOD | 1 | + * | 1 SEND_TOD_MOD | "immediate transition" | 2 | + * | 2 NOT_SET | mttbu/mttbu40/mttbl | 2 | + * | 2 NOT_SET | TFMR |=3D MOVE_CHIP_TOD_TO_TB | 6 | + * | 6 SYNC_WAIT | "sync pulse from ChipTOD" | 7 | + * | 7 GET_TOD | ChipTOD xscom MOVE_TOD_TO_TB_REG | 8 | + * | 8 TB_RUNNING | mttbu/mttbu40 | 8 | + * | 8 TB_RUNNING | TFMR |=3D LOAD_TOD_MOD | 1 | + * | 8 TB_RUNNING | mttbl | 9 | + * | 9 TB_ERROR | TFMR |=3D CLEAR_TB_ERRORS | 0 | + * + * - LOAD_TOD_MOD will also move states 2,6 to state 1, omitted from table + * because it's not a typical init flow. + * + * - The ERROR state can be entered from most/all other states on invalid + * states (e.g., if some TFMR control bit is set from a state where it's + * not listed to cause a transition away from), omitted to avoid clutter. + * + * Note: mttbl causes a timebase error because this inevitably causes + * ticks to be lost and TB to become unsynchronized, whereas TB can be + * adjusted using mttbu* without losing ticks. mttbl behaviour is not + * modelled. + * + * Note: the TB state machine does not actually cause any real TB adjustme= nt! + * TB starts out synchronized across all vCPUs (hardware threads) in + * QMEU, so for now the purpose of the TBST and ChipTOD model is simply + * to step through firmware initialisation sequences. + */ +static unsigned int tfmr_get_tb_state(uint64_t tfmr) +{ + return (tfmr & TFMR_TBST_ENCODED) >> (63 - 31); +} + +static uint64_t tfmr_new_tb_state(uint64_t tfmr, unsigned int tbst) +{ + tfmr &=3D ~TFMR_TBST_LAST; + tfmr |=3D (tfmr & TFMR_TBST_ENCODED) >> 4; /* move state to last state= */ + tfmr &=3D ~TFMR_TBST_ENCODED; + tfmr |=3D (uint64_t)tbst << (63 - 31); /* move new state to state */ + + if (tbst =3D=3D TBST_TB_RUNNING) { + tfmr |=3D TFMR_TB_VALID; + } else { + tfmr &=3D ~TFMR_TB_VALID; + } + + return tfmr; +} + +static void tb_state_machine_step(CPUPPCState *env) +{ + uint64_t tfmr =3D env->spr[SPR_TFMR]; + unsigned int tbst =3D tfmr_get_tb_state(tfmr); + + if (!(tfmr & TFMR_TB_ECLIPZ) || tbst =3D=3D TBST_TB_ERROR) { + return; + } + + if (env->pnv_tod_tbst.tb_sync_pulse_timer) { + env->pnv_tod_tbst.tb_sync_pulse_timer--; + } else { + tfmr |=3D TFMR_TB_SYNC_OCCURED; + env->spr[SPR_TFMR] =3D tfmr; + } + + if (env->pnv_tod_tbst.tb_state_timer) { + env->pnv_tod_tbst.tb_state_timer--; + return; + } + + if (tfmr & TFMR_LOAD_TOD_MOD) { + tfmr &=3D ~TFMR_LOAD_TOD_MOD; + if (tbst =3D=3D TBST_GET_TOD) { + tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); + tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; + } else { + tfmr =3D tfmr_new_tb_state(tfmr, TBST_SEND_TOD_MOD); + /* State seems to transition immediately */ + tfmr =3D tfmr_new_tb_state(tfmr, TBST_NOT_SET); + } + } else if (tfmr & TFMR_MOVE_CHIP_TOD_TO_TB) { + if (tbst =3D=3D TBST_SYNC_WAIT) { + tfmr =3D tfmr_new_tb_state(tfmr, TBST_GET_TOD); + env->pnv_tod_tbst.tb_state_timer =3D 3; + } else if (tbst =3D=3D TBST_GET_TOD) { + if (env->pnv_tod_tbst.tod_sent_to_tb) { + tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_RUNNING); + tfmr &=3D ~TFMR_MOVE_CHIP_TOD_TO_TB; + env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + env->pnv_tod_tbst.tod_sent_to_tb =3D 0; + } + } else { + qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: MOVE_CHIP_TOD_TO_T= B " + "state machine in invalid state 0x%x\n", tbst); + tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); + tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; + env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + } + } + + env->spr[SPR_TFMR] =3D tfmr; +} + target_ulong helper_load_tfmr(CPUPPCState *env) { - return env->spr[SPR_TFMR]; + tb_state_machine_step(env); + + return env->spr[SPR_TFMR] | TFMR_TB_ECLIPZ; } =20 void helper_store_tfmr(CPUPPCState *env, target_ulong val) { - env->spr[SPR_TFMR] =3D val; + uint64_t tfmr =3D env->spr[SPR_TFMR]; + uint64_t clear_on_write; + unsigned int tbst =3D tfmr_get_tb_state(tfmr); + + if (!(val & TFMR_TB_ECLIPZ)) { + qemu_log_mask(LOG_UNIMP, "TFMR non-ECLIPZ mode not implemented\n"); + tfmr &=3D ~TFMR_TBST_ENCODED; + tfmr &=3D ~TFMR_TBST_LAST; + goto out; + } + + /* Update control bits */ + tfmr =3D (tfmr & ~TFMR_CONTROL_MASK) | (val & TFMR_CONTROL_MASK); + + /* Several bits are clear-on-write, only one is implemented so far */ + clear_on_write =3D val & TFMR_FIRMWARE_CONTROL_ERROR; + tfmr &=3D ~clear_on_write; + + /* + * mtspr always clears this. The sync pulse timer makes it come back + * after the second mfspr. + */ + tfmr &=3D ~TFMR_TB_SYNC_OCCURED; + env->pnv_tod_tbst.tb_sync_pulse_timer =3D 1; + + if (ppc_cpu_tir(env_archcpu(env)) !=3D 0 && + (val & (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB))) { + qemu_log_mask(LOG_UNIMP, "TFMR timebase state machine can only be " + "driven by thread 0\n"); + goto out; + } + + if (((tfmr | val) & (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB)) = =3D=3D + (TFMR_LOAD_TOD_MOD | TFMR_MOVE_CHIP_TOD_TO_TB)) { + qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: LOAD_TOD_MOD and " + "MOVE_CHIP_TOD_TO_TB both set\n"); + tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); + tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; + env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + goto out; + } + + if (tfmr & TFMR_CLEAR_TB_ERRORS) { + /* + * Workbook says TFMR_CLEAR_TB_ERRORS should be written twice. + * This is not simulated/required here. + */ + tfmr =3D tfmr_new_tb_state(tfmr, TBST_RESET); + tfmr &=3D ~TFMR_CLEAR_TB_ERRORS; + tfmr &=3D ~TFMR_LOAD_TOD_MOD; + tfmr &=3D ~TFMR_MOVE_CHIP_TOD_TO_TB; + tfmr &=3D ~TFMR_FIRMWARE_CONTROL_ERROR; /* XXX: should this be cle= ared? */ + env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + env->pnv_tod_tbst.tod_sent_to_tb =3D 0; + goto out; + } + + if (tbst =3D=3D TBST_TB_ERROR) { + qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: mtspr TFMR in TB_ERROR" + " state\n"); + tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; + return; + } + + if (tfmr & TFMR_LOAD_TOD_MOD) { + /* Wait for an arbitrary 3 mfspr until the next state transition. = */ + env->pnv_tod_tbst.tb_state_timer =3D 3; + } else if (tfmr & TFMR_MOVE_CHIP_TOD_TO_TB) { + if (tbst =3D=3D TBST_NOT_SET) { + tfmr =3D tfmr_new_tb_state(tfmr, TBST_SYNC_WAIT); + env->pnv_tod_tbst.tb_ready_for_tod =3D 1; + env->pnv_tod_tbst.tb_state_timer =3D 3; /* arbitrary */ + } else { + qemu_log_mask(LOG_GUEST_ERROR, "TFMR error: MOVE_CHIP_TOD_TO_T= B " + "not in TB not set state 0x%x\n= ", + tbst); + tfmr =3D tfmr_new_tb_state(tfmr, TBST_TB_ERROR); + tfmr |=3D TFMR_FIRMWARE_CONTROL_ERROR; + env->pnv_tod_tbst.tb_ready_for_tod =3D 0; + } + } + +out: + env->spr[SPR_TFMR] =3D tfmr; } #endif =20 --=20 2.42.0 From nobody Wed Nov 27 02:34:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701433122; cv=none; d=zohomail.com; s=zohoarc; b=Aw1wQY+zOSZJCRkpEhnWoGH3J2qkTiUv4jp1PTzkde3jEAUopOkVzsa0fZbKvRXEbCtwhiStwpnYGQufOIM4ciXw3/XvzlQwHopn+ME2H8ROSxLfUWmEVgkHxtT+Ofa1iPplKVgzFD9Cwsx++CM7UP7+K6AZTz/1JTV7tVMRWio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701433122; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+eX2kvgWbhTaxtdvAuhzjJIFrnwX3H6eq3lOaxpWW3g=; b=nDzs+22Ci/OnwytCvkjZujxEHjFv6KBu7RqoETxVTzFY2g8IBejNoKEpzKorSJtgKQMvJQSmwUOWfrV9B78LyqIPvr3K6ZwHdAWKdjT12w3MO+48Qu9WSsTYcBeN8UbHDnLYUiilhA4fmqj9iYcDxd3bmKekV8d5stiat/Pmc3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701433122766436.28419913060395; Fri, 1 Dec 2023 04:18:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r92TA-0006BF-VF; Fri, 01 Dec 2023 07:18:08 -0500 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 1r92SM-0005cb-D4; Fri, 01 Dec 2023 07:17:21 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r92SK-0006PJ-IB; Fri, 01 Dec 2023 07:17:18 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6cc02e77a9cso1969011b3a.0; Fri, 01 Dec 2023 04:17:14 -0800 (PST) Received: from wheely.local0.net ([124.170.16.164]) by smtp.gmail.com with ESMTPSA id r19-20020aa78b93000000b006cdd39faaaesm2830782pfd.20.2023.12.01.04.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 04:17:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701433033; x=1702037833; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+eX2kvgWbhTaxtdvAuhzjJIFrnwX3H6eq3lOaxpWW3g=; b=kHQsms2eZnRPxoYQKnY8EhEUX7n6NOsOueq7k62dKTTRysg9qss/h8sGrz21Nf74QJ +OlHFxuvTA6xh7NqxLV7gG+yZfoVgjSSnGnB7CMKQxpZhatmBAKFC17U+WG+xgQfJ0jy yZfQMc7URNVeR1k/dkI0iB9y40hTPTb5O1GHKMSXmHlmLl/qftIPpfAWQxyGsvBb6E3j cRs81RlazLDeGxtV20Y6mksCDI+tOK/30QYpmONPCQ2TpQkAOJJcKjBWzF/XfNZr/kAt 0E20Q62D99+lIXiDCPLxH87lq0gQTNqlP16jKINb4EftYDRDeauqtOmLw8LS9G041+dq HuVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701433033; x=1702037833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+eX2kvgWbhTaxtdvAuhzjJIFrnwX3H6eq3lOaxpWW3g=; b=DZHuWqnxBEsmdzn50NpQCWPnKVGKX7tukb0bERqFFtsfP05+HaxsqsLxtGE7/FH5Ii v7y4T4wqjQyTeAfKP/6xQXB5DggDzUxNyHmr+9M5/LrwUkO/VU/lK0jhX4fmqAZPoIi5 S5czqVAc0ATV7xs1brYKS+CNgsurGbGJjXu125waoRkMblQcn00LhJ5K8ibpO6M3sGL0 p6W5QZC+iOYTZHt2mqRBLbWlKxFSsa+CCbBxMmwguKuOKTF7ZF4PuXk7TxkUFt82/I0u CtZwnv/S9ZehAbUNSi3rvg8SfjNICWair/0SqgG0M1+Zs2UcvjvpvVprOHu7uNr2bWXg ngWg== X-Gm-Message-State: AOJu0YwHX+/kIn/acpm0qwCZhVMS+VaKFlCOOeYG9EzbapBdl1e/Mhf2 8wCNgMJazN97EpWpCHk9BJ5gGeeP4uI= X-Google-Smtp-Source: AGHT+IFftIQfafI3SyiwHnrlJLdVehBDgQMdim2QgUfQNLvrKg/HOX+EO5REehN8GZ9zhwlDrw1Grw== X-Received: by 2002:a05:6a00:1142:b0:6cb:901a:874d with SMTP id b2-20020a056a00114200b006cb901a874dmr28773153pfm.10.1701433032917; Fri, 01 Dec 2023 04:17:12 -0800 (PST) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , qemu-devel@nongnu.org Subject: [PATCH v3 8/8] target/ppc: Add SMT support to time facilities Date: Fri, 1 Dec 2023 22:16:36 +1000 Message-ID: <20231201121636.142694-9-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201121636.142694-1-npiggin@gmail.com> References: <20231201121636.142694-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=npiggin@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701433123307000001 Content-Type: text/plain; charset="utf-8" The TB, VTB, PURR, HDEC SPRs are per-LPAR registers, and the TFMR is a per-core register. Add the necessary SMT synchronisation and value sharing. The TFMR can only drive the timebase state machine via thread 0 of the core, which is almost certainly not right, but it is enough for skiboot and certain other proprietary firmware. Signed-off-by: Nicholas Piggin Acked-by: C=C3=A9dric Le Goater --- target/ppc/timebase_helper.c | 105 ++++++++++++++++++++++++++++++++--- target/ppc/translate.c | 42 +++++++++++++- 2 files changed, 136 insertions(+), 11 deletions(-) diff --git a/target/ppc/timebase_helper.c b/target/ppc/timebase_helper.c index bc1d54a427..a23fbf75ff 100644 --- a/target/ppc/timebase_helper.c +++ b/target/ppc/timebase_helper.c @@ -60,19 +60,55 @@ target_ulong helper_load_purr(CPUPPCState *env) =20 void helper_store_purr(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_purr(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_purr(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_purr(cenv, val); + } } #endif =20 #if !defined(CONFIG_USER_ONLY) void helper_store_tbl(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_tbl(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_tbl(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_tbl(cenv, val); + } } =20 void helper_store_tbu(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_tbu(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_tbu(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_tbu(cenv, val); + } } =20 void helper_store_atbl(CPUPPCState *env, target_ulong val) @@ -102,17 +138,53 @@ target_ulong helper_load_hdecr(CPUPPCState *env) =20 void helper_store_hdecr(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_hdecr(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_hdecr(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_hdecr(cenv, val); + } } =20 void helper_store_vtb(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_vtb(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_vtb(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_vtb(cenv, val); + } } =20 void helper_store_tbu40(CPUPPCState *env, target_ulong val) { - cpu_ppc_store_tbu40(env, val); + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + if (nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LPAR)) { + cpu_ppc_store_tbu40(env, val); + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cpu_ppc_store_tbu40(cenv, val); + } } =20 target_ulong helper_load_40x_pit(CPUPPCState *env) @@ -211,6 +283,21 @@ static uint64_t tfmr_new_tb_state(uint64_t tfmr, unsig= ned int tbst) return tfmr; } =20 +static void write_tfmr(CPUPPCState *env, target_ulong val) +{ + CPUState *cs =3D env_cpu(env); + + if (cs->nr_threads =3D=3D 1) { + env->spr[SPR_TFMR] =3D val; + } else { + CPUState *ccs; + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cenv->spr[SPR_TFMR] =3D val; + } + } +} + static void tb_state_machine_step(CPUPPCState *env) { uint64_t tfmr =3D env->spr[SPR_TFMR]; @@ -224,7 +311,7 @@ static void tb_state_machine_step(CPUPPCState *env) env->pnv_tod_tbst.tb_sync_pulse_timer--; } else { tfmr |=3D TFMR_TB_SYNC_OCCURED; - env->spr[SPR_TFMR] =3D tfmr; + write_tfmr(env, tfmr); } =20 if (env->pnv_tod_tbst.tb_state_timer) { @@ -262,7 +349,7 @@ static void tb_state_machine_step(CPUPPCState *env) } } =20 - env->spr[SPR_TFMR] =3D tfmr; + write_tfmr(env, tfmr); } =20 target_ulong helper_load_tfmr(CPUPPCState *env) @@ -357,7 +444,7 @@ void helper_store_tfmr(CPUPPCState *env, target_ulong v= al) } =20 out: - env->spr[SPR_TFMR] =3D tfmr; + write_tfmr(env, tfmr); } #endif =20 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 329da4d518..bd103b1026 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -247,13 +247,24 @@ static inline bool gen_serialize(DisasContext *ctx) return true; } =20 -#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) +#if defined(TARGET_PPC64) +static inline bool gen_serialize_core(DisasContext *ctx) +{ + if (ctx->flags & POWERPC_FLAG_SMT) { + return gen_serialize(ctx); + } + return true; +} +#endif + static inline bool gen_serialize_core_lpar(DisasContext *ctx) { +#if defined(TARGET_PPC64) if (ctx->flags & POWERPC_FLAG_SMT_1LPAR) { return gen_serialize(ctx); } - +#endif return true; } #endif @@ -667,12 +678,20 @@ void spr_read_atbu(DisasContext *ctx, int gprn, int s= prn) #if !defined(CONFIG_USER_ONLY) void spr_write_tbl(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } + translator_io_start(&ctx->base); gen_helper_store_tbl(tcg_env, cpu_gpr[gprn]); } =20 void spr_write_tbu(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } + translator_io_start(&ctx->base); gen_helper_store_tbu(tcg_env, cpu_gpr[gprn]); } @@ -696,6 +715,9 @@ void spr_read_purr(DisasContext *ctx, int gprn, int spr= n) =20 void spr_write_purr(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } translator_io_start(&ctx->base); gen_helper_store_purr(tcg_env, cpu_gpr[gprn]); } @@ -709,6 +731,9 @@ void spr_read_hdecr(DisasContext *ctx, int gprn, int sp= rn) =20 void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } translator_io_start(&ctx->base); gen_helper_store_hdecr(tcg_env, cpu_gpr[gprn]); } @@ -721,12 +746,18 @@ void spr_read_vtb(DisasContext *ctx, int gprn, int sp= rn) =20 void spr_write_vtb(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } translator_io_start(&ctx->base); gen_helper_store_vtb(tcg_env, cpu_gpr[gprn]); } =20 void spr_write_tbu40(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core_lpar(ctx)) { + return; + } translator_io_start(&ctx->base); gen_helper_store_tbu40(tcg_env, cpu_gpr[gprn]); } @@ -1220,11 +1251,18 @@ void spr_write_hmer(DisasContext *ctx, int sprn, in= t gprn) =20 void spr_read_tfmr(DisasContext *ctx, int gprn, int sprn) { + /* Reading TFMR can cause it to be updated, so serialize threads here = too */ + if (!gen_serialize_core(ctx)) { + return; + } gen_helper_load_tfmr(cpu_gpr[gprn], tcg_env); } =20 void spr_write_tfmr(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core(ctx)) { + return; + } gen_helper_store_tfmr(tcg_env, cpu_gpr[gprn]); } =20 --=20 2.42.0