From nobody Mon Nov 25 07:52:20 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=1716255093; cv=none; d=zohomail.com; s=zohoarc; b=WiWf2YOBACJNiLX/97Ckt5NV4HUJrB9MmioLtLWoT1oIJRMZVl3wDPUdalE6ftArDDu6vw9MJO6h1plC+QMccBADHmv2grnkTpPUX+j0JICRxDK86imy+o/nF4QSdVlKfuNfmmp47miETxKFTo+gOC9dvkaszd3OoEBPntJ/YcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255093; 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=8bJqKySc80avuNyu9z8N9jqGjQygsej/MCRmpsZm7nw=; b=CPUbOjeyHV0p0Zv2FXf2870aVJGFkFjV6KdXFEw1GXkklLDLNRSVAjI0dqZx1nOVcYtgPRTo/j1dtaS9uetZbz5jqU5aBqgu0u/PMApX+dccVRc+WEvL8yTEmkkAYSsg8dJzsLiYNGlxvsFEvBQDbzJy/yGk5QvufGlR20QFa40= 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 1716255093710664.7586383179068; Mon, 20 May 2024 18:31:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELD-0007h7-4l; Mon, 20 May 2024 21:31:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9EL2-0007eP-9R; Mon, 20 May 2024 21:30:52 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9EKy-0005J1-SG; Mon, 20 May 2024 21:30:46 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ec486198b6so86363015ad.1; Mon, 20 May 2024 18:30:43 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255042; x=1716859842; 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=8bJqKySc80avuNyu9z8N9jqGjQygsej/MCRmpsZm7nw=; b=Htww+7+9K++kAwkWI2NOwwvbwaGhpNNgLoeEQKe/HJMHPvNqLoZ/a4B0J27vqJFfKC f0TsIdmi+OzWimoWff5Wsj2R1cTHECFpxOhmYvhrBSDCK7dAig3K/Mo5aOFfmuODC/0y e4uxHyk9H8MKj9GhbnvBp0Pjg31aqypZvHOM2pXwq/fCvc/wRRnANkjwKi20PNFY1RBD bYIwevwtrWy2f2tQOp8zdRT7BMdgprVnKF2oIsonBIzJweYhGl2pVpfjBwJaMHzesv8a YCJ1ZjfgspJudidCIzE4GBF/+uY5RMh43b9+rdss0KhbMD2bmiM6nhWpT6LcW+S1zlju VrEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255042; x=1716859842; 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=8bJqKySc80avuNyu9z8N9jqGjQygsej/MCRmpsZm7nw=; b=ChVhEthPKGxoCiZmD9BGnABz+IPZ06e9FAyKHL0XQ16uppGg5SzuZq5Z2vadkHGSCu gfKEpnfluzor34NfqP106x7zbauq1BzNteRpukDzd/eecYm6oA+EY/i1sPTzVMVgij8C zw10yyZeOIeKv9i2An8sV7TL0xQNjd5rqwgYneA2MjS1InIMe5aY2dnl2r5I68NVUw0v qX+Bguut1ew4vkkTXsuilPtikB1HnvKP9MAj8OKj9tYt8clnhkhxkAWob8ygZD1+oOct 5fDCVqCD5ket5svg3E5WlDj9z5KfH5VcrCEiekAvsMe+Qn6iSmfUVaGNGVjJle75YMNx AxMg== X-Forwarded-Encrypted: i=1; AJvYcCUZdwK9g0FstDYXQeV4jKjCPSdCxQvSqN0o2I8ohLraYtAxcog/I0Yy4CX+zhshGxtJ2o1kjxJqXFrY4F6OtxO/43WAqs0= X-Gm-Message-State: AOJu0Yw86l3K8x36J9mjCva+JstROhpDMfCo3t5SMQ2HctTMHkcgMpOj zZcVV1hmqF5LKjP7WYevWa4250KdytaUWGgAyuOC9+Ss08kJumce5zvfkw== X-Google-Smtp-Source: AGHT+IFXDbjSukV5fQmIxhDS/57UrdTeRZfX0Ut0fkv2FwETnFN87p+/u6KefoSiiuJPO1q/r/o4fg== X-Received: by 2002:a05:6a21:3408:b0:1af:b311:6a70 with SMTP id adf61e73a8af0-1afde1159damr27485624637.27.1716255041964; Mon, 20 May 2024 18:30:41 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 01/12] target/ppc: Make checkstop actually stop the system Date: Tue, 21 May 2024 11:30:17 +1000 Message-ID: <20240521013029.30082-2-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::633; envelope-from=npiggin@gmail.com; helo=mail-pl1-x633.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 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: 1716255095785100007 Content-Type: text/plain; charset="utf-8" checkstop state does not halt the system, interrupts continue to be serviced, and other CPUs run. Make it stop the machine with qemu_system_guest_panicked. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/excp_helper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 3be086d10b..b2b51537b7 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -19,6 +19,8 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "qemu/log.h" +#include "sysemu/sysemu.h" +#include "sysemu/runstate.h" #include "cpu.h" #include "exec/exec-all.h" #include "internal.h" @@ -425,6 +427,8 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, tar= get_ulong vector, =20 static void powerpc_mcheck_checkstop(CPUPPCState *env) { + /* KVM guests always have MSR[ME] enabled */ +#ifdef CONFIG_TCG CPUState *cs =3D env_cpu(env); =20 if (FIELD_EX64(env->msr, MSR, ME)) { @@ -437,9 +441,15 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env) if (qemu_log_separate()) { qemu_log("Machine check while not allowed. " "Entering checkstop state\n"); - } - cs->halted =3D 1; - cpu_interrupt_exittb(cs); + + /* + * This stops the machine and logs CPU state without killing QEMU + * (like cpu_abort()) so the machine can still be debugged (because + * it is often a guest error). + */ + qemu_system_guest_panicked(NULL); + cpu_loop_exit_noexc(cs); +#endif } =20 static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255101; cv=none; d=zohomail.com; s=zohoarc; b=lDYxFK+rnuQcbEZNZ+oIgf42i0vFAyA4FZkH/9YwmC1tFmZz8Kz67wee+2dLHkCdTgwxBoFccYlA2sSfNeyeYv8GTICaMKvyAE2wBj/XpBN5vwJmhGiBgKCF9yqj6Ag2K8GHTRNpl4t9ZsREHuMsmCJRMgPXssvCGmwSilCkv9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255101; 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=d7DjxgiD7bWPAbcsJtjRKCQRkvkfUf5f4ixXD/z1Ahc=; b=OhniYRzLmHRRTdTL8QK7Truz3X8hv/hgmhVhMPodxHYYKUP+Bl/AisdVzDwrP+g0EeqWiO0t3mD5dZh/Ams64S0SwcHB9tr+PpxIBRzmTSwRJoWIieuK42/N2fDze7czVz02tx8H98oo/VpTdUf1cvlnlFXQFyMAjDSCW2ub+Ls= 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 1716255101370169.40867914095918; Mon, 20 May 2024 18:31:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELJ-0007jJ-BZ; Mon, 20 May 2024 21:31:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9EL4-0007ei-M1; Mon, 20 May 2024 21:30:52 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9EL2-0005JE-C3; Mon, 20 May 2024 21:30:49 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ee12baa01cso100633675ad.0; Mon, 20 May 2024 18:30:47 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255046; x=1716859846; 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=d7DjxgiD7bWPAbcsJtjRKCQRkvkfUf5f4ixXD/z1Ahc=; b=RkpAp23k3MOpK41Vt7mU3x0YoYYdHvuOLnKR7E8QV7JYtbvHzlKII/j+HY+cv/1r2s FHWBkEHv/4pwI9WcHYhiG7qiDhvSE0GwCb4sXhBgK6NO10NxCZes5IkGd0iS57p5Mf3W njlllXI5IyTf5QleSn+asI11rmECXL1rXj3oOYA3JIVf8YAsejI0yeY9hvoegIe9xthr pz7uXGXLdC1BotSTdmm84wAbnzas5Z9iAKPswMmE9kQLwJgsHFh/P+X2DZXK4xOAse8L 3ZxlN/hCZuYUS+zMwnxk/TlV3ZCxxhPPqeCjQO6pf44UsFWifSe6B5gUc6VPY+0lm5LH k3Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255046; x=1716859846; 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=d7DjxgiD7bWPAbcsJtjRKCQRkvkfUf5f4ixXD/z1Ahc=; b=cvTxE6Y7423lgJrdiFkCYgnWQ4jnH7bqXxMOH7ACI9Hn0gCRXhyJG/ONCqVYA7SPGr mkPQcJ5whN0rK4upr9DgeoJcQXYA/JRn6XmpgiTg+vIFLrRWvjNT/vKWCu47+2TC3Pv6 9lhyGfihgBEo5F8dz2n8sBp4jaNeXoLdAEMMrnRzpd+y8kF6fEt3r2Mck6IWp8laEzHJ VzjFsFJNovrZCh5k3AtQH254odYjiZwd36lRPIiN3t2egEN1e7mlmHXH4d6oyRqVwA0i Tf3Or2SoT7DFx3nj6BTDGriSOav59CzcieNNts4NIThl7II/V1pohCreQK/ahY0CNWN6 JzNw== X-Forwarded-Encrypted: i=1; AJvYcCWbPiQHXb0/dz4IceUhP1SKx/Joj6xsDmrOQ1NoadxiGtp9Yu8fA2sGZQy+XCRvRYoil9v3bNdZZ8tp4V+NVZzYwntoxLY= X-Gm-Message-State: AOJu0YxlgljlD/Eu6QThCz9KoLoqvfTRHi2VCpiAWTDOL99Q+hVA5Qo6 DtRTgmEgvmstWdYyMPKsjM7gRJe+GildWta1QSKvWKWSH5TeFualUgnw/A== X-Google-Smtp-Source: AGHT+IFWi527TyuchW5RRd5ValpciJ5XybjYTfYTj4KEtNvzR61MKZMT8gzgGM9IiTgNYkN+ORBOog== X-Received: by 2002:a17:90a:5781:b0:2b2:6ede:5ce0 with SMTP id 98e67ed59e1d1-2b6cceef30dmr25227028a91.39.1716255045848; Mon, 20 May 2024 18:30:45 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 02/12] target/ppc: improve checkstop logging Date: Tue, 21 May 2024 11:30:18 +1000 Message-ID: <20240521013029.30082-3-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::632; envelope-from=npiggin@gmail.com; helo=mail-pl1-x632.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 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: 1716255101906100001 Content-Type: text/plain; charset="utf-8" Change the logging not to print to stderr as well, because a checkstop is a guest error (or perhaps a simulated machine error) rather than a QEMU error, so send it to the log. Update the checkstop message, and log CPU registers too. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles Reviewed-by: Richard Henderson --- target/ppc/excp_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index b2b51537b7..17bf8df9d7 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -430,17 +430,19 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env) /* KVM guests always have MSR[ME] enabled */ #ifdef CONFIG_TCG CPUState *cs =3D env_cpu(env); + FILE *f; =20 if (FIELD_EX64(env->msr, MSR, ME)) { return; } =20 - /* Machine check exception is not enabled. Enter checkstop state. */ - fprintf(stderr, "Machine check while not allowed. " - "Entering checkstop state\n"); - if (qemu_log_separate()) { - qemu_log("Machine check while not allowed. " - "Entering checkstop state\n"); + f =3D qemu_log_trylock(); + if (f) { + fprintf(f, "Entering checkstop state: " + "machine check with MSR[ME]=3D0\n"); + cpu_dump_state(cs, f, CPU_DUMP_FPU | CPU_DUMP_CCOP); + qemu_log_unlock(f); + } =20 /* * This stops the machine and logs CPU state without killing QEMU --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255121; cv=none; d=zohomail.com; s=zohoarc; b=H7gO7+e7Qg405eYJWg6MQJ//OCmsr6NahFXVgtBm8aU4cGNTuZMBFoQHjY9kwCubltXRpvu+GcUDibuZU7qC5q/UCpNytGiJKl0VvRLkK8jvzYzZMWylRrrvYVykbhvBKoPCra5FOKEaIkjC4H9AfmSqeGYimtg6rnlfsGwc9mM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255121; 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=3Cb2K5HbBY0bvGK5PB6n1V41h45TqBZ5zktjAGXJHR8=; b=d+QO6ZrH4QjvXCCn8PFaeeX9Y7RZfb7HWQqVu9yLyD1cuQK+uG84LqhXy5j157LisZ0YWnJuRDjdss5CG+MofgbhpC0V1+c8G1D0mmiREjZa5DfWlC4TkZXVDGnz6mBExW+oQ8W3AW256Em6UMqX3/mS8JTZ+3IBjhBzXQKpG3c= 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 1716255121256154.46485400258848; Mon, 20 May 2024 18:32:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELL-0007kk-1X; Mon, 20 May 2024 21:31:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELA-0007h8-W1; Mon, 20 May 2024 21:30:57 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9EL5-0005JP-MI; Mon, 20 May 2024 21:30:55 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1f0937479f8so90374485ad.3; Mon, 20 May 2024 18:30:50 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255050; x=1716859850; 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=3Cb2K5HbBY0bvGK5PB6n1V41h45TqBZ5zktjAGXJHR8=; b=TuPUlz57QxqqL1GyvHSU3ZnP9BL/JnFqbM9grCM3mDArWOafoueAE2c9Vo1Qn/rZOK bPH79n5fjWPw9pfSFwsED+x20kQCA6Ie+6e5WeOo5M4cqzAdu4kq41qZluTpgANp0URw xacHEY7dq4/oRt0nT8ltV3NgUW/CYI9SDB/GgjiPsLw30UbBvB2E7PzRNKa+KSIi+HBh jNzP759Cf3eK8gEjhm0mVs0RIhCxcsVmrHTapOF5kZlrEGnaWqHtVCTmL07ndAB4xK3m 2bKuq43aVTuCAsDCBqvE5RfySxfJL8vOauNPzLVC3CnfeK0zxuzH1NbN7GixiODRzY78 pSvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255050; x=1716859850; 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=3Cb2K5HbBY0bvGK5PB6n1V41h45TqBZ5zktjAGXJHR8=; b=hPsgFMrAwWPgdxmmSAnA1rWGEmE0fmMmXMzSu59bid/DuqIStQSFxJTpCW2O0afHOu HRnUEeTiH9Sxm9NeeAXbroEgbaHtRzI1SroNYXs5x9PAah8yffOTPCHakT6BdWx8pUeX mbuGnZ8FZYn1jzYxZdsUBfhc+ztj8YwMVGJlWKWIWpsoSiFeDHEZ0Q1wOQw3gCyDCo1H PMfITLeFanLWjMvxA0+VdG+p4e3uGT9sZmbiMf22W8SYAF3ACTrf1xguWTUjukp8HD3r 5fUI0zI7Qv26a/e0y8+QD7ZHVdxrQRzNeWccJrZXFIlbzYze0HTqrOuCVaekPDOEZaSU dDrQ== X-Forwarded-Encrypted: i=1; AJvYcCWiPyI2QCf9+t7Rpl3+nN8OlVNsIfi6NZgHU6Q3oAlCV4qG/P6BnA4oeAf4ZgkX7MzgtC1G99p40L9aoSzAQ/HrGFTxZYg= X-Gm-Message-State: AOJu0YxM7UGSuP9360o2ZbKPCzKQ5JZaYwR4IGaHeBv5r4eZY9Wbjk8f L1txrhVqs6DyB2Av3V7oj84iy/VSrsbHNIo6SUvQNYuOZtqixtrlkYqEFg== X-Google-Smtp-Source: AGHT+IFGgnwQcwpgVKWJplzzXWcycbHv/ryhulZBiZ9UNlTm783P3Aj6cvq0vN7RJ5zhcFrfldiy3Q== X-Received: by 2002:a17:90a:9513:b0:2b6:2079:71a4 with SMTP id 98e67ed59e1d1-2bd55467d1amr8032615a91.20.1716255049555; Mon, 20 May 2024 18:30:49 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 03/12] target/ppc: Implement attn instruction on BookS 64-bit processors Date: Tue, 21 May 2024 11:30:19 +1000 Message-ID: <20240521013029.30082-4-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::635; envelope-from=npiggin@gmail.com; helo=mail-pl1-x635.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 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: 1716255121978100001 Content-Type: text/plain; charset="utf-8" attn is an implementation-specific instruction that on POWER (and G5/ 970) can be enabled with a HID bit (disabled =3D illegal), and executing it causes the host processor to stop and the service processor to be notified. Generally used for debugging. Implement attn and make it checkstop the system, which should be good enough for QEMU debugging. Signed-off-by: Nicholas Piggin Reviewed-by: Richard Henderson --- target/ppc/cpu.h | 12 +++++ target/ppc/helper.h | 1 + target/ppc/insn32.decode | 4 ++ target/ppc/cpu_init.c | 69 ++++++++++++++++++++++++++++ target/ppc/excp_helper.c | 43 +++++++++++++---- target/ppc/translate/misc-impl.c.inc | 10 ++++ 6 files changed, 130 insertions(+), 9 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c358927211..2532408be0 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1375,6 +1375,9 @@ struct CPUArchState { /* Power management */ int (*check_pow)(CPUPPCState *env); =20 + /* attn instruction enable */ + int (*check_attn)(CPUPPCState *env); + #if !defined(CONFIG_USER_ONLY) void *load_info; /* holds boot loading state */ #endif @@ -1523,6 +1526,7 @@ struct PowerPCCPUClass { int n_host_threads; void (*init_proc)(CPUPPCState *env); int (*check_pow)(CPUPPCState *env); + int (*check_attn)(CPUPPCState *env); }; =20 ObjectClass *ppc_cpu_class_by_name(const char *name); @@ -2320,6 +2324,8 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define HID0_NAP (1 << 22) /* pre-2.06 */ #define HID0_HILE PPC_BIT(19) /* POWER8 */ #define HID0_POWER9_HILE PPC_BIT(4) +#define HID0_ENABLE_ATTN PPC_BIT(31) /* POWER8 */ +#define HID0_POWER9_ENABLE_ATTN PPC_BIT(3) =20 /*************************************************************************= ****/ /* PowerPC Instructions types definitions = */ @@ -3025,6 +3031,12 @@ static inline int check_pow_nocheck(CPUPPCState *env) return 1; } =20 +/* attn enable check = */ +static inline int check_attn_none(CPUPPCState *env) +{ + return 0; +} + /*************************************************************************= ****/ /* PowerPC implementations definitions = */ =20 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 55293e20a9..09d50f9b76 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -825,5 +825,6 @@ DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, e= nv) #if defined(TARGET_PPC64) DEF_HELPER_1(clrbhrb, void, env) DEF_HELPER_FLAGS_2(mfbhrbe, TCG_CALL_NO_WG, i64, env, i32) +DEF_HELPER_1(attn, noreturn, env) #endif #endif diff --git a/target/ppc/insn32.decode b/target/ppc/insn32.decode index d4dd022df4..ee33141476 100644 --- a/target/ppc/insn32.decode +++ b/target/ppc/insn32.decode @@ -1198,3 +1198,7 @@ EIEIO 011111 ----- ----- ----- 1101010110 - =20 MFBHRBE 011111 ..... ..... ..... 0100101110 - @XFX_bhrbe CLRBHRB 011111 ----- ----- ----- 0110101110 - + +## Misc POWER instructions + +ATTN 000000 00000 00000 00000 0100000000 0 diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 1ec84b5ddc..ee01415c32 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -2107,6 +2107,26 @@ static int check_pow_hid0_74xx(CPUPPCState *env) return 0; } =20 +#if defined(TARGET_PPC64) +static int check_attn_hid0(CPUPPCState *env) +{ + if (env->spr[SPR_HID0] & HID0_ENABLE_ATTN) { + return 1; + } + + return 0; +} + +static int check_attn_hid0_power9(CPUPPCState *env) +{ + if (env->spr[SPR_HID0] & HID0_POWER9_ENABLE_ATTN) { + return 1; + } + + return 0; +} +#endif + static void init_proc_405(CPUPPCState *env) { register_40x_sprs(env); @@ -2138,6 +2158,7 @@ POWERPC_FAMILY(405)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 405"; pcc->init_proc =3D init_proc_405; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_DCR | PPC_WRTEE | PPC_CACHE | PPC_CACHE_ICBI | PPC_40x_ICBT | @@ -2210,6 +2231,7 @@ POWERPC_FAMILY(440EP)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 440 EP"; pcc->init_proc =3D init_proc_440EP; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -2248,6 +2270,7 @@ POWERPC_FAMILY(460EX)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 460 EX"; pcc->init_proc =3D init_proc_440EP; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -2308,6 +2331,7 @@ POWERPC_FAMILY(440GP)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 440 GP"; pcc->init_proc =3D init_proc_440GP; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_DCR | PPC_DCRX | PPC_WRTEE | PPC_MFAPIDI | PPC_CACHE | PPC_CACHE_ICBI | @@ -2382,6 +2406,7 @@ POWERPC_FAMILY(440x5)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 440x5"; pcc->init_proc =3D init_proc_440x5; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_DCR | PPC_WRTEE | PPC_RFMCI | PPC_CACHE | PPC_CACHE_ICBI | @@ -2417,6 +2442,7 @@ POWERPC_FAMILY(440x5wDFPU)(ObjectClass *oc, void *dat= a) dc->desc =3D "PowerPC 440x5 with double precision FPU"; pcc->init_proc =3D init_proc_440x5; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_FLOAT | PPC_FLOAT_FSQRT | PPC_FLOAT_STFIWX | @@ -2465,6 +2491,7 @@ POWERPC_FAMILY(MPC5xx)(ObjectClass *oc, void *data) dc->desc =3D "Freescale 5xx cores (aka RCPU)"; pcc->init_proc =3D init_proc_MPC5xx; pcc->check_pow =3D check_pow_none; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MEM_EIEIO | PPC_MEM_SYNC | PPC_CACHE_ICBI | PPC_FLOAT | PPC_FLOAT_STFIWX | @@ -2507,6 +2534,7 @@ POWERPC_FAMILY(MPC8xx)(ObjectClass *oc, void *data) dc->desc =3D "Freescale 8xx cores (aka PowerQUICC)"; pcc->init_proc =3D init_proc_MPC8xx; pcc->check_pow =3D check_pow_none; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MEM_EIEIO | PPC_MEM_SYNC | PPC_CACHE_ICBI | PPC_MFTB; @@ -2557,6 +2585,7 @@ POWERPC_FAMILY(G2)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC G2"; pcc->init_proc =3D init_proc_G2; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_STFIWX | @@ -2595,6 +2624,7 @@ POWERPC_FAMILY(G2LE)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC G2LE"; pcc->init_proc =3D init_proc_G2; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_STFIWX | @@ -2741,6 +2771,7 @@ POWERPC_FAMILY(e200)(ObjectClass *oc, void *data) dc->desc =3D "e200 core"; pcc->init_proc =3D init_proc_e200; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; /* * XXX: unimplemented instructions: * dcblc @@ -3029,6 +3060,7 @@ POWERPC_FAMILY(e500v1)(ObjectClass *oc, void *data) dc->desc =3D "e500v1 core"; pcc->init_proc =3D init_proc_e500v1; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_SPE | PPC_SPE_SINGLE | PPC_WRTEE | PPC_RFDI | @@ -3072,6 +3104,7 @@ POWERPC_FAMILY(e500v2)(ObjectClass *oc, void *data) dc->desc =3D "e500v2 core"; pcc->init_proc =3D init_proc_e500v2; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE | PPC_WRTEE | PPC_RFDI | @@ -3115,6 +3148,7 @@ POWERPC_FAMILY(e500mc)(ObjectClass *oc, void *data) dc->desc =3D "e500mc core"; pcc->init_proc =3D init_proc_e500mc; pcc->check_pow =3D check_pow_none; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | PPC_WRTEE | PPC_RFDI | PPC_RFMCI | PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | @@ -3161,6 +3195,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) dc->desc =3D "e5500 core"; pcc->init_proc =3D init_proc_e5500; pcc->check_pow =3D check_pow_none; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | PPC_WRTEE | PPC_RFDI | PPC_RFMCI | PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | @@ -3209,6 +3244,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data) dc->desc =3D "e6500 core"; pcc->init_proc =3D init_proc_e6500; pcc->check_pow =3D check_pow_none; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | PPC_WRTEE | PPC_RFDI | PPC_RFMCI | PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | @@ -3271,6 +3307,7 @@ POWERPC_FAMILY(603)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 603"; pcc->init_proc =3D init_proc_603; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3310,6 +3347,7 @@ POWERPC_FAMILY(603E)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 603e"; pcc->init_proc =3D init_proc_603; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3355,6 +3393,7 @@ POWERPC_FAMILY(e300)(ObjectClass *oc, void *data) dc->desc =3D "e300 core"; pcc->init_proc =3D init_proc_e300; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_STFIWX | @@ -3410,6 +3449,7 @@ POWERPC_FAMILY(604)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 604"; pcc->init_proc =3D init_proc_604; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3455,6 +3495,7 @@ POWERPC_FAMILY(604E)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 604E"; pcc->init_proc =3D init_proc_604E; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3511,6 +3552,7 @@ POWERPC_FAMILY(740)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 740"; pcc->init_proc =3D init_proc_740; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3576,6 +3618,7 @@ POWERPC_FAMILY(750)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 750"; pcc->init_proc =3D init_proc_750; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3722,6 +3765,7 @@ POWERPC_FAMILY(750cl)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 750 CL"; pcc->init_proc =3D init_proc_750cl; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; /* * XXX: not implemented: * cache lock instructions: @@ -3829,6 +3873,7 @@ POWERPC_FAMILY(750cx)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 750CX"; pcc->init_proc =3D init_proc_750cx; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3901,6 +3946,7 @@ POWERPC_FAMILY(750fx)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 750FX"; pcc->init_proc =3D init_proc_750fx; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -3973,6 +4019,7 @@ POWERPC_FAMILY(750gx)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 750GX"; pcc->init_proc =3D init_proc_750gx; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -4032,6 +4079,7 @@ POWERPC_FAMILY(745)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 745"; pcc->init_proc =3D init_proc_745; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -4077,6 +4125,7 @@ POWERPC_FAMILY(755)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 755"; pcc->init_proc =3D init_proc_755; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | @@ -4143,6 +4192,7 @@ POWERPC_FAMILY(7400)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7400 (aka G4)"; pcc->init_proc =3D init_proc_7400; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4222,6 +4272,7 @@ POWERPC_FAMILY(7410)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7410 (aka G4)"; pcc->init_proc =3D init_proc_7410; pcc->check_pow =3D check_pow_hid0; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4322,6 +4373,7 @@ POWERPC_FAMILY(7440)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7440 (aka G4)"; pcc->init_proc =3D init_proc_7440; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4444,6 +4496,7 @@ POWERPC_FAMILY(7450)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7450 (aka G4)"; pcc->init_proc =3D init_proc_7450; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4573,6 +4626,7 @@ POWERPC_FAMILY(7445)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7445 (aka G4)"; pcc->init_proc =3D init_proc_7445; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4704,6 +4758,7 @@ POWERPC_FAMILY(7455)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7455 (aka G4)"; pcc->init_proc =3D init_proc_7455; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4855,6 +4910,7 @@ POWERPC_FAMILY(7457)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 7457 (aka G4)"; pcc->init_proc =3D init_proc_7457; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -4989,6 +5045,7 @@ POWERPC_FAMILY(e600)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC e600"; pcc->init_proc =3D init_proc_e600; pcc->check_pow =3D check_pow_hid0_74xx; + pcc->check_attn =3D check_attn_none; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -5904,6 +5961,7 @@ POWERPC_FAMILY(970)(ObjectClass *oc, void *data) dc->desc =3D "PowerPC 970"; pcc->init_proc =3D init_proc_970; pcc->check_pow =3D check_pow_970; + pcc->check_attn =3D check_attn_hid0; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -5979,6 +6037,7 @@ POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data) dc->desc =3D "POWER5+"; pcc->init_proc =3D init_proc_power5plus; pcc->check_pow =3D check_pow_970; + pcc->check_attn =3D check_attn_hid0; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -6086,6 +6145,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->pcr_supported =3D PCR_COMPAT_2_06 | PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER7; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_hid0; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -6247,6 +6307,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->pcr_supported =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_= 2_05; pcc->init_proc =3D init_proc_POWER8; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_hid0; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -6439,6 +6500,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER9; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_hid0_power9; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -6618,6 +6680,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) PCR_COMPAT_2_06 | PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER10; pcc->check_pow =3D check_pow_nocheck; + pcc->check_attn =3D check_attn_hid0_power9; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -6856,6 +6919,11 @@ static void init_ppc_proc(PowerPCCPU *cpu) warn_report("no power management check handler registered." " Attempt QEMU to crash very soon !"); } + + if (env->check_attn =3D=3D NULL) { + warn_report("no attn check handler registered." + " Attempt QEMU to crash very soon !"); + } } =20 =20 @@ -7317,6 +7385,7 @@ static void ppc_cpu_instance_init(Object *obj) env->flags =3D pcc->flags; env->bfd_mach =3D pcc->bfd_mach; env->check_pow =3D pcc->check_pow; + env->check_attn =3D pcc->check_attn; =20 /* * Mark HV mode as supported if the CPU has an MSR_HV bit in the diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 17bf8df9d7..e786a9044b 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -154,6 +154,7 @@ static uint32_t ppc_ldl_code(CPUArchState *env, target_= ulong addr) =20 return insn; } + #endif =20 static void ppc_excp_debug_sw_tlb(CPUPPCState *env, int excp) @@ -425,21 +426,20 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, t= arget_ulong vector, env->reserve_addr =3D -1; } =20 -static void powerpc_mcheck_checkstop(CPUPPCState *env) -{ - /* KVM guests always have MSR[ME] enabled */ #ifdef CONFIG_TCG +/* + * This stops the machine and logs CPU state without killing QEMU (like + * cpu_abort()) because it is often a guest error as opposed to a QEMU err= or, + * so the machine can still be debugged. + */ +static G_NORETURN void powerpc_checkstop(CPUPPCState *env, const char *rea= son) +{ CPUState *cs =3D env_cpu(env); FILE *f; =20 - if (FIELD_EX64(env->msr, MSR, ME)) { - return; - } - f =3D qemu_log_trylock(); if (f) { - fprintf(f, "Entering checkstop state: " - "machine check with MSR[ME]=3D0\n"); + fprintf(f, "Entering checkstop state: %s\n", reason); cpu_dump_state(cs, f, CPU_DUMP_FPU | CPU_DUMP_CCOP); qemu_log_unlock(f); } @@ -451,6 +451,31 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env) */ qemu_system_guest_panicked(NULL); cpu_loop_exit_noexc(cs); +} + +#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) +void helper_attn(CPUPPCState *env) +{ + /* POWER attn is unprivileged when enabled by HID, otherwise illegal */ + if ((*env->check_attn)(env)) { + powerpc_checkstop(env, "host executed attn"); + } else { + raise_exception_err(env, POWERPC_EXCP_HV_EMU, + POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL); + } +} +#endif +#endif /* CONFIG_TCG */ + +static void powerpc_mcheck_checkstop(CPUPPCState *env) +{ + /* KVM guests always have MSR[ME] enabled */ +#ifdef CONFIG_TCG + if (FIELD_EX64(env->msr, MSR, ME)) { + return; + } + + powerpc_checkstop(env, "machine check with MSR[ME]=3D0"); #endif } =20 diff --git a/target/ppc/translate/misc-impl.c.inc b/target/ppc/translate/mi= sc-impl.c.inc index c1661d2f43..cbf82b1ea0 100644 --- a/target/ppc/translate/misc-impl.c.inc +++ b/target/ppc/translate/misc-impl.c.inc @@ -145,3 +145,13 @@ static bool trans_EIEIO(DisasContext *ctx, arg_EIEIO *= a) =20 return true; } + +static bool trans_ATTN(DisasContext *ctx, arg_ATTN *a) +{ +#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) + gen_helper_attn(tcg_env); + return true; +#else + return false; +#endif +} --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255161; cv=none; d=zohomail.com; s=zohoarc; b=AxIgF39TynwuUQd2vwYfMAb64a1ZvC4tRmTdNo01AysjeO3dwhEA5iABh2+90wZrXTCOQmGJmDakcqClyw1EW4fm4DjHQMKmHnjIjmNgg46bQRRCz+FfRQe1sgRZ4teEne+VZSpMyHPMqHHgfEq5pw2ZDjkkx5AI1W2t/zG+gZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255161; 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=DM7C9zYU/JYPQc+IpanR0zGx9fNeS+QDv9SFSyE3708=; b=H8ivsJk61D2X+MRcnXhfsd02SEF7gWwxnFRnl7Mbc0LasNaJWnmGm7CMPrDSf4ahw4FByN6cjTTfEVhKkAT8ah2T2tHMR7mxUSIPhg203O/wa5IaNFRmcXbg/B2zukdwKieS3Q6iLEyx27Ar5bdDZlCvsIElaoR+MlwVF9v8klQ= 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 1716255161364638.948098007383; Mon, 20 May 2024 18:32:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELK-0007jh-BT; Mon, 20 May 2024 21:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELC-0007hM-2H; Mon, 20 May 2024 21:31:01 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9EL9-0005Jp-LA; Mon, 20 May 2024 21:30:57 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1eca195a7c8so91608135ad.2; Mon, 20 May 2024 18:30:54 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255053; x=1716859853; 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=DM7C9zYU/JYPQc+IpanR0zGx9fNeS+QDv9SFSyE3708=; b=k8g/0rQ+f9TAbI60bfRQW8+zIqivev2Dv/LnzVJJNDfYA2IwobbyfVaw7DR0nZenRF MVTMVXx9x3SYhpx6wbB6y0kbhmtngeF5lpBteGi8T29vpmidy+NL592xBNOm3YXuH9H+ lexWkG+zX6YYkYRHH+m1r3MiUF4oYFdUB7hkm1PqKIKuK3caaDswVkTzgEYVR/wl9Ii7 +QdWpEorGAq4NddNAgsuz9eL0VO0KFhIjUhqZNaoNBtyswutmwdez1VvjSkVtTNtNSYn JkYC0GrhvuyN174Q+yWq/m4IRxkwC+A7dyth+1WpaV48ylAf8mcBoUdFTkhnonCjXR04 GAnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255053; x=1716859853; 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=DM7C9zYU/JYPQc+IpanR0zGx9fNeS+QDv9SFSyE3708=; b=nJ6p63aNekbfmK71KjpY69CH+JYSahFuEEpYVe7zjMEAGTlrpZxHd7zbWtOeAKu7R+ rJU5HjAsbVKj4M5Ryph/XlBXUGnQDBwKfDtJQbAbg3dZ3/zM5ShGaetrZVvpJ2VV+PXg J72aXT0NNbvpOJlg9ecT9HJ+3iV5jmQs1EMFaRzdNJ8neycYEbINi83w+CS7FKjW8MdZ DNSAb2abMI3y4mTpYCW0WPkGq7SAJwAXc0dh4BfPL/Rf3BpXlY3CqXR5HjJQDylFfQgi ebzXVMp+AVzYH0vMvsOo4l/3ou+XIu+BLMU6bPjKA97RoTb22YZpzqQcN+kpYVgIPXPP aTAA== X-Forwarded-Encrypted: i=1; AJvYcCUJbImd13S0A+mBsFWlAfDRV75UmXgP76tqGd9nAYkjh37Rk2cyng1s7QbUT6WnlgWgjQ6E+coy9Ht+OWO6UjAsBi0gEb8= X-Gm-Message-State: AOJu0YyyrkViJS2SM6YqkbHQKwJC7w+I7lWeAGjz8NmfSnFjEEMMhXBX dUlshX6DNe2Flop41bV9EB5+MmZ3AfWjw8w9qKNth+aaSJetukoVyNeqJQ== X-Google-Smtp-Source: AGHT+IFdqgktDuzumxetQ6n515AaYMkRNijVtks8f5C9Yfhn3THLuqM4j1WUb6waCPz/9ngoCiHrkA== X-Received: by 2002:a17:90a:ad86:b0:2b6:22bd:f4b2 with SMTP id 98e67ed59e1d1-2b6cc03f435mr25384106a91.4.1716255053583; Mon, 20 May 2024 18:30:53 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 04/12] target/ppc: BookE DECAR SPR is 32-bit Date: Tue, 21 May 2024 11:30:20 +1000 Message-ID: <20240521013029.30082-5-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::636; envelope-from=npiggin@gmail.com; helo=mail-pl1-x636.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 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: 1716255162114100001 Content-Type: text/plain; charset="utf-8" The DECAR SPR is 32-bits width. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index ee01415c32..927721d49a 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -792,7 +792,7 @@ static void register_BookE_sprs(CPUPPCState *env, uint6= 4_t ivor_mask) 0x00000000); spr_register(env, SPR_BOOKE_DECAR, "DECAR", SPR_NOACCESS, SPR_NOACCESS, - SPR_NOACCESS, &spr_write_generic, + SPR_NOACCESS, &spr_write_generic32, 0x00000000); /* SPRGs */ spr_register(env, SPR_USPRG0, "USPRG0", --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255146; cv=none; d=zohomail.com; s=zohoarc; b=DrOhL+oJC5Y7ZvLnT/ZyT/O/ec0YzOx6nwQKi0MkGMsUkfeVd/MaR/T86aCxoq0vAZSlonjALTccAmFhimH217JnDFB4hBcgcWgjOgpQp/pY0RP9SU570LN/UZaiJ95a4adUBEwcC5nLgHWAILuKi6sOWoIszzNTu4itKfRdL64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255146; 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=yt1vYtOLZ3aoBsS6/LYMaUEQfiphsblSQKxcObVD0IY=; b=Q/AWp6nkMtEIjfN74sIURniCWttP5XzzTFQH6rvBqC9nmT6GOX1ls0UP0zxaiOmVkd2zc9SPdl59vr4BQQjh2yd46jhbYIuJjMFT0V41V0gGpfnxsG7szh8l3y84C7Yy7nZdBcG6eoJ7Kyg/Dnzn+cjunqcncN7gyQsRNcDGfvg= 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 1716255146906235.95130371949665; Mon, 20 May 2024 18:32:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELK-0007kj-Uq; Mon, 20 May 2024 21:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELE-0007hd-Qp; Mon, 20 May 2024 21:31:01 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELD-0005KN-8D; Mon, 20 May 2024 21:31:00 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ee12baa01cso100637155ad.0; Mon, 20 May 2024 18:30:58 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255057; x=1716859857; 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=yt1vYtOLZ3aoBsS6/LYMaUEQfiphsblSQKxcObVD0IY=; b=fcHSZl/uZ7q6NjuVtbmjmXsEZ529t+zlmQolzVB7x0ZkWPktpz/gOpqN9r14lTt3ui 04zNca0onHxDDACHyEU0vSLGmoylipnxyk9FdHX4LpBJoVJ4jgrNXvO9GZW3el9OnzJd ns75q8WcAI/9k4HN9R6IryvMxJmrTXXLTdk5KH/848v3eeZOgGsErtaLnELg5TBlnG3H 3cLAu8aDC8S1ASqMe1oTgUCqPGT8p/62wlfoV9+2/3lxMo4+TAu2AYrCI8kdBeKW8Fp5 rQesQpYrQpZyY+bQ1/8z78KKdmFfeqacQ7547NT+DkyXyU5Eb87oMPjQiU4JEMyioUlt hO6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255057; x=1716859857; 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=yt1vYtOLZ3aoBsS6/LYMaUEQfiphsblSQKxcObVD0IY=; b=VSINcvZ9X36TOdyhnxMAKgz0CeuUJGRMCQuIoOuMnPnLvrULqsYjq3ThkLgC2j39Rc sVxkdjlOIcGZ088b2bxvXH7fm9ETalU9YNmfM/sqG1Oo24ETcFg/U7b05vvrfsezoKFz K3nhoTtHRCPf0mxvzOfaXOEEmBIRmlfl/65A4GeJGk8hYNxzuHSEZctTUEWpFEDLZxWM 2wRbi5ZU6tMGSoxaY61QgoKcQlgtt8zFZTUFLoGgiYV++pYHCchwBrnrbTxmLgNE/xjf nkCBYPjFITHBXtR6ShQeivBxDKowAWBdM9cL2RDsoZX8/JZ6exelCMRCF4pXgfGcfXGz eHcQ== X-Forwarded-Encrypted: i=1; AJvYcCWII0cuzS+nNI8YvPptZFSRIYJFYD088h6MdrL3t9+YU0Ar4AOcKYLi5csK/qegLm9847Ws4av4J2S8jlWQvgC5pYBKW28= X-Gm-Message-State: AOJu0Yz6EU/37Tt5nTnxyFHa7xhmybiaslSdJ6hV7aysMBhrzaLeDgpj HPru8IqlxFrbz1+pe346+htYZN5CxWds0ml+En2aqaoe8fjfzM6oB86akA== X-Google-Smtp-Source: AGHT+IHuusVkxnovyOtIhawZ0Wno0E2ysFn2y61lGOMKr4PgqyIpMftCq5nZWPSlEtFA4McKH7xSiQ== X-Received: by 2002:a17:90b:4a43:b0:2bd:839f:7f36 with SMTP id 98e67ed59e1d1-2bd839f7ff7mr3103481a91.10.1716255057358; Mon, 20 May 2024 18:30:57 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 05/12] target/ppc: Wire up BookE ATB registers for e500 family Date: Tue, 21 May 2024 11:30:21 +1000 Message-ID: <20240521013029.30082-6-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::632; envelope-from=npiggin@gmail.com; helo=mail-pl1-x632.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 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: 1716255148037100003 Content-Type: text/plain; charset="utf-8" From the Freescale PowerPC Architecture Primer: Alternate time base APU. This APU, implemented on the e500v2, defines a 64-bit time base counter that differs from the PowerPC defined time base in that it is not writable and counts at a different, and typically much higher, frequency. The alternate time base always counts up, wrapping when the 64-bit count overflows. This implementation of ATB uses the same frequency as the TB. The existing spr_read_atbu/l functions are unused without this patch to wire them into the SPR. RTEMS uses this SPR on the e6500, though this hasn't been tested. Signed-off-by: Nicholas Piggin --- target/ppc/cpu_init.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 927721d49a..892fb6ce02 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -920,6 +920,18 @@ static void register_BookE206_sprs(CPUPPCState *env, u= int32_t mas_mask, #endif } =20 +static void register_atb_sprs(CPUPPCState *env) +{ + spr_register(env, SPR_ATBL, "ATBL", + &spr_read_atbl, SPR_NOACCESS, + &spr_read_atbl, SPR_NOACCESS, + 0x00000000); + spr_register(env, SPR_ATBU, "ATBU", + &spr_read_atbu, SPR_NOACCESS, + &spr_read_atbu, SPR_NOACCESS, + 0x00000000); +} + /* SPR specific to PowerPC 440 implementation */ static void register_440_sprs(CPUPPCState *env) { @@ -2927,6 +2939,11 @@ static void init_proc_e500(CPUPPCState *env, int ver= sion) register_BookE206_sprs(env, 0x000000DF, tlbncfg, mmucfg); register_usprgh_sprs(env); =20 + if (version !=3D fsl_e500v1) { + /* e500v1 has no support for alternate timebase */ + register_atb_sprs(env); + } + spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255190; cv=none; d=zohomail.com; s=zohoarc; b=XErKazBD9+vvWR7n/oYHxC0ZpcdAXz/HI81tI2ZKi0CbvY66jDRrFJ9itsGdxn9rkZrdV3izH+7NE9pNXDlzYqyBtTe9aY2EqFZpjb89z2Fn2+CvNTscKG1db1Rx1ScbhCsDRULgEJY7Yie3QO2zKRIbmnosjsymktG486Cw3JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255190; 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=xELS6oYgKZZUA8AMO1krYjCwP0RoNjeqV7WiJZCCiK8=; b=iyzAP+KSsjgosIEkiMH9BZaUGgB7EW5uRXVLpKjwKpqlGYpNw6wK0XbSGTxlaykhttTI/9j6uKMUCCGLNT0uJYiboyATv6UysSVWMYX1cibuZ9p93wu1/e4rhiyOsHCGqcMgEXvktBZSBoiatnBP+tjVL/hMlZdRcUb7OVg4QdY= 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 17162551906121023.000548418254; Mon, 20 May 2024 18:33:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELN-0007m4-Pd; Mon, 20 May 2024 21:31:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELJ-0007jg-G7; Mon, 20 May 2024 21:31:06 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELH-0005Kf-RS; Mon, 20 May 2024 21:31:05 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1eeabda8590so87921545ad.0; Mon, 20 May 2024 18:31:02 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255061; x=1716859861; 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=xELS6oYgKZZUA8AMO1krYjCwP0RoNjeqV7WiJZCCiK8=; b=RlRBzjBQ44bZN03jO8PdFTr8jUYAfs8/2jroz7az9gcmdNNo4Nb7MmjTIjcVB99aUK E2jCHFKZonGyUp5vUQdDPqaT50J7/AjhVXgs4d11you0p1thFJGrpbMLOo+6hl/zoYIC jy/J6jbC3lejO5oqHcheGSw4wKLFaq1yYg4RmfoSmfNIGSmBXokEsdUeO7wO2R6dlnOe fv/wt0/L3S+ScKPefL1LHBctWfIQMLz40ePVDVBzAkhb+Sz3rzLw76ORZcLYTJYQNPfo lOSM/AMcZGYwjSqAcEI9XgGmhH8kXXJ+SKGTm5Whd1B1Wbj2tAoxxogRxybBjz/4FqRa mB8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255061; x=1716859861; 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=xELS6oYgKZZUA8AMO1krYjCwP0RoNjeqV7WiJZCCiK8=; b=ZmAi8nkkWBecpaxm3qfCA2zV+TaKFA9fNZXEATbtiXRDMFOZP4aGvh3ml7D9vyWogn wj5gv870bOeHOrWPXFHKKlHe2dkeg296G034MR+YNnaDutNdH7jYLKUcFcEOWXP/jRDG uCJt+ujXQoinrCxzlBCizSmbfhjtCKYbV1Dh/VfJpAG/Lnkz/yYv3YaQ8OEh3MtwJoVX eOBGp9X+4RZyT0p0xeNFUnMl7Tgpeas6dIxYSYjk9hZeXITqORxv7Cfl6xg6ChwhGMkR /GJJNdhNO4Vnft6UVMIoYRJ5aA+Kcw8eenwdloB6Ttw8Hsu4bo4Y9gtBIqgAaV7G47A9 xJMg== X-Forwarded-Encrypted: i=1; AJvYcCWhKWEogRz5T27yEgGU06s1Z/2LlR5ZvFD/2BtufUn1DdAkwK8yysPic3taIOiGGg8aczJP7Bc6JRiGI7dBTmBuEPDy19s= X-Gm-Message-State: AOJu0YxxuUeTptRVKiU/4Wy2R/I6phhT6ATKCn6TzGZ1/pdjS6qgNGH0 +mcMYbEggmJY/Zgga4D144L17le87dPAxp4G8QUNCDOxwniRE+mBQrH74Q== X-Google-Smtp-Source: AGHT+IG908KthP33QWrdcsoeqRSjsXhA5tcUx2Jl5Q6MW61VWboIkEJjvBLo/AxYLMvFhLM3Px30rw== X-Received: by 2002:a17:90a:eb07:b0:2b4:3659:b3f5 with SMTP id 98e67ed59e1d1-2b6ccd886efmr21839507a91.47.1716255061450; Mon, 20 May 2024 18:31:01 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 06/12] target/ppc: Add PPR32 SPR Date: Tue, 21 May 2024 11:30:22 +1000 Message-ID: <20240521013029.30082-7-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::62e; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62e.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 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: 1716255192269100003 Content-Type: text/plain; charset="utf-8" PPR32 provides access to the upper half of PPR. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu.h | 1 + target/ppc/spr_common.h | 2 ++ target/ppc/cpu_init.c | 12 ++++++++++++ target/ppc/translate.c | 16 ++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 2532408be0..141cbefb4c 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2120,6 +2120,7 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_POWER_MMCRS (0x37E) #define SPR_WORT (0x37F) #define SPR_PPR (0x380) +#define SPR_PPR32 (0x382) #define SPR_750_GQR0 (0x390) #define SPR_440_DNV0 (0x390) #define SPR_750_GQR1 (0x391) diff --git a/target/ppc/spr_common.h b/target/ppc/spr_common.h index eb2561f593..9e40b3b608 100644 --- a/target/ppc/spr_common.h +++ b/target/ppc/spr_common.h @@ -203,6 +203,8 @@ void spr_read_tfmr(DisasContext *ctx, int gprn, int spr= n); void spr_write_tfmr(DisasContext *ctx, int sprn, int gprn); void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn); void spr_read_dexcr_ureg(DisasContext *ctx, int gprn, int sprn); +void spr_read_ppr32(DisasContext *ctx, int sprn, int gprn); +void spr_write_ppr32(DisasContext *ctx, int sprn, int gprn); #endif =20 void register_low_BATs(CPUPPCState *env); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 892fb6ce02..7684a59d75 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5623,6 +5623,14 @@ static void register_HEIR64_spr(CPUPPCState *env) 0x00000000); } =20 +static void register_power7_common_sprs(CPUPPCState *env) +{ + spr_register(env, SPR_PPR32, "PPR32", + &spr_read_ppr32, &spr_write_ppr32, + &spr_read_ppr32, &spr_write_ppr32, + 0x00000000); +} + static void register_power8_tce_address_control_sprs(CPUPPCState *env) { spr_register_kvm(env, SPR_TAR, "TAR", @@ -6118,6 +6126,7 @@ static void init_proc_POWER7(CPUPPCState *env) register_power6_common_sprs(env); register_HEIR32_spr(env); register_power6_dbg_sprs(env); + register_power7_common_sprs(env); register_power7_book4_sprs(env); =20 /* env variables */ @@ -6264,6 +6273,7 @@ static void init_proc_POWER8(CPUPPCState *env) register_power6_common_sprs(env); register_HEIR32_spr(env); register_power6_dbg_sprs(env); + register_power7_common_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); register_power8_ebb_sprs(env); @@ -6431,6 +6441,7 @@ static void init_proc_POWER9(CPUPPCState *env) register_power6_common_sprs(env); register_HEIR32_spr(env); register_power6_dbg_sprs(env); + register_power7_common_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); register_power8_ebb_sprs(env); @@ -6625,6 +6636,7 @@ static void init_proc_POWER10(CPUPPCState *env) register_power6_common_sprs(env); register_HEIR64_spr(env); register_power6_dbg_sprs(env); + register_power7_common_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); register_power8_ebb_sprs(env); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index ca4f4c9371..137370b649 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -1414,6 +1414,22 @@ void spr_read_dexcr_ureg(DisasContext *ctx, int gprn= , int sprn) gen_load_spr(t0, sprn + 16); tcg_gen_ext32u_tl(cpu_gpr[gprn], t0); } + +/* The PPR32 SPR accesses the upper 32-bits of PPR */ +void spr_read_ppr32(DisasContext *ctx, int sprn, int gprn) +{ + gen_load_spr(cpu_gpr[gprn], SPR_PPR); + tcg_gen_shri_tl(cpu_gpr[gprn], cpu_gpr[gprn], 32); +} + +void spr_write_ppr32(DisasContext *ctx, int sprn, int gprn) +{ + TCGv t0 =3D tcg_temp_new(); + + tcg_gen_shli_tl(t0, cpu_gpr[gprn], 32); + gen_store_spr(SPR_PPR, t0); + spr_store_dump_spr(SPR_PPR); +} #endif =20 #define GEN_HANDLER(name, opc1, opc2, opc3, inval, type) = \ --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255148; cv=none; d=zohomail.com; s=zohoarc; b=LoiNlvbH+V7omhpeRQZsb4AbWPivn4eveONM1XdiuxEt5t4aqrJEJYn628c7bs5NgiBVARWfIQq93vzxCVvDepQbVT6I54hDTjiHDH/onH9AKJ1SwVMa1807WJLkTYwE1mfJJZ7+akW1hFI9UQV7i6CZcENggL0LwDxi05R3vA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255148; 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=IjlPsYtB8Kd+0Ny4SiPL3hIvcQ0jYiMqPq1SDRuz4OE=; b=LWOouj0DEetzs8MqOuPLnVg4JhY6VCoPVZEhan5zUd03dF/ItDCULzpgdmYSwbgK9a0ZbfoEGCpgIIsMxvhVnODXYOgs0Eyg/ltDE83d5NpyAn8ijS4BToqJSCqBCPGgwsLmj2P5n7Cwo6viYMCxp25zcQywMklgMy/ghekjbB4= 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 1716255148279721.0947262224648; Mon, 20 May 2024 18:32:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELP-0007nl-PY; Mon, 20 May 2024 21:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELO-0007mY-24; Mon, 20 May 2024 21:31:10 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELL-0005L7-Hu; Mon, 20 May 2024 21:31:09 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-66986f58b43so1335905a12.0; Mon, 20 May 2024 18:31:06 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255065; x=1716859865; 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=IjlPsYtB8Kd+0Ny4SiPL3hIvcQ0jYiMqPq1SDRuz4OE=; b=kHOb56SdVvuHXo7M3VmSIWflImIwDmtaIjPs+ZD5bqU1TKQuhadTxmEfUJYQhyvKxu kssgDGTBIziRJ2vkn96S696OfFstT+o4b6cTypJt4dY7T6YVIT6/7zrgOY6pNCCHK9GG iqwHExMOW0fsnj7Rq26RuFJTZE3RdLDBg8CXlRR/5aOztX1cRZ1fZqHQywObUmeL0lNK ja2sKHfL3xJ/QrTr0cBOkj/4Jy786AkGhkSEgbSVxF4I3m6MLzOQTfqrqC6i77MPjMoQ R5nr9QLfKWl2C7uX3bwZn+zINuMs9UVM5O6SqqsThbpouoMOzf208P6ot8WeLQAcczJ+ SkLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255065; x=1716859865; 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=IjlPsYtB8Kd+0Ny4SiPL3hIvcQ0jYiMqPq1SDRuz4OE=; b=D40yUuayt0yOUICyhT0eOT7BkOwAyqQTCFSgyns7ofNiDeRzpcl9SoKwzH26+TY7L/ 2cIX2wGSefiMaj7Zy7IsuQ/3fwgQtlqjRwiDL4gISNhl1MjqTiwqYYnO3z7yGuwek2XE iZ6N5wbfb+ulsDjdndkbYJBfmIrxtw46OzpaQgxuags9dE4NT71Ot4IUmAbZs89UWyQV gUHH47MjEyuY29M4BK1mBjo44EqcwYNUKv3MZNEBNRw36nTPCny9oiVEe/4awqe9KQNS awaKRF6rl899POLfWhtwgth4IbGCXZZYoFHQdWbChyiePaq/vLUe3FTZlsbO4O5Nmk0S PlvQ== X-Forwarded-Encrypted: i=1; AJvYcCW9mxXTX6j4/dVSPFb4N1my/J/iOczmJpl8AkYtYSPmMysFbAx8ZgFR1weJ01/XO3VnPSJAstUuKuEXsSSr0wdd4CZZvxE= X-Gm-Message-State: AOJu0YxuUVLurTyO3GCMeQWX+oYTM05GKS8rIg7LVmhksoJpRDOpnjqj tiQ/hcaCDDK/P03YsGcgWVYPXETIfJe9HunUJL8uTQergGZ5mQKulZcjYg== X-Google-Smtp-Source: AGHT+IF5KzDGdGUVIjp7ZnJAXcX+JuBJBSiOWFuaBb0D9cKRNZuE4kKPRenquYdP9NJBqE5NalOSww== X-Received: by 2002:a17:90a:520b:b0:2bd:9255:91b6 with SMTP id 98e67ed59e1d1-2bd9255b060mr918209a91.4.1716255065349; Mon, 20 May 2024 18:31:05 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 07/12] target/ppc: add helper to write per-LPAR SPRs Date: Tue, 21 May 2024 11:30:23 +1000 Message-ID: <20240521013029.30082-8-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::532; envelope-from=npiggin@gmail.com; helo=mail-pg1-x532.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 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: 1716255150033100007 Content-Type: text/plain; charset="utf-8" An SPR can be either per-thread, per-core, or per-LPAR. Per-LPAR means per-thread or per-core, depending on 1LPAR mode. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/spr_common.h | 2 ++ target/ppc/translate.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/target/ppc/spr_common.h b/target/ppc/spr_common.h index 9e40b3b608..85f73b860b 100644 --- a/target/ppc/spr_common.h +++ b/target/ppc/spr_common.h @@ -83,6 +83,8 @@ void spr_read_generic(DisasContext *ctx, int gprn, int sp= rn); void spr_write_generic(DisasContext *ctx, int sprn, int gprn); void spr_write_generic32(DisasContext *ctx, int sprn, int gprn); void spr_core_write_generic(DisasContext *ctx, int sprn, int gprn); +void spr_core_write_generic32(DisasContext *ctx, int sprn, int gprn); +void spr_core_lpar_write_generic(DisasContext *ctx, int sprn, int gprn); void spr_write_MMCR0(DisasContext *ctx, int sprn, int gprn); void spr_write_MMCR1(DisasContext *ctx, int sprn, int gprn); void spr_write_MMCRA(DisasContext *ctx, int sprn, int gprn); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 137370b649..c688551434 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -535,6 +535,34 @@ void spr_core_write_generic(DisasContext *ctx, int spr= n, int gprn) spr_store_dump_spr(sprn); } =20 +void spr_core_write_generic32(DisasContext *ctx, int sprn, int gprn) +{ + TCGv t0; + + if (!(ctx->flags & POWERPC_FLAG_SMT)) { + spr_write_generic32(ctx, sprn, gprn); + return; + } + + if (!gen_serialize(ctx)) { + return; + } + + t0 =3D tcg_temp_new(); + tcg_gen_ext32u_tl(t0, cpu_gpr[gprn]); + gen_helper_spr_core_write_generic(tcg_env, tcg_constant_i32(sprn), t0); + spr_store_dump_spr(sprn); +} + +void spr_core_lpar_write_generic(DisasContext *ctx, int sprn, int gprn) +{ + if (ctx->flags & POWERPC_FLAG_SMT_1LPAR) { + spr_core_write_generic(ctx, sprn, gprn); + } else { + spr_write_generic(ctx, sprn, gprn); + } +} + static void spr_write_CTRL_ST(DisasContext *ctx, int sprn, int gprn) { /* This does not implement >1 thread */ --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255177; cv=none; d=zohomail.com; s=zohoarc; b=Rcs6RNRxLmkJjNydIuSztsU7ofaebAos8jn87P94r5GHvg0a85APfUn+98GI1VN9gtQOL4USxKbE98d5EJAg++bA5dZtjSQNedWEsrzVabVI/71jMsG79c9JUOsV0B1+Mzf77Ur7a8UIJDjmP0Qh/mWYZMoF3ekfL7LRzC1sp1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255177; 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=Mzfw0EKvyp7V4Mv+crjJx37Vf+DDxSzVKkZLcfZPdSY=; b=XoDquko04rztEpN11x7jJ6EN/N4/K+jbSnDwmHzhMwCZbpvjhsw3dBE0JnGYCFK+IukqNFwqjUHxd4goM9Omc6Uz0qh3AZB5FyH6AtFHjb/yQ+KLjvgGUC0OiOdN/FeEMz51y2T/Fzz9+Nma9nBSK6UklP617EKpUz1ZqRn1NHM= 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 1716255177814431.6138504856989; Mon, 20 May 2024 18:32:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELT-0007qr-A6; Mon, 20 May 2024 21:31:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELR-0007oM-Fj; Mon, 20 May 2024 21:31:13 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELP-0005LZ-O6; Mon, 20 May 2024 21:31:13 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ecc23e6c9dso93376115ad.2; Mon, 20 May 2024 18:31:11 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255069; x=1716859869; 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=Mzfw0EKvyp7V4Mv+crjJx37Vf+DDxSzVKkZLcfZPdSY=; b=VdXGj3vZv4H1H+nZRA8wtO1OOVo1x4qEuRCDCwxBwqvVsHNVJfVtgYl64pZ7aOVuJC /xl16qj2EqZtQP8HrA5PdW6gqx7/gZErfg/RyUwgJjA8B82X80ofU7F6oEkiUMzZtVV+ fdChWNG/NE+qcUgdzXJR7kmLBl5z7Fcm5BxFgD+fAOT6ah3CoK7kftsuVXiyRjiTPlgx yOrJoALaeYJiNSH+TKQLr4abb+9cQD3DBjBvFYokJvi4OLvuIKHPnhz8xZYpZd8Wcgwb MjTfUCWF4Zli5C5RLu4qeM0CK4hSODudLfI6VNWFq0FqxpQqrIcsiMsQWz4ji9ulOZ2L fPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255069; x=1716859869; 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=Mzfw0EKvyp7V4Mv+crjJx37Vf+DDxSzVKkZLcfZPdSY=; b=ZelC8pIQqu2VMXqgpndoEeuhdbTSWluhILuHuwKYHIXppXQf24+dhtD5Tdl1cR337i ITCvxYSgKWFHQT85aAzR6b/k78QkxOlEJ+PDj9cG03jg8t35idTeWNq3B0HzjvrRWrok v9NuEIHhjW6b0GV8tvhUCzoAQEP6uXGuWQHNDzFKxfa8ut/Qq+nn6Le/1EN+HmaSIwhM OIuZQyWhn38b4NObQRWDY6J7kEQpJRJ+sU0V8CQgBubGdNlCaCd0s2aXdLM84s+hYbpU 32ZnTcZzSG60/pFBX9/wMZ1xB5xg/VKYNOabqRXkUSlnHncL5GQtpNHPf16pXe9sFM4n 3sZQ== X-Forwarded-Encrypted: i=1; AJvYcCXGq8dACOWFAwX56/u++5wTPdPfTFmza+0cEN+3mB//4DceUxgzLXywOZqDGltV+lgvqc/4ueFs80h4nC3zJ9P34J0F3zI= X-Gm-Message-State: AOJu0YyrXXiiiElB45XRU7jPY3x4G4dwdi6iKzOMMhO7Yo20vB05AkN4 SCe7a2WYc0k4CJN1xQLbHgLC4HKB6freVPZDzOEGQ5b316DGQYQ38D085Q== X-Google-Smtp-Source: AGHT+IFHjGj6Cho4o2IaXtwWuBc+YXHxkTSoL6ro8glBDRHFYuKaxszitf2HxY1d/MDI5HriSZWJJA== X-Received: by 2002:a17:90a:fb96:b0:2b9:dd9c:34cb with SMTP id 98e67ed59e1d1-2b9dd9c350amr13459408a91.27.1716255069351; Mon, 20 May 2024 18:31:09 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 08/12] target/ppc: Add SMT support to simple SPRs Date: Tue, 21 May 2024 11:30:24 +1000 Message-ID: <20240521013029.30082-9-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::629; envelope-from=npiggin@gmail.com; helo=mail-pl1-x629.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 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: 1716255178263100001 Content-Type: text/plain; charset="utf-8" AMOR, MMCRC, HRMOR, TSCR, HMEER, RPR SPRs are per-core or per-LPAR registers with simple (generic) implementations. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu_init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 7684a59d75..023b58a3ac 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -246,7 +246,7 @@ static void register_amr_sprs(CPUPPCState *env) spr_register_hv(env, SPR_AMOR, "AMOR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_lpar_write_generic, 0); #endif /* !CONFIG_USER_ONLY */ } @@ -5489,7 +5489,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env) spr_register_hv(env, SPR_MMCRC, "MMCRC", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic32, + &spr_read_generic, &spr_core_write_generic32, 0x00000000); spr_register_hv(env, SPR_MMCRH, "MMCRH", SPR_NOACCESS, SPR_NOACCESS, @@ -5529,7 +5529,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env) spr_register_hv(env, SPR_HRMOR, "HRMOR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic, 0x00000000); } =20 @@ -5757,7 +5757,7 @@ static void register_power_common_book4_sprs(CPUPPCSt= ate *env) spr_register_hv(env, SPR_TSCR, "TSCR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic32, + &spr_read_generic, &spr_core_write_generic32, 0x00000000); spr_register_hv(env, SPR_HMER, "HMER", SPR_NOACCESS, SPR_NOACCESS, @@ -5767,7 +5767,7 @@ static void register_power_common_book4_sprs(CPUPPCSt= ate *env) spr_register_hv(env, SPR_HMEER, "HMEER", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic, 0x00000000); spr_register_hv(env, SPR_TFMR, "TFMR", SPR_NOACCESS, SPR_NOACCESS, @@ -5843,7 +5843,7 @@ static void register_power8_rpr_sprs(CPUPPCState *env) spr_register_hv(env, SPR_RPR, "RPR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_core_write_generic, 0x00000103070F1F3F); #endif } --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255136; cv=none; d=zohomail.com; s=zohoarc; b=Jczx6juduSQ3qJ5V1GEGQ05/olWqraX/KHAmOvsB3/gfoEdcNgQeBplx8h3HkVDHjUQ8EumoaUZxccNxKAlbzMRZkvKA6B2j8f4j/ZbAXEQ1P0X06HDisfZCynK7mSgXi4tGdLKyzWQgX2eboXgSMLP68/EQib1BmojQLOAYvNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255136; 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=UogJLS5LbK3AS3jvsFfTXAjp3CkBWXTUBHu2pm6GqSs=; b=cUn+RgZwBm1PEyERZoRIRib4VXKnhjPTGaYK8TDUR+kiP2uiZr6S4Y8heVy71hej3WE/JB+VmZFW/YUlvpNHncaJGMObEZPYVlMujdzb6HtURkpQprxdcKMWGdJ7AEZB787+pycuoKkwE4BTz2Vc2Qxi0AqGSOrqBTy2JC5jVSQ= 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 1716255136316850.2153827540241; Mon, 20 May 2024 18:32:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELY-0007un-6N; Mon, 20 May 2024 21:31:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELV-0007tF-Js; Mon, 20 May 2024 21:31:17 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELU-0005Lv-12; Mon, 20 May 2024 21:31:17 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ee954e0aa6so63336475ad.3; Mon, 20 May 2024 18:31:14 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255073; x=1716859873; 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=UogJLS5LbK3AS3jvsFfTXAjp3CkBWXTUBHu2pm6GqSs=; b=RiYRx4hGqqBL04kRrG+biySKnb33eaPqyrM5nMxIeVV9AH/gljiv9HWU/Myt+MowZ2 kAy04uRQJxjDvImgMrJzmZ2w3yaWtbE68ihRDbF8mapuepivM4tEtlPBuDAe+NBi+vUA Jyk8t7F307W1GCkQrrfsND9q3m8llKlgbg6xA2QXKNxjFSiNhGUsyFNLNM/6LOToKYTw tZPtZU2MJ++Ib95onGAkwas9hBnOTToAmTtMgcgyn6zuUGOIVWcSC5A88wOghzOfYTmy G6sDSSU2IKkR4wEJK+cCa8yyUvNzzXOnoAbmF9ggS5dQ9rDt/lUi8VJxVXsLbntUtMi8 cUOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255073; x=1716859873; 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=UogJLS5LbK3AS3jvsFfTXAjp3CkBWXTUBHu2pm6GqSs=; b=cfkOEMCrylW5fH15PXFUL1yBwtC2cQ7IrmAeTGIRtawOQFA7Iltl5DHsEjLnlY/BCL 2LmtXEsJYzR05nd6nNEaa/FKG4aAk6k4hVs7X1k9Txzryr13xClnY9rP3GJ4JLTvH7MH L04tQ7XPTnEl1Abaq573kSEljFXAaq77eD0BMB942SryRqYkgtv5yGyN3jxG0uFUg193 Hsv3sBZ0lUadT1Wx2PGesRMnGi1tux8XJQ75UAjMRn6PDsMCNWe2lRc9v0WyHrf+a2A/ nuCD8ollbw03k/Z4MqT19DT4QSauvilc2gaYIW+Zkavc5RGPL58aI80CtwV1COvxpsyG ywbQ== X-Forwarded-Encrypted: i=1; AJvYcCXPMHRo89mTpYi903narJXIYPl5cJx5/lj3rmrWDyFDcngnDhQoAUIwR8pzlESzUBuSTRJiiJYCt12STJSFUuZUymeXITM= X-Gm-Message-State: AOJu0YxII5JH3CHJGo+nnLX/f3khX/rpE7iMWrcbF0Fx1tRodvzVo6Q4 TVMIr2SQ+gl1SIEP9W7X53DLDn/JzU3Cdq/8iPgcxiY/wI0+oKIJTeU0Ug== X-Google-Smtp-Source: AGHT+IGtvLHxUi5PyR4zdLbum+I2X6bRb4sgxoE1vgY+KPuTf+GDFeRz+tiEvrELGfp1hiLmOtl/Ow== X-Received: by 2002:a17:90b:4c09:b0:2bd:9255:4738 with SMTP id 98e67ed59e1d1-2bd925558d6mr765591a91.5.1716255073239; Mon, 20 May 2024 18:31:13 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 09/12] target/ppc: Add SMT support to PTCR SPR Date: Tue, 21 May 2024 11:30:25 +1000 Message-ID: <20240521013029.30082-10-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::62b; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62b.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 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: 1716255137985100003 Content-Type: text/plain; charset="utf-8" PTCR is a per-core register. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/misc_helper.c | 16 ++++++++++++++-- target/ppc/translate.c | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 6f419c9346..a67930d031 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -173,6 +173,7 @@ void helper_store_sdr1(CPUPPCState *env, target_ulong v= al) void helper_store_ptcr(CPUPPCState *env, target_ulong val) { if (env->spr[SPR_PTCR] !=3D val) { + CPUState *cs =3D env_cpu(env); PowerPCCPU *cpu =3D env_archcpu(env); target_ulong ptcr_mask =3D PTCR_PATB | PTCR_PATS; target_ulong patbsize =3D val & PTCR_PATS; @@ -194,8 +195,19 @@ void helper_store_ptcr(CPUPPCState *env, target_ulong = val) return; } =20 - env->spr[SPR_PTCR] =3D val; - tlb_flush(env_cpu(env)); + if (cs->nr_threads =3D=3D 1 || !(env->flags & POWERPC_FLAG_SMT_1LP= AR)) { + env->spr[SPR_PTCR] =3D val; + tlb_flush(cs); + } else { + CPUState *ccs; + + THREAD_SIBLING_FOREACH(cs, ccs) { + PowerPCCPU *ccpu =3D POWERPC_CPU(ccs); + CPUPPCState *cenv =3D &ccpu->env; + cenv->spr[SPR_PTCR] =3D val; + tlb_flush(ccs); + } + } } } =20 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index c688551434..76f829ad12 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -971,6 +971,10 @@ void spr_write_hior(DisasContext *ctx, int sprn, int g= prn) } void spr_write_ptcr(DisasContext *ctx, int sprn, int gprn) { + if (!gen_serialize_core(ctx)) { + return; + } + gen_helper_store_ptcr(tcg_env, cpu_gpr[gprn]); } =20 --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255132; cv=none; d=zohomail.com; s=zohoarc; b=UYzbVe5FKsrerDONmW4TWWiIdW1si/wajPSY3+oEB/mpym5cBVgArGNMb96pxesRh+DfcAx/L+0CvW4Pcie99y3QHLimCm47UM130ulsrWyoWRC0A8ZgI+qfBenOxQU1UyP6zuNovne0EUVhtxwNvHJEVhFb8GdbP5FyO10+we8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255132; 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=3M7m5trFhZtr2BOnL6BUkZtoVjgJAKVr9rWvGV0l+Ss=; b=be4t+soLrJYR5aWxTdix7KTs01axt7rjMRERFDqH9koxz3kNS3ZbylIJMddGJsFwxHzjzsjtcAIJxd5fHNu1+FQhEw/eoVvc5caigA87ACSgDhIjhFh8FMtUtl3W0QhdpJMKGvvmYB7q89NWxpshIei6jfdULr2ABpzTJeqednI= 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 1716255132279241.1716767932586; Mon, 20 May 2024 18:32:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELb-0007w4-V0; Mon, 20 May 2024 21:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELZ-0007vK-Hf; Mon, 20 May 2024 21:31:21 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELX-0005Nf-PZ; Mon, 20 May 2024 21:31:21 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1edfc57ac0cso94445885ad.3; Mon, 20 May 2024 18:31:19 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255078; x=1716859878; 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=3M7m5trFhZtr2BOnL6BUkZtoVjgJAKVr9rWvGV0l+Ss=; b=Ib2hRZwhqBrVxHzxW1uBzjxh/N3AIot1+IEYu71WFmkCP+i1lm/C6+8Trf5fDA7Ts5 MYOQDR1F3pYVjBkg6O6vPqXpns5P/AziGc0Qek8BsFzstPJLO+M1UPKd9YnBW1xlPYyS bRmoO1VJa91jn93iuidhL9vc5AysmzKmeLF3coIRnTH8rGfPxQPAeq0paI98/AUt1rYL kHYblTnjMyN6Dc2J18Us0KgTYxc4RoP4pf/mjWUGd4YHiNXPs31jwtpsebblFUlcX5kE m6K1hqz4VS18RgyI2SX/ffKOF+5fdKXO7Nx9pDP7HwBTOwkl7FmqAwYJwVS/0nb9UUd+ DGQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255078; x=1716859878; 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=3M7m5trFhZtr2BOnL6BUkZtoVjgJAKVr9rWvGV0l+Ss=; b=roxVwZs0EJWGkfjuHmmh64eUMwt2DM4I2j1JjWBL3KAHdDnfv4hproHEsQVJcXOy9F sEEfqJ+z1iks48iZALes5UplkhtyaZard24ALF4bcvsdflJjRffKFwH9G/+AZK7c9VOb 8+YHP5rgkCS/Vr2hK8snnXj+ol08bkTyEH62ucNcTdC8ombelGIvL4M84cxlmSeHDXTx OyOjVr6LWM+SP+B1z8IDsLErwxhK93ahzeEBtfRFq+PUpVmgIqxLWVHA7Ce5LEjeEVEc ebAb+FMkQB6IcD01uT5+ZksXH0k+8eEPLHYgTLBL1O7LR+WA8ikkiwMavm+CBmqGpqqD yGgA== X-Forwarded-Encrypted: i=1; AJvYcCVnmdzq4v8rZxoMlrOTxnLoY6QLQF2wtnUnnzW6K55J9TQJ0Er/F+oGl/WP9TeWyVZbPKttvQuYpt5knjoh+EmATdB071E= X-Gm-Message-State: AOJu0YwQgyTxUukJXiJkjbw8dmoo4HOxXf+IAyRaxSrPBwQWvBgbcRUo hlkW5L47ibvnzqvNmoHUz2szlaTa+wXWd754K0TK25pWS4m0koJ/OAD1pw== X-Google-Smtp-Source: AGHT+IG/23uwQqUn8GVpGUqtv2fyANvuOcSA61N3zjEUVW0k7HIG/TALEyVK83OJUJw1mIdTqPJaeQ== X-Received: by 2002:a17:90a:1fcb:b0:2b6:29d3:30b with SMTP id 98e67ed59e1d1-2b6cc566cd9mr24929387a91.7.1716255077750; Mon, 20 May 2024 18:31:17 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 10/12] target/ppc: Implement LDBAR, TTR SPRs Date: Tue, 21 May 2024 11:30:26 +1000 Message-ID: <20240521013029.30082-11-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::635; envelope-from=npiggin@gmail.com; helo=mail-pl1-x635.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 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: 1716255133913100003 Content-Type: text/plain; charset="utf-8" LDBAR, TTR are a Power-specific SPRs. These simple implementations are enough for IBM proprietary firmware for now. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu.h | 2 ++ target/ppc/cpu_init.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 141cbefb4c..823be85d03 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2098,6 +2098,7 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_DEXCR (0x33C) #define SPR_IC (0x350) #define SPR_VTB (0x351) +#define SPR_LDBAR (0x352) #define SPR_MMCRC (0x353) #define SPR_PSSCR (0x357) #define SPR_440_INV0 (0x370) @@ -2144,6 +2145,7 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_440_IVLIM (0x399) #define SPR_TSCR (0x399) #define SPR_750_DMAU (0x39A) +#define SPR_POWER_TTR (0x39A) #define SPR_750_DMAL (0x39B) #define SPR_440_RSTCFG (0x39B) #define SPR_BOOKE_DCDBTRL (0x39C) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 023b58a3ac..7f2f8e5a4a 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5784,6 +5784,16 @@ static void register_power_common_book4_sprs(CPUPPCS= tate *env) &spr_access_nop, &spr_write_generic, &spr_access_nop, &spr_write_generic, 0x00000000); + spr_register_hv(env, SPR_LDBAR, "LDBAR", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_core_lpar_write_generic, + 0x00000000); + spr_register_hv(env, SPR_POWER_TTR, "TTR", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_core_write_generic, + 0x00000000); #endif } =20 --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255125; cv=none; d=zohomail.com; s=zohoarc; b=LZJN+2D/6kDcZEz6Drf2Z1iPf3fgIthYC1sWxtK+VMPPTXB9pO16nCju/RjN5br1m6aq9r0iHeMNxSn7lYuun1DfL0gaNMuRd8KhasssXlTWAvbObbkrPkYUjrwEBTqR/THow6YYVUh83+OO2OiPQWm3TXVSCy3tyqkuCVnFkm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255125; 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=R6icibkdfPpt4XbdV/F4GetelVPwQDspWmBNSa+4i68=; b=Ed9bIbTkBUNjUGyIg3EnsKbyyfu/ODUvcjbEmAb59cL6ncxRRZc6W0b8OC7zShLsyEzifBR06ygop0F9wnBo3oPPYTggTkmSgwP4go55dS2QXPnCOxB1yACRa44crTFqMw2pj/m1ex3VHht8YntHtM6Pse+3TvXzmVLORaoerTI= 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 171625512556336.43393476758729; Mon, 20 May 2024 18:32:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELg-0007y0-0r; Mon, 20 May 2024 21:31:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELe-0007wv-02; Mon, 20 May 2024 21:31:26 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELc-0005O2-4R; Mon, 20 May 2024 21:31:25 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1f2f566a7c7so62970045ad.1; Mon, 20 May 2024 18:31:23 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255082; x=1716859882; 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=R6icibkdfPpt4XbdV/F4GetelVPwQDspWmBNSa+4i68=; b=f/9TvpFQY945mpI8JwEX9wmb9vhb7vhpbKG+RVnhQHAQ3Dorf5JoH96k5lM8CQAosF +fAaN2Rt36HA5HZ+RBKNuZPSoXJS2RYjJc/Ftj4GcjQbmQY/0YgjRZutWZHOWPs40k4q bxzxo7haMJTRy7KC55pq3ILRbT4gq6Md0JAJ3bschH6SMfEkp0X3/Hss6NnvFxc4Ywuh UuhqpYK9p3B2djdw/CoE2fd90JT0ugKw2vlN60k5PMBBD8BJOpg3K9L2EtPbzJWt2Ply HiquzsQffJnvWGxyCNsvVT7GkViO6S4DdtWYuBVjzcPbLt0QwlBf1yvm8Q1MylezDX7Y zqbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255082; x=1716859882; 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=R6icibkdfPpt4XbdV/F4GetelVPwQDspWmBNSa+4i68=; b=N6v5sGsctJ0/Dfgiq6sU58k4uLaOAT9L/ExzdW32fDZ9/3XIevrgMLo8DMnbQ/zDqX la/BHJQ+wdlgXtJ7QsTcT3WPSWjFlxL0ggiBlqbUn2RofcCB8jXgtHOsp4YFA2h09Lg6 R9Z7YrzoPLM8lOCyKbTuGyENZIvPS4K+X7jfDrT0yRBmba2Hvi0hY5fyVEv304VUqlr+ ddqAta7PAAZII1STsPjW8INtbZwGW06xIbMjGP43nD8JaqMF7bKu7vfsphwBvkYgG74Q UBiOySdnPFhujf8tcC4LgJ2CwQEqXqBgwQVIYZXFUB+KI8uzQnbDPZPAkYcKVtvCuKBY 7uDg== X-Forwarded-Encrypted: i=1; AJvYcCXfALHDqCJksKpyzduTJe1jth96PpFvxNV74H4vhpPkBRKQFQ3wMbMJICQMIS4z8ThmeF34nbAxrh6+vZAf4OgRRtxildc= X-Gm-Message-State: AOJu0YwU2ASVWhsKR3ibqQYcRltbXGCJoDWET7XFMfkCLNSMCh8IYU88 a7wHALmHt8ulZSDHZVfBcPr7ifs3yfZ9re/HPPu7qK0qejGpFVUukpcNFA== X-Google-Smtp-Source: AGHT+IFLdPH2zR4zHEQ2Rj0k/IZRsfN6iieCHtl90TcWewylSzHSmyWY+9aGV69bNY9i/QnpbC7OCQ== X-Received: by 2002:a17:90a:d507:b0:2b6:ab87:59bf with SMTP id 98e67ed59e1d1-2b6cc78068fmr24823727a91.27.1716255081799; Mon, 20 May 2024 18:31:21 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 11/12] target/ppc: Implement SPRC/SPRD SPRs Date: Tue, 21 May 2024 11:30:27 +1000 Message-ID: <20240521013029.30082-12-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::630; envelope-from=npiggin@gmail.com; helo=mail-pl1-x630.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 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: 1716255125915100001 Content-Type: text/plain; charset="utf-8" This implements the POWER SPRC/SPRD SPRs, and SCRATCH0-7 registers that can be accessed via these indirect SPRs. SCRATCH registers only provide storage, but they are used by firmware for low level crash and progress data, so this implementation logs writes to the registers to help with analysis. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu.h | 7 +++-- target/ppc/helper.h | 3 ++ target/ppc/spr_common.h | 3 ++ target/ppc/cpu_init.c | 10 ++++++ target/ppc/misc_helper.c | 66 ++++++++++++++++++++++++++++++++++++++++ target/ppc/translate.c | 18 +++++++++++ 6 files changed, 105 insertions(+), 2 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 823be85d03..e4c342b17d 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1264,6 +1264,9 @@ struct CPUArchState { ppc_slb_t slb[MAX_SLB_ENTRIES]; /* PowerPC 64 SLB area */ struct CPUBreakpoint *ciabr_breakpoint; struct CPUWatchpoint *dawr0_watchpoint; + + /* POWER CPU regs/state */ + target_ulong scratch[8]; /* SCRATCH registers (shared across core) */ #endif target_ulong sr[32]; /* segment registers */ uint32_t nb_BATs; /* number of BATs */ @@ -1806,9 +1809,9 @@ void ppc_compat_add_property(Object *obj, const char = *name, #define SPR_SPRG2 (0x112) #define SPR_SPRG3 (0x113) #define SPR_SPRG4 (0x114) -#define SPR_SCOMC (0x114) +#define SPR_POWER_SPRC (0x114) #define SPR_SPRG5 (0x115) -#define SPR_SCOMD (0x115) +#define SPR_POWER_SPRD (0x115) #define SPR_SPRG6 (0x116) #define SPR_SPRG7 (0x117) #define SPR_ASR (0x118) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 09d50f9b76..57bf8354e7 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -730,6 +730,9 @@ DEF_HELPER_2(book3s_msgsndp, void, env, tl) DEF_HELPER_2(book3s_msgclrp, void, env, tl) DEF_HELPER_1(load_tfmr, tl, env) DEF_HELPER_2(store_tfmr, void, env, tl) +DEF_HELPER_FLAGS_2(store_sprc, TCG_CALL_NO_RWG, void, env, tl) +DEF_HELPER_FLAGS_1(load_sprd, TCG_CALL_NO_RWG_SE, tl, env) +DEF_HELPER_FLAGS_2(store_sprd, TCG_CALL_NO_RWG, void, env, tl) #endif DEF_HELPER_2(store_sdr1, void, env, tl) DEF_HELPER_2(store_pidr, void, env, tl) diff --git a/target/ppc/spr_common.h b/target/ppc/spr_common.h index 85f73b860b..01aff449bc 100644 --- a/target/ppc/spr_common.h +++ b/target/ppc/spr_common.h @@ -207,6 +207,9 @@ void spr_write_lpcr(DisasContext *ctx, int sprn, int gp= rn); void spr_read_dexcr_ureg(DisasContext *ctx, int gprn, int sprn); void spr_read_ppr32(DisasContext *ctx, int sprn, int gprn); void spr_write_ppr32(DisasContext *ctx, int sprn, int gprn); +void spr_write_sprc(DisasContext *ctx, int sprn, int gprn); +void spr_read_sprd(DisasContext *ctx, int sprn, int gprn); +void spr_write_sprd(DisasContext *ctx, int sprn, int gprn); #endif =20 void register_low_BATs(CPUPPCState *env); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 7f2f8e5a4a..f21dbcfefb 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5794,6 +5794,16 @@ static void register_power_common_book4_sprs(CPUPPCS= tate *env) SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_core_write_generic, 0x00000000); + spr_register_hv(env, SPR_POWER_SPRC, "SPRC", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_write_sprc, + 0x00000000); + spr_register_hv(env, SPR_POWER_SPRD, "SPRD", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_sprd, &spr_write_sprd, + 0x00000000); #endif } =20 diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index a67930d031..fa47be2298 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -307,6 +307,72 @@ void helper_store_dpdes(CPUPPCState *env, target_ulong= val) } bql_unlock(); } + +/* Indirect SCOM (SPRC/SPRD) access to SCRATCH0-7 are implemented. */ +void helper_store_sprc(CPUPPCState *env, target_ulong val) +{ + if (val & ~0x3f8ULL) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid SPRC register value " + TARGET_FMT_lx"\n", val); + return; + } + env->spr[SPR_POWER_SPRC] =3D val; +} + +target_ulong helper_load_sprd(CPUPPCState *env) +{ + target_ulong sprc =3D env->spr[SPR_POWER_SPRC]; + + switch (sprc & 0x3c0) { + case 0: /* SCRATCH0-7 */ + return env->scratch[(sprc >> 3) & 0x7]; + default: + qemu_log_mask(LOG_UNIMP, "mfSPRD: Unimplemented SPRC:0x" + TARGET_FMT_lx"\n", sprc); + break; + } + return 0; +} + +static void do_store_scratch(CPUPPCState *env, int nr, target_ulong val) +{ + CPUState *cs =3D env_cpu(env); + CPUState *ccs; + uint32_t nr_threads =3D cs->nr_threads; + + /* + * Log stores to SCRATCH, because some firmware uses these for debuggi= ng + * and logging, but they would normally be read by the BMC, which is + * not implemented in QEMU yet. This gives a way to get at the informa= tion. + * Could also dump these upon checkstop. + */ + qemu_log("SPRD write 0x" TARGET_FMT_lx " to SCRATCH%d\n", val, nr); + + if (nr_threads =3D=3D 1) { + env->scratch[nr] =3D val; + return; + } + + THREAD_SIBLING_FOREACH(cs, ccs) { + CPUPPCState *cenv =3D &POWERPC_CPU(ccs)->env; + cenv->scratch[nr] =3D val; + } +} + +void helper_store_sprd(CPUPPCState *env, target_ulong val) +{ + target_ulong sprc =3D env->spr[SPR_POWER_SPRC]; + + switch (sprc & 0x3c0) { + case 0: /* SCRATCH0-7 */ + do_store_scratch(env, (sprc >> 3) & 0x7, val); + break; + default: + qemu_log_mask(LOG_UNIMP, "mfSPRD: Unimplemented SPRC:0x" + TARGET_FMT_lx"\n", sprc); + break; + } +} #endif /* defined(TARGET_PPC64) */ =20 void helper_store_pidr(CPUPPCState *env, target_ulong val) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 76f829ad12..ab11e48e3f 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -1363,6 +1363,24 @@ void spr_write_tfmr(DisasContext *ctx, int sprn, int= gprn) gen_helper_store_tfmr(tcg_env, cpu_gpr[gprn]); } =20 +void spr_write_sprc(DisasContext *ctx, int sprn, int gprn) +{ + gen_helper_store_sprc(tcg_env, cpu_gpr[gprn]); +} + +void spr_read_sprd(DisasContext *ctx, int gprn, int sprn) +{ + gen_helper_load_sprd(cpu_gpr[gprn], tcg_env); +} + +void spr_write_sprd(DisasContext *ctx, int sprn, int gprn) +{ + if (!gen_serialize_core(ctx)) { + return; + } + gen_helper_store_sprd(tcg_env, cpu_gpr[gprn]); +} + void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn) { translator_io_start(&ctx->base); --=20 2.43.0 From nobody Mon Nov 25 07:52:20 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=1716255156; cv=none; d=zohomail.com; s=zohoarc; b=PbZltcgr3tDKNScSmk+SKpHHyMayhUwVeBrqudDOFqvLv+ukxZIn7N1hUBuz6/eWyVzlXV1codnOkrpaDgHP41brdP1kiVghWpSFvS6G6Zb3SqVh8W/bp0z+wX+kZnrBoQuiEbUkbqDFkifOwKSXUFPPynqqaXA5YpBY2f4bIFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716255156; 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=jkT0FWB24KQBqdJ8LIoXwTuEUugVA4P7cz61QMqZCII=; b=BL08x29kXsD/qOTO9pHeNz/KsSUmACn/2RDVbdDI5/7pz0IUq6TpRs4L4eznl/34EPyLlMzWwRtU/kAm+sYo/bDAUOpEW9Ac5rI8pz3lDsfKwR8GVX+xNxnmwV7J3wt7zM9MwrIGX1AoO3vbBr4g9nuHAZ3ycPDMui1O0PF4RRA= 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 1716255156219328.02437853714696; Mon, 20 May 2024 18:32:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9ELj-0007zi-Lj; Mon, 20 May 2024 21:31:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9ELh-0007yS-Vj; Mon, 20 May 2024 21:31:29 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9ELf-0005ON-UN; Mon, 20 May 2024 21:31:29 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1f0537e39b3so90452225ad.3; Mon, 20 May 2024 18:31:27 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bd7f0cd400sm2514953a91.31.2024.05.20.18.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716255086; x=1716859886; 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=jkT0FWB24KQBqdJ8LIoXwTuEUugVA4P7cz61QMqZCII=; b=grROf15uNbyQ+pUpfpx90evdswIkOBMy1Ldbsxgno4s3uL/T/IOkXrkpEpuP7KJLdh wlhNiQmcWYw86y8o62pqSVPiyDqo1dqJ8Mbi4cI2cQlab3xfwschxy3orMZ6dLyFRnA7 HnOD13alEoNB/SrmDIjPKDv9TtvzvIif+APjKZLqbtr3RoNaeOdXAEcmIevmwSqXHkSa 3+Cd9RMR3o9tA/G3uNvOCDlbTAUIQEh+C/LMBSSnzKMUxteDDmfo/AB8WSJAzT69cYmp UuWBT6gc9O7b970id7WeJtWWqPCXW0sDzoFFzvaZkBKnvO23mi8FhMMaFdSAVIds4Y8X OFOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716255086; x=1716859886; 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=jkT0FWB24KQBqdJ8LIoXwTuEUugVA4P7cz61QMqZCII=; b=FE/v54g2vcIpPhySyIKRrgD+vbG1xCngs9kZ2T42flEnT1tWFM0sQIVd+kyQpYPC3n kUWiU1LUo4l7wyGcbj2YN44CQoI7xdinECdHxgFCA+tweoaBbrt0DeBbVl+zWKmQwhJ0 AMB+vcMomzI8UiGyQy2JpbusEuz0ZrF+zHiAekrMTW9ZryqBU53kWOHPDR/FLQDweTIw zQzjvnzBs7Syj/cJOPXSvdb+1/bKNFuAQFyptiBUKGpoc/dJui2adT7mrBdQlPgy3SGs XS8YHigFcCLgS8n+1sjjQ1CwBJJ0qLbNH/BC4cgNkhsHS7wnDXs3jqqC10zKyCact9zv EQLA== X-Forwarded-Encrypted: i=1; AJvYcCVYvT1j/8nm/xeBVo/DjyxMuCYaNNPyQoOAeiWaiAdLkDwHyB/gkMrseUkfXBEzX1Cu5fo3mrprktHEFBXewRZ+zX4a0n0= X-Gm-Message-State: AOJu0YyzmdDaFRkoNpNryJdkeK7nhFreBK+sUkWooyX4BSau+kky6rKD 2n63sm1cwHS+hkRtGsZ3/ZQlyJ34lUqIRz95x5nKZubl92kqxTDvuefR0g== X-Google-Smtp-Source: AGHT+IF5QKp04E5MXYkw7XZOLh61QQ03MEhxOpI15f+MRhI9g7q32x5wrUaSrl+Ti/lII9XeH5sz/A== X-Received: by 2002:a17:90a:5502:b0:2ac:40c8:1ed3 with SMTP id 98e67ed59e1d1-2b6cc342957mr28346504a91.5.1716255086033; Mon, 20 May 2024 18:31:26 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Glenn Miles , Richard Henderson , Chinmay Rath Subject: [PATCH v2 12/12] target/ppc: add SMT support to msgsnd broadcast Date: Tue, 21 May 2024 11:30:28 +1000 Message-ID: <20240521013029.30082-13-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521013029.30082-1-npiggin@gmail.com> References: <20240521013029.30082-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::62a; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62a.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 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: 1716255158159100003 Content-Type: text/plain; charset="utf-8" msgsnd has a broadcast mode that sends hypervisor doorbells to all threads belonging to the same core as the target. A "subcore" mode sends to all or one thread depending on 1LPAR mode. Signed-off-by: Nicholas Piggin Reviewed-by: Glenn Miles --- target/ppc/cpu.h | 6 +- target/ppc/helper.h | 2 +- target/ppc/excp_helper.c | 57 +++++++++++++------ .../ppc/translate/processor-ctrl-impl.c.inc | 2 +- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index e4c342b17d..e201b7f6c2 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1163,7 +1163,11 @@ FIELD(FPSCR, FI, FPSCR_FI, 1) =20 #define DBELL_TYPE_DBELL_SERVER (0x05 << DBELL_TYPE_SHIFT) =20 -#define DBELL_BRDCAST PPC_BIT(37) +#define DBELL_BRDCAST_MASK PPC_BITMASK(37, 38) +#define DBELL_BRDCAST_SHIFT 25 +#define DBELL_BRDCAST_SUBPROC (0x1 << DBELL_BRDCAST_SHIFT) +#define DBELL_BRDCAST_CORE (0x2 << DBELL_BRDCAST_SHIFT) + #define DBELL_LPIDTAG_SHIFT 14 #define DBELL_LPIDTAG_MASK (0xfff << DBELL_LPIDTAG_SHIFT) #define DBELL_PIRTAG_MASK 0x3fff diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 57bf8354e7..dd92c6a937 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -695,7 +695,7 @@ DEF_HELPER_FLAGS_3(store_sr, TCG_CALL_NO_RWG, void, env= , tl, tl) =20 DEF_HELPER_1(msgsnd, void, tl) DEF_HELPER_2(msgclr, void, env, tl) -DEF_HELPER_1(book3s_msgsnd, void, tl) +DEF_HELPER_2(book3s_msgsnd, void, env, tl) DEF_HELPER_2(book3s_msgclr, void, env, tl) #endif =20 diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index e786a9044b..0a9e8539a4 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2978,7 +2978,7 @@ void helper_msgsnd(target_ulong rb) PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *cenv =3D &cpu->env; =20 - if ((rb & DBELL_BRDCAST) || (cenv->spr[SPR_BOOKE_PIR] =3D=3D pir))= { + if ((rb & DBELL_BRDCAST_MASK) || (cenv->spr[SPR_BOOKE_PIR] =3D=3D = pir)) { ppc_set_irq(cpu, irq, 1); } } @@ -2997,6 +2997,16 @@ static bool dbell_type_server(target_ulong rb) return (rb & DBELL_TYPE_MASK) =3D=3D DBELL_TYPE_DBELL_SERVER; } =20 +static inline bool dbell_bcast_core(target_ulong rb) +{ + return (rb & DBELL_BRDCAST_MASK) =3D=3D DBELL_BRDCAST_CORE; +} + +static inline bool dbell_bcast_subproc(target_ulong rb) +{ + return (rb & DBELL_BRDCAST_MASK) =3D=3D DBELL_BRDCAST_SUBPROC; +} + void helper_book3s_msgclr(CPUPPCState *env, target_ulong rb) { if (!dbell_type_server(rb)) { @@ -3006,32 +3016,43 @@ void helper_book3s_msgclr(CPUPPCState *env, target_= ulong rb) ppc_set_irq(env_archcpu(env), PPC_INTERRUPT_HDOORBELL, 0); } =20 -static void book3s_msgsnd_common(int pir, int irq) +void helper_book3s_msgsnd(CPUPPCState *env, target_ulong rb) { - CPUState *cs; + int pir =3D rb & DBELL_PROCIDTAG_MASK; + bool brdcast =3D false; + CPUState *cs, *ccs; + PowerPCCPU *cpu; =20 - bql_lock(); - CPU_FOREACH(cs) { - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - CPUPPCState *cenv =3D &cpu->env; + if (!dbell_type_server(rb)) { + return; + } =20 - /* TODO: broadcast message to all threads of the same processor */ - if (cenv->spr_cb[SPR_PIR].default_value =3D=3D pir) { - ppc_set_irq(cpu, irq, 1); - } + cpu =3D ppc_get_vcpu_by_pir(pir); + if (!cpu) { + return; } - bql_unlock(); -} + cs =3D CPU(cpu); =20 -void helper_book3s_msgsnd(target_ulong rb) -{ - int pir =3D rb & DBELL_PROCIDTAG_MASK; + if (dbell_bcast_core(rb) || (dbell_bcast_subproc(rb) && + (env->flags & POWERPC_FLAG_SMT_1LPAR))) { + brdcast =3D true; + } =20 - if (!dbell_type_server(rb)) { + if (cs->nr_threads =3D=3D 1 || !brdcast) { + ppc_set_irq(cpu, PPC_INTERRUPT_HDOORBELL, 1); return; } =20 - book3s_msgsnd_common(pir, PPC_INTERRUPT_HDOORBELL); + /* + * Why is bql needed for walking CPU list? Answer seems to be because = ppc + * irq handling needs it, but ppc_set_irq takes the lock itself if nee= ded, + * so could this be removed? + */ + bql_lock(); + THREAD_SIBLING_FOREACH(cs, ccs) { + ppc_set_irq(POWERPC_CPU(ccs), PPC_INTERRUPT_HDOORBELL, 1); + } + bql_unlock(); } =20 #ifdef TARGET_PPC64 diff --git a/target/ppc/translate/processor-ctrl-impl.c.inc b/target/ppc/tr= anslate/processor-ctrl-impl.c.inc index 0142801985..8abbb89630 100644 --- a/target/ppc/translate/processor-ctrl-impl.c.inc +++ b/target/ppc/translate/processor-ctrl-impl.c.inc @@ -59,7 +59,7 @@ static bool trans_MSGSND(DisasContext *ctx, arg_X_rb *a) =20 #if !defined(CONFIG_USER_ONLY) if (is_book3s_arch2x(ctx)) { - gen_helper_book3s_msgsnd(cpu_gpr[a->rb]); + gen_helper_book3s_msgsnd(tcg_env, cpu_gpr[a->rb]); } else { gen_helper_msgsnd(cpu_gpr[a->rb]); } --=20 2.43.0