From patchwork Thu Jun 27 10:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2240EC30653 for ; Thu, 27 Jun 2024 10:01:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwH-0004wh-3I; Thu, 27 Jun 2024 06:01:13 -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 1sMlwF-0004wT-UD for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:11 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwE-0001ZC-B3 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:11 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-7067a2e9607so3839391b3a.3 for ; Thu, 27 Jun 2024 03:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482469; x=1720087269; 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=9SbOXMdD9Afo9G+k2c8nKcFprRWncVmzYgA0dcpIFRM=; b=fl9UINKxO0NLuqqzyo8BT2fq5WyQXDQZRQdWHakguc15GULVtHUO4hCbOhFLN62IMd ZB2sl//WkbQv7ZnnK+BXlFe7i6KyVrvoKFM5KBlQ0VaVR+vvL6NO1hqN/l7bddbX7WXW a47+XXXmkyKWvqID1ScGQ2JUeWh3dTw+UEzm4nEY1lCsmmK7B4Fm4BvAW1CLUHXoazK/ lQoBjsb/A2PYCQft7JeQHaM5+Ohy6Bi4f8VDjaSE35W7klCoQZLqjhHQPm80jl8M1hu6 Ev3rC0ztXYjFLIMRhT0OsVABu6IC2kkAn291LZLpe8czZCPr7Ny3LqXux6AnkoFrL38V PMew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482469; x=1720087269; 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=9SbOXMdD9Afo9G+k2c8nKcFprRWncVmzYgA0dcpIFRM=; b=mcO+jj6sUVQOxHKV+tsCN+NBg7eD16OtwUjb4NOl3wbP/QuC5S6lkwPsV6x3WZxYpR FT+4SS/UCaKawc9ZCPfdBQRK62akJuWLuboPfQ5AujdQbwgreSS1joQMXsa2pYvkft5u D+WhIzOyeOba6pGRaewGcgZnGbruYLVMpTcUQCbKxCwCF+/GaNrB/h9vxtu2I0kESQ8Q MtJf4iewcxX+VtJFL5F2DJRNUURNekmAuPVgrNQ7aeWAN67C98dMhOp89KXz3cnpLXbd QjcSXqYZK8zjAJH2igvVct61H4sP0T9rdAafI507e6j8lj/Gay4tecMKv1Sgg1ElTNwK cRsg== X-Gm-Message-State: AOJu0YwzmGfmr29ml32dqenShQNM8eFhSemW+ESSTUrydNtVElm7VRed 8siZL0PreN0kNDVRCbTYb+4WkKEiDl+GvqZdG9GvsSXcUGB1IDRkn/EOP8pE X-Google-Smtp-Source: AGHT+IF3MUcSMi3w/Up7qCoJNqQKwduv5II7kpoB4syDjuHb27AzrelLTkCBjZsYc8HV4bQwjwBOhw== X-Received: by 2002:a05:6a00:18a3:b0:704:3a0f:1d88 with SMTP id d2e1a72fcca58-70670ffc05dmr19409067b3a.21.1719482468559; Thu, 27 Jun 2024 03:01:08 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:08 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Rajnesh Kanwal , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 01/32] target/riscv: Extend virtual irq csrs masks to be 64 bit wide. Date: Thu, 27 Jun 2024 20:00:22 +1000 Message-ID: <20240627100053.150937-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=alistair23@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Rajnesh Kanwal AIA extends the width of all IRQ CSRs to 64bit even in 32bit systems by adding missing half CSRs. This seems to be missed while adding support for virtual IRQs. The whole logic seems to be correct except the width of the masks. Fixes: 1697837ed9 ("target/riscv: Add M-mode virtual interrupt and IRQ filtering support.") Fixes: 40336d5b1d ("target/riscv: Add HS-mode virtual interrupt and IRQ filtering support.") Signed-off-by: Rajnesh Kanwal Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis Message-ID: <20240520125157.311503-2-rkanwal@rivosinc.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 58ef7079dc..dd89edb06a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1197,18 +1197,18 @@ static const target_ulong sstatus_v1_10_mask = SSTATUS_SIE | SSTATUS_SPIE | */ /* Bit STIP can be an alias of mip.STIP that's why it's writable in mvip. */ -static const target_ulong mvip_writable_mask = MIP_SSIP | MIP_STIP | MIP_SEIP | +static const uint64_t mvip_writable_mask = MIP_SSIP | MIP_STIP | MIP_SEIP | LOCAL_INTERRUPTS; -static const target_ulong mvien_writable_mask = MIP_SSIP | MIP_SEIP | +static const uint64_t mvien_writable_mask = MIP_SSIP | MIP_SEIP | LOCAL_INTERRUPTS; -static const target_ulong sip_writable_mask = SIP_SSIP | LOCAL_INTERRUPTS; -static const target_ulong hip_writable_mask = MIP_VSSIP; -static const target_ulong hvip_writable_mask = MIP_VSSIP | MIP_VSTIP | +static const uint64_t sip_writable_mask = SIP_SSIP | LOCAL_INTERRUPTS; +static const uint64_t hip_writable_mask = MIP_VSSIP; +static const uint64_t hvip_writable_mask = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP | LOCAL_INTERRUPTS; -static const target_ulong hvien_writable_mask = LOCAL_INTERRUPTS; +static const uint64_t hvien_writable_mask = LOCAL_INTERRUPTS; -static const target_ulong vsip_writable_mask = MIP_VSSIP | LOCAL_INTERRUPTS; +static const uint64_t vsip_writable_mask = MIP_VSSIP | LOCAL_INTERRUPTS; const bool valid_vm_1_10_32[16] = { [VM_1_10_MBARE] = true, From patchwork Thu Jun 27 10:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6C4EC3064D for ; Thu, 27 Jun 2024 10:07:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwK-0004x9-JI; Thu, 27 Jun 2024 06:01:16 -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 1sMlwJ-0004x0-BI for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:16 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwH-0001ZX-I3 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:14 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-70670188420so4012391b3a.2 for ; Thu, 27 Jun 2024 03:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482472; x=1720087272; 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=XHVdgQ5R0OU4he+m9ZDS4YAng1a0QCz6gz1s5XZ7cf0=; b=lTy/a9VmlcBlFNvzWq4EmE4OzcYzzEbtpivONxSuaQJHk4SatoZ22m30uj0GR0nu+H yWrtcn9GGsD8QkIwhob8QOy1ZH0zjwDN4GAWNQdDQzMyq2+rOR6lpquRGMuzGKG1bIgA YDe5JQ2LNDA3F9ThzA/HarZnElm3FSCId57TPhGZySnn8YaKVnAzaipuU8mYL5q2D0c/ PTfdI/ceHcUNT9PK0R4+cB5y9wyyIikgknOgZB9WKIEoFifBcS6XhhHpplzK3PiZ0Qap gf34+L3k4BsQzEs6h86EnuIX9HbaIbjst0p0FfD+HWQeYx3Av7mpvSOW5DovDi/JgHkL dacQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482472; x=1720087272; 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=XHVdgQ5R0OU4he+m9ZDS4YAng1a0QCz6gz1s5XZ7cf0=; b=HiD0vNRjFd+g2MYq4JWe6q0lF8ToswYbWLIBSmKIcP7PiFngoN2RiQloIbSbFGk+a0 T+ErfAYIgD9k/Savbr2lP9ejaMD2c/kUswaWtAtRtgjPitlkL+bbW44dvrHzbcDB0IAh P+HvTV6E0sI8pRbE+nm26pKVQoboAapgfqI/SivPqbD7r+gz0Gfwc/jLgsoEMor53LTr soV8WZdVcLJkKip/EFPDT2lpcj4PPZZ+FiNTX72NKj8HypgjyeJWbh15/+gpXIA9hw55 OSh8ceBuRK9xutrlw6RAlIGPAq85Cyv1pRBuTQgDMYkIqSfrHJcORd5ObBMnjtdQAlyO U+3g== X-Gm-Message-State: AOJu0YwubU/cBKO17QpZN+D7bibstaJxJikWx2rQKhaM9J9Oi37FtBgv OkmSXYZlJR5tGvLZl4PHspHb3SqDS0SphOBmeNX568WFGitAPCOrk419PF7N X-Google-Smtp-Source: AGHT+IEIjTxOTZ+8LPGC1VoXdY16gbAcuKdNKVBV//ifj0meDne7H76OnSlgkcV4ntsvAMZi4s3mXA== X-Received: by 2002:a05:6a00:9290:b0:706:636a:21e1 with SMTP id d2e1a72fcca58-7066e4e6832mr19253105b3a.6.1719482471690; Thu, 27 Jun 2024 03:01:11 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:11 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Rajnesh Kanwal , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 02/32] target/riscv: Move Guest irqs out of the core local irqs range. Date: Thu, 27 Jun 2024 20:00:23 +1000 Message-ID: <20240627100053.150937-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Rajnesh Kanwal Qemu maps IRQs 0:15 for core interrupts and 16 onward for guest interrupts which are later translated to hgiep in `riscv_cpu_set_irq()` function. With virtual IRQ support added, software now can fully use the whole local interrupt range without any actual hardware attached. This change moves the guest interrupt range after the core local interrupt range to avoid clash. Fixes: 1697837ed9 ("target/riscv: Add M-mode virtual interrupt and IRQ filtering support.") Fixes: 40336d5b1d ("target/riscv: Add HS-mode virtual interrupt and IRQ filtering support.") Signed-off-by: Rajnesh Kanwal Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Message-ID: <20240520125157.311503-3-rkanwal@rivosinc.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 3 ++- target/riscv/csr.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 74318a925c..a470fda9be 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -695,7 +695,8 @@ typedef enum RISCVException { #define IRQ_M_EXT 11 #define IRQ_S_GEXT 12 #define IRQ_PMU_OVF 13 -#define IRQ_LOCAL_MAX 16 +#define IRQ_LOCAL_MAX 64 +/* -1 is due to bit zero of hgeip and hgeie being ROZ. */ #define IRQ_LOCAL_GUEST_MAX (TARGET_LONG_BITS - 1) /* mip masks */ diff --git a/target/riscv/csr.c b/target/riscv/csr.c index dd89edb06a..ee33019b03 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1145,7 +1145,14 @@ static RISCVException write_stimecmph(CPURISCVState *env, int csrno, #define VSTOPI_NUM_SRCS 5 -#define LOCAL_INTERRUPTS (~0x1FFF) +/* + * All core local interrupts except the fixed ones 0:12. This macro is for + * virtual interrupts logic so please don't change this to avoid messing up + * the whole support, For reference see AIA spec: `5.3 Interrupt filtering and + * virtual interrupts for supervisor level` and `6.3.2 Virtual interrupts for + * VS level`. + */ +#define LOCAL_INTERRUPTS (~0x1FFFULL) static const uint64_t delegable_ints = S_MODE_INTERRUPTS | VS_MODE_INTERRUPTS | MIP_LCOFIP; From patchwork Thu Jun 27 10:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6D90C2BD09 for ; Thu, 27 Jun 2024 10:02:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwY-0004yi-QP; Thu, 27 Jun 2024 06:01:30 -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 1sMlwM-0004xV-35 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:18 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwK-0001Zl-Ae for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:17 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-706a1711ee5so1721919b3a.0 for ; Thu, 27 Jun 2024 03:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482475; x=1720087275; 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=5Zbww0x25XgOxnxpJhSt8HZ1tEpLVotQQz6WQupL3AI=; b=RdIAawFO6kq7MxyieqXywl7+cx0znbmZLI0jBYnXsxZsFAu9nE7P8gH+5XKC3CbxU9 rQhGvpUOE+TYUR9krtfYwUuhUoWXkAhbLwP5oETMpTKffR65VUbF2srGzrvDMLtiSz6K jb/YH+VqfDVCTXvxTmd9J7BZeLeGM43A6qwDCVgYBHoYMVQET2ygirznhC16P5WHjA/T E3fdL7iIwwXwpBQ7Xfxno7qQDm0WF9xcv+07LeDKQYgLsgNT5gs/3tgpRHwOpkrpeMag Helapg5tIhDGipY4bIojPBOGaUYhDHD+s91tRkEFBFQDhv/LtBiGo5gFEsSnoMBzCaiL MR+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482475; x=1720087275; 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=5Zbww0x25XgOxnxpJhSt8HZ1tEpLVotQQz6WQupL3AI=; b=H/WyJO62hjwXhYlPY6OT/aXgUFe17UzyYvZPIK6yJIQFBjYerDXjcE4xNOCpgHYZ6J 1lZan3ZZZH1eBjgirThm3F3xjrb6HiDo3zugmnApMRAxBiMElCDBszmjROoX8yLgpkNl WmaLlCcN0XkHfB638Z3Gt/wPhGwRDXD9Hcx+axInTB9itZujqeHUiThgH9mp1n56zqk5 wBp4ZHwZuuz8tGzhNX1T+3g4RDLGwxFFBR28ZVlxDHEYa0FncrwiqVlRsd+TIbDcmhiQ V6Dn6omCQjFFE/z0B5hYBDtWbYCB40U1zVOi5NvMv0bJwAbPuqSqhN9sMjt94eR8wAQ+ 4ulA== X-Gm-Message-State: AOJu0YxZ4vtuNItx1kegpx9w/i70JEYNDelB21XSupYLwU73DO3EMdD5 Ielz8wvDFVQMBEw63HzD2GN/SS9JE1oaf2MKXZPvBisbwAPuMGGb8VxerV5l X-Google-Smtp-Source: AGHT+IHUyhy6H2RVGOrywT3w4EcatuiZEe2cmmSKkHQYEt9HMgrwHapH3AUJXhMhq3gvgLhl8dA7iA== X-Received: by 2002:a05:6a00:929d:b0:706:67c9:16d0 with SMTP id d2e1a72fcca58-706746f0a52mr14954844b3a.26.1719482474629; Thu, 27 Jun 2024 03:01:14 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:14 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jerry Zhang Jian , Frank Chang , Alistair Francis Subject: [PULL 03/32] target/riscv: zvbb implies zvkb Date: Thu, 27 Jun 2024 20:00:24 +1000 Message-ID: <20240627100053.150937-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=alistair23@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jerry Zhang Jian According to RISC-V crypto spec, Zvkb extension is a subset of the Zvbb extension [1]. 1: https://github.com/riscv/riscv-crypto/blob/1769c2609bf4535632e0c0fd715778f212bb272e/doc/vector/riscv-crypto-vector-zvkb.adoc?plain=1#L10 Signed-off-by: Jerry Zhang Jian Reviewed-by: Frank Chang Reviewed-by: Alistair Francis Message-ID: <20240528130349.20193-1-jerry.zhangjian@sifive.com> [ Changes by AF: - Tidy up commit message - Rebase ] Signed-off-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 683f604d9f..fa8a17cc60 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -667,6 +667,10 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); } + if (cpu->cfg.ext_zvbb) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); + } + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32x) { From patchwork Thu Jun 27 10:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 928F3C3064D for ; Thu, 27 Jun 2024 10:04:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwd-000508-7N; Thu, 27 Jun 2024 06:01:35 -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 1sMlwP-0004xk-NJ for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:25 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwN-0001aE-Cq for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:20 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-70698bcd19eso2194010b3a.0 for ; Thu, 27 Jun 2024 03:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482478; x=1720087278; 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=7Os9dSPxVJFr6h4ij+p8yPFL3Km5u7oyL3YdiKrf7h8=; b=babtBiKDnf4m0T9FiUgY1/GJxjuAzSc0RNV7Xekb+hKhLsjQv2bIOiKdTTK2BwK5Ej n7kik76zLlhGRqZNACAU+y/hNQaL4zsO8NfQPeRsBldMKNgevJKJSemQPQLhp0j85tVP LtpcUf2ejb6dRBZ4OHBPwUnDYs0z448frXJ+Qoy1DnwryFtwVseo3oYb2CLsK3xVgtqk u+LvWmeeghv/vdhorgzjOsr9VFXa09UELBWq05RO3pgDL1UBUXS3cvWfjU79LfoeX4P+ Dt3S5MuHrQ6iPPe+Pfqt3kwtgDeoKDhypTDg9Kj6XR3zo3AQ+MMTKvlXH/wO6a8C70wZ uFiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482478; x=1720087278; 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=7Os9dSPxVJFr6h4ij+p8yPFL3Km5u7oyL3YdiKrf7h8=; b=H60AmP0vNHgohV8XNmxL5Zk3z4lXUjOtqiEr/zVqyW/fTkQDG3NV9Ii1gSj2uY5Qr7 U151u3CJiJRNsCGb2VtpAd83avYE/dtTTDvux6XCyQ3siu/Ci8GQU/0FFmvZ/j1CRWYB 1jJJMptUGBNOMYT7IUy9qmKqG1VZa0LuQSddgCdNyuCakNpV5yg46qCZM67HoSP3eT2G BzejGIK+qQA1Gk1rJJGlJq8eyCiL5Dpn2ZVgblj5W+iPT7oY/j/ue2+Cu/Bkaug/P0P0 q9cOhKoo8UI2+P7AnrPKeQAWlR+4JkELbK86kDeN4MbyqHk2dXLy+x7X0IjqXtxZIB53 n5aA== X-Gm-Message-State: AOJu0YzOmQrA342/C/11VyQ38IKXkfIMlza45e1xm/pG3Bu1O1w9yC/N uDLyTiDKS7emI2RHstsW6yzo+zQCA1XasYbC087qc2W4JJi9dzWn67reeWuO X-Google-Smtp-Source: AGHT+IHPnhcEx335l/QMUu2R0HLdkqWzGMCNJM2jLYcikSA3C6F1sAav/BfGKry7hCI3/EsKiMuCEQ== X-Received: by 2002:a05:6a00:1387:b0:706:a5f9:5240 with SMTP id d2e1a72fcca58-706a5f9535dmr5509454b3a.13.1719482477605; Thu, 27 Jun 2024 03:01:17 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:17 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Anup Patel , Alistair Francis Subject: [PULL 04/32] hw/riscv/virt.c: add address-cells in create_fdt_one_aplic() Date: Thu, 27 Jun 2024 20:00:25 +1000 Message-ID: <20240627100053.150937-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=alistair23@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza We need #address-cells properties in all interrupt controllers that are referred by an interrupt-map [1]. For the RISC-V machine, both PLIC and APLIC controllers must have this property. PLIC already sets it in create_fdt_socket_plic(). Set the property for APLIC in create_fdt_one_aplic(). [1] https://lore.kernel.org/linux-arm-kernel/CAL_JsqJE15D-xXxmELsmuD+JQHZzxGzdXvikChn6KFWqk6NzPw@mail.gmail.com/ Suggested-by: Anup Patel Fixes: e6faee65855b ("hw/riscv: virt: Add optional AIA APLIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- include/hw/riscv/virt.h | 1 + hw/riscv/virt.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 3db839160f..c0dc41ff9a 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -118,6 +118,7 @@ enum { #define FDT_PLIC_ADDR_CELLS 0 #define FDT_PLIC_INT_CELLS 1 #define FDT_APLIC_INT_CELLS 2 +#define FDT_APLIC_ADDR_CELLS 0 #define FDT_IMSIC_INT_CELLS 0 #define FDT_MAX_INT_CELLS 2 #define FDT_MAX_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \ diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 5676d66d12..e903f05851 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -609,6 +609,8 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr); qemu_fdt_add_subnode(ms->fdt, aplic_name); qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic"); + qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#address-cells", + FDT_APLIC_ADDR_CELLS); qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#interrupt-cells", FDT_APLIC_INT_CELLS); qemu_fdt_setprop(ms->fdt, aplic_name, "interrupt-controller", NULL, 0); From patchwork Thu Jun 27 10:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF563C2BD09 for ; Thu, 27 Jun 2024 10:01:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwc-0004zo-VN; Thu, 27 Jun 2024 06:01:34 -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 1sMlwU-0004xw-Hv for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:29 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwQ-0001aV-30 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:26 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-706683e5249so4122001b3a.2 for ; Thu, 27 Jun 2024 03:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482480; x=1720087280; 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=H5ID2rbibjMInT22rN33D3iPwNHGXHXZ0Ds9aS1mUWE=; b=IIwW7J0oFO2Ypk2fokrX5msUC+4J1nG2T+XyDpAKKFNCFu0cHIzZnCKh7kD5vFiaE/ AhTGGpLiQofXyb7IKp8cAYY/TmJD+7GqQDvSzRHoxN3wKEHoGKYMfHJbFfLTx+3EdM7u UzDarUBnnw9FO346qoBlHLg4k50AO9wNXLRoguh34dyyo5L2kyCrRqTgg4z76q3hVNlQ /CBoSujkwcDL7+vUXI1LFf4NFyN7UsKAaZGR/mYDIOrQutbIP/bkalze16sxkO+6TFu2 5C72eWKpHSanhoZ2yBWJbDuLtFehD1/AkM1U218m6iUnJCoVkTmhGSS58Iq5+56fc9w6 b1sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482480; x=1720087280; 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=H5ID2rbibjMInT22rN33D3iPwNHGXHXZ0Ds9aS1mUWE=; b=cqHH8IURnmsLsha2BUcV2LR0wL2QvzJN9r6sUPxzRqs5n9tOOBgCnQVUz4iX0kozwI fFTVdwHdeGbsv6YVTgww1PsPZM4nNlFBPpFOxxmGUFqm9Dn0guAcEZFzxLNMF+s60jc2 p9c1bjAhpoixalgAJ7G2TFCuPeQJYvCq4yvHTUfk1dYYNLgycyrTPgTOTV5cZQcEEVYB 7fipK+67jGFaR/haQmJl0UNxiiiQASnduo8ZtfoUS0sp90fON0inUj2KeTBjcY+WFnf4 sloKET1zBJHvep2ZjFQAqgHkSPnbJ1TkFqcfipvxLkuki8B8v9CAsUDVE+kZ9qBATfl6 FTVA== X-Gm-Message-State: AOJu0YyKZXmTMaCdYvQd0dre8vJ3Tthpa5brN5AAu324brM0rsVCLPVH gGosdk7N/lIpbY+tdc4sknk4oylixjQ8RYN+YbwGNRw3UT43zJxEJUw/W59Q X-Google-Smtp-Source: AGHT+IHs3VdUTvBR9DQAZMIQqQEGAS9aoS06IajRAyP+mTZpC2UoJNSAG68Kw5vlbqQRL/4d1CCzgQ== X-Received: by 2002:a05:6a00:2289:b0:706:b179:dc5d with SMTP id d2e1a72fcca58-706b179de78mr2408270b3a.25.1719482480283; Thu, 27 Jun 2024 03:01:20 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:19 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis Subject: [PULL 05/32] hw/riscv/virt.c: add aplic nodename helper Date: Thu, 27 Jun 2024 20:00:26 +1000 Message-ID: <20240627100053.150937-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=alistair23@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza We'll change the aplic DT nodename in the next patch and the name is hardcoded in 2 different functions. Create a helper to change a single place later. While we're at it, in create_fdt_socket_aplic(), move 'aplic_name' inside the conditional to avoid allocating a string that won't be used when socket == NULL. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index e903f05851..569d9def24 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -588,6 +588,12 @@ static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap, } +/* Caller must free string after use */ +static char *fdt_get_aplic_nodename(unsigned long aplic_addr) +{ + return g_strdup_printf("/soc/aplic@%lx", aplic_addr); +} + static void create_fdt_one_aplic(RISCVVirtState *s, int socket, unsigned long aplic_addr, uint32_t aplic_size, uint32_t msi_phandle, @@ -597,7 +603,7 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, bool m_mode, int num_harts) { int cpu; - g_autofree char *aplic_name = NULL; + g_autofree char *aplic_name = fdt_get_aplic_nodename(aplic_addr); g_autofree uint32_t *aplic_cells = g_new0(uint32_t, num_harts * 2); MachineState *ms = MACHINE(s); @@ -606,7 +612,6 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, aplic_cells[cpu * 2 + 1] = cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_S_EXT); } - aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr); qemu_fdt_add_subnode(ms->fdt, aplic_name); qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic"); qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#address-cells", @@ -648,7 +653,6 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, uint32_t *aplic_phandles, int num_harts) { - g_autofree char *aplic_name = NULL; unsigned long aplic_addr; MachineState *ms = MACHINE(s); uint32_t aplic_m_phandle, aplic_s_phandle; @@ -674,9 +678,8 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, aplic_s_phandle, 0, false, num_harts); - aplic_name = g_strdup_printf("/soc/aplic@%lx", aplic_addr); - if (!socket) { + g_autofree char *aplic_name = fdt_get_aplic_nodename(aplic_addr); platform_bus_add_all_fdt_nodes(ms->fdt, aplic_name, memmap[VIRT_PLATFORM_BUS].base, memmap[VIRT_PLATFORM_BUS].size, From patchwork Thu Jun 27 10:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1863C2BD09 for ; Thu, 27 Jun 2024 10:02:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwd-00050B-Pj; Thu, 27 Jun 2024 06:01:35 -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 1sMlwV-0004y6-5o for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:29 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwT-0001cH-BE for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:26 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-707f9c3bd02so110190b3a.0 for ; Thu, 27 Jun 2024 03:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482483; x=1720087283; 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=Lk4RFwjLc+09kgFZ8qZ2DitRvmSjRrWDbykPLIpzSxg=; b=DMO48xq7qswwCmjUMpzeHibPETezpVZ8njOi5aoKKScjhEcUPviOWB91I3tkEA28U4 VDQDxv4h4HPKaBPVRx2tk7IZg7rU/GfqB/8zb5maQoW+7R/wZ4hUkzPlKazb0bbkiPG8 dua5+GkPLgU1sPscpbX6UIslprtyjbt9Ed0sGQRnx0MYXvFDNeUAIclXSbt7I61serjU 2eDXKxKn3jge+TtizgOfZB8Oazi/J0B5cg9CaugPhWT9tXcVgEkhwifDAUBB4/jUYB9d eq6BpDt2jdA0cn2o6ocWnGUmmwUBRFmamutg5Kk+5wqJh6owQIWjeZ49hHrqJuxPW0Fm mSlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482483; x=1720087283; 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=Lk4RFwjLc+09kgFZ8qZ2DitRvmSjRrWDbykPLIpzSxg=; b=OoGTDcNt4Wb8QNsbuUsTQenKyQOA1GdDk8PJfyMyECOucbGuzjZue0ipqM7mf568KP jSxNbnwVcy9bNdDWid9IbZi9TMqZdHw1wiAbhCKLqgmToY+nJolXWtFVcMDk4jzouV5z cB0LEVxzHLudZEiCgDPeGL/VA5m6VTqLfi5+Pmfik2NTmfFRtt0xhZU4ZIKpnaONcCOT Mm8BY5KA4OCWNJIUa09USUz55I0dlDAF46TO9XE71JUHPttAA7LesUZpuK6AXiKecPr4 i8r5Rux1/OCbcbf8kFBop/VUCqh9lkPP6sv82B4O61gEW64Y+TzLCoi8M5KzeFDUfIQK IKxw== X-Gm-Message-State: AOJu0Yw/90Sr3d6BYHh2mW488kJ0wt86+nq7C9soIO8q8fgnggouY4kP SsABeWP5PCXuP0ME/GwLWCi64OcO5ppuvCD5zyOtpfpi27LJqvbIBjgbgNxb X-Google-Smtp-Source: AGHT+IGCzweCVynD46ygmLkjsegPoRR0Fb8+6wbRBz6QNj3O8uMTLkcGNsAVe4PuQzEKJYBiDRwwWg== X-Received: by 2002:a05:6a20:7528:b0:1a7:7ac1:a3ba with SMTP id adf61e73a8af0-1bcf7ffa0f7mr10896541637.53.1719482483292; Thu, 27 Jun 2024 03:01:23 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:22 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 06/32] hw/riscv/virt.c: rename aplic nodename to 'interrupt-controller' Date: Thu, 27 Jun 2024 20:00:27 +1000 Message-ID: <20240627100053.150937-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The correct name of the aplic controller node, as per Linux kernel DT docs [1], is 'interrupt-controller@addr'. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml Reported-by: Conor Dooley Fixes: e6faee65855b ("hw/riscv: virt: Add optional AIA APLIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 569d9def24..a803c33e21 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -591,7 +591,7 @@ static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap, /* Caller must free string after use */ static char *fdt_get_aplic_nodename(unsigned long aplic_addr) { - return g_strdup_printf("/soc/aplic@%lx", aplic_addr); + return g_strdup_printf("/soc/interrupt-controller@%lx", aplic_addr); } static void create_fdt_one_aplic(RISCVVirtState *s, int socket, From patchwork Thu Jun 27 10:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC1D1C2BD09 for ; Thu, 27 Jun 2024 10:05:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwe-00050V-I9; Thu, 27 Jun 2024 06:01:36 -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 1sMlwb-0004ze-3h for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:34 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwX-0001cs-CH for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:32 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6f8d0a00a35so7005869a34.2 for ; Thu, 27 Jun 2024 03:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482486; x=1720087286; 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=Q+eeNlFB8GixGjITkNWps0WtpsIa1zNDxCGuytiuKIQ=; b=SHVsJgK3DcmSAKs6Tcc+sUEiYbSnMdx6IIdW3qtIlDUt+v/QCQjLie4EW/hry4jlWo a0/VA2c7RtpHsSsd67XFLanKHfjTcrLBjThF0Dzp0/jvAhS/o98D4R+mRJ3o2oWUIB/m ViMkdFULeV0UR6xRCgGs+cjPyVCUxrvosQGlFhukVO5pXZMaH+U+w/UZ+ry4iiKNEjoG DT7uO6rcFjh1fETFYJRELpr0Bd9/l5HxxaoKUkMSKuctMhJQ8ur5nqb0J/RoIoN/PUrz BaGqz9MAy6Bi05rC0LPZXns+Rzo22BO3yBzIntOgPr9W25r+fcviU3OvTKhM0mgJ1pxE Ri/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482486; x=1720087286; 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=Q+eeNlFB8GixGjITkNWps0WtpsIa1zNDxCGuytiuKIQ=; b=necpxBhmowDSJ8Vxyjhsp4I2KwPwrGit+h1huy/5I3/mQqExEwUa8ktz0FgC6hiVaP y/UgSC8PYGRswWQgT6Do6y5qKAVC+lbtVgfq5bSdPGgazNOYGZ5vC1nD05GGieQZsSK+ VShCtYREFZItk+Ii6HDoHqJvTNQA5S6EC/TlM1B+HNzC0koAci1W/u4diUB+UfeONIZJ hvCpEFE5ufuRkdmU5FM8/WiIapqf61djzvcSdKUlykkTM7SF/LP6NZ+4aiuKxlQoJgFt JHACEO0O9wa2RBVwEfssTE2AEZACR0aRQ8HK7/z1BzM1Bg98xqIcDhS8T6bR+pZ9Mwmc Uq5w== X-Gm-Message-State: AOJu0YxRMePJzNIeqQj3JBbHansAffMFPZZKh1HVMEjuuO+5zoG7eLrR kgQN19mnQv/9+iZp9fi/ibzaJ4643K4h6c9FPOQ420RrtuYVn4SsfMEpaVLj X-Google-Smtp-Source: AGHT+IFQnutwQGVZAxVvlm79DohdPZj6MHxRC9K9rwOoZofaWpmovVStQXhnQRuGJaj35md+aEREMQ== X-Received: by 2002:a05:6870:1491:b0:254:b7d9:2dd0 with SMTP id 586e51a60fabf-25cfcfa10f2mr14767976fac.55.1719482486276; Thu, 27 Jun 2024 03:01:26 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:25 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 07/32] hw/riscv/virt.c: aplic DT: add 'qemu, aplic' to 'compatible' Date: Thu, 27 Jun 2024 20:00:28 +1000 Message-ID: <20240627100053.150937-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32d; envelope-from=alistair23@gmail.com; helo=mail-ot1-x32d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The DT docs for riscv,aplic [1] predicts a 'qemu,aplic' enum in the 'compatible' property. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml Reported-by: Conor Dooley Fixes: e6faee65855b ("hw/riscv: virt: Add optional AIA APLIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-5-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a803c33e21..746df3f294 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -606,6 +606,9 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, g_autofree char *aplic_name = fdt_get_aplic_nodename(aplic_addr); g_autofree uint32_t *aplic_cells = g_new0(uint32_t, num_harts * 2); MachineState *ms = MACHINE(s); + static const char * const aplic_compat[2] = { + "qemu,aplic", "riscv,aplic" + }; for (cpu = 0; cpu < num_harts; cpu++) { aplic_cells[cpu * 2 + 0] = cpu_to_be32(intc_phandles[cpu]); @@ -613,7 +616,9 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, } qemu_fdt_add_subnode(ms->fdt, aplic_name); - qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,aplic"); + qemu_fdt_setprop_string_array(ms->fdt, aplic_name, "compatible", + (char **)&aplic_compat, + ARRAY_SIZE(aplic_compat)); qemu_fdt_setprop_cell(ms->fdt, aplic_name, "#address-cells", FDT_APLIC_ADDR_CELLS); qemu_fdt_setprop_cell(ms->fdt, aplic_name, From patchwork Thu Jun 27 10:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67A24C3064D for ; Thu, 27 Jun 2024 10:04:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwe-00050e-Ol; Thu, 27 Jun 2024 06:01:36 -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 1sMlwc-0004zt-SN for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:34 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwZ-0001dF-J5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:33 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70685ab8fb1so3516344b3a.2 for ; Thu, 27 Jun 2024 03:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482489; x=1720087289; 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=NDqAmBS4P/7Jqnzeh6wlGENLL0Hv6eaUHFS63phjrpQ=; b=NwGhQWC+aEeafpnCFumjA4mAAtu1xoWHHBKYHxbSGwm/63/Bwh+06y/H6XNJkMQwgV l+WjletZaU5aoncMqnosAaAxioTrFCwaKjgOqizLRay5BvlL8V3Rk0fMiKtUlfDxiILw VXGxkpsQKMSfsAtnufsqIB1TgogO8Mtl+q7lhijtfYq8H1jYO0EhtxOBmhn69z1QENNF LBHzOShfFaqthOwKvuIVO8zmj3+Run7de6/rJ23wjFYVk/E+FbxjO1QQTIBDtyM2WdOp z/9eBV8yRRVy0y+wYyvP2rvPqhNjc7SEgefutbEjByY+mBjS+fbOynaGlo87+LQQ2pvn oqEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482489; x=1720087289; 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=NDqAmBS4P/7Jqnzeh6wlGENLL0Hv6eaUHFS63phjrpQ=; b=f20amrJdljXN+Wxd3VrY27cLxLZH9v8bx0dRzXB0cNbnXKFsRC16HFPxLt79y2+VYs zP0Q487iwhqszUgpGDBwJWXLYXwmaEAgyFGZ2iTW7Lc6DugeLwwl60heyrt0unMoCLjy J23+WrI8tob2yXCvhoBZfjUW08REHDXs93GuT9U2ujVG4/tKuuqm7i8MQYn0XSoOqz02 +yZrknv5U1cmG2wifPn5tRnXYwZmng6MN2K3Ps5d9faV+aycjzPCkh2Eanxd3QeeFHwC qZ8eTEJiD+i3cjisUyRYptH/NLq8JDZsFfppcEVuBOgIbCvfwpnD5tkoqOsx8ur4pv+0 DL9w== X-Gm-Message-State: AOJu0Yyr2KXemzs8cAJacIlNxdSeMhzk7FT/17gF1B1kBBdQYX6aRwKv WP4pDw4UM1ZpSyZofy3jNfxRSh0hMx325mnZPdZWTMuMb5/tK7oo0fTv6tpt X-Google-Smtp-Source: AGHT+IFBoWHFZfN1qyNOpp5kKQjNBe/z0Rb8qJMyEvhMj2ZtVT7/RNK7kQAygytkV84Xwgfs05BpAw== X-Received: by 2002:a05:6a00:a28:b0:706:a89d:e98d with SMTP id d2e1a72fcca58-706a89de9f9mr5650135b3a.31.1719482489275; Thu, 27 Jun 2024 03:01:29 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:28 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 08/32] hw/riscv/virt.c: aplic DT: rename prop to 'riscv, delegation' Date: Thu, 27 Jun 2024 20:00:29 +1000 Message-ID: <20240627100053.150937-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The DT docs for riscv,aplic [1] predicts a 'riscv,delegation' property. Not 'riscv,delegate'. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,aplic.yaml Reported-by: Conor Dooley Fixes: e6faee65855b ("hw/riscv: virt: Add optional AIA APLIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-6-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 746df3f294..9c6b39b7df 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -640,7 +640,7 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket, if (aplic_child_phandle) { qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,children", aplic_child_phandle); - qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate", + qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegation", aplic_child_phandle, 0x1, VIRT_IRQCHIP_NUM_SOURCES); } From patchwork Thu Jun 27 10:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B229DC3064D for ; Thu, 27 Jun 2024 10:03:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwf-00050y-8r; Thu, 27 Jun 2024 06:01:37 -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 1sMlwe-00050E-9l for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:36 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwc-0001dn-Kk for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:35 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-70b2421471aso5492570a12.0 for ; Thu, 27 Jun 2024 03:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482492; x=1720087292; 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=QU4i8l0CHf3BaV0XsBQvH3OwC1graQuHSr1WC6y7TUI=; b=VNJhOCWs3rfVj2aY/0IAtddvdu9/mu6qyIA59U0vEP49c93Q5F035nJm3+2O2vnWXw B2elf4zpXqXqpr7xpPie2XDYxXQ/ofNzmP4PKdpTc/vn935nB7ZTmwmn2kN70joYAZyk oMCYxhEObBKHiwoGsjRgiLD/29pvVDd+I1aEsdqsu9c+yOPvI8JoWCEvU71t/XSx7ra/ 96oWXkirgVZ6Ssng41ohXKrD+KsfhVv/2w5/vroXfa6bs8oh/Rr7NXI37rxTvi0w9qUi aqe90KpZwnd3eweIXOLcu77g0Uuze1zR14UctS9PMFBUC8FLBzq+SXViV60YZ+vINFpF EYOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482492; x=1720087292; 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=QU4i8l0CHf3BaV0XsBQvH3OwC1graQuHSr1WC6y7TUI=; b=oHH/SANnfs4+VAlu1Nx3toOmwl4Qn/GKPwyN9zamGEFua829Hhk3/8F807606G54VL 6SYBMhRpKHD4j4E1wLkf3VeQ2Ud3rTzMZXyNF3RO1vWJ+c6XXMK9ax5Bwjegw+QGIrpR DRCzRELpGOsLEczlmXE97lpimFDtP3tREqDA4W2W/l0pacPa6jUULzII5cA6igIlc4wA P/GL/2hyzbkITtAFrFffGB18gZOr/laGxD8FBiTQt8Rc0Bt9gPG7ON33SiI/dwjnYwPZ hJXnLRIiTwICVJfG5tWtCXr1RP80MutHuHddYUyFGb4NZKgS98SZAwjc4H9Xvt9mD+kd 5GEA== X-Gm-Message-State: AOJu0Yxldh9gcHH07upTRNovbV2T5VtkzHYCHgw4z0NahFVmRisMtFH+ fYzS1VR2fLXBGcVXxJkI8ZP4s/ixvlQBf+sW1OKXyMvr6mks29vzUS0a9AXn X-Google-Smtp-Source: AGHT+IEH7XsxyLynGCWLyoMFRpBeoo20IiYHETZrBSFrYKwLLfTyI0H//zfxmdyOyO+D8QNsdWlSew== X-Received: by 2002:a05:6a20:6387:b0:1bd:1e0f:efa3 with SMTP id adf61e73a8af0-1bd1e0ff0dbmr6675761637.4.1719482492263; Thu, 27 Jun 2024 03:01:32 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:31 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 09/32] hw/riscv/virt.c: change imsic nodename to 'interrupt-controller' Date: Thu, 27 Jun 2024 20:00:30 +1000 Message-ID: <20240627100053.150937-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=alistair23@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The Linux DT docs for imsic [1] predicts an 'interrupt-controller@addr' node, not 'imsic@addr', given this node inherits the 'interrupt-controller' node. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml Reported-by: Conor Dooley Fixes: 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-7-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 9c6b39b7df..376e362a68 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -538,7 +538,8 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, } } - imsic_name = g_strdup_printf("/soc/imsics@%lx", (unsigned long)base_addr); + imsic_name = g_strdup_printf("/soc/interrupt-controller@%lx", + (unsigned long)base_addr); qemu_fdt_add_subnode(ms->fdt, imsic_name); qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", "riscv,imsics"); qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells", From patchwork Thu Jun 27 10:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2D1BC41513 for ; Thu, 27 Jun 2024 10:04:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwj-00052g-4S; Thu, 27 Jun 2024 06:01:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMlwg-00052A-OB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:38 -0400 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwf-0001eP-6V for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:38 -0400 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5c21ef72be3so1036457eaf.2 for ; Thu, 27 Jun 2024 03:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482495; x=1720087295; 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=7jZvBLMTasb9eS7DfRHEia3PyJ7fRL3eXKnFZzLUWrg=; b=AmPNSxYAouIOWVMAIpmDhG3NyZ0jFczMvMQ/SiKSUSLlyQiduAsZd+BheODN6UaHfy 8+5xnd7NgJbIeBXfIN+8c1yvL5vCW1CvOxfyTRoNuz5nkPCwmjA0UlsZWV6zck7XjehZ Xr9t6D7z2cCvMnVdykK37lBHmpIFefOTyZJ6LZgYAKPVJEwLRmjrxcMud2RpQIo93Jn/ hMJ1aQutOh3AOe/nxGrqPX697NnLJLUbhnOq7ajbSKbtGs6yjGSZvw615Yr2dbV4NwUc 4zxt1yJ5xlj81QsQVqaDgrY2mSd050g/1DNr5S6Aue5ptY/u1Iuks+YMl+XJFxSfeymA p3mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482495; x=1720087295; 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=7jZvBLMTasb9eS7DfRHEia3PyJ7fRL3eXKnFZzLUWrg=; b=TvrpdX3yRrae6VSplIzF7Kjrr431YfYl1BL9zp0xjOYTqcR8nq82a8XME9fuMBHOdd 9cFkatsnFB3ETkuxJ7skX2VSI5rAFNeISBsnzWqSXECN3/5NhnBFCz2WtFR0WpmGNIUV t9VvDMUvLiJh6+Z+si+Nt30wfmU15FcanU/cuJz4kp+Tt0ysdZeLfGtKEg1oMpB9BqSt +DG/53FrEibXQTA56bJ22vFK5lEZtgwcCfba0OoY6XxZz9DjXr1530Mc7SYQ55+jViaG 3zKhyBYmPgs6JEnTl+yPTv4wY8LyMCRHz0as2GMrBDwfugHfcyN2ZEI0MPtquaTCv7TU ChaA== X-Gm-Message-State: AOJu0YwJ0EbD9GmpHxgv9Eq9tSL0e2FvisSeiI1RFvLvfbxG7/JP5dr4 sOxBsn1HCrX3ieDAHuwcnwVDNMA8vUfGuHpQWSIt6zYLsXXVP+Kr2QZ2p2EW X-Google-Smtp-Source: AGHT+IEHV26eGqKyh6Lu7Ts7gc/X3NzhEHoElKQAVXolVRBvMjC+mdR8tnAdZSfiXIq0LvVnFNdq0A== X-Received: by 2002:a05:6870:158d:b0:24f:dc76:f6d2 with SMTP id 586e51a60fabf-25d06e2890emr14257687fac.45.1719482495537; Thu, 27 Jun 2024 03:01:35 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:35 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 10/32] hw/riscv/virt.c: imsics DT: add 'qemu, imsics' to 'compatible' Date: Thu, 27 Jun 2024 20:00:31 +1000 Message-ID: <20240627100053.150937-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=alistair23@gmail.com; helo=mail-oo1-xc31.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The DT docs for riscv,imsics [1] predicts a 'qemu,imsics' enum in the 'compatible' property. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml Reported-by: Conor Dooley Fixes: 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240531202759.911601-8-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 376e362a68..e1ecf79551 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -515,6 +515,9 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, uint32_t imsic_max_hart_per_socket, imsic_addr, imsic_size; g_autofree uint32_t *imsic_cells = NULL; g_autofree uint32_t *imsic_regs = NULL; + static const char * const imsic_compat[2] = { + "qemu,imsics", "riscv,imsics" + }; imsic_cells = g_new0(uint32_t, ms->smp.cpus * 2); imsic_regs = g_new0(uint32_t, socket_count * 4); @@ -541,7 +544,10 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, imsic_name = g_strdup_printf("/soc/interrupt-controller@%lx", (unsigned long)base_addr); qemu_fdt_add_subnode(ms->fdt, imsic_name); - qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", "riscv,imsics"); + qemu_fdt_setprop_string_array(ms->fdt, imsic_name, "compatible", + (char **)&imsic_compat, + ARRAY_SIZE(imsic_compat)); + qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells", FDT_IMSIC_INT_CELLS); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0); From patchwork Thu Jun 27 10:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78795C2BD09 for ; Thu, 27 Jun 2024 10:06:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwm-00053J-HQ; Thu, 27 Jun 2024 06:01:44 -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 1sMlwj-00052u-Vm for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:41 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwi-0001f9-Bh for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:41 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-25c9786835eso3962064fac.3 for ; Thu, 27 Jun 2024 03:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482498; x=1720087298; 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=Mwf6ZQFn6phEZgcwA7tImzDlpbG5FD6Mkg1OZw2C/gI=; b=mjpYXJQrOodd4UJ2nxyBpG7IBHHiCDmw32CYT6T9hG/A6DGINW4ghWp+P+L9UNOi/6 VIk2vrILZWgwcgfoAR92QrTOt3FGlEekKKxFfaCqHe6BDFhDRi+GD+Q1AgQS7ndyB1Cj EwsapugBp6dV6YLVu7hmo6O35JPMxSXq3TLhZ/oSF7kMqBQpoPQ89Nqj9mnH6fm8UmHv X7AIg2IlZLI3k9CLl414X7oqYuT3LPYgEpwqtXkjXd5Ex0PChqycgl9bw6NAZONDKBMQ 4Js5DtVaJ3KDSV9EUyF2AZruFXfGrQCWzolA8UApMTE4Z7HqDNQkkp+fKbNH76rtP5Pe UN5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482498; x=1720087298; 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=Mwf6ZQFn6phEZgcwA7tImzDlpbG5FD6Mkg1OZw2C/gI=; b=JjYQbXju843hAmojxIDp36L7ExgPaoh5zqNw3p2NfjkqYsDJBOWVCtf0sxo7mdgcgz A1Yv1JKORcHCDySPoKNuFvoKxgeV4xeiDdxihSzk3oy3yoLS3dtkox9f27bLfz87OmG/ eWTBbTIL7uwL0EcypWPH941exF2K09iKMvjpcy1DFoun1znMZNwlKwZhGecLi4VkZbJa rqzax8TqvPh+mMtJaWjBnDL33omuxsTlMa4OT655ZMYJ+vWEZkEV4lP4z1KNy2PpoFwy 9wVQYY5spvgC17KSyRQFZO1V8mq4RoksWjfRVXHaBYx+XVikpli+Wgx/CXCOAkI005M5 kNKw== X-Gm-Message-State: AOJu0Yw7o7hSlePWsYW+1L5Xnd/psAOF0P3HYqcfRjA6G2VQwVwGaj97 1sPiNFAxXqIw32e3f0PcO3VC3cJ+x8oeZeP8MxpoGWcdDAbN8r2wtX7CLiLv X-Google-Smtp-Source: AGHT+IE0Hgjo3Hk5c21CeGSve8WUJ+SeQA364qxrTBKUhliq3RfleWPXm2KlkFfxeoz/oPUkIoFmFA== X-Received: by 2002:a05:6870:4208:b0:25a:6d14:f84a with SMTP id 586e51a60fabf-25d06e37917mr13307074fac.42.1719482498485; Thu, 27 Jun 2024 03:01:38 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:38 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Conor Dooley , Alistair Francis Subject: [PULL 11/32] hw/riscv/virt.c: imsics DT: add '#msi-cells' Date: Thu, 27 Jun 2024 20:00:32 +1000 Message-ID: <20240627100053.150937-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=alistair23@gmail.com; helo=mail-oa1-x2b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel Henrique Barboza The DT docs for riscv,imsics [1] requires a 'msi-cell' property. Add one and set it zero. [1] Documentation/devicetree/bindings/interrupt-controller/riscv,imsics.yaml Reported-by: Conor Dooley Fixes: 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to virt machine") Signed-off-by: Daniel Henrique Barboza Message-ID: <20240531202759.911601-9-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index e1ecf79551..9b648540e6 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -552,6 +552,7 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0); qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0); + qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#msi-cells", 0); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended", imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs, From patchwork Thu Jun 27 10:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96BF5C2BD09 for ; Thu, 27 Jun 2024 10:05:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlx8-0005ZP-DB; Thu, 27 Jun 2024 06:02: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 1sMlx2-0005Mj-O0 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:02 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwl-0001fc-7p for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:00 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-701b0b0be38so6421952b3a.0 for ; Thu, 27 Jun 2024 03:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482501; x=1720087301; 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=VvMRDH0FQIgQ5mFYlmZC/NLgQuA8hoNsfm8XEnF2ha4=; b=ewn1/Yw0Kahqc7FQrdJanSH5CqPh4GT6lN9IcE1vLS/jDcWNU1scF53YEOUbHll59M h4LCTxdk9LSi5VLfVZYnoP6EGBSgdWb4212NGEt3ThQ60rhk0Jgl93kdcm2gsIB+eSbU KLuYgqx1dNkqC1rzfMoaaHOh3f+LhCseWmnSVhjWlDDhX9KnA9l/fKlbdxlt4zbTwhz7 U5ELR/NL6KME7y4tQSQWAL4YTljtfG33MhamL6ASWx2Xdegis5jpN6/Sf1WljYrF1Rzk VO/98yc80FpR43hYEg4sqw0L93mOWypLbSQAvNg29+Ay7jr5hq28Y12lQUWuzxvLbX2T 1rQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482501; x=1720087301; 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=VvMRDH0FQIgQ5mFYlmZC/NLgQuA8hoNsfm8XEnF2ha4=; b=T1bWmnWy8Y+is1xv3x8gSxCKjaR3usi3uvHSw7y6hgjYb78ZD+oiB1N0/7P/1Awd6n DwyU/TxbpMo8T1PJoWHAjf1EDGTqdJHX4MH+O0PtSaAuPzJVOBgtZ5i7NwH/VVMAva8C hqeV1eoHy2uT6El7FwZXGPME1NFP3Z6JVldxq9G9+MzdSb5Y3tEEUs/OiSVYmRV6yWt6 XrofH8LD6Lndl7rH6+tdiP625jE9FtqF2z91iFaDfACDkNlOLXCPHmamUydBGT3RxXAH lMDqbRzbqScvWkGkI6Id82AoAg1EtICahmy5CAmqXILiVWE4LSSn+XXKTfxC4ZAAje5E QICg== X-Gm-Message-State: AOJu0YwBE57bhdeNlRQdvWp5DPlmL/oXztuWT/bzd7JC4CRWy7I3ki7x Ch0uX3IFYaMfkHUTyxMM5i27+l8siP5iA73Gg5qmqdM1p3gRv4PasTkWSrK/ X-Google-Smtp-Source: AGHT+IGnARjqFpwr5iB98XKm5Y+AJevAy0S0llDAudCOoxX/IkffRKLqnvxqWAbaEKJ7wiUQZs72Mw== X-Received: by 2002:a05:6a00:3cd3:b0:704:2696:d08e with SMTP id d2e1a72fcca58-70681ee315emr13261496b3a.13.1719482501469; Thu, 27 Jun 2024 03:01:41 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:41 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Chao Du , Andrew Jones , Alistair Francis Subject: [PULL 12/32] target/riscv/kvm: add software breakpoints support Date: Thu, 27 Jun 2024 20:00:33 +1000 Message-ID: <20240627100053.150937-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=alistair23@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Chao Du This patch implements insert/remove software breakpoint process. For RISC-V, GDB treats single-step similarly to breakpoint: add a breakpoint at the next step address, then continue. So this also works for single-step debugging. Implement kvm_arch_update_guest_debug(): Set the control flag when there are active breakpoints. This will help KVM to know the status in the userspace. Add some stubs which are necessary for building, and will be implemented later. Signed-off-by: Chao Du Reviewed-by: Andrew Jones Acked-by: Alistair Francis Message-ID: <20240606014501.20763-2-duchao@eswincomputing.com> Signed-off-by: Alistair Francis --- target/riscv/kvm/kvm-cpu.c | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 235e2cdaca..748fe5980f 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1969,3 +1969,72 @@ static const TypeInfo riscv_kvm_cpu_type_infos[] = { }; DEFINE_TYPES(riscv_kvm_cpu_type_infos) + +static const uint32_t ebreak_insn = 0x00100073; +static const uint16_t c_ebreak_insn = 0x9002; + +int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) +{ + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 2, 0)) { + return -EINVAL; + } + + if ((bp->saved_insn & 0x3) == 0x3) { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) + || cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&ebreak_insn, 4, 1)) { + return -EINVAL; + } + } else { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&c_ebreak_insn, 2, 1)) { + return -EINVAL; + } + } + + return 0; +} + +int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) +{ + uint32_t ebreak; + uint16_t c_ebreak; + + if ((bp->saved_insn & 0x3) == 0x3) { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&ebreak, 4, 0) || + ebreak != ebreak_insn || + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) { + return -EINVAL; + } + } else { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&c_ebreak, 2, 0) || + c_ebreak != c_ebreak_insn || + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 2, 1)) { + return -EINVAL; + } + } + + return 0; +} + +int kvm_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type) +{ + /* TODO; To be implemented later. */ + return -EINVAL; +} + +int kvm_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type) +{ + /* TODO; To be implemented later. */ + return -EINVAL; +} + +void kvm_arch_remove_all_hw_breakpoints(void) +{ + /* TODO; To be implemented later. */ +} + +void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) +{ + if (kvm_sw_breakpoints_active(cs)) { + dbg->control |= KVM_GUESTDBG_ENABLE; + } +} From patchwork Thu Jun 27 10:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A00E3C3064D for ; Thu, 27 Jun 2024 10:02:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlwy-0005BY-M9; Thu, 27 Jun 2024 06:01:57 -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 1sMlwt-0005AY-Lr for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:51 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwo-0001fl-MY for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:51 -0400 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6fa0d077694so3602203a34.0 for ; Thu, 27 Jun 2024 03:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482505; x=1720087305; 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=6rwQsSYLKQgi4K97lVRX96DE9ZTfnP0leAGSv9Zh3mk=; b=DKl2IhAWV9Voa/EI9v/4ZV4WmNo4oeJfoN+G9GPNwT6pPGPKqT30RgNLSHXj/swq5Y SepFzYqNoamHaksnJDjvLd3+SnMzTyBXLuwRu4mN0vMB5cSjstDxWcGxMlAYq/IhFSUo 2OXRmfYoN+P4T7vjfZpwq4x7Uo5pc2EhTjc2v1nbW6SZZrnTGUs2W590oDLrdYldVOMc uvf8e4axQw9ENF+/ZduhkbaVNIlcKJtN6gpq6VLDhPc9+rQ+4jcqLeApyf+U3NeewXBu nAwTGfbY+CblqRWC6QNdLn24JSTaD0S0mi4LUcjLe9HcCvf4lqycEWJLT5U/8WOB05H6 ZXaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482505; x=1720087305; 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=6rwQsSYLKQgi4K97lVRX96DE9ZTfnP0leAGSv9Zh3mk=; b=GpnU9ZvqiAW6QdzfYT4vPLWXoAbVNvAcsaeTTFiKR2nArxzv16c6Z4uBUrioeCevz2 MOQ8gZDue1YpnL0r9OQCLZZvoBI8EkhpO7+xafu6vWRywNpG+NepIO4ypDM+AzOkMDOd GXgUqvTp+4GBAobEqQ7zTeJ6vub6L767ziPPgr2KU10ygwtepy8CHWGUDUpN2HMlR53u rZqavFVqZg58RmV58Pyihh6DTrRj78KpVWUf/6AWcZqY4ANALRkqs3byGUvAGYUNcQAS TtuxfNVSkBj/4FfNygZDdGEo7lMDYLlenIFPl5xCMqNQxRA50Gl/AljdleNIWWm0gIT1 Zu4Q== X-Gm-Message-State: AOJu0Yzsn+Yxw/w2lpCKStYRtZNdiKIVhSQShPmjsYG0UvB/DI5QRkvk t64QxBQLZ/ReRUBG2RGO7iW9JSeGN5K2ZnQm/3FlM3wKT3iE+mOvKaJ2x8X1 X-Google-Smtp-Source: AGHT+IEAdpCuXdHD4ZYfF65M15BUKtMZ63gCMbHAlTpoJGh9ZLVRDdgQrosXr4m1VYlOqg14l3Zc9A== X-Received: by 2002:a05:6870:4208:b0:258:3c97:f091 with SMTP id 586e51a60fabf-25d06bc9224mr13719286fac.9.1719482504729; Thu, 27 Jun 2024 03:01:44 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:44 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Chao Du , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 13/32] target/riscv/kvm: handle the exit with debug reason Date: Thu, 27 Jun 2024 20:00:34 +1000 Message-ID: <20240627100053.150937-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=alistair23@gmail.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Chao Du If the breakpoint belongs to the userspace then set the ret value. Signed-off-by: Chao Du Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Message-ID: <20240606014501.20763-3-duchao@eswincomputing.com> Signed-off-by: Alistair Francis --- target/riscv/kvm/kvm-cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 748fe5980f..1047961fed 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1555,6 +1555,21 @@ static int kvm_riscv_handle_csr(CPUState *cs, struct kvm_run *run) return ret; } +static bool kvm_riscv_handle_debug(CPUState *cs) +{ + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + + /* Ensure PC is synchronised */ + kvm_cpu_synchronize_state(cs); + + if (kvm_find_sw_breakpoint(cs, env->pc)) { + return true; + } + + return false; +} + int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) { int ret = 0; @@ -1565,6 +1580,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) case KVM_EXIT_RISCV_CSR: ret = kvm_riscv_handle_csr(cs, run); break; + case KVM_EXIT_DEBUG: + if (kvm_riscv_handle_debug(cs)) { + ret = EXCP_DEBUG; + } + break; default: qemu_log_mask(LOG_UNIMP, "%s: un-handled exit reason %d\n", __func__, run->exit_reason); From patchwork Thu Jun 27 10:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A750C2BD09 for ; Thu, 27 Jun 2024 10:05:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlx7-0005SG-A3; Thu, 27 Jun 2024 06:02: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 1sMlx1-0005I8-4n for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:00 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwr-0001gD-NZ for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:01:58 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-6eab07ae82bso5512816a12.3 for ; Thu, 27 Jun 2024 03:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482508; x=1720087308; 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=FLCyPqMhz46RMQyVFn3nlk/YPcVVg7QWv/riYPUXA0Q=; b=KPk7VPnbbgY29O3yLpxtefZN1rJ7xZ/Bj7YLGr6UqfeFCDoJDccausF2P14L+Mxwq2 k08ZIHWbVgVrnhTFcq6sZVHRlxaAitVRMARl2MsyGxKSJ6zP3XF9/umHBLr4k4NQDKlz Tu952VQ3kYmTApvo06fgzBMT0HFr2RH+SrhqP4XnuN6TbTLWXZeDpsLtTD6CCaHF0R7G 0e9cIGsMETd/DhsNAihJLJryGvaxS2oYofz6NnhAPhQAKxnrNgBYPerFEOXyJFrNx9ul UT2L8qGSEsabnR8V9silJMBbYci0sMgiTFVYOHYTBBaJ1grdFsto6+paeizB5geO3vk5 YKVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482508; x=1720087308; 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=FLCyPqMhz46RMQyVFn3nlk/YPcVVg7QWv/riYPUXA0Q=; b=rFpLMMqN1e3Yo4VxIjmLsz/y3FYd38+rJU2a5jw6xrUwFW0abhhK1IC2p1Lu47Ns87 0+8uF4tzugxs50tb8Pdi8j06kFcTgFSZ2yGVKVwijakefB4SBCRu1bIFCKc68Yx8Z52Z cpS5NQzcvTYpMM+dUd21qSwIejouO9TSKPpV5gG7Rp+6YTpSC3Ykk481onvkce8MCbve 45JUw3cDqK4qtxIcYNKEkd07fmfUc1BljsBDEMilenfhSAg30qTuyzlQSXV5UweAznLP 9bhBuzURn2MQU+v5cY9asGw8vBYV8aWmUMos7xEG9vTrKLbWsClh4xjOJhNM08JRvJhh lUkw== X-Gm-Message-State: AOJu0Yz0rS+xim5IRwFu/pTv/FH9e/fmO0CqjMY89KU9RqgEjl/dl14i Z25QP6H0l6QyfIvtjKlYMBHLll6xe2PrJZFS049XXYAu/o+z+H9ZZqozBRrK X-Google-Smtp-Source: AGHT+IFRsJi8Lk/YkWmZNzyYq1os59XyudwW9DbXAz8UNZbqOp6WG+o9Z93x0Czo5Bhzx8xLQUI1ww== X-Received: by 2002:a05:6a20:ba20:b0:1bd:19e2:744c with SMTP id adf61e73a8af0-1bd19e274e6mr6680379637.4.1719482507949; Thu, 27 Jun 2024 03:01:47 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:47 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Chao Du , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 14/32] target/riscv/kvm: define TARGET_KVM_HAVE_GUEST_DEBUG Date: Thu, 27 Jun 2024 20:00:35 +1000 Message-ID: <20240627100053.150937-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=alistair23@gmail.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Chao Du To enable the KVM GUEST DEBUG for RISC-V at QEMU side. Signed-off-by: Chao Du Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Message-ID: <20240606014501.20763-4-duchao@eswincomputing.com> Signed-off-by: Alistair Francis --- configs/targets/riscv64-softmmu.mak | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/targets/riscv64-softmmu.mak b/configs/targets/riscv64-softmmu.mak index f688ffa7bc..917980e63e 100644 --- a/configs/targets/riscv64-softmmu.mak +++ b/configs/targets/riscv64-softmmu.mak @@ -1,6 +1,7 @@ TARGET_ARCH=riscv64 TARGET_BASE_ARCH=riscv TARGET_SUPPORTS_MTTCG=y +TARGET_KVM_HAVE_GUEST_DEBUG=y TARGET_XML_FILES= gdb-xml/riscv-64bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-64bit-virtual.xml # needed by boot.c TARGET_NEED_FDT=y From patchwork Thu Jun 27 10:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9AE4C3064D for ; Thu, 27 Jun 2024 10:05:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxA-0005oj-QZ; Thu, 27 Jun 2024 06:02:08 -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 1sMlx4-0005Ns-Eh for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:04 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwv-0001gc-JT for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:01 -0400 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6fa11ac8695so4553853a34.3 for ; Thu, 27 Jun 2024 03:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482512; x=1720087312; 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=4VavWRGjlSUvFItRJ7LlymYt3dfzs/4J/YRywHyYUT4=; b=HdsAfD/tfAgt9gJZRpkeGxVh0VewjVAwVwO0AQy8wsqAvXQMKSqMq4vidgKRqwxqy+ AMRqAMqOqJ9f2qwfjusMcDNyFJ0DBdD2Fu11kL7GuBjxcNmFULlXG5DoNMv6ZL6SeHM+ 9MXkrQvqp35uSLmuaIdwFBgpkcFOVr2Vh68rY4PFMzpH7urm5+uwi0dXtf2MQEunF/Wm GL6gtYmyZykGJd26bI/qeLV6cWz3349pFv3+4zg6fsqjOCS16xO3qIzN8aYzfNfMP1Kw CA1Pp/RTO9U53u9fpPlyxe1tkFZ9MXYmmufjR3SNNejv7L0whCBQ+t0ubIgKREui/HPE +QdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482512; x=1720087312; 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=4VavWRGjlSUvFItRJ7LlymYt3dfzs/4J/YRywHyYUT4=; b=M3GCQbUp185TICG7G8KYJa0LVmW+jQdLrJvwhUoSOAU90H8NOsVm9mufIoPemasGXQ 10gvwTn7nMC6kAn95tU2Xe2pBkADzR+4HASDTg6ZgafdysRbXbAM1WNqJA70lysbkzu9 +pBSgr++9sMkCB6SI1NKqeFrNJOuHottZquETWaWspEL7muMOZWck/wcpEc1eTx3jegi hxsBIGV7xIkw6EL6v1piamkKobk6mSRXjgN+9UYqBCXTvwpdTiMfkJpylF/eB71FBdlH 5jEdlVfegtqSqyOgelTHfHH3MumB9chZo5Ghqtu7FnxECgew/Iiv0ZVFvzQxsCelhVk1 iqbg== X-Gm-Message-State: AOJu0YxWtU5miCdTUtJo7vuq32vZZtj1Uw+XCdHnWhBi3gDbYeyUIHp7 5HGuFglUsTvGNiD0wE20KJo8XWGrF+5uzWedp9jsaj8Y0ej21yDryyTuvGc5 X-Google-Smtp-Source: AGHT+IGCJ3gvtZPhr+7l5Ak6zzh/8JpdZXn298Nr0iWrnT8sforOauQ/Ug94EeZ+xh+NFPjj8+/sJw== X-Received: by 2002:a05:6870:8a24:b0:25c:ba98:27e with SMTP id 586e51a60fabf-25d06c6e4acmr14064728fac.32.1719482511967; Thu, 27 Jun 2024 03:01:51 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:51 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jim Shu , "Fea . Wang" , Frank Chang , LIU Zhiwei , Alistair Francis Subject: [PULL 15/32] target/riscv: Reuse the conversion function of priv_spec Date: Thu, 27 Jun 2024 20:00:36 +1000 Message-ID: <20240627100053.150937-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=alistair23@gmail.com; helo=mail-ot1-x329.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jim Shu Public the conversion function of priv_spec in cpu.h, so that tcg-cpu.c could also use it. Signed-off-by: Jim Shu Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20240606135454.119186-2-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 2 +- target/riscv/tcg/tcg-cpu.c | 13 ++++--------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6fe0d712b4..b4c9e13774 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -830,4 +830,5 @@ const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); /* Implemented in th_csr.c */ void th_register_custom_csrs(RISCVCPU *cpu); +const char *priv_spec_to_str(int priv_version); #endif /* RISCV_CPU_H */ diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 69a08e8c2c..fd0f09c468 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1790,7 +1790,7 @@ static int priv_spec_from_str(const char *priv_spec_str) return priv_version; } -static const char *priv_spec_to_str(int priv_version) +const char *priv_spec_to_str(int priv_version) { switch (priv_version) { case PRIV_VERSION_1_10_0: diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index fa8a17cc60..4c6141f947 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -76,16 +76,11 @@ static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint32_t bit, static const char *cpu_priv_ver_to_str(int priv_ver) { - switch (priv_ver) { - case PRIV_VERSION_1_10_0: - return "v1.10.0"; - case PRIV_VERSION_1_11_0: - return "v1.11.0"; - case PRIV_VERSION_1_12_0: - return "v1.12.0"; - } + const char *priv_spec_str = priv_spec_to_str(priv_ver); - g_assert_not_reached(); + g_assert(priv_spec_str); + + return priv_spec_str; } static void riscv_cpu_synchronize_from_tb(CPUState *cs, From patchwork Thu Jun 27 10:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 217CEC2BD09 for ; Thu, 27 Jun 2024 10:04:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlx9-0005e4-8X; Thu, 27 Jun 2024 06:02: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 1sMlx4-0005Np-E5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:04 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlwz-0001gs-Uu for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:01 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-706627ff48dso4166230b3a.1 for ; Thu, 27 Jun 2024 03:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482515; x=1720087315; 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=9aUCnalnUbISmCX7rnd1hepHfDNLqfkxy2lbhGVkz3Q=; b=QBw05HWo76t7Mcq4WaakuBCVs2IMnNTG+50nnqaqY0XH4aKHnkz1gO2VHQzWXNzsm9 2fy6EnsFj3Ro8tnM4MxBzh6l5rXjn15MaSC+V+51uBbH648XTrkCa3JoyVve4bG2dEdI 1ZMs13m+720/JvQqc2W+RSsuEkTP5e29fVoZdby9gvl9x8suqN3IDK1WRZsSVPdoz9fH EeZ+0EcE8XaxEmcAo7ncfPUXnktw3TopmK6ZmtLgD3bPLG/ZnyHZsNE+5dcP+PHqP17f K+lhiNj8SmTuYYZ2kAy+00/sO/ynj9v0SIw8qmC//GKtxPKoonu0n2LS3jRlW3U6GErs yRZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482515; x=1720087315; 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=9aUCnalnUbISmCX7rnd1hepHfDNLqfkxy2lbhGVkz3Q=; b=JrK4CrssR0YHx/Vab+u6/1NFpp0X8IpFYMxTa1gxHmjvS9gLqOn8hfcjjmgOxEwovY a+A//ykbPzvWVP0DveUxK8VNLI8yu/j3Rr0mZaeMJaKhv2pBl70uCHSCF4kvSsSDYqS7 fCYwceOc6vyjlJz3Yc6R8B7SalVrzu50s219vCqwsmF2lEvCzTT5DFzccyBFa7QTJpA0 EqyW7XdglHBWJrEcQYsrhAW9tIu9aQE3q8mk7FLewlLIWg+6lE2mmAca+yX1jKP0DxDU UAkm5y5+3HG9cAMJEJTmXkzYoftqyMp61NrhEousHzsSplOZauHei9M7rdyun7V3Dqc3 YJ7Q== X-Gm-Message-State: AOJu0YxoxejxQC5Yn1Hh6ANDR/qE4GX6xBLXO5kqyEOPIRoD3xk5q6T1 ODDl8zqYB4b5QbHTtA47C14rNYaTUXQIhhenVYiKU/o8MaVWEIopaBTOxJQH X-Google-Smtp-Source: AGHT+IGInls2vv1jQdzTlwg9kn3sxblXT56o/xLZlxbKYxUsJWCMiMOQYlfHt2Kbjq2JsuOaAAOOKg== X-Received: by 2002:aa7:9d11:0:b0:706:6525:611f with SMTP id d2e1a72fcca58-70674751f13mr14066320b3a.31.1719482515558; Thu, 27 Jun 2024 03:01:55 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:55 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, "Fea.Wang" , Frank Chang , Weiwei Li , LIU Zhiwei , Alistair Francis Subject: [PULL 16/32] target/riscv: Define macros and variables for ss1p13 Date: Thu, 27 Jun 2024 20:00:37 +1000 Message-ID: <20240627100053.150937-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=alistair23@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Fea.Wang" Add macros and variables for RISC-V privilege 1.13 support. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: Weiwei Li Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20240606135454.119186-3-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 4 +++- target/riscv/cpu_cfg.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index b4c9e13774..90b8f1b08f 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -96,12 +96,14 @@ extern RISCVCPUProfile *riscv_profiles[]; #define PRIV_VER_1_10_0_STR "v1.10.0" #define PRIV_VER_1_11_0_STR "v1.11.0" #define PRIV_VER_1_12_0_STR "v1.12.0" +#define PRIV_VER_1_13_0_STR "v1.13.0" enum { PRIV_VERSION_1_10_0 = 0, PRIV_VERSION_1_11_0, PRIV_VERSION_1_12_0, + PRIV_VERSION_1_13_0, - PRIV_VERSION_LATEST = PRIV_VERSION_1_12_0, + PRIV_VERSION_LATEST = PRIV_VERSION_1_13_0, }; #define VEXT_VERSION_1_00_0 0x00010000 diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index e1e4f32698..fb7eebde52 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -136,6 +136,7 @@ struct RISCVCPUConfig { * TCG always implement/can't be user disabled, * based on spec version. */ + bool has_priv_1_13; bool has_priv_1_12; bool has_priv_1_11; From patchwork Thu Jun 27 10:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1526DC2BD09 for ; Thu, 27 Jun 2024 10:04:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlx9-0005dR-5k; Thu, 27 Jun 2024 06:02: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 1sMlx6-0005OA-9g for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:04 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlx3-0001h7-0E for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:03 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70679845d69so3370659b3a.1 for ; Thu, 27 Jun 2024 03:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482519; x=1720087319; 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=zDmHgwe/yLeAAO02Qn8XqoyaNs3eApAfdC0KQgpDfB8=; b=kmXMw0otjom2D0WUcZ0OSB1ajmuNprlsax5k8BSZhui6qBfpc8pPTqCwz+4XPT/UKL nKSusrnXCFa92p8dAWVv7OAicBNEFzYrPdhgIFW2/wKCpRa++PQvlomxpI45PviqQsIN Xi/HHsVovgKLPVp3j3uoN5YDc8k7mUz0ly/ztSetf/m2JQ77rwSS6qqOtYFGEfgVlFsf 1hmctu4p4zIa3GRXf1OzUkO6qfgZbRhecwEAeDyO5My1vN5lnkRJA3AY1I3+r2BpSBXQ SbwL9x9NTME3brex1QJm9oPSh3qSU10EYwNwE3GGUYGVgSA9+GMKhyx3Thzo+bkYikA8 xbUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482519; x=1720087319; 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=zDmHgwe/yLeAAO02Qn8XqoyaNs3eApAfdC0KQgpDfB8=; b=ZNgRkAaYEBV7+QTrBRbxbA+CRPgANAaCtvVPGlvMpx5iulhNfa0Vd07SxhmcgnaBOR qfEOyb8vro+HDcBhgLfEgD0x0PhzJkh67jKTgp1ZHFnXWorcgrAgrp8s+IkWCyiJDtIh oyxRdDqSTr5zkraNWtPrZm52vDu6FFyA7ucEP+EeS55Bq84pWG1vRp/NkhirgCV6eB/B xwALfKRaEBWKgLs+aIw3zzTf3FQq6tUKweatUFurgtRdx/mBqnim01qKA1rIBTEUzoOv IzHKItuy23pusGx7IOx5yuYvJvYmpkEK8RUDKZ39bh5ewnZu850hYF04/lD+s4IqNtCa kAYA== X-Gm-Message-State: AOJu0YwpSd5cEnRqG3kJ60cHRJ2o36XMU5n83Mlp9+8Na3pp2vYO2trX 5aUGOJCth+kPohQdKi7hM+HQycIf6EakjgMPxk4MESJ9cj42mxVG5UXKiLdU X-Google-Smtp-Source: AGHT+IGeyKfoH3ak7Via7nTbG6lxjunFbANvaBtrMPi/NjXr4Xw4d5s8uMJXWwQl4Py0/eTChl9iug== X-Received: by 2002:a05:6a00:398f:b0:704:3678:3f03 with SMTP id d2e1a72fcca58-7067455bf67mr13919910b3a.5.1719482518770; Thu, 27 Jun 2024 03:01:58 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:01:58 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, "Fea.Wang" , Frank Chang , Weiwei Li , Alistair Francis Subject: [PULL 17/32] target/riscv: Add 'P1P13' bit in SMSTATEEN0 Date: Thu, 27 Jun 2024 20:00:38 +1000 Message-ID: <20240627100053.150937-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Fea.Wang" Based on privilege 1.13 spec, there should be a bit56 for 'P1P13' in mstateen0 that controls access to the hedeleg. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-ID: <20240606135454.119186-4-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index a470fda9be..c895aa0334 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -315,6 +315,7 @@ #define SMSTATEEN0_CS (1ULL << 0) #define SMSTATEEN0_FCSR (1ULL << 1) #define SMSTATEEN0_JVT (1ULL << 2) +#define SMSTATEEN0_P1P13 (1ULL << 56) #define SMSTATEEN0_HSCONTXT (1ULL << 57) #define SMSTATEEN0_IMSIC (1ULL << 58) #define SMSTATEEN0_AIA (1ULL << 59) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index ee33019b03..a19e1afa1f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2252,6 +2252,10 @@ static RISCVException write_mstateen0(CPURISCVState *env, int csrno, wr_mask |= SMSTATEEN0_FCSR; } + if (env->priv_ver >= PRIV_VERSION_1_13_0) { + wr_mask |= SMSTATEEN0_P1P13; + } + return write_mstateen(env, csrno, wr_mask, new_val); } @@ -2287,6 +2291,10 @@ static RISCVException write_mstateen0h(CPURISCVState *env, int csrno, { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; + if (env->priv_ver >= PRIV_VERSION_1_13_0) { + wr_mask |= SMSTATEEN0_P1P13; + } + return write_mstateenh(env, csrno, wr_mask, new_val); } From patchwork Thu Jun 27 10:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A4C0C3064D for ; Thu, 27 Jun 2024 10:03:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxC-0005vg-8f; Thu, 27 Jun 2024 06:02:10 -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 1sMlx8-0005X2-0h for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:06 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlx6-0001hp-2B for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:05 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-700cc97b220so1378844a34.0 for ; Thu, 27 Jun 2024 03:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482522; x=1720087322; 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=a7nUOVc8poO2k61wXomx0Mx7KlCErB954jv8HLoD7N4=; b=CAPaVOOIEuRxUNytAPIZxfBBCWw26O5pBtA7E5mDAfmXj2Nc/tms3Pz/fP9vEyocwv u15SqqJhXu3bTelfwX8HKQXgdJneQIrv/Ul66YlEhr+pYmPH1YilDmABmMT6OiHHwDpn 7eNVHQmC6kD3ArQ9IOcG2MKJ0Udel5KyO4B+TUFI8/1a1jQBWYzKm6UGQogYiqitQVlK ePwsdeLEcAssLSsVECRlvQd5q0qV79GwcF4md4wA2moJYAz5a9MvbumbVXWn9dn/KcpF 80YScoOYtAHcH14vwP68KF42IHi/1OBtnXjgVoCaVayStPc/9AB3eHtvBhQNUuSg3myJ Ysbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482522; x=1720087322; 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=a7nUOVc8poO2k61wXomx0Mx7KlCErB954jv8HLoD7N4=; b=Vfp/Vgu+ipbVYftCfU4ApNVrkGDYIacyAYtJ/EXEJ3U0qI+ZxaIbZuTvHDFsXm/DCy iqgjUijqFLfmLpXjqJvJ/czZ42nW8K0hvuG0MCSD8Z3/Ju7ps9muy3L8pVRCwquariCD p9/ThfZCTbnX8TDhAcT1FvLphZ7EbPQLWLvoa591hGj70zuaXpGiWCioxPvHLpuqDg2d W7dZzNkc2ipYDTTXSmg1L6fNDphMVxkDb2nMdbQtuEVlQ+Cz+jClYfiE8C9me9sIqpcX I2s/bhTrS+v8XGpbjIrL7HXTLXeYUmMbSIkPWbTuFRd00kO8EaGJjKEGPJBuN0kyUsBm RhJg== X-Gm-Message-State: AOJu0YzvnLJWFmoYNDjPXTF4s+a71uSAuD/+c7gzS9LHJZ23EHrzmI3W k4Yx75KRronlamQ6+3B3qN3royl+pT/gUZplBsP4zU7ehv/EvKQD9Z1G3vp1 X-Google-Smtp-Source: AGHT+IH22vdkztO0vTep4QjsMx/oz+x31D0X47UMXRdwd5yuSWwMQb6dvSOPtSA/SQy8oyrOqlvcKA== X-Received: by 2002:a05:6870:d152:b0:254:8908:4281 with SMTP id 586e51a60fabf-25d06e55f68mr12608592fac.44.1719482522055; Thu, 27 Jun 2024 03:02:02 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:01 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, "Fea.Wang" , Frank Chang , LIU Zhiwei , Alistair Francis Subject: [PULL 18/32] target/riscv: Add MEDELEGH, HEDELEGH csrs for RV32 Date: Thu, 27 Jun 2024 20:00:39 +1000 Message-ID: <20240627100053.150937-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=alistair23@gmail.com; helo=mail-ot1-x332.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Fea.Wang" Based on privileged spec 1.13, the RV32 needs to implement MEDELEGH and HEDELEGH for exception codes 32-47 for reserving and exception codes 48-63 for custom use. Add the CSR number though the implementation is just reading zero and writing ignore. Besides, for accessing HEDELEGH, it should be controlled by mstateen0 'P1P13' bit. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20240606135454.119186-5-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 2 ++ target/riscv/csr.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index c895aa0334..096a51b331 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -156,6 +156,8 @@ /* 32-bit only */ #define CSR_MSTATUSH 0x310 +#define CSR_MEDELEGH 0x312 +#define CSR_HEDELEGH 0x612 /* Machine Trap Handling */ #define CSR_MSCRATCH 0x340 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index a19e1afa1f..6f15612e76 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3229,6 +3229,33 @@ static RISCVException write_hedeleg(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } +static RISCVException read_hedelegh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + RISCVException ret; + ret = smstateen_acc_ok(env, 0, SMSTATEEN0_P1P13); + if (ret != RISCV_EXCP_NONE) { + return ret; + } + + /* Reserved, now read zero */ + *val = 0; + return RISCV_EXCP_NONE; +} + +static RISCVException write_hedelegh(CPURISCVState *env, int csrno, + target_ulong val) +{ + RISCVException ret; + ret = smstateen_acc_ok(env, 0, SMSTATEEN0_P1P13); + if (ret != RISCV_EXCP_NONE) { + return ret; + } + + /* Reserved, now write ignore */ + return RISCV_EXCP_NONE; +} + static RISCVException rmw_hvien64(CPURISCVState *env, int csrno, uint64_t *ret_val, uint64_t new_val, uint64_t wr_mask) @@ -4633,6 +4660,10 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MSTATUSH] = { "mstatush", any32, read_mstatush, write_mstatush }, + [CSR_MEDELEGH] = { "medelegh", any32, read_zero, write_ignore, + .min_priv_ver = PRIV_VERSION_1_13_0 }, + [CSR_HEDELEGH] = { "hedelegh", hmode32, read_hedelegh, write_hedelegh, + .min_priv_ver = PRIV_VERSION_1_13_0 }, /* Machine Trap Handling */ [CSR_MSCRATCH] = { "mscratch", any, read_mscratch, write_mscratch, From patchwork Thu Jun 27 10:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D4BEC2BD09 for ; Thu, 27 Jun 2024 10:03:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxD-00064W-DW; Thu, 27 Jun 2024 06:02: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 1sMlxB-0005pb-47 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:09 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlx9-0001iE-C4 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:08 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-706a1711ee5so1722496b3a.0 for ; Thu, 27 Jun 2024 03:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482526; x=1720087326; 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=+2ZtPlx1gfPCtUTgrKOFONw9SOdI5ccx3X/2YcbrFmM=; b=PxIX0gePqbQzku9ZTvlyXJNfiIawfRbpmdybJmzvGgGupKSfsMj4mcUIdbECmgk0fm Y1fbn8Dy5GiwDItTy2eET7f/d80+FwwcQCASpePXDN97Jkj7eXG9kdOGzYZ3N1km3JE0 QRQGJaIa4q7FcAzElHhrhSs6NsLLypUrRXCL3LjOiy8Rrj1vVwIpBEbobFvSEZWRqHTy tSc1DmGX8KsOQMCpkdcLZmOuWG8NyBCspexrIBxyEBSaWAZ3tIHehN1n5lGD8V1ySDSx MmcWPTeGlJUazq/G4K/UHnYtWKf5zjI+Bph0PvwrfCt5gUfhgFIbZvblmuzWx0BVpoN7 pyiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482526; x=1720087326; 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=+2ZtPlx1gfPCtUTgrKOFONw9SOdI5ccx3X/2YcbrFmM=; b=iUWHq7Mia6hp2o8l8NNNt88W9yoPFfFbczrUpy7RfEeixTic4eHoPMt4yzXfhf8Tkn kcLqgZubTBO+nwLoypAzcDKoYjprfyFzjj+k2ZKSMwxEDksUxhCtlbgFF7DNyOYo4Pge y9bdTjoojid6aTeXSnaqht+GOifEcCWPvOayptaaFXKNIdIcds0vzl4DGuj1UFH9qC5M QHhXKcpglIadkLcKTud+j6Z3ToJdBLiUdjJeZFnO53aH11IGCdc0XkKTdkDAZQHFhzcj w3kH5bKwL5/nhBFNfU+YtXnKYvh0zyR+B9UDk75HkludQx85FSFa+1HkXyhthVsHImSS MYxw== X-Gm-Message-State: AOJu0YwsxJgbezF06MYVId0Gqd8FAF5fjSOKpVeAeEM2KeewwNrNv6ay Nlf6ZQzkeOLCSW4fXB+rVmJoVnvM0KHEW+KXfBY4r0hlbHMnWoilJaWZACGy X-Google-Smtp-Source: AGHT+IFxkBI4qboUzeCkA6q0oEkqA+onz8dJdSXqVVgMOfzOGt2lZhT62kN0qO0pBVgTb+j9kRvwrA== X-Received: by 2002:a05:6a00:c8e:b0:704:2811:62 with SMTP id d2e1a72fcca58-706745be4c5mr15284762b3a.13.1719482525517; Thu, 27 Jun 2024 03:02:05 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:05 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, "Fea.Wang" , Frank Chang , LIU Zhiwei , Alistair Francis Subject: [PULL 19/32] target/riscv: Reserve exception codes for sw-check and hw-err Date: Thu, 27 Jun 2024 20:00:40 +1000 Message-ID: <20240627100053.150937-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=alistair23@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Fea.Wang" Based on the priv-1.13.0, add the exception codes for Software-check and Hardware-error. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20240606135454.119186-6-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 096a51b331..c257c5ed7d 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -673,6 +673,8 @@ typedef enum RISCVException { RISCV_EXCP_INST_PAGE_FAULT = 0xc, /* since: priv-1.10.0 */ RISCV_EXCP_LOAD_PAGE_FAULT = 0xd, /* since: priv-1.10.0 */ RISCV_EXCP_STORE_PAGE_FAULT = 0xf, /* since: priv-1.10.0 */ + RISCV_EXCP_SW_CHECK = 0x12, /* since: priv-1.13.0 */ + RISCV_EXCP_HW_ERR = 0x13, /* since: priv-1.13.0 */ RISCV_EXCP_INST_GUEST_PAGE_FAULT = 0x14, RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT = 0x15, RISCV_EXCP_VIRT_INSTRUCTION_FAULT = 0x16, From patchwork Thu Jun 27 10:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF27FC30653 for ; Thu, 27 Jun 2024 10:03:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxG-0006QG-BT; Thu, 27 Jun 2024 06:02:14 -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 1sMlxE-0006EV-Pc for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:12 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxC-0001iU-NO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:12 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-70675977d0eso3947974b3a.0 for ; Thu, 27 Jun 2024 03:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482529; x=1720087329; 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=x13WhTxcZG7M/CZkZViFdoYco9hukctsn/jx6KYUPo8=; b=FaY/TtcOWF2RdWwUgWTvN9GH6c8NfpwiZneO3E3/844XFtbPLxAB2/ulQv4UUId4G+ 7vwZIh9LzhBQjzgaHJWclmXX24KV3RZ1Eb2EetxqQ8vlhnRxVwxXfy0RX0G6b2l5qSQX a8zJpZx3wKHmkq7wGLRi5LRNjJy/+ZDa38U8P28aLQEPlG7fbChUcfvEXC0rgfLxS4nX S+wXWA+xNOLeQQ3BYU0JvDfIUtWSFOsULZYvzfpAQRy2ZxYVhoFYEFA+N9vn8a6OVEc+ 4nnuSBlI638qkUQ73c2nw8Xxa1DjY3+W34eADqer7zpxM8PTSMgD0nm5Dhw3GVGC3FiY 7/RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482529; x=1720087329; 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=x13WhTxcZG7M/CZkZViFdoYco9hukctsn/jx6KYUPo8=; b=uzERbsACf9zpT0Hhg7up4WSgTUuBX8w1VSDXnU3/baIQ+0m+K+o4A2QIPd8uPDvUzT MdvsehYYxiaHQTy4A1kfpMqjpGFuCcE4aG79ejTEcWRxpND2hVPkE4wLws4ZR7j6erMN rY4h9weqEpOqGmlyZlx7TXgfH6dOh6sfd/C+4EG3BoIuQb9ClEsTDXcW6UOl6ypKG6va OrisLNOvxAnYpD1fG/Ej4w0KB7L74FtMZCXn1Jy1t53Q7FWp5xCTxCKAF6xtH0hlziAG ri5q1z3i1jS4T1Fn4BG7DEUC819P7iO5j+nojGV11hCSvFTEY6PdLX4yfhXwKTdSIFpb VVCg== X-Gm-Message-State: AOJu0YwfDgSyh/aT8e+mhxPyUidbBEWUKf3icMvagxOBEiYgm3cQ1L3K 1a3neR1byo537pKHobql/bUM9peXkD0BAHaqm2mhQ3+W234vliZ5Fz/KYl1L X-Google-Smtp-Source: AGHT+IGaiiOvIvsq9mFKFWmueQB73fzF7cruGF30UBAPwOZ4omNUwzBlmIR7WQ4djt/rF4Aa1aE99g== X-Received: by 2002:aa7:92c2:0:b0:705:c029:c9a7 with SMTP id d2e1a72fcca58-706745b6d61mr12030306b3a.15.1719482529019; Thu, 27 Jun 2024 03:02:09 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:08 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, "Fea.Wang" , Frank Chang , Weiwei Li , LIU Zhiwei , Alistair Francis Subject: [PULL 20/32] target/riscv: Support the version for ss1p13 Date: Thu, 27 Jun 2024 20:00:41 +1000 Message-ID: <20240627100053.150937-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Fea.Wang" Add RISC-V privilege 1.13 support. Signed-off-by: Fea.Wang Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: Weiwei Li Reviewed-by: LIU Zhiwei Message-ID: <20240606135454.119186-7-fea.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 6 +++++- target/riscv/tcg/tcg-cpu.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fd0f09c468..4760cb2cc1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1779,7 +1779,9 @@ static int priv_spec_from_str(const char *priv_spec_str) { int priv_version = -1; - if (!g_strcmp0(priv_spec_str, PRIV_VER_1_12_0_STR)) { + if (!g_strcmp0(priv_spec_str, PRIV_VER_1_13_0_STR)) { + priv_version = PRIV_VERSION_1_13_0; + } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_12_0_STR)) { priv_version = PRIV_VERSION_1_12_0; } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_11_0_STR)) { priv_version = PRIV_VERSION_1_11_0; @@ -1799,6 +1801,8 @@ const char *priv_spec_to_str(int priv_version) return PRIV_VER_1_11_0_STR; case PRIV_VERSION_1_12_0: return PRIV_VER_1_12_0_STR; + case PRIV_VERSION_1_13_0: + return PRIV_VER_1_13_0_STR; default: return NULL; } diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 4c6141f947..eb6f7b9d12 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -318,6 +318,10 @@ static void riscv_cpu_update_named_features(RISCVCPU *cpu) cpu->cfg.has_priv_1_12 = true; } + if (cpu->env.priv_ver >= PRIV_VERSION_1_13_0) { + cpu->cfg.has_priv_1_13 = true; + } + /* zic64b is 1.12 or later */ cpu->cfg.ext_zic64b = cpu->cfg.cbom_blocksize == 64 && cpu->cfg.cbop_blocksize == 64 && From patchwork Thu Jun 27 10:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 279ACC2BD09 for ; Thu, 27 Jun 2024 10:06:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxK-0006i8-AM; Thu, 27 Jun 2024 06:02:19 -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 1sMlxI-0006Yb-9x for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:16 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxG-0001ii-Lh for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:16 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70698bcd19eso2194700b3a.0 for ; Thu, 27 Jun 2024 03:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482532; x=1720087332; 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=EsLiAHFyCsutJDc2599A4Vu0YvGo61TqCblpFBlIdck=; b=U69pmD2lBQfTcJozBSpCx1h2CJkKbJy3R8xznx2YmnodboNo5s0SoXFeJNs5Ipr+K1 Jp0ehn/fxbhk9oZr7MfW5KwGlziWYoyjeeNOD2clC2yyF2N08WGI/0ES4MlYxUytPgKa 5j/fNaU+lTJBNcI4oc3l3U6jEdBueK6buRwjJuSyk8IPW4B717jx5xhOIsuOcFfmKawJ 5ZZtvcFskASerC5J13bncOjQEHLtwC0bXuUBsgx+pKDUR31XDtEGJuxofqQe5Fn580ZY 64IwSoI5r3Ra5l01Y9kRkz3Iu7acjJF7obMVqaYkobwTVZAgiTOTe30DycZTenhhHixN PXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482532; x=1720087332; 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=EsLiAHFyCsutJDc2599A4Vu0YvGo61TqCblpFBlIdck=; b=xMUMSez3g3vDgXnhtGaGNhl6YZk/WGkOdlXapQKMzFBRxzqnjD+dFxm6r3K8tDra5y xuwoZKdJh4eL77OB4BGyEybOKwYl6pEHkDfHTqYfXb8BDjkYF5c/5nv6njdZW9qhXVcW neeY7PB63mKEX14LC7Pw+Vrk8adxTF89TJPVwatyFBZfvVwVo4ENC9rpwGhaEoM8O9kC WLayy/rPIqsqBWuahlqFNc59fCpJ6VhLOLqOWu4hn061OjSJfdaCWWpy9pNOni8lGkjG 0OnbxNnEsVjN6IGUScn2527v5ekVOmAfrSgN1hV+xnhviF033mUlFGuOO7zq+V6XwDFp lx0A== X-Gm-Message-State: AOJu0YxsCzi3xqNtpYcObGlkqvSavrJQx2nLH/V/ST+dvLFqKPMq/qmA NhYdxp4vbHTIJzbIxHY6ASxJkB1lqHi0xdsHYZ1hYrquhC/XSzmQMJQuV1Y+ X-Google-Smtp-Source: AGHT+IH9IJrxKTJsMDGKvGKulwVzNLPAtUGlNCLckZC5UBnfGaMyeLlO1z0jX7uz1WFsxeAX4C6ZqA== X-Received: by 2002:a05:6a00:2195:b0:706:6c38:31f3 with SMTP id d2e1a72fcca58-706745830e0mr14179622b3a.8.1719482532046; Thu, 27 Jun 2024 03:02:12 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:11 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Sunil V L , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 21/32] hw/riscv/virt.c: Make block devices default to virtio Date: Thu, 27 Jun 2024 20:00:42 +1000 Message-ID: <20240627100053.150937-22-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=alistair23@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L RISC-V virt is currently missing default type for block devices. Without this being set, proper backend is not created when option like -cdrom is used. So, make the virt board's default block device type be IF_VIRTIO similar to other architectures. We also need to set no_cdrom to avoid getting a default cdrom device. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Message-ID: <20240620064718.275427-1-sunilvl@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 9b648540e6..bc0893e087 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1764,6 +1764,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->init = virt_machine_init; mc->max_cpus = VIRT_CPUS_MAX; mc->default_cpu_type = TYPE_RISCV_CPU_BASE; + mc->block_default_type = IF_VIRTIO; + mc->no_cdrom = 1; mc->pci_allow_0_address = true; mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; From patchwork Thu Jun 27 10:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37C01C2BD09 for ; Thu, 27 Jun 2024 10:05:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxM-0006lK-DM; Thu, 27 Jun 2024 06:02: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 1sMlxL-0006iZ-DW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:19 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxI-0001kx-OK for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:18 -0400 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3d55e2e0327so1343303b6e.0 for ; Thu, 27 Jun 2024 03:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482535; x=1720087335; 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=8hc3Rw3zZB7nBLeNjAJQMLk441yVfIEAPDQCPVGgw7E=; b=BAlzntdeuFh3kWd5WQCIoOIdU4j/5p0jwh28UHfMOqpW2oaQe2pYxP9UFWspJUwLYh K8jOjd8JNWZnV/zhNt4Bf0/FX6oiKhMHjhldsKkh+wMTP6d5ocwn7L+bSYiWfxMZVEag 3uVg3HyuiVUTAoPGTYMXTK6Ua5HJd16kJZe9RlPDwCjZJQalMypQ6Hu1RE4RuM0l34Wz nTXUxIMDgiDQcqrteHOAfiIVb6wPrXwVtMM22gI9juWqXjxjhyfXk4ixJ0fybTYlwZ5v VLwbcfxnvR4sIdfxyy0rC4WW1BDbVd9BcjUBG5GIWnHHfUxLu86ShPq80KS65VfLaizi /qqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482535; x=1720087335; 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=8hc3Rw3zZB7nBLeNjAJQMLk441yVfIEAPDQCPVGgw7E=; b=o6qrhd70PSe6kAaSpqvHVpzDvJUcUSNHgNreDbRVoRIf9owZWw2PKMJIvQwmYVs/is GbDvWyNo59mqHjDIhEBfz6oFaUF4R2cJ5WnZHEp2rNqMInLsrpUIF/8RFqPsqiGvAybF YL4RYliVZNkwUIccCGg0o8qZt2oZ1Nl1v+pEMDzBe/wkdUeJ6l/2pknhUBl/Zh01mht0 CGCzMjdEFlgOjVrBYusLpv9qbIHUAfGCE7vtE0q+1mEFP8wpojtcKhM7oYRlz9ZxuEp8 AsOkDbxfqXUo0Q5Phz40sbXzE1I4sKWn0W0PaLwIiQPD1tqbI8etny9ISPVuwRRme51v ZbVg== X-Gm-Message-State: AOJu0YyQutngg0mCeKeuCCaLr/CNJooyaYXwlTbKeR4PTO/gCQvQqfPG TRQwfGzaXk8zvYRcDFLkPSgw4vrkp14m0w59YoiAYpqO0pgPQJXQh9YVfwtI X-Google-Smtp-Source: AGHT+IEmGd736Qq7Y4LelCYcKP5+YlZHytq2n78dnsUYA90un5EXbsXat4u9vpDAhM7Q1eGqoJi8Fw== X-Received: by 2002:a05:6808:1412:b0:3d5:6575:6fe4 with SMTP id 5614622812f47-3d56575710dmr3285784b6e.26.1719482535270; Thu, 27 Jun 2024 03:02:15 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:14 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Branislav Brzak , Alistair Francis , Richard Henderson Subject: [PULL 22/32] target/riscv: Fix froundnx.h nanbox check Date: Thu, 27 Jun 2024 20:00:43 +1000 Message-ID: <20240627100053.150937-23-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=alistair23@gmail.com; helo=mail-oi1-x233.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Branislav Brzak helper_froundnx_h function mistakenly uses single percision nanbox check instead of the half percision one. This patch fixes the issue. Signed-off-by: Branislav Brzak Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson Message-ID: <20240608214546.226963-1-brzakbranislav@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/fpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 871a70a316..91b1a56d10 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -676,7 +676,7 @@ uint64_t helper_fround_h(CPURISCVState *env, uint64_t rs1) uint64_t helper_froundnx_h(CPURISCVState *env, uint64_t rs1) { - float16 frs1 = check_nanbox_s(env, rs1); + float16 frs1 = check_nanbox_h(env, rs1); frs1 = float16_round_to_int(frs1, &env->fp_status); return nanbox_h(env, frs1); } From patchwork Thu Jun 27 10:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B301DC2BD09 for ; Thu, 27 Jun 2024 10:04:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxj-000753-Q1; Thu, 27 Jun 2024 06:02:43 -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 1sMlxP-0006m0-19 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:23 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxM-0001sU-5X for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:22 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-7065a2f4573so4560719b3a.2 for ; Thu, 27 Jun 2024 03:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482538; x=1720087338; 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=3PBJYVBwlZcM3vrZPZTYGjjElJE2GDldPlxWfqT4Lng=; b=VOp8qkKXUWdRmjQJ8EuZ/k0Q+H/gpH0K2WssbFr4ET9e6FZoowmfhxxsEOZkIP04ND JRXVH8VzACFgDadg/c6ZFs8PtSYUuL/xIptrxvq55XzVtYGuzoEII/CS3Ll+wl9aEiUU DYMfB1O99tx8L9CE3C9WYjhAqTjDRthTQlNq69YGW3LkesUjZmI+TPlRweeakqXwnY/X WtsUtO2DHLU3LE8e91SBxCMU5lxMY8kTj4mt9U7gy7S3ZxZR1OaiFuZL0fblZ+sPDNc4 ZkU/Dca4eGWnWLL/gzhh9R1TKN9dOqbSWirNwOsTC8B4w3ox9J7YMdBDUGvkgfNxWg+8 V9MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482538; x=1720087338; 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=3PBJYVBwlZcM3vrZPZTYGjjElJE2GDldPlxWfqT4Lng=; b=KlPkRdvkfTw6ogqgsbltpllPwV+iqyWUFFb3ZGLnCtiJCejd2zplbUZWxm3ofdmxrN cykiOJSlMlv4hD8Q/b4U48KZvMOvIhT7L9F9ecupc+Bm2ojLz4i1M1BTjlF+eoTWfbTS cCXk58t5zfQoDbh9y27jzjPqlCxH+oSUa+SdSEqmZ3T5Bo6237bAGWbPH/E97+hU/dub FUYvFQ7/bjBCrzCyaTWN85LUFch02YulgTUElXoweM5ou9k9rhDR2/dh42Xmp5aI6oRs LOvBMeMQd0kYMcZ9DovSH9YMf90ITayZ+35JVe5dcMbQ+B4g3dWCFVG/LJjZqxgnMEhA 6m1Q== X-Gm-Message-State: AOJu0YyL1ch/Ihph3rm2QN9hd5EvZE3YPK8ZsV7iFVlHZrgtO2ZgDxkJ TTqbQOlOJDT2gGwBKpdmUEFvHyFthx+7DrYJqA/EArR7SImRsrZ3Fo84Vu9R X-Google-Smtp-Source: AGHT+IEJQM4eKkM4nv7oVkK3yujEJlkyul5WTiFcWAod+14xI0UFGni0M/8MtptwtINoDCwLVzUDgA== X-Received: by 2002:a05:6a00:a06:b0:706:9073:45ee with SMTP id d2e1a72fcca58-70690734663mr10959698b3a.25.1719482538319; Thu, 27 Jun 2024 03:02:18 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:17 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , Alistair Francis Subject: [PULL 23/32] target/riscv: fix instructions count handling in icount mode Date: Thu, 27 Jun 2024 20:00:44 +1000 Message-ID: <20240627100053.150937-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=alistair23@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Léger When icount is enabled, rather than returning the virtual CPU time, we should return the instruction count itself. Add an instructions bool parameter to get_ticks() to correctly return icount_get_raw() when icount_enabled() == 1 and instruction count is queried. This will modify the existing behavior which was returning an instructions count close to the number of cycles (CPI ~= 1). Signed-off-by: Clément Léger Reviewed-by: Atish Patra Message-ID: <20240618112649.76683-1-cleger@rivosinc.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6f15612e76..432c59dc66 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -762,14 +762,18 @@ static RISCVException write_vcsr(CPURISCVState *env, int csrno, } /* User Timers and Counters */ -static target_ulong get_ticks(bool shift) +static target_ulong get_ticks(bool shift, bool instructions) { int64_t val; target_ulong result; #if !defined(CONFIG_USER_ONLY) if (icount_enabled()) { - val = icount_get(); + if (instructions) { + val = icount_get_raw(); + } else { + val = icount_get(); + } } else { val = cpu_get_host_ticks(); } @@ -804,14 +808,14 @@ static RISCVException read_timeh(CPURISCVState *env, int csrno, static RISCVException read_hpmcounter(CPURISCVState *env, int csrno, target_ulong *val) { - *val = get_ticks(false); + *val = get_ticks(false, (csrno == CSR_INSTRET)); return RISCV_EXCP_NONE; } static RISCVException read_hpmcounterh(CPURISCVState *env, int csrno, target_ulong *val) { - *val = get_ticks(true); + *val = get_ticks(true, (csrno == CSR_INSTRETH)); return RISCV_EXCP_NONE; } @@ -875,11 +879,11 @@ static RISCVException write_mhpmcounter(CPURISCVState *env, int csrno, int ctr_idx = csrno - CSR_MCYCLE; PMUCTRState *counter = &env->pmu_ctrs[ctr_idx]; uint64_t mhpmctr_val = val; + bool instr = riscv_pmu_ctr_monitor_instructions(env, ctr_idx); counter->mhpmcounter_val = val; - if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || - riscv_pmu_ctr_monitor_instructions(env, ctr_idx)) { - counter->mhpmcounter_prev = get_ticks(false); + if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || instr) { + counter->mhpmcounter_prev = get_ticks(false, instr); if (ctr_idx > 2) { if (riscv_cpu_mxl(env) == MXL_RV32) { mhpmctr_val = mhpmctr_val | @@ -902,12 +906,12 @@ static RISCVException write_mhpmcounterh(CPURISCVState *env, int csrno, PMUCTRState *counter = &env->pmu_ctrs[ctr_idx]; uint64_t mhpmctr_val = counter->mhpmcounter_val; uint64_t mhpmctrh_val = val; + bool instr = riscv_pmu_ctr_monitor_instructions(env, ctr_idx); counter->mhpmcounterh_val = val; mhpmctr_val = mhpmctr_val | (mhpmctrh_val << 32); - if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || - riscv_pmu_ctr_monitor_instructions(env, ctr_idx)) { - counter->mhpmcounterh_prev = get_ticks(true); + if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || instr) { + counter->mhpmcounterh_prev = get_ticks(true, instr); if (ctr_idx > 2) { riscv_pmu_setup_timer(env, mhpmctr_val, ctr_idx); } @@ -926,6 +930,7 @@ static RISCVException riscv_pmu_read_ctr(CPURISCVState *env, target_ulong *val, counter->mhpmcounter_prev; target_ulong ctr_val = upper_half ? counter->mhpmcounterh_val : counter->mhpmcounter_val; + bool instr = riscv_pmu_ctr_monitor_instructions(env, ctr_idx); if (get_field(env->mcountinhibit, BIT(ctr_idx))) { /* @@ -946,9 +951,8 @@ static RISCVException riscv_pmu_read_ctr(CPURISCVState *env, target_ulong *val, * The kernel computes the perf delta by subtracting the current value from * the value it initialized previously (ctr_val). */ - if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || - riscv_pmu_ctr_monitor_instructions(env, ctr_idx)) { - *val = get_ticks(upper_half) - ctr_prev + ctr_val; + if (riscv_pmu_ctr_monitor_cycles(env, ctr_idx) || instr) { + *val = get_ticks(upper_half, instr) - ctr_prev + ctr_val; } else { *val = ctr_val; } From patchwork Thu Jun 27 10:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 813AAC2BD09 for ; Thu, 27 Jun 2024 10:06:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxn-0007hX-5Q; Thu, 27 Jun 2024 06:02:47 -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 1sMlxT-00070H-H9 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:33 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxQ-00022t-Rk for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:26 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7041053c0fdso4624082b3a.3 for ; Thu, 27 Jun 2024 03:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482542; x=1720087342; 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=YnkZtfqlRk/cYHVUB0haBca2EsSvWjX5ehFS1hvQupE=; b=arWaMsBL3wFg8+1rwIXSUYSu2QiUFRni47qxhMDtiMruSumKZU2LpgSrnTfMCiv5Ra AVPPJIcYLnSKcQxmi7eDvFcC6r+6wqBhUq4zy1bLFpl6xgHiSCItZpcxL+IKu+nKcHm0 fmeSqvSKSk/SVeRJlVCUkQpQgF2aFdx14FOoY7grUYStaBsIgvIYqGOUpZZ9YhLQKO4Q 4s37aUP9ZMxDh+IoEghLdO3Mg4qcX+REkizcC4kqM+O9h6GUIkYvFnPas0BBkBSzSywb yNK7sllTGheHzlpseJTlz8S7XFtDNBmkI0dnrURd7toZ/z9WsUb5iMWb2g9gEHdLIIcT 7CNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482542; x=1720087342; 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=YnkZtfqlRk/cYHVUB0haBca2EsSvWjX5ehFS1hvQupE=; b=M4HDkAyGP4cDOf6BZbp6rsjYasa3x5XwVssRWa2NP8SK1TL0cU/rJm8mtxIfPFCjlw 6GBT+em/r8YWhjbldyuu2YMIyLcViLi30IAvu8sh9JttGohn7r9skIxdYMinPXp23GaC xgoTnoB2qo3d0Tflwe1WEGDAwnIIn3XzHz6G6RlvkRoeJPaQzsTN+kdzUp+dcrGGxypB RzPRNUNRiPE9XnkDUSgHlOlQ3QJFBfWGeiRw7WHpZNhQKl1DnQQJPjnkKOTN6R2P7wV/ tCl+FeFm4X38QJElWKu1HcqJwpDaL45xb9h4spQy3mKIZixpGj3BC42BpFOv6UvLdvzR Fofw== X-Gm-Message-State: AOJu0YwnbcJUb5OLmd1F+eJEelCCy6bjw87KC1lwxoRZW0jidmnJdGys X9UvE8s9qRNQJRlMj51PowRVJatwXJyFxndYCDiCSz4nOkqBdyQe0eupvHWs X-Google-Smtp-Source: AGHT+IHUFnWvX+Z7yhzkGn8VfG/zDNOZvrKxs1fwaNoPM1fq6R0o8wZHu226DvUYRVYEwYcQias+BQ== X-Received: by 2002:aa7:8f8f:0:b0:706:b19c:46cf with SMTP id d2e1a72fcca58-706b19c4a75mr2201839b3a.20.1719482542055; Thu, 27 Jun 2024 03:02:22 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:21 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 24/32] target/riscv: Introduce extension implied rules definition Date: Thu, 27 Jun 2024 20:00:45 +1000 Message-ID: <20240627100053.150937-25-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=alistair23@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang RISCVCPUImpliedExtsRule is created to store the implied rules. 'is_misa' flag is used to distinguish whether the rule is derived from the MISA or other extensions. 'ext' stores the MISA bit if 'is_misa' is true. Otherwise, it stores the offset of the extension defined in RISCVCPUConfig. 'ext' will also serve as the key of the hash tables to look up the rule in the following commit. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-ID: <20240625114629.27793-2-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 23 +++++++++++++++++++++++ target/riscv/cpu.c | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 90b8f1b08f..87742047ce 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -124,6 +124,29 @@ typedef enum { EXT_STATUS_DIRTY, } RISCVExtStatus; +typedef struct riscv_cpu_implied_exts_rule { +#ifndef CONFIG_USER_ONLY + /* + * Bitmask indicates the rule enabled status for the harts. + * This enhancement is only available in system-mode QEMU, + * as we don't have a good way (e.g. mhartid) to distinguish + * the SMP cores in user-mode QEMU. + */ + unsigned long *enabled; +#endif + /* True if this is a MISA implied rule. */ + bool is_misa; + /* ext is MISA bit if is_misa flag is true, else multi extension offset. */ + const uint32_t ext; + const uint32_t implied_misa_exts; + const uint32_t implied_multi_exts[]; +} RISCVCPUImpliedExtsRule; + +extern RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[]; +extern RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[]; + +#define RISCV_IMPLIED_EXTS_RULE_END -1 + #define MMU_USER_IDX 3 #define MAX_RISCV_PMPS (16) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4760cb2cc1..7b071ade04 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2250,6 +2250,14 @@ RISCVCPUProfile *riscv_profiles[] = { NULL, }; +RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { + NULL +}; + +RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { + NULL +}; + static Property riscv_cpu_properties[] = { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), From patchwork Thu Jun 27 10:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54E85C2BD09 for ; Thu, 27 Jun 2024 10:04:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxl-0007U8-EO; Thu, 27 Jun 2024 06:02:45 -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 1sMlxX-00073Q-Bi for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:33 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxU-00029E-EF for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:30 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7041053c0fdso4624129b3a.3 for ; Thu, 27 Jun 2024 03:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482546; x=1720087346; 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=OSFAAtkK04aUf0dxdh06bjVR315nH132+u1Sn1Pe3ZU=; b=VZdiLPZ7xdVbAcMocFvXmjmt98lhVH7VB4Ez5DET8fS97evr2TgeyedHdYsBjM2ROj kL0eSfKi/QsbFAFyQFSa7pxZrO6pqwjwF6ZUVbgOvJnhDlV23+UOolHX6GrbDLk17v3W wbQ4CN6deYHnrY3ISyuFZtsgHYdShTsxNxU7un793wQaGxJL+xaGF/et/VakRFmhnN91 IS8/bRYoAcMERayfXV+AAkHK8/SdaMeLaEGhlsdqhpwqHKfdrvnCfIae3JBtHIuNq0MG iwEpDxwmWj6pvQfvblp/qIjBiM88CP3GRjviqfRNA/ZL9GpaGrLzgEB1PGblIn25OPI5 PFmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482546; x=1720087346; 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=OSFAAtkK04aUf0dxdh06bjVR315nH132+u1Sn1Pe3ZU=; b=G3OywOD///UZWDt9KnO/BQ8HNNZkN4mKt+IjO7vgkKzpHYtebeQcnMvv9SMToqJXiX 3OrkdNOpWlvzG9DZ0M3eRaEIHPKRly3KQR+5SIj02K+g/LagAQh19vmCAv2g9OYN//ud aM1anostwGS0b4YXWFNpVuDgpIIFXVLJ8BXnp4zGu5jLJvRrrECz6fKt4Tcg7r1qjTdX Ti34F6X2y2xr5iV2aiamP4eTq9pJdhVX1P5DUvaBgRUYZPsEhoiAqECDP9kKs2scyOtU fe0Fv+9n6WC0ovWWlFPz/LJTsm2UNjH+VbW7be3CmXjV4D1ICvERth5EsLd5kSgbLSqt xcHg== X-Gm-Message-State: AOJu0YyNWdqXs4YYKNar+a6AZp8ftqrED+VozDa0Hqm34GiVhOlP9Qa7 HGIRzqZ89z1kp4LiOw3ws+Dxr8SK0UiVXnysmoAqKsGnKq4OTyDLPcpPgp/q X-Google-Smtp-Source: AGHT+IHyoOLGVL3sT60nT6pbfROBT3jUwBAEqpogpcc9ozdxI9JIqMG1m7nplZiwhF+KfR3/4nKyLw== X-Received: by 2002:aa7:8614:0:b0:706:73bc:50b7 with SMTP id d2e1a72fcca58-706745b42fdmr11789387b3a.16.1719482545664; Thu, 27 Jun 2024 03:02:25 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:25 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 25/32] target/riscv: Introduce extension implied rule helpers Date: Thu, 27 Jun 2024 20:00:46 +1000 Message-ID: <20240627100053.150937-26-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=alistair23@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang Introduce helpers to enable the extensions based on the implied rules. The implied extensions are enabled recursively, so we don't have to expand all of them manually. This also eliminates the old-fashioned ordering requirement. For example, Zvksg implies Zvks, Zvks implies Zvksed, etc., removing the need to check the implied rules of Zvksg before Zvks. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Reviewed-by: Daniel Henrique Barboza Message-ID: <20240625114629.27793-3-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 121 +++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index eb6f7b9d12..1a3aef5bff 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -31,11 +31,17 @@ #include "hw/core/accel-cpu.h" #include "hw/core/tcg-cpu-ops.h" #include "tcg/tcg.h" +#ifndef CONFIG_USER_ONLY +#include "hw/boards.h" +#endif /* Hash that stores user set extensions */ static GHashTable *multi_ext_user_opts; static GHashTable *misa_ext_user_opts; +static GHashTable *multi_ext_implied_rules; +static GHashTable *misa_ext_implied_rules; + static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) { return g_hash_table_contains(multi_ext_user_opts, @@ -836,11 +842,117 @@ static void riscv_cpu_validate_profiles(RISCVCPU *cpu) } } +static void riscv_cpu_init_implied_exts_rules(void) +{ + RISCVCPUImpliedExtsRule *rule; +#ifndef CONFIG_USER_ONLY + MachineState *ms = MACHINE(qdev_get_machine()); +#endif + static bool initialized; + int i; + + /* Implied rules only need to be initialized once. */ + if (initialized) { + return; + } + + for (i = 0; (rule = riscv_misa_ext_implied_rules[i]); i++) { +#ifndef CONFIG_USER_ONLY + rule->enabled = bitmap_new(ms->smp.cpus); +#endif + g_hash_table_insert(misa_ext_implied_rules, + GUINT_TO_POINTER(rule->ext), (gpointer)rule); + } + + for (i = 0; (rule = riscv_multi_ext_implied_rules[i]); i++) { +#ifndef CONFIG_USER_ONLY + rule->enabled = bitmap_new(ms->smp.cpus); +#endif + g_hash_table_insert(multi_ext_implied_rules, + GUINT_TO_POINTER(rule->ext), (gpointer)rule); + } + + initialized = true; +} + +static void cpu_enable_implied_rule(RISCVCPU *cpu, + RISCVCPUImpliedExtsRule *rule) +{ + CPURISCVState *env = &cpu->env; + RISCVCPUImpliedExtsRule *ir; + bool enabled = false; + int i; + +#ifndef CONFIG_USER_ONLY + enabled = test_bit(cpu->env.mhartid, rule->enabled); +#endif + + if (!enabled) { + /* Enable the implied MISAs. */ + if (rule->implied_misa_exts) { + riscv_cpu_set_misa_ext(env, + env->misa_ext | rule->implied_misa_exts); + + for (i = 0; misa_bits[i] != 0; i++) { + if (rule->implied_misa_exts & misa_bits[i]) { + ir = g_hash_table_lookup(misa_ext_implied_rules, + GUINT_TO_POINTER(misa_bits[i])); + + if (ir) { + cpu_enable_implied_rule(cpu, ir); + } + } + } + } + + /* Enable the implied extensions. */ + for (i = 0; + rule->implied_multi_exts[i] != RISCV_IMPLIED_EXTS_RULE_END; i++) { + cpu_cfg_ext_auto_update(cpu, rule->implied_multi_exts[i], true); + + ir = g_hash_table_lookup(multi_ext_implied_rules, + GUINT_TO_POINTER( + rule->implied_multi_exts[i])); + + if (ir) { + cpu_enable_implied_rule(cpu, ir); + } + } + +#ifndef CONFIG_USER_ONLY + bitmap_set(rule->enabled, cpu->env.mhartid, 1); +#endif + } +} + +static void riscv_cpu_enable_implied_rules(RISCVCPU *cpu) +{ + RISCVCPUImpliedExtsRule *rule; + int i; + + /* Enable the implied MISAs. */ + for (i = 0; (rule = riscv_misa_ext_implied_rules[i]); i++) { + if (riscv_has_ext(&cpu->env, rule->ext)) { + cpu_enable_implied_rule(cpu, rule); + } + } + + /* Enable the implied extensions. */ + for (i = 0; (rule = riscv_multi_ext_implied_rules[i]); i++) { + if (isa_ext_is_enabled(cpu, rule->ext)) { + cpu_enable_implied_rule(cpu, rule); + } + } +} + void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp) { CPURISCVState *env = &cpu->env; Error *local_err = NULL; + riscv_cpu_init_implied_exts_rules(); + riscv_cpu_enable_implied_rules(cpu); + riscv_cpu_validate_misa_priv(env, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); @@ -1346,6 +1458,15 @@ static void riscv_tcg_cpu_instance_init(CPUState *cs) misa_ext_user_opts = g_hash_table_new(NULL, g_direct_equal); multi_ext_user_opts = g_hash_table_new(NULL, g_direct_equal); + + if (!misa_ext_implied_rules) { + misa_ext_implied_rules = g_hash_table_new(NULL, g_direct_equal); + } + + if (!multi_ext_implied_rules) { + multi_ext_implied_rules = g_hash_table_new(NULL, g_direct_equal); + } + riscv_cpu_add_user_properties(obj); if (riscv_cpu_has_max_extensions(obj)) { From patchwork Thu Jun 27 10:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8C6FC2BD09 for ; Thu, 27 Jun 2024 10:04:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxk-0007Mu-7U; Thu, 27 Jun 2024 06:02:44 -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 1sMlxY-00073c-Oa for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:33 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxX-0002Db-3g for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:32 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70679845d69so3371140b3a.1 for ; Thu, 27 Jun 2024 03:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482549; x=1720087349; 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=AnEaxExSxNmbwr/9W4/pvVWPb9oM7FgPkjyis6ytKNc=; b=biI5mAMqkRWZaNfd1jCBIwTbacjhZUhpR6QZFwSUaxxo6WHX2v8kVoVtTRl7NstTZd gVs9PhFSywjWjIsZ7YFmoocjWFsrGAGPMo7tajPWIXDVFE/hk3vZlZ0OWguQmY1Svbvj N1sWsQKPXWvwaBXbr0O8qu7PeL+H5G5/KCB6adzb6crrV9iidQWlCeftolMtsOZBVgOF M6zvGJe3GJ2F3IaaXYuBxmPcvaqh00vPJP6sz2AWK9O9RfnViiQ/0DBoSgM+EyJHfqpz bYq59I+JTWK0lN6BR0bN5734ke/LJBJPR0K6/GyhsfOLC6hDM33x/KwSrIM1jsuiXiKN AgIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482549; x=1720087349; 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=AnEaxExSxNmbwr/9W4/pvVWPb9oM7FgPkjyis6ytKNc=; b=Pyh5MrdDzQS23exAuAKh2WsYyWABpiNW96PxkMZc9xM+tmny3LEAFLAfRhZnOLgPLE sIFQQOjj58M8UI/vQ+KN+cHrEcnFomfWJo0IACnfetOULP2i3q5TYkJSvIVU5BJ0af6O vtdzB32VbiXbdzkxnmi9enpW18M6B7ELoEBuDNjVQaWp4lMqQpTzKJOsG5ImzASMSNpE aP/pYh9DD8tDTAX3qOZsPuPUaVRNCeGgZo2wLJxsut4miP98dYt+Y5lePTvWhuEwmp/W jf7F6WTSHpYJgCGH3WN7pt27TL4RVbZ3k5Nk20QRaxi3Zo6fXD56vQEdUrdcPI19aU+t L3Kg== X-Gm-Message-State: AOJu0YwANfCzHw8gg1iam8QY+Rx9DDSzlrdJxI+2ce3vsU5TdFmwqJmv 316XgPLpftrWbwyIyfjdTEgKOCF4sZjdVXA0TVe0dT3d3ujL8IPvF8D1ubmH X-Google-Smtp-Source: AGHT+IHtqf5Txsppm8q8DMszDbNclDzwwb1/Hc2PWeJNHIaTPYrKAIPIU/AD7wgGseGslDKWqnAPOA== X-Received: by 2002:aa7:8611:0:b0:706:375e:220d with SMTP id d2e1a72fcca58-706746fa56cmr12021869b3a.30.1719482549185; Thu, 27 Jun 2024 03:02:29 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:28 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 26/32] target/riscv: Add MISA extension implied rules Date: Thu, 27 Jun 2024 20:00:47 +1000 Message-ID: <20240627100053.150937-27-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=alistair23@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang Add MISA extension implied rules to enable the implied extensions of MISA recursively. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Message-ID: <20240625114629.27793-4-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7b071ade04..b463bd8370 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2250,8 +2250,56 @@ RISCVCPUProfile *riscv_profiles[] = { NULL, }; +static RISCVCPUImpliedExtsRule RVA_IMPLIED = { + .is_misa = true, + .ext = RVA, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zalrsc), CPU_CFG_OFFSET(ext_zaamo), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule RVD_IMPLIED = { + .is_misa = true, + .ext = RVD, + .implied_misa_exts = RVF, + .implied_multi_exts = { RISCV_IMPLIED_EXTS_RULE_END }, +}; + +static RISCVCPUImpliedExtsRule RVF_IMPLIED = { + .is_misa = true, + .ext = RVF, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule RVM_IMPLIED = { + .is_misa = true, + .ext = RVM, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zmmul), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule RVV_IMPLIED = { + .is_misa = true, + .ext = RVV, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve64d), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { - NULL + &RVA_IMPLIED, &RVD_IMPLIED, &RVF_IMPLIED, + &RVM_IMPLIED, &RVV_IMPLIED, NULL }; RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { From patchwork Thu Jun 27 10:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A29BC2BD09 for ; Thu, 27 Jun 2024 10:03:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxk-0007P1-IZ; Thu, 27 Jun 2024 06:02:44 -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 1sMlxg-00078J-T9 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:42 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxb-0002LB-LK for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:40 -0400 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7f38f5584ebso294339039f.3 for ; Thu, 27 Jun 2024 03:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482553; x=1720087353; 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=+3b4i1MebHelO8I9kGEWGTWysdpA0laU5VjzsEYbS4w=; b=jikOLZxx11Q3QYE6zxTh/d2Cfb5nSpxUIjMHfuPQr1u1w5AZnIIj4qPiQ8503db6Td Sx+t1sbVz3OBzvJm9fyBLJ5MQ7RNfySyyapa+DJRnikECsgCN3TaApRGNN1jXBEerUK1 2izAEPWkJ/f2gNffXwmVdrAEUGHaUQmAP+Qf898pYPf3NwSD7wE2EjB8c7l91n+/Ub4u scfxPH+X+dgQBAkde+pZOzoDwNQUQntwGfFybQlPFFSsh1wJLObFViga1qNhwKwjplCr s1twZW9qrfRPObcKDcxroOX6RgBso+GbJ4mrcn95cOpOIlfBuGyNpNwzagrCxx1KlVyO 3Lyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482553; x=1720087353; 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=+3b4i1MebHelO8I9kGEWGTWysdpA0laU5VjzsEYbS4w=; b=FWgP4xOwVmuTpQmrrtZHvw68kxkQe7R1Hk7pTAw9S7t6Efg14e5OMe//38IdvOVekW 46Zwi3zYFkjHhbE+56i/5kyX2pzLyEBt0rEYBhLY6gPCluutQG84rCgOIDiK9uyufM0Y VBTu9gCGYIMGodzAEYGrpieWUEZ7cCNgP24Sp29z/WWFPuUp4p+EOv+rW/F/Qhi7CKLd CTx91vKomsUn2i0VoQ6uWvgcK3oBfPgokTfbaMn+14PuMXmDWUqZml8J9IuGmW5a1l4u FD9dy0LzBpuIv+Ce2ZZ1KzHjhUMgrwsD4zTVTwDDjk1xrxX41Lx3k2ofYmmzoOSXBgOT svpA== X-Gm-Message-State: AOJu0YyQP8ZNIgu34zFvBcQ8Ru+Jqib7RxAhLA9BIFffBJbCQCxCTo/B 8Ey70mXYnVwg61ckB4GeL0tZZBc5z3pjjOdoOxBmi7uYV9Hetv72LVGx7ZSh X-Google-Smtp-Source: AGHT+IHVhTDcL4fZw0QdopDpSTnzN6sCGIUt84GQR18fIeKROJAC4knWU00AewUDkSIni8CttZijCg== X-Received: by 2002:a05:6602:2d82:b0:7eb:8a6e:11e1 with SMTP id ca18e2360f4ac-7f3a4dc2c31mr1765560839f.5.1719482552823; Thu, 27 Jun 2024 03:02:32 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:32 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 27/32] target/riscv: Add multi extension implied rules Date: Thu, 27 Jun 2024 20:00:48 +1000 Message-ID: <20240627100053.150937-28-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::d33; envelope-from=alistair23@gmail.com; helo=mail-io1-xd33.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UPPERCASE_50_75=0.008 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang Add multi extension implied rules to enable the implied extensions of the multi extension recursively. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Message-ID: <20240625114629.27793-5-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 340 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b463bd8370..a2640cf259 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2297,12 +2297,352 @@ static RISCVCPUImpliedExtsRule RVV_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zcb), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zca), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZCD_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zcd), + .implied_misa_exts = RVD, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zca), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZCE_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zce), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zcb), CPU_CFG_OFFSET(ext_zcmp), + CPU_CFG_OFFSET(ext_zcmt), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZCF_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zcf), + .implied_misa_exts = RVF, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zca), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZCMP_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zcmp), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zca), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZCMT_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zcmt), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zca), CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZDINX_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zdinx), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zfinx), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZFA_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zfa), + .implied_misa_exts = RVF, + .implied_multi_exts = { RISCV_IMPLIED_EXTS_RULE_END }, +}; + +static RISCVCPUImpliedExtsRule ZFBFMIN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zfbfmin), + .implied_misa_exts = RVF, + .implied_multi_exts = { RISCV_IMPLIED_EXTS_RULE_END }, +}; + +static RISCVCPUImpliedExtsRule ZFH_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zfh), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zfhmin), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZFHMIN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zfhmin), + .implied_misa_exts = RVF, + .implied_multi_exts = { RISCV_IMPLIED_EXTS_RULE_END }, +}; + +static RISCVCPUImpliedExtsRule ZFINX_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zfinx), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZHINX_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zhinx), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zhinxmin), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZHINXMIN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zhinxmin), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zfinx), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZICNTR_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zicntr), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZIHPM_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zihpm), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZK_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zk), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zkn), CPU_CFG_OFFSET(ext_zkr), + CPU_CFG_OFFSET(ext_zkt), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZKN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zkn), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zbkb), CPU_CFG_OFFSET(ext_zbkc), + CPU_CFG_OFFSET(ext_zbkx), CPU_CFG_OFFSET(ext_zkne), + CPU_CFG_OFFSET(ext_zknd), CPU_CFG_OFFSET(ext_zknh), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZKS_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zks), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zbkb), CPU_CFG_OFFSET(ext_zbkc), + CPU_CFG_OFFSET(ext_zbkx), CPU_CFG_OFFSET(ext_zksed), + CPU_CFG_OFFSET(ext_zksh), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVBB_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvbb), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvkb), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVE32F_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zve32f), + .implied_misa_exts = RVF, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve32x), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVE32X_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zve32x), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zicsr), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVE64D_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zve64d), + .implied_misa_exts = RVD, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve64f), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVE64F_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zve64f), + .implied_misa_exts = RVF, + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve32f), CPU_CFG_OFFSET(ext_zve64x), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVE64X_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zve64x), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve32x), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVFBFMIN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvfbfmin), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve32f), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVFBFWMA_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvfbfwma), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvfbfmin), CPU_CFG_OFFSET(ext_zfbfmin), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVFH_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvfh), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvfhmin), CPU_CFG_OFFSET(ext_zfhmin), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVFHMIN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvfhmin), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve32f), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKN_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvkn), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvkned), CPU_CFG_OFFSET(ext_zvknhb), + CPU_CFG_OFFSET(ext_zvkb), CPU_CFG_OFFSET(ext_zvkt), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKNC_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvknc), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvkn), CPU_CFG_OFFSET(ext_zvbc), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKNG_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvkng), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvkn), CPU_CFG_OFFSET(ext_zvkg), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKNHB_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvknhb), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zve64x), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKS_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvks), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvksed), CPU_CFG_OFFSET(ext_zvksh), + CPU_CFG_OFFSET(ext_zvkb), CPU_CFG_OFFSET(ext_zvkt), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKSC_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvksc), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvks), CPU_CFG_OFFSET(ext_zvbc), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + +static RISCVCPUImpliedExtsRule ZVKSG_IMPLIED = { + .ext = CPU_CFG_OFFSET(ext_zvksg), + .implied_multi_exts = { + CPU_CFG_OFFSET(ext_zvks), CPU_CFG_OFFSET(ext_zvkg), + + RISCV_IMPLIED_EXTS_RULE_END + }, +}; + RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED, &RVD_IMPLIED, &RVF_IMPLIED, &RVM_IMPLIED, &RVV_IMPLIED, NULL }; RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { + &ZCB_IMPLIED, &ZCD_IMPLIED, &ZCE_IMPLIED, + &ZCF_IMPLIED, &ZCMP_IMPLIED, &ZCMT_IMPLIED, + &ZDINX_IMPLIED, &ZFA_IMPLIED, &ZFBFMIN_IMPLIED, + &ZFH_IMPLIED, &ZFHMIN_IMPLIED, &ZFINX_IMPLIED, + &ZHINX_IMPLIED, &ZHINXMIN_IMPLIED, &ZICNTR_IMPLIED, + &ZIHPM_IMPLIED, &ZK_IMPLIED, &ZKN_IMPLIED, + &ZKS_IMPLIED, &ZVBB_IMPLIED, &ZVE32F_IMPLIED, + &ZVE32X_IMPLIED, &ZVE64D_IMPLIED, &ZVE64F_IMPLIED, + &ZVE64X_IMPLIED, &ZVFBFMIN_IMPLIED, &ZVFBFWMA_IMPLIED, + &ZVFH_IMPLIED, &ZVFHMIN_IMPLIED, &ZVKN_IMPLIED, + &ZVKNC_IMPLIED, &ZVKNG_IMPLIED, &ZVKNHB_IMPLIED, + &ZVKS_IMPLIED, &ZVKSC_IMPLIED, &ZVKSG_IMPLIED, NULL }; From patchwork Thu Jun 27 10:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CC3EC30653 for ; Thu, 27 Jun 2024 10:05:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxn-0007qS-VK; Thu, 27 Jun 2024 06:02:48 -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 1sMlxh-00078K-Le for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:43 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxe-0002VI-9T for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:40 -0400 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3d5654d5f4fso597833b6e.1 for ; Thu, 27 Jun 2024 03:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482556; x=1720087356; 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=tedPVH5tOOaMJ1rcUzWl+rZdz35T4y32JngaUuhBL4k=; b=P7R2koOFxVOjjg4BayZjS9cDt0npyvyNaII80UHOl3GOzbb/YMMoEzVGjiuVan+ndC l9dtg0qKHrjxCeIPKcR4FZMNxkpTkCbJKxZF3rs77rfUZwPtyI7ATNjuUKw8SDB2PD75 L2Cuh7Tywdm/T5fvj0+lA/VWGwv/Xr0v4sKDaFzE6/31C04R4i8YYeQ4d7uEoL7kZrXf C4EnKuPg+R0X5clL6PxyiWuEqe9qeexSe4r9NW0SQ8rWR4ykDYt8w3NBX3FxQniqYnK/ npEe03EMYBkszHTOkNn6Cw20+Pnctft6LRUE1De5g5r1J2Lbevpt9s2Rq4FcrSJsd3CI DSiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482556; x=1720087356; 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=tedPVH5tOOaMJ1rcUzWl+rZdz35T4y32JngaUuhBL4k=; b=w/WrOJnTmjnSsCwJpQJlc/eS1XD1LMFm+XTObVxiQ28q1jJjIpbnEc09gC6UBGuWqg RKOWvxjPQBcAqQr76lnG7MGgbG6+TUJi4yG9adPztFt+j+jZ1DeoPcraKfehawaT/LTf GRvBlBEhbpU5I25Nwkpb1NmjZsLtCugCRvutAbXWHzqwXfT+x3V2UriWuMDkRWTzTAiy mPr9xXa17zTdv/fU4G6JBdsnFCYXuzOM4jmxFkpfII5eH74wyF8vDypCN09Mm4zZzwNS tYqAcBLrQN1AL+3MdYNF21anUYVlrHT9Uyu0BgauGNfRFwCIq4TiNlSb01JJjhSlU/Mf 4guA== X-Gm-Message-State: AOJu0YzY3Hh0MetH11AxYAWxkqECET50RrC355IrMmgudVqOqlXoxa1b Sj4uRvzrwnzwsyGna6G/sGKB9BM/ZD5qkyLWizSSGImZIsMOikt0fPKWhQBN X-Google-Smtp-Source: AGHT+IH+5rS9Z2R3xEdnXY4nMw8/TguA/29gryFOXrx0HPDbcqXM7uctFFqv/K7BgM06kS2uxjsTgg== X-Received: by 2002:a05:6870:8183:b0:25d:921:75ec with SMTP id 586e51a60fabf-25d0921ad16mr13707220fac.36.1719482556416; Thu, 27 Jun 2024 03:02:36 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:35 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 28/32] target/riscv: Add Zc extension implied rule Date: Thu, 27 Jun 2024 20:00:49 +1000 Message-ID: <20240627100053.150937-29-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=alistair23@gmail.com; helo=mail-oi1-x230.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang Zc extension has special implied rules that need to be handled separately. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Reviewed-by: Daniel Henrique Barboza Message-ID: <20240625114629.27793-6-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 1a3aef5bff..ccca9037ed 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -925,11 +925,45 @@ static void cpu_enable_implied_rule(RISCVCPU *cpu, } } +/* Zc extension has special implied rules that need to be handled separately. */ +static void cpu_enable_zc_implied_rules(RISCVCPU *cpu) +{ + RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu); + CPURISCVState *env = &cpu->env; + + if (cpu->cfg.ext_zce) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); + + if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max == MXL_RV32) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); + } + } + + /* Zca, Zcd and Zcf has a PRIV 1.12.0 restriction */ + if (riscv_has_ext(env, RVC) && env->priv_ver >= PRIV_VERSION_1_12_0) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); + + if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max == MXL_RV32) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); + } + + if (riscv_has_ext(env, RVD)) { + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcd), true); + } + } +} + static void riscv_cpu_enable_implied_rules(RISCVCPU *cpu) { RISCVCPUImpliedExtsRule *rule; int i; + /* Enable the implied extensions for Zc. */ + cpu_enable_zc_implied_rules(cpu); + /* Enable the implied MISAs. */ for (i = 0; (rule = riscv_misa_ext_implied_rules[i]); i++) { if (riscv_has_ext(&cpu->env, rule->ext)) { From patchwork Thu Jun 27 10:00:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB543C3064D for ; Thu, 27 Jun 2024 10:04:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxp-00088n-Sw; Thu, 27 Jun 2024 06:02:49 -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 1sMlxk-0007O4-9Z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:44 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxh-0002db-RF for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:43 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70679845d69so3371292b3a.1 for ; Thu, 27 Jun 2024 03:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482560; x=1720087360; 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=0CiGEo1Y49vMlYu6YFDvaSALmsVarL7E0mLlpzBDHLw=; b=FbJaKiMjqLyaey+EdcDA4+XNQdcjaYrOdJ2OJQa4HNy8UAIiqSxcOD5khsA6z3kbGR gDeLUb/wCNFZWBDEYx6IXaVIF/ppqhDU4Ww1ay6vSl4IN7kAz3usynEnXFAd7vh52nQz t5ebzI2SqQX6gt/ykQAvaMroUPKRpChRNFMJQkFtZDzsI4mADR/9xvY51Cjz9p8Kaihh AD+UeQrzyRdvj5E3wSYjbtK808z8uQq19feap0/jPokAOJkjw5QGkkkQn+O8TEfuP1YR eilXGrFQ0fBOONY39RzJ+vAOIkV/maAgjsy8w4ytC895zp9IXVb1Oho88Jh7zh6rGAgj s8Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482560; x=1720087360; 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=0CiGEo1Y49vMlYu6YFDvaSALmsVarL7E0mLlpzBDHLw=; b=diumcG1wc+1PwudRjYCibok1cXz+OetoyJLQjw2anR7X3ATiqIL7bMiV5hIBQvYyYU GsAljMuL5LAyDsjjKsiySVQKaSZbcp5g5wMsRDRnXY5I7+QiCPn9yRH6hSTTo4hUbK+E HDUq6bO6QZvza7Dps8RPDLz+fIjeKOJATiUjSNOFzeLzsnsqWodIKFXpWWW4aL6vCiHj LIoWv3pI2QZnbQAWahzBuNCtOdrqOd5hInr+NhnFxBQHji5sdtaKJtGNtFMBMqUGPAYu yYz09CxyEnjmyb7MA9s5EuChbkuoErXF5Qn8w9z7GBywTsqZ6WkenZLY3rXW/EMYd5JU PFhg== X-Gm-Message-State: AOJu0YzDcolouThSUvPUQ0F38MyoYhHB+K4Mgkcdm+Q4bOucIfhHqbFg iun3CsGGkkAA77vG5LgkoW9qT4kD6M5DA0m+uH9j39ppEFiBUiXphSTwfb7m X-Google-Smtp-Source: AGHT+IFxyeVOxvHAWK/I6aiu5y9meVreMlZTjABEQSxjEWxsqA9EhRjkOMNoYZTzdDrTCqG6xW8z8w== X-Received: by 2002:a05:6a00:cd0:b0:706:348a:528a with SMTP id d2e1a72fcca58-7067459a758mr16330700b3a.10.1719482560004; Thu, 27 Jun 2024 03:02:40 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:39 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Jerry Zhang Jian , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 29/32] target/riscv: Remove extension auto-update check statements Date: Thu, 27 Jun 2024 20:00:50 +1000 Message-ID: <20240627100053.150937-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Frank Chang Remove the old-fashioned extension auto-update check statements as they are replaced by the extension implied rules. Signed-off-by: Frank Chang Reviewed-by: Jerry Zhang Jian Tested-by: Max Chou Reviewed-by: Daniel Henrique Barboza Message-ID: <20240625114629.27793-7-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 119 ------------------------------------- 1 file changed, 119 deletions(-) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index ccca9037ed..ae25686824 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -471,10 +471,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) return; } - if (cpu->cfg.ext_zfh) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zfhmin), true); - } - if (cpu->cfg.ext_zfhmin && !riscv_has_ext(env, RVF)) { error_setg(errp, "Zfh/Zfhmin extensions require F extension"); return; @@ -496,9 +492,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) error_propagate(errp, local_err); return; } - - /* The V vector extension depends on the Zve64d extension */ - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64d), true); } /* The Zve64d extension depends on the Zve64f extension */ @@ -507,18 +500,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) error_setg(errp, "Zve64d/V extensions require D extension"); return; } - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64f), true); - } - - /* The Zve64f extension depends on the Zve64x and Zve32f extensions */ - if (cpu->cfg.ext_zve64f) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64x), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32f), true); - } - - /* The Zve64x extension depends on the Zve32x extension */ - if (cpu->cfg.ext_zve64x) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32x), true); } /* The Zve32f extension depends on the Zve32x extension */ @@ -527,11 +508,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) error_setg(errp, "Zve32f/Zve64f extensions require F extension"); return; } - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32x), true); - } - - if (cpu->cfg.ext_zvfh) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvfhmin), true); } if (cpu->cfg.ext_zvfhmin && !cpu->cfg.ext_zve32f) { @@ -554,11 +530,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) return; } - /* Set the ISA extensions, checks should have happened above */ - if (cpu->cfg.ext_zhinx) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); - } - if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) { error_setg(errp, "Zdinx/Zhinx/Zhinxmin extensions require Zfinx"); return; @@ -576,27 +547,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) } } - if (cpu->cfg.ext_zce) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); - if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max == MXL_RV32) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); - } - } - - /* zca, zcd and zcf has a PRIV 1.12.0 restriction */ - if (riscv_has_ext(env, RVC) && env->priv_ver >= PRIV_VERSION_1_12_0) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); - if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max == MXL_RV32) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); - } - if (riscv_has_ext(env, RVD)) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcd), true); - } - } - if (mcc->misa_mxl_max != MXL_RV32 && cpu->cfg.ext_zcf) { error_setg(errp, "Zcf extension is only relevant to RV32"); return; @@ -630,52 +580,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) return; } - /* - * Shorthand vector crypto extensions - */ - if (cpu->cfg.ext_zvknc) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); - } - - if (cpu->cfg.ext_zvkng) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkn), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkg), true); - } - - if (cpu->cfg.ext_zvkn) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkned), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvknhb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkt), true); - } - - if (cpu->cfg.ext_zvksc) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvks), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); - } - - if (cpu->cfg.ext_zvksg) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvks), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkg), true); - } - - if (cpu->cfg.ext_zvks) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvksed), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvksh), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkt), true); - } - - if (cpu->cfg.ext_zvkt) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvbc), true); - } - - if (cpu->cfg.ext_zvbb) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvkb), true); - } - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32x) { @@ -691,29 +595,6 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp) return; } - if (cpu->cfg.ext_zk) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkn), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkr), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkt), true); - } - - if (cpu->cfg.ext_zkn) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkne), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknd), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknh), true); - } - - if (cpu->cfg.ext_zks) { - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksed), true); - cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); - } - if (cpu->cfg.ext_zicntr && !cpu->cfg.ext_zicsr) { if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_zicntr))) { error_setg(errp, "zicntr requires zicsr"); From patchwork Thu Jun 27 10:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714080 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA28DC30653 for ; Thu, 27 Jun 2024 10:05:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxp-00089Z-Vl; Thu, 27 Jun 2024 06:02:50 -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 1sMlxm-0007gd-PK for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:46 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxk-0002hS-EP for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:46 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-25cb3f1765bso3965839fac.1 for ; Thu, 27 Jun 2024 03:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482563; x=1720087363; 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=cDQcF84dre27NKrwxyR57edDUqmhHmvi6h4uP6eUGW4=; b=gTgh/koDtKWDZLXV3XOeA+ArnkcO7w2jGSAM8Kf+JBzQrIm1FKTJJvA0pn/OjyNuSq GlxgWdRXA8arVw4u0XTZ/O1PJCcBO8naPkieZRvzTcYzX463nnA+IjhZBCEWXVqVZJ7a sde9rRz9qcM7c3nv9p1NZOvwtsWsoPuVJnCNubIYrVtXoYjWrnfiOF0YCz/b0dn8whgE 0gCsnlTYmRysPdl4MLi/cgc91dmEH7VKWLavgThS7tosxpJYYM6kX1/xYp8xgT1s8doh lV1W+aQzn4k29LtMnY9essgpo40jlz4zquXrs35iFkCPga/J1vkdcuFeyglLoTd94uID U03w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482563; x=1720087363; 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=cDQcF84dre27NKrwxyR57edDUqmhHmvi6h4uP6eUGW4=; b=f4EYStEI/SPUy/Q1lSvovZRotNPIQwrXlr1fhdjyLq1huts6UBC/nuJzo9d6t6F2Qh lHVNaQquUVQioHt+lzwSZ/QVNnHomLhUzfQNxYYiUYMyzXpgjf60y24LWXtiZ5uzlizQ Wlw8N1LGy5rJ7wUezo/gre3tqZWqY9qIgeHv/qZAQBFt6ie5p/zXbcn8HGTQcTPitKLt mRKqfIMrEwQANA4gYh1NqEe0KlCmTCU3C2yrY3DGnkL63KWvZxq4oClNZiVM4s6QV49W YzV23lIWdl6G1RIHXhPIqwFQHL0z/MZ1GuOu0wIZUmGwmeHvfYJvH0JFiv5tU6U5ausr TtZA== X-Gm-Message-State: AOJu0YyXV6tlk/yOO/nDPOfIEQbZ0Wqzi+5Q5LYwx6BlutJK9Fsu0DK3 pO4E6TUNQjVJ38gRsDTHRbiMjsnf+pHQcAKyVijvfqYF1SdwOiKQpRksnb9g X-Google-Smtp-Source: AGHT+IHaR4uoCayL/kQbVJIxOjQmdU+U6FiaTlptZ719Vt61JO3ifSee0Yz734yodVkLat7Z6nof9g== X-Received: by 2002:a05:6870:828b:b0:25c:c42b:5349 with SMTP id 586e51a60fabf-25d06f021c4mr12401782fac.59.1719482562789; Thu, 27 Jun 2024 03:02:42 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:42 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alvin Chang , Alistair Francis Subject: [PULL 30/32] target/riscv: Add functions for common matching conditions of trigger Date: Thu, 27 Jun 2024 20:00:51 +1000 Message-ID: <20240627100053.150937-31-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::30; envelope-from=alistair23@gmail.com; helo=mail-oa1-x30.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Alvin Chang According to RISC-V Debug specification version 0.13 [1] (also applied to version 1.0 [2] but it has not been ratified yet), there are several common matching conditions before firing a trigger, including the enabled privilege levels of the trigger. This commit adds trigger_common_match() to prepare the common matching conditions for the type 2/3/6 triggers. For now, we just implement trigger_priv_match() to check if the enabled privilege levels of the trigger match CPU's current privilege level. Remove the related code in riscv_cpu_debug_check_breakpoint() and invoke trigger_common_match() to check the privilege levels of the type 2 and type 6 triggers for the breakpoints. This commit also changes the behavior of looping the triggers. In previous implementation, if we have a type 2 trigger and env->virt_enabled is true, we directly return false to stop the loop. Now we keep looping all the triggers until we find a matched trigger. Only the execution bit and the executed PC should be futher checked in riscv_cpu_debug_check_breakpoint(). [1]: https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_vote [2]: https://github.com/riscv/riscv-debug-spec/releases/tag/1.0.0-rc1-asciidoc Signed-off-by: Alvin Chang Reviewed-by: Alistair Francis Message-ID: <20240626132247.2761286-2-alvinga@andestech.com> Signed-off-by: Alistair Francis --- target/riscv/debug.c | 101 +++++++++++++++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index b110370ea6..11125f333b 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -241,6 +241,76 @@ static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index) } } +/* + * Check the privilege level of specific trigger matches CPU's current privilege + * level. + */ +static bool trigger_priv_match(CPURISCVState *env, trigger_type_t type, + int trigger_index) +{ + target_ulong ctrl = env->tdata1[trigger_index]; + + switch (type) { + case TRIGGER_TYPE_AD_MATCH: + /* type 2 trigger cannot be fired in VU/VS mode */ + if (env->virt_enabled) { + return false; + } + /* check U/S/M bit against current privilege level */ + if ((ctrl >> 3) & BIT(env->priv)) { + return true; + } + break; + case TRIGGER_TYPE_AD_MATCH6: + if (env->virt_enabled) { + /* check VU/VS bit against current privilege level */ + if ((ctrl >> 23) & BIT(env->priv)) { + return true; + } + } else { + /* check U/S/M bit against current privilege level */ + if ((ctrl >> 3) & BIT(env->priv)) { + return true; + } + } + break; + case TRIGGER_TYPE_INST_CNT: + if (env->virt_enabled) { + /* check VU/VS bit against current privilege level */ + if ((ctrl >> 25) & BIT(env->priv)) { + return true; + } + } else { + /* check U/S/M bit against current privilege level */ + if ((ctrl >> 6) & BIT(env->priv)) { + return true; + } + } + break; + case TRIGGER_TYPE_INT: + case TRIGGER_TYPE_EXCP: + case TRIGGER_TYPE_EXT_SRC: + qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n", type); + break; + case TRIGGER_TYPE_NO_EXIST: + case TRIGGER_TYPE_UNAVAIL: + qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exist\n", + type); + break; + default: + g_assert_not_reached(); + } + + return false; +} + +/* Common matching conditions for all types of the triggers. */ +static bool trigger_common_match(CPURISCVState *env, trigger_type_t type, + int trigger_index) +{ + return trigger_priv_match(env, type, trigger_index); +} + /* type 2 trigger */ static uint32_t type2_breakpoint_size(CPURISCVState *env, target_ulong ctrl) @@ -785,22 +855,18 @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs) for (i = 0; i < RV_MAX_TRIGGERS; i++) { trigger_type = get_trigger_type(env, i); + if (!trigger_common_match(env, trigger_type, i)) { + continue; + } + switch (trigger_type) { case TRIGGER_TYPE_AD_MATCH: - /* type 2 trigger cannot be fired in VU/VS mode */ - if (env->virt_enabled) { - return false; - } - ctrl = env->tdata1[i]; pc = env->tdata2[i]; if ((ctrl & TYPE2_EXEC) && (bp->pc == pc)) { - /* check U/S/M bit against current privilege level */ - if ((ctrl >> 3) & BIT(env->priv)) { - env->badaddr = pc; - return true; - } + env->badaddr = pc; + return true; } break; case TRIGGER_TYPE_AD_MATCH6: @@ -808,19 +874,8 @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs) pc = env->tdata2[i]; if ((ctrl & TYPE6_EXEC) && (bp->pc == pc)) { - if (env->virt_enabled) { - /* check VU/VS bit against current privilege level */ - if ((ctrl >> 23) & BIT(env->priv)) { - env->badaddr = pc; - return true; - } - } else { - /* check U/S/M bit against current privilege level */ - if ((ctrl >> 3) & BIT(env->priv)) { - env->badaddr = pc; - return true; - } - } + env->badaddr = pc; + return true; } break; default: From patchwork Thu Jun 27 10:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77B20C3064D for ; Thu, 27 Jun 2024 10:06:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxr-0008OT-E0; Thu, 27 Jun 2024 06:02:51 -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 1sMlxp-00085K-D5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:49 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxn-0002jk-AK for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:48 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7066a4a611dso3747936b3a.3 for ; Thu, 27 Jun 2024 03:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482566; x=1720087366; 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=R2ySpE5U7zE2XXo/BjdiRlPjhvKqenUQik4nMBEH7xQ=; b=fsFSMm6qA7MUGs3xDfmNOfyFSemvUHopQzGEwKrxx1YgiWaldbw0+6bH5QE2zQU9tA oDGw9BlgUk30n9p0hHa6mCknCLt6/C+efVtuWwBq57poOS9R2KL42ZDMZDANYsnTonsf YDJrMrna3JTKf+SP/VpEQ70EfcMkrYXs3Ra4k+jPjrgFQe4UUX8UAcrNLOC1cI1E73d0 P9w7284+gMsA4+JYIiK/7+wLIN81buptlRYUG8wq9U2mAu7jRL4bccrEr1qRjZDcQEv+ A3SEuB/tc8aRkUdKXRUTaUqUxg83IbMsrUVRCxmMKTvm6P2MNGU0usVxEMBCMpqJVvkV S1mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482566; x=1720087366; 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=R2ySpE5U7zE2XXo/BjdiRlPjhvKqenUQik4nMBEH7xQ=; b=sFyxnp6DYGvfib1kZhx35XyatX8g+4OoiudI9y1xFCyplMHx/L+49fFXkcYAUTfoBU C/JkrNKV/6p0f0mv3zYI2PL8YqFntb74DjMwAY7hMW65uwyeZi95Sn6pfPvd/uon+buQ ADoZuahBEPxk3ps43tZqHGLZLHADKkkFsD6islP0Uxk34YFh4x9lqtqUgrWYPHudmo6D isdPnPMDcLBNVvaa/euBCIzyWfR6tac9NNskW6OxH5Hn9+dKc15nTHLmSbTZM79DdIE+ edKs8VYYSItl8vPjyVNGqNaHVpDsB0YlBA5rgs2LD+daFn+X3Z/wJ1U7yBGUpcwd4mmZ qqhQ== X-Gm-Message-State: AOJu0Yy+aF44K8uhlFMRsea/PTN1qYTO9EItq3rbvgKT2Xxzq8SJAKRi whfoQLql7M/p0G1nT9erZtnaLICnVT0cUQ129aD7f7ZHOCYYMitwe6ChfwoA X-Google-Smtp-Source: AGHT+IF3B6v82GALcn8dTX5L8YxkKs51s5fCTOPBZvyWyQjDweO1JF0/t5JzVKSFu+AjrNvUBy6I4g== X-Received: by 2002:aa7:8a53:0:b0:706:29e6:2edf with SMTP id d2e1a72fcca58-70674548ef7mr11921175b3a.4.1719482565544; Thu, 27 Jun 2024 03:02:45 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:45 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alvin Chang , Alistair Francis Subject: [PULL 31/32] target/riscv: Apply modularized matching conditions for watchpoint Date: Thu, 27 Jun 2024 20:00:52 +1000 Message-ID: <20240627100053.150937-32-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=alistair23@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Alvin Chang We have implemented trigger_common_match(), which checks if the enabled privilege levels of the trigger match CPU's current privilege level. Remove the related code in riscv_cpu_debug_check_watchpoint() and invoke trigger_common_match() to check the privilege levels of the type 2 and type 6 triggers for the watchpoints. This commit also changes the behavior of looping the triggers. In previous implementation, if we have a type 2 trigger and env->virt_enabled is true, we directly return false to stop the loop. Now we keep looping all the triggers until we find a matched trigger. Only load/store bits and loaded/stored address should be further checked in riscv_cpu_debug_check_watchpoint(). Signed-off-by: Alvin Chang Acked-by: Alistair Francis Message-ID: <20240626132247.2761286-3-alvinga@andestech.com> Signed-off-by: Alistair Francis --- target/riscv/debug.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 11125f333b..c290d6002e 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -901,13 +901,12 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) for (i = 0; i < RV_MAX_TRIGGERS; i++) { trigger_type = get_trigger_type(env, i); + if (!trigger_common_match(env, trigger_type, i)) { + continue; + } + switch (trigger_type) { case TRIGGER_TYPE_AD_MATCH: - /* type 2 trigger cannot be fired in VU/VS mode */ - if (env->virt_enabled) { - return false; - } - ctrl = env->tdata1[i]; addr = env->tdata2[i]; flags = 0; @@ -920,10 +919,7 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) } if ((wp->flags & flags) && (wp->vaddr == addr)) { - /* check U/S/M bit against current privilege level */ - if ((ctrl >> 3) & BIT(env->priv)) { - return true; - } + return true; } break; case TRIGGER_TYPE_AD_MATCH6: @@ -939,17 +935,7 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) } if ((wp->flags & flags) && (wp->vaddr == addr)) { - if (env->virt_enabled) { - /* check VU/VS bit against current privilege level */ - if ((ctrl >> 23) & BIT(env->priv)) { - return true; - } - } else { - /* check U/S/M bit against current privilege level */ - if ((ctrl >> 3) & BIT(env->priv)) { - return true; - } - } + return true; } break; default: From patchwork Thu Jun 27 10:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13714077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE2FC3064D for ; Thu, 27 Jun 2024 10:05:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMlxu-0000LT-F2; Thu, 27 Jun 2024 06:02:54 -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 1sMlxr-0008Rq-Oq for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:51 -0400 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMlxp-0002qx-Uj for qemu-devel@nongnu.org; Thu, 27 Jun 2024 06:02:51 -0400 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7f61549406eso12605339f.1 for ; Thu, 27 Jun 2024 03:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719482568; x=1720087368; 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=h+j6fKPVNUKUnpKxQMAdtrznAy8Ydu67u7x9DuieKE0=; b=I8j3lzUZAi/FSmYd2acqpG6FgRmbVaqptERU3A0gGZRe1spJksiCPOYU5fWIMJZpv6 OxxCjGy5SXl83GdKCxDr5wuhNfDe6hARPfROeW14jhv51sl+b4NeYWIpB3ZbPXry/vvw CrxrAn7Bx7DUFNWHtCuU2mCXsVTDAqQZxN4zwwUWIrLfSUSNY4PtFy0B9yKzOYKZvSb7 h0PGiB3Y50Wqnbf9wcMsGAmij9cs2gn49H70nMSmAUMGd0q+atCHVlPFXl2WE8iM7K/W PUV/DA8tsHgqPB8z+y4pviLIql1GMKIyPTbILL2EwUK0XOlnKO1oxEvID16emu9Tr13v F73Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719482568; x=1720087368; 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=h+j6fKPVNUKUnpKxQMAdtrznAy8Ydu67u7x9DuieKE0=; b=WSh0VFnEqoec/5O+ZdjCFDlXJwTN3fGnPAiW1r/beS99HGDqNk0zZRADwk7OvlBj6n ssoGL8uCsdlarOxG/gASKl5hQPUVwJO2/qMLEnpc4UbabpcWaAFJ0H0QBoewE3Zb4ndD cBQRq9Kdtz4RTTVPVrroUQRDVeQuvSb3NZGl5QC8pPxEzC5I76ttL6v9xu4tFJR7ZtyE lPu8yt2gLV1EIpoATicX2ogHT1mkLCq5KwHferI0R8CZsxFmDf1KTJ74sHydRPFYiJlb I3LlIX2uCJh5ZLBtdZoM5+ZPZskyAnIhM4Knx1/DeJMe8a+YHqTmZtw3RIYreexjVU6l R5Sw== X-Gm-Message-State: AOJu0YxHKqBuXXpzEuoaWZ4c0RUFH7s0pTfyQILAvlgDl8bP4uftTqjv Wc+5IO49hQ4KvIAPn2n3atWdlDmFJTIIErU8IoeJRPYT5fcNinZDmUX13X/r X-Google-Smtp-Source: AGHT+IHNOnh4snA1JbyAl60XYCAUC6EPph/N571XudXc5WX1XegVfyIoxxTlpRi6NKvpqP+zREoRbQ== X-Received: by 2002:a05:6602:6d15:b0:7eb:71b9:fc8 with SMTP id ca18e2360f4ac-7f3a755b3c3mr1514878739f.16.1719482568291; Thu, 27 Jun 2024 03:02:48 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a07326sm932431b3a.111.2024.06.27.03.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 03:02:47 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alvin Chang , Alistair Francis Subject: [PULL 32/32] target/riscv: Apply modularized matching conditions for icount trigger Date: Thu, 27 Jun 2024 20:00:53 +1000 Message-ID: <20240627100053.150937-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627100053.150937-1-alistair.francis@wdc.com> References: <20240627100053.150937-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::d31; envelope-from=alistair23@gmail.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Alvin Chang We have implemented trigger_common_match(), which checks if the enabled privilege levels of the trigger match CPU's current privilege level. We can invoke trigger_common_match() to check the privilege levels of the type 3 triggers. Signed-off-by: Alvin Chang Acked-by: Alistair Francis Message-ID: <20240626132247.2761286-4-alvinga@andestech.com> Signed-off-by: Alistair Francis --- target/riscv/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index c290d6002e..0b5099ff9a 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -624,7 +624,7 @@ void helper_itrigger_match(CPURISCVState *env) if (get_trigger_type(env, i) != TRIGGER_TYPE_INST_CNT) { continue; } - if (check_itrigger_priv(env, i)) { + if (!trigger_common_match(env, TRIGGER_TYPE_INST_CNT, i)) { continue; } count = itrigger_get_count(env, i);