From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580841; cv=none; d=zohomail.com; s=zohoarc; b=BdHUdlkgTM7iZW/AM1tvsC7RMjypsdPD+XVUxAuBmtwxKhT/pRte7b2+F7+no5r2NOPpCjrkmpXNGQFcdJugABnRrp7lml6s6t3R02lHnMmtul9dLBjHDTPJovT5wz2lhNjRPUmBEJAcVwxz8mUCpFHFsHmJCW+x9xN/qSNUMvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580841; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Uj7cBvZDFBEE4zf1v5At7rUrfvkSLy1+9y5oquwMnEY=; b=e3fCIMR5WoL9GK4ZNd0xniUd76bkrHw1CZ7ugHRVHn1VohBiAE8VxFjwEO0I71dEOxWYxv0MIsLT4k/TSUxFEYkLqZGam/bFZFS/P2D4DEiR7WVCEvgSxwCvPk+GecDZQRHYxR9V1CZmzBg1AYgGVaQ3eferfKasrO0dCQScnVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580841100611.108951191662; Tue, 17 Oct 2023 15:14:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssIz-0001dZ-9d; Tue, 17 Oct 2023 18:12: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 1qssIx-0001cm-Fu for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:47 -0400 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qssIm-0002Ts-FJ for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:47 -0400 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-57bca5b9b0aso3275995eaf.3 for ; Tue, 17 Oct 2023 15:12:36 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580755; x=1698185555; 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=Uj7cBvZDFBEE4zf1v5At7rUrfvkSLy1+9y5oquwMnEY=; b=XlZqw6G9V5ACRBVUQ5/ZuxlWfblmIoi+P1n4d1yteJk7T98dNP6aVmv20hs5GC5opD r8ox4//bvZHETwhZMVyZZbBpwJ8nNmhYy9T90rK9mEY+v/iSupsCvHwuuaP6NI2oPwsE uvJ3XCFcl9p6Uw3/YXrLQi9MRcZLxxjzsj8TvRi5/NFcPUXx26r6geqK/eV3uz+as4PW WPLrMJrAX6nH+b3PL47Pzs/J2vHPXl1cUP1Ane58F9iE0Iq7LgNxJ8LN5yXdrLGrzZNC dzwgEaJ18X7zlokYjRZo14VIHQN7dRVSoQkAPYGVjEsk0C0J8L5xMZgyVfd6HcGiLx3+ NOGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580755; x=1698185555; 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=Uj7cBvZDFBEE4zf1v5At7rUrfvkSLy1+9y5oquwMnEY=; b=DaLK/8JpPhGMtYuhSkI+7OCno5nytDv2hPrfheajMe8lfSHXTOIjcWw4VGW4qJMaDj YG5O2cmbTCK5+O/nuBjdUQaWcCII4GakjJZT10Dq37g7UVLHrSL9HF+LXdRh4rjzet+Z MgDily6HUDKf381aC3Gt75QU0JisG2yubVY2Od4QfaGDkTL8dzhCpMQo29zpU1XkF8a2 TJe+/M+FF4Hi2Jqu+oadMzCbzIPVpewRYqUovZUhmKaJdONDFGv7MAKAhk9/g4p1V3E7 mbMG+Hf51LdQbTgVyVziL/EZEzQuYg+CtI2KwufeUp9h9iMg/DThPkXhrFClsZZOBgKy CHdQ== X-Gm-Message-State: AOJu0YysNgBmIqAtwe9J9q/ebhkpNEGqxPUIqoXMxzjrnhWpqJ4XuPD2 tzAhO8nn3P0jGpuH9tC+hliPzVWdiEzcsW9ATbQ= X-Google-Smtp-Source: AGHT+IHfx8/Cn6hLaea6pU+KETmLXxLpeGhgvTCuvyP99+zu8gcFQpl5WYepc7WulUXj70Wn+7MYVg== X-Received: by 2002:a05:6358:ce08:b0:143:82e0:8cbc with SMTP id gt8-20020a056358ce0800b0014382e08cbcmr3542099rwb.1.1697580754797; Tue, 17 Oct 2023 15:12:34 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 1/6] target/riscv/cpu.c: add zicntr extension flag Date: Tue, 17 Oct 2023 19:12:21 -0300 Message-ID: <20231017221226.136764-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580841665100002 Content-Type: text/plain; charset="utf-8" zicntr is the Base Counters and Timers extension described in chapter 12 of the unprivileged spec. It describes support for RDCYCLE, RDTIME and RDINSTRET. QEMU already implements it way before it was a discrete extension. zicntr is part of the RVA22 profile, so let's add it to QEMU to make the future profile implementation flag complete. Given than it represents an already existing feature, default it to 'true' for all CPUs. Accelerators are responsible for disabling them if the user wants to. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 12 ++++++++++++ target/riscv/cpu_cfg.h | 1 + 2 files changed, 13 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 2f98ce56e0..f478245254 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -79,6 +79,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zicbom, PRIV_VERSION_1_12_0, ext_zicbom), ISA_EXT_DATA_ENTRY(zicboz, PRIV_VERSION_1_12_0, ext_zicboz), ISA_EXT_DATA_ENTRY(zicond, PRIV_VERSION_1_12_0, ext_zicond), + ISA_EXT_DATA_ENTRY(zicntr, PRIV_VERSION_1_12_0, ext_zicntr), ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_zicsr), ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_zifencei), ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl), @@ -1175,6 +1176,15 @@ static void riscv_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(obj), riscv_cpu_set_irq, IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); #endif /* CONFIG_USER_ONLY */ + + /* + * The timer and performance counters extensions were supported + * in QEMU before they were added as discrete extensions in the + * ISA. To keep compatibility we'll always default them to 'true' + * for all CPUs. Each accelerator will decide what to do when + * users disable them. + */ + RISCV_CPU(obj)->cfg.ext_zicntr =3D true; } =20 typedef struct misa_ext_info { @@ -1263,6 +1273,8 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), =20 + MULTI_EXT_CFG_BOOL("zicntr", ext_zicntr, true), + MULTI_EXT_CFG_BOOL("zba", ext_zba, true), MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), MULTI_EXT_CFG_BOOL("zbc", ext_zbc, true), diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 208cac1c7c..3c91b63609 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -62,6 +62,7 @@ struct RISCVCPUConfig { bool ext_zksh; bool ext_zkt; bool ext_zifencei; + bool ext_zicntr; bool ext_zicsr; bool ext_zicbom; bool ext_zicboz; --=20 2.41.0 From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580840; cv=none; d=zohomail.com; s=zohoarc; b=f/ggbyktpKE5wMkdP/EH5APyrh3z3sC3v1d21ZuMJjTxq3TbtG7UBOVYpzw0lKIr+SPpEPvUCQX0ujw8NoKsm/oeW49CjjzfANsU5XzjP3z3jJxeExJcb1WvbcZrnQdXTw3ZFZ3ddc9wkzsHoAtp5zPkJ/ZhYPGxqmQgDz1XnJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580840; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gtEJKckoNw0Ykb9iqkOPeUtRXkS38Xbs5K+yuRMiDLo=; b=QOU79o4eZBo1XPIgvNC1xhS8RkQHy4nQ/OEbQsUd9Av6db8/FOO/ePztNqyaTOd8teJcx3RuYpgNmBawrpO7zejIOy6KTRPVB3VWpxfOVrth/K81QVHX6Pn/Ox1sJKOTJ3Mz2uWL4Yhhd6LvwTo+/uSsaUuZhRbxgZfJVAjmT8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580840958265.8820448048044; Tue, 17 Oct 2023 15:14:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssIy-0001dB-Bn; Tue, 17 Oct 2023 18:12: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 1qssIx-0001cc-2q for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:47 -0400 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qssIp-0002V5-Bk for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:46 -0400 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-581de3e691dso577092eaf.3 for ; Tue, 17 Oct 2023 15:12:38 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580758; x=1698185558; 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=gtEJKckoNw0Ykb9iqkOPeUtRXkS38Xbs5K+yuRMiDLo=; b=E6RTdNZB/fJelpzjAdHlZwDafxJbbvr7evkbSLsJBLw7H6S9wp1je+3TIEkcwT4XcK /0iAwKspMeV5Dy4f7IufrPFfPuu9rqkln8iAgMJKJLTO0CdVETxra+S2FtHSfwA95Xm+ A12GSEwb64ET/IskIXzyj47Ts5xFmLcI+ZBd7+a6ctGu9IZTWFMsafmB6/ITp3lY7Nv+ rh2PdvPjuSFWbLvPf1y957hFh2h3DyoyailWRl0loy3Zq7f+c/sHmUgZHbfNmlByWqFk n/vgFmp9Nouky26AmDsxy3gLIKLsnDd/xNWuR70ZmJaRIfuz7xTWRmGpJxs2GqoyEn9F +wxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580758; x=1698185558; 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=gtEJKckoNw0Ykb9iqkOPeUtRXkS38Xbs5K+yuRMiDLo=; b=uVUJo74S93J/wWwlVwcKHdaq1f4j+Lg5j3IYCosag8CgxFTdD0MtRBTxHG/KZ9q7NT ropJn1BBtKyHz2TMcN92y2j52+bK/ivdwApCr1gTm/iHfe1BxA0EwFGTdmJ5HjAHeWp3 By9KYp4Be/tCzkofUMFUfS4LsYqVSGN0uzFm1B12Xir+7tPNZr9ZuJpYHayzbZosdvce xrjOK0F4iAOS5mm9h6T/4ZKEW/BTiPUk0DWkaJ54QPcXoeCSCW58qN+a3koHx82vKO+o OPZE/zcMRdxxie7Jq8WACa3Tm9qvRGqHXWs3HhoFHjqYsCr8r95GZDAPGa1LOVgW6PSR hD+Q== X-Gm-Message-State: AOJu0Yz++3/hPbwBX8w4wkDJ1KkIIUf372/TeJ0BZTf5BUhok0ExlWDD FgKO+1FzN/q0eHi2ie+C98hv7kJcf9QDohQOrLc= X-Google-Smtp-Source: AGHT+IFTomQtlx2Fdwb6WFoYL8nxgbGHPkA2r3jRYxttldqSgW2MpqpjgIzQ7RiePn95G+an54U9cA== X-Received: by 2002:a05:6359:2a7:b0:166:d1a1:7738 with SMTP id ek39-20020a05635902a700b00166d1a17738mr4656759rwb.0.1697580757722; Tue, 17 Oct 2023 15:12:37 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 2/6] target/riscv/tcg: add ext_zicntr disable support Date: Tue, 17 Oct 2023 19:12:22 -0300 Message-ID: <20231017221226.136764-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c33; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580841658100001 Content-Type: text/plain; charset="utf-8" Support for the zicntr counters are already in place. We need a way to disable them if the user wants to. This is done by restricting access to the CYCLE, TIME, and INSTRET counters via the 'ctr()' predicate when we're about to access them. Disabling zicntr happens via the command line or if its dependency, zicsr, happens to be disabled. We'll check for zicsr during realize() and, in case it's absent, disable zicntr. However, if the user was explicit about having zicntr support, error out instead of disabling it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/csr.c | 4 ++++ target/riscv/tcg/tcg-cpu.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index a5be1c202c..05c6a69123 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -122,6 +122,10 @@ static RISCVException ctr(CPURISCVState *env, int csrn= o) =20 if ((csrno >=3D CSR_CYCLE && csrno <=3D CSR_INSTRET) || (csrno >=3D CSR_CYCLEH && csrno <=3D CSR_INSTRETH)) { + if (!riscv_cpu_cfg(env)->ext_zicntr) { + return RISCV_EXCP_ILLEGAL_INST; + } + goto skip_ext_pmu_check; } =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index bbce254ee1..a01b876621 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -541,6 +541,14 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); } =20 + 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"); + return; + } + cpu->cfg.ext_zicntr =3D false; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need. --=20 2.41.0 From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580800; cv=none; d=zohomail.com; s=zohoarc; b=R0fZMoI2D5mzTiEzyt61uioQdvrTIJ2KDsVf7g3y8yhNGl6MVeUkeervFPszeoxiZMxMDxn85wtkKcyzp5F/Y1OpMZYUHpteeWg+UV1COE7iT01RYLAlUlQ2jPI1zgLpo9+9cVuiSSDpc/j+dXRHiYMnoYVjL8pSSztOVr2f1Es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580800; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Juy9Fo26ThtU0g+UY2hVD044MQTFgCmF6GOFzAjzMiI=; b=TrM4NYeAM9D356h3On3QPGECB5nQuIzJEQCNQWeRDHuMKew4w4r+FyCAENYn4aFZjBiwBiphXZhsY2FYg7/IPmzZwJxaeYVNB+HglI3CxKrbXDmgrKTNZw65UUB8ZkJpbOjFg4cbR/kUo2DbJrZVnBWWd70w13E6pqwAbseF5gE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580800857342.57794151735743; Tue, 17 Oct 2023 15:13:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssJ9-0001ow-3v; Tue, 17 Oct 2023 18:12:59 -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 1qssJ7-0001o8-CP for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:57 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qssIs-0002Wh-1a for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:57 -0400 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6c0b8f42409so4228001a34.0 for ; Tue, 17 Oct 2023 15:12:41 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580760; x=1698185560; 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=Juy9Fo26ThtU0g+UY2hVD044MQTFgCmF6GOFzAjzMiI=; b=gsainKF7k7KzOWMP7nQ4d/tgFOZ2JYBdFRMVQLS1LzGsl9/kES730mu10IC9B/mNMa AmZulnP2Jk/V26AutgHlAdpIlcvu7/MMIGpvAGUAikks9nIjSK7xYIsSm7VddBvRbZLz 26NY5VRKgjcySlHjyJqhbG9+LoUwgdIOgIYrb4tWOPfkPJTbhmdHDocE/TEoU26Tc5bU LBL0Tvnr0y5o2mGzkhepppYa/C9wNCOez2DFnYOtxT5F8XBW+vnCkB3qEhWXCtoNFTOU XIM7+Zy0fhrT+ps+5STApzDjeSu4rQ0TBizbbOx4KpiLJ32LY1Zk9Glg0UnMGqTDVUcx O6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580760; x=1698185560; 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=Juy9Fo26ThtU0g+UY2hVD044MQTFgCmF6GOFzAjzMiI=; b=W4f38kqeUNtsZibifL2y8ZSxcPjiWz5LmRLNLDnIJz2mZEnSIYKcrV6tWs8awzu2yb oSlT82s5+nas3dVxW176tpceu9gL+DZUHtd1xz9lDxT16IxRmdtpZw8M6hcRhtG3K6ru wNSCCJBFN50OX3VPxmW3/WMcGMvh9fdupy0PDWEBYI2gtHtJEuw2NY7vYwbZt85rX5pK xK04nQ2SZRn6rsU8VzX3gGkLUJ80dZN7unS6TvyA1J8rgk0lhprC4o7fza22WLQQ7Bj5 wcM3I7za5CNN3F/I6xHxchQqtvgICmbb6xgDfmrTC+xfWW5FsjxaW3tobGtu/UU46YVH XGYA== X-Gm-Message-State: AOJu0YwBwDKvNEVPEnyTjdbZVLTQfVPAjn0ysyAAv9B9Z6oYSAQnn409 6UlS63P36pwV38EzD0MkGTguZewCJUmQE9K7a74= X-Google-Smtp-Source: AGHT+IF8BPJuoys33rsqefNcP1VEer+wmPKM60y6SCkUqstQQEo04SYBNz7yZTAZmSFdi0BVRHViHQ== X-Received: by 2002:a05:6830:71a2:b0:6b8:f730:7ab4 with SMTP id el34-20020a05683071a200b006b8f7307ab4mr4689556otb.0.1697580760616; Tue, 17 Oct 2023 15:12:40 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 3/6] target/riscv/kvm: add zicntr reg Date: Tue, 17 Oct 2023 19:12:23 -0300 Message-ID: <20231017221226.136764-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580801410100001 Content-Type: text/plain; charset="utf-8" Add zicntr support in the KVM driver now that QEMU supports it. This reg was added in Linux 6.6. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/kvm/kvm-cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 5695f2face..6c2a92d171 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -215,6 +215,7 @@ static void kvm_riscv_update_cpu_misa_ext(RISCVCPU *cpu= , CPUState *cs) static KVMCPUConfig kvm_multi_ext_cfgs[] =3D { KVM_EXT_CFG("zicbom", ext_zicbom, KVM_RISCV_ISA_EXT_ZICBOM), KVM_EXT_CFG("zicboz", ext_zicboz, KVM_RISCV_ISA_EXT_ZICBOZ), + KVM_EXT_CFG("zicntr", ext_zicntr, KVM_RISCV_ISA_EXT_ZICNTR), KVM_EXT_CFG("zihintpause", ext_zihintpause, KVM_RISCV_ISA_EXT_ZIHINTPA= USE), KVM_EXT_CFG("zbb", ext_zbb, KVM_RISCV_ISA_EXT_ZBB), KVM_EXT_CFG("ssaia", ext_ssaia, KVM_RISCV_ISA_EXT_SSAIA), --=20 2.41.0 From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580858; cv=none; d=zohomail.com; s=zohoarc; b=YvACpCAMQbwchJW1FJeFfZGsj4Bxk4oNDPMj7iuRv06d0bVlNoLV7sLLaH7Yis1WQrDpFqnNX4wLw85fS0xRQjRjv8Axy/s3by9xyu4+kTxOolSxYS15OgbKo1aw0gbQ6JMMkVB9zku72RkSdeB/ZIOqnpoRg4bBEAqLobrgsHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580858; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9MNQGvEfEHzx/KxNbakqMdUCKWjRU5l73TxA8cZv8xU=; b=c+DfuFsZKNV6iihTXWPOtgcy/ix7WU3XfsFD5gWFnfz3eeIryMg23kiKX7tEM1rSljbK1z7kJihqft30wIDn9+ksIqUnB9ZJjPUT7kaiQQq3zajkzQH2mZBfpvxEjM0Q03kzEjNf19aHEYSGa4cF+jt9XX6g3/1EF8zmLUhlYhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580858768291.168625938776; Tue, 17 Oct 2023 15:14:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssIz-0001du-Tu; Tue, 17 Oct 2023 18:12: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 1qssIx-0001cw-Td for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:48 -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 1qssIv-0002XH-Fq for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:47 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6b5af4662b7so3511841b3a.3 for ; Tue, 17 Oct 2023 15:12:45 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580764; x=1698185564; 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=9MNQGvEfEHzx/KxNbakqMdUCKWjRU5l73TxA8cZv8xU=; b=HDwghnVHrzacUS/S4txCgiDtZmDftTisZ+ZYWaKY5yazUP8LoPdH4FrSyLS59wRyIU F8I4yiC/9/o9MM3pzMn4SeQ+3pq1Wrcgk2mVP/pB4HG3M9VKUh9c6GEghqeVpcEcNMHD CAsuoLL65z7tOrLCMIpAxI7x5H37Xit7SQ0Sex8QYQIopIEDDzcJpqNyBtcMWT6OByiJ RpQDJ1hbsmRp25vbEEFPGMec283haEF6n0gLjIpVYtjFsel3x4ZC+tIxlkox1Hx689Xt foiU9rVDQPJ3Y5JmLBmkU9p1MdVne9G73iW8GnneaGDIwccPS//G/7tZHsLbv2iMcCqT FRkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580764; x=1698185564; 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=9MNQGvEfEHzx/KxNbakqMdUCKWjRU5l73TxA8cZv8xU=; b=wt0eLWhuVNQ4pSYNQtRTtxFwAYJ2nQ57cEzy6U5EobSPjzECv78StKn1L9LhDMKgHa yEH4VwT/v1WIo40XF2bHVcrxcQAYsxO7TYmTZQlDrW1Qf/iVFWB8Eqs2wFvcKhS8I3a6 VDjZWHD87u02TsrlSRDo30t49kSPegeZZPAtMKNWbLRmVplzwGur6/OorUv/Pmn8qvwo GwtBOlV2UcX764HAZUBNwKf4dwa6L3vqU9LwgRDZRdt9o1zL8Fl8lGze0eXwE314MaZI B9wUVdOlf/MfqNIS9Nst09Ohsonw4OtVJ8lsUXVtn5WL1mikXCqV+hPfHLqJGcZrif5N ZNVw== X-Gm-Message-State: AOJu0Ywk1EhM0kqyc8aa9GAz/nfdFJBqC8MNT0pV4IaDuNFaXA/C0XjE G+0lVTy2WFes/4tCyeB4bzJVuEJNwrcxA7oYlF8= X-Google-Smtp-Source: AGHT+IGC9OH51cLhjyWojWhdj4LYjJ0h5rPPfO0QTzz5pN1LHRM6rzgSa1f8xVMLSBx61rlolrmfLA== X-Received: by 2002:a05:6a00:17a8:b0:6b8:69fa:8ff with SMTP id s40-20020a056a0017a800b006b869fa08ffmr3666403pfg.17.1697580763421; Tue, 17 Oct 2023 15:12:43 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 4/6] target/riscv/cpu.c: add zihpm extension flag Date: Tue, 17 Oct 2023 19:12:24 -0300 Message-ID: <20231017221226.136764-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580859651100001 Content-Type: text/plain; charset="utf-8" zihpm is the Hardware Performance Counters extension described in chapter 12 of the unprivileged spec. It describes support for 29 unprivileged performance counters, hpmcounter3-hpmcounter31. As with zicntr, QEMU already implements zihpm before it was even an extension. zihpm is also part of the RVA22 profile, so add it to QEMU to complement the future profile implementation. Default it to 'true' for all existing CPUs since it was always present in the code. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 3 +++ target/riscv/cpu_cfg.h | 1 + 2 files changed, 4 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f478245254..c64cd726f4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -84,6 +84,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_zifencei), ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl), ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause), + ISA_EXT_DATA_ENTRY(zihpm, PRIV_VERSION_1_12_0, ext_zihpm), ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul), ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa), @@ -1185,6 +1186,7 @@ static void riscv_cpu_init(Object *obj) * users disable them. */ RISCV_CPU(obj)->cfg.ext_zicntr =3D true; + RISCV_CPU(obj)->cfg.ext_zihpm =3D true; } =20 typedef struct misa_ext_info { @@ -1274,6 +1276,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), =20 MULTI_EXT_CFG_BOOL("zicntr", ext_zicntr, true), + MULTI_EXT_CFG_BOOL("zihpm", ext_zihpm, true), =20 MULTI_EXT_CFG_BOOL("zba", ext_zba, true), MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 3c91b63609..173bd7d910 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -69,6 +69,7 @@ struct RISCVCPUConfig { bool ext_zicond; bool ext_zihintntl; bool ext_zihintpause; + bool ext_zihpm; bool ext_smstateen; bool ext_sstc; bool ext_svadu; --=20 2.41.0 From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580814; cv=none; d=zohomail.com; s=zohoarc; b=HMB1ivH2Mpj3TK40rMYRMuJksHyxyv2XGAWWsoxeHMbKLCiLH2Nt8q96RhHe3B9h+r6RGC0TfAIZE7V7W/a0NfGpYAkmyvICEOlfuOcETMWT08ooujuoiLAChiCBjRNw/dyoFqLHQ/ER9pjQt7pg74Kf+UngX3lI2bdCEj5mh18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580814; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mz7t1eTY2QIkrHe4fc0zNZ5iKeKzZ2HJQpX/CMXgkQk=; b=fAyiKlDWvYLZaUf/B7ijUU10sOiN4px6IIiROFqon8FlSeAeGv9XmAvgq/KMgIO/NYyKf329SjRPj3uRBFIh/QEPBgwbMHjqNeqZAEDTlykxWQKM1+AqpERmpCAoB+SR/LA61upHR5XpOZRJsVWHKxa67lJ35fR06LNZECSFy2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580814779136.93758410402165; Tue, 17 Oct 2023 15:13:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssJ1-0001f9-Tr; Tue, 17 Oct 2023 18:12:52 -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 1qssJ0-0001eA-2G for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:50 -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 1qssIy-0002Xe-6Y for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:49 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so2794368b3a.2 for ; Tue, 17 Oct 2023 15:12:47 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580766; x=1698185566; 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=Mz7t1eTY2QIkrHe4fc0zNZ5iKeKzZ2HJQpX/CMXgkQk=; b=XvRvS+eCHbNYaXxpYJ6HZNp2tKSBVjqbYSTDd0NJc+I8BjuAtSNHpujP3H3arwOC8c JalXo9mipCATeKGv7Q+ZC/QwVFLHjXxi8HvX/UWvKmhBZjpVBrc27FFEcmNBOvNeCAR0 zuHgz6Wo2EvvN2JkSBOLpWc3KA3dR9P+NH9RTT4H3vJlcJdZdovyD+Aih2bWXxAqXR4l 3uHhkCPykIt5FFqWyu0KbXtW9HYUouk+N1tfSyB3DCx/wJCLzVK0Rm3pa1Zc+sdpRrWu HISHON9k6xfSrE3iGjAtypRHnWk9AdyS6QVj8VDoUx7KVBTSDnVur3P82jLhryyJsi7E uMmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580766; x=1698185566; 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=Mz7t1eTY2QIkrHe4fc0zNZ5iKeKzZ2HJQpX/CMXgkQk=; b=KNrYDr1TKs+VsIaHicsaB5BHw2AxBk0f/Whpqi6sBn8wJ9V7hAMyu/yj6U49oe+Y8Y uw91/QE7PLa36p6udINLXGuomularkdSBmWaKV4RviH17m/Arl/v2838PcwSTHob3YvD MOpNkope7mRnjunh2FszMwWyDdeL2xo2alVn3WgKtyZYzNtxxsS9kJDSbvUjKaKq7Ojh DCxviatpLBcBTlIDbuQC/QY13/dh9aAx1zCoMssd1/EZtUm8zFEqVYbibyQ1KNeZlOCT y407JMXgFhNQjIY1SEkFX8MwpSbcJCb4OXuB8PSJQz23dGiR30iRzAFtUChHKKrj1fW+ s14g== X-Gm-Message-State: AOJu0YwLQJn6P4tmH1TCtpw1PWTopTCFnyJ/XPuOir/E8rGsAlYiwFLw QlI7uOekFJNVHBKyPj+h19Gj6U+4pop1Em0ptXg= X-Google-Smtp-Source: AGHT+IEN53qaHlNU7pExZudWY85UGLBSioCvEDSs+hXFIb/i6+Gub0uAwNz8ZLCheXhZ986YVhMEeQ== X-Received: by 2002:a05:6a00:98a:b0:6b5:608d:64e1 with SMTP id u10-20020a056a00098a00b006b5608d64e1mr3781575pfg.33.1697580766273; Tue, 17 Oct 2023 15:12:46 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 5/6] target/riscv/tcg: add ext_zihpm disable support Date: Tue, 17 Oct 2023 19:12:25 -0300 Message-ID: <20231017221226.136764-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580815712100001 Content-Type: text/plain; charset="utf-8" Disabling ext_zihpm does nothing at this moment. Add support to disable the hpmcounter3-hpmcounter31 counters if the user disables zihpm. There is already code in place in target/riscv/csr.c in all predicates for these counters (ctr() and mctr()) that disables them if cpu->cfg.pmu_num is zero. Thus, setting cpu->cfg.pmu_num to zero if 'zihpm=3Dfalse' is enough to disable the extension. Set cpu->pmu_avail_ctrs mask to zero as well since this is also checked to verify if the counters exist. Signed-off-by: Daniel Henrique Barboza --- target/riscv/tcg/tcg-cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index a01b876621..7a4400e2ba 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -549,6 +549,19 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) cpu->cfg.ext_zicntr =3D false; } =20 + if (cpu->cfg.ext_zihpm && !cpu->cfg.ext_zicsr) { + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_zihpm))) { + error_setg(errp, "zihpm requires zicsr"); + return; + } + cpu->cfg.ext_zihpm =3D false; + } + + if (!cpu->cfg.ext_zihpm) { + cpu->cfg.pmu_num =3D 0; + cpu->pmu_avail_ctrs =3D 0; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need. --=20 2.41.0 From nobody Wed Nov 27 16:30:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697580820; cv=none; d=zohomail.com; s=zohoarc; b=EE4FubDES2TMYcaMZfGKhbwxCCLhn4o7AGCRbZiU7l/wxnDsJF/Au3A/FRlP/bZ/T5SIGEw/hi+XhDem8tdmv1p99v1Be79zl13nT2H3dNj7lZqNTqNBcicp5FbXzzlt6Lr+gOAuiOa0qwVAXm02PBcBDQ6WVv9M9c8SL1guHgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697580820; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tu1uQppmcaudXCZ6wZyPs+oZqs9eNWAN3vjDAnHlDMw=; b=bDK8bVb/HEWi3fpp+cFJAvFXE3Pm0zk7ktXJQEHJcuiYrGtrKitDqiTBJl78bqq53zhox7+CWe9pJI5dV3Pl6tDpG14xl7f0a8wlmIaqG+vwlB/QOjHWOQyEG8aBjeN/yEQkS06P90BKyQ0yKfP0ZNx27iRl6wMlLGQOw7sPsIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697580820832993.6945658124492; Tue, 17 Oct 2023 15:13:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qssJ4-0001g3-Cu; Tue, 17 Oct 2023 18:12: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 1qssJ2-0001fX-CJ for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:52 -0400 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qssJ0-0002YC-Sd for qemu-devel@nongnu.org; Tue, 17 Oct 2023 18:12:52 -0400 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-35743e88193so25254135ab.3 for ; Tue, 17 Oct 2023 15:12:50 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.45.186.249]) by smtp.gmail.com with ESMTPSA id t13-20020a62d14d000000b006be077531aesm2011023pfl.220.2023.10.17.15.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 15:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697580769; x=1698185569; 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=Tu1uQppmcaudXCZ6wZyPs+oZqs9eNWAN3vjDAnHlDMw=; b=I3fDPaHJ4uV9CvaCKB+RF83NuEcyUa+/itVLJuJfDXa7rpD7+hvUXxtpHMeB1+xE3+ nxE7bDWc1KqxIQqOjl7cEZxWN0iSIizOPLfhVRQmKmsMOysB6YeIWxSS4rFBIDCxU6Iq y6ojwfq43INK6gHQHEkyC1izMXmkYmUovmkSJHL9s96QA/3iC2sE922OOekjKHJtyZz8 xfHc38Ik32n7JFERrHmTqMKa90PErl8xC+LeZDLY16vDUw4be5vdP04HGZcHKQrbdmHG ax83YByN79yV0wZsJQPRuOsFn76AdDcI6Sv8EwbGbu4mwdxPe63eTYXHftg8oX2WCsbE fdnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697580769; x=1698185569; 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=Tu1uQppmcaudXCZ6wZyPs+oZqs9eNWAN3vjDAnHlDMw=; b=dZKdHIozhdedswh/6aRxeHOy2KQryxJM3CJpQvDIeeuGTiTrmdbnNRuhOKpHe6Geeg 43HLDGe0Z2lSxfnci7V83xjq+CsGYHQDf8Zff1VOT64wz+zrUHAxVrp49ge8vHDEN2hK eLq1ZP5dVVwYg38l4YUudE+IXA7bs5w/Yokudsgk2aAu9yTB5FcdTO7DUdXN/ZpzxnCX fMGSZhiUNGxwRgGaZF5z/ee8bYNERGTCUZYhb+LUWyO6J8KOakW8lwtyvDVa4CaZaPId zCxa98LifP0ACrAR5+eHyQTamoovgbI7MLFoqjRVMvSEMSQUP7Tlc2n8w2EDbRwYbB13 dseg== X-Gm-Message-State: AOJu0YxEh29P3i/o42wSSbTvYnW37dINnDYveas0P86DF877yKW6WGAJ sBS89ibxGEU7ETrweoHIBDw2FToGi8hrrNYMUe4= X-Google-Smtp-Source: AGHT+IEgHkSaUJ+tzrikgdyRVO/qigwx8IgeyH5JPHSaAKB9FfwsiwqUKDcarl77j7c38i+aVerA6Q== X-Received: by 2002:a05:6e02:1546:b0:357:6410:9494 with SMTP id j6-20020a056e02154600b0035764109494mr5115257ilu.15.1697580769242; Tue, 17 Oct 2023 15:12:49 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v2 6/6] target/riscv/kvm: add zihpm reg Date: Tue, 17 Oct 2023 19:12:26 -0300 Message-ID: <20231017221226.136764-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017221226.136764-1-dbarboza@ventanamicro.com> References: <20231017221226.136764-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::131; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1697580822042100001 Content-Type: text/plain; charset="utf-8" Add zihpm support in the KVM driver now that QEMU supports it. This reg was added in Linux 6.6. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/kvm/kvm-cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 6c2a92d171..5246fc2bdc 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -217,6 +217,7 @@ static KVMCPUConfig kvm_multi_ext_cfgs[] =3D { KVM_EXT_CFG("zicboz", ext_zicboz, KVM_RISCV_ISA_EXT_ZICBOZ), KVM_EXT_CFG("zicntr", ext_zicntr, KVM_RISCV_ISA_EXT_ZICNTR), KVM_EXT_CFG("zihintpause", ext_zihintpause, KVM_RISCV_ISA_EXT_ZIHINTPA= USE), + KVM_EXT_CFG("zihpm", ext_zihpm, KVM_RISCV_ISA_EXT_ZIHPM), KVM_EXT_CFG("zbb", ext_zbb, KVM_RISCV_ISA_EXT_ZBB), KVM_EXT_CFG("ssaia", ext_ssaia, KVM_RISCV_ISA_EXT_SSAIA), KVM_EXT_CFG("sstc", ext_sstc, KVM_RISCV_ISA_EXT_SSTC), --=20 2.41.0