From nobody Tue Nov 26 22:18:41 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=1703181246; cv=none; d=zohomail.com; s=zohoarc; b=TlsfrK8a9pO4lNq2/5hjgVumajii/Ri0h4k6EOAM/55oKkgVTRbcYKpdFZjdXv0aFgPD1pc1jX7w1QKBfjhysykLHKza79Omqi1N40KHz/IZru/a/xtkFm+t7BZWEZarnUbnsJ0ChQDy1tv0MM3QKB3p4V0if/ahxaGcK6JGM+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181246; 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=bNKontpfLUZyadIzXzNBnB69eWAYBQx8Z06ZfrYR8/0=; b=Wb9TKee+kvL73ttkAW3/I+S1BTmigX+QleLmAK7Qt/opvm1pujvy2hLkoI8JidfdMuemUQcNKYeLCVqt8ZYSHqCbouComtZIeYVapLYuCWRwX70TSgCAPkqaV8eWKhszI+55B3iGqgsaiZf5S4zF7gujD76AOB1kwLBc8Masan0= 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 1703181246675666.2125023222288; Thu, 21 Dec 2023 09:54:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGND6-0002Uo-VS; Thu, 21 Dec 2023 12:51:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGND5-0002U2-2V for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:51:51 -0500 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGND3-0007w0-6l for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:51:50 -0500 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-35fcea0ac1aso5028565ab.1 for ; Thu, 21 Dec 2023 09:51:48 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181107; x=1703785907; 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=bNKontpfLUZyadIzXzNBnB69eWAYBQx8Z06ZfrYR8/0=; b=IeCcfGki/r1XMetuUJQ1OKkUFjMttf2qNURwlEFN1a4F1Frxsrxa/0GO9q5kWyHzPf ynhlP3wXksfod9bs1FCJSATY/jbaB+F3JILGhtME8D2A7SaHPNbcqGRmfYZn96eh7H7d bSDg3rYQVOwg0nQGDdQkd/vpLvjARUuS3cyxRU4GWXmnXiH2ts5Uq8tOKHMIg2zhN5X8 bsSkZ5RLGXI8MjStRnZzPBe+ePZwNnnYDSdL+yExErbBhueJhQ7i1BcVTWQf/Hn9nI83 5z94b990SUEqYGdzBvlEFIjKszWDts+G7ISh+8hTVHKDpMmEM6j61FlkEEBsbijGefAx LcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181107; x=1703785907; 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=bNKontpfLUZyadIzXzNBnB69eWAYBQx8Z06ZfrYR8/0=; b=XTiOitJLZQlW9KxT2ETqBmohWeU16BSYn/f3R/EZvDEao+k6swSCVCAcQjNN1NM0ab rxt0y2LTriPcYV9dRV1O+UfM3tPM8StgfYQZhMDGaA6ZAiGwBXKe47mNGc7HkjGh7RN+ GEZy8jli8/GKY+phaI2enDQhRDFIvK1AoNbeAsz5BXs0oX8nUkYKuBDXSMnTmtY6wY3a czhVH5fQPCKTsc1AiR1V3Wufc2n/TNwzgkTLQUqHCfkooZ3Q/9v5wZAqKDKqoA/MCDmg +j50sI1byHM9v7XESDd9g27pYCG1EChjUUZ/AOROwXPPwaKFX19sQHKFL5bzAViOVQQr 4Jsg== X-Gm-Message-State: AOJu0YwLxDx8HULkt8kmQ4I7ezgCyc8iqGJ9MaW5Fq0ulJqp7uePkC4n O/eDjkZa2aQppKcU8AAhEMtk3vcOQfp4mBYcJuqFBA== X-Google-Smtp-Source: AGHT+IH4el+xtvfYc8eu3QrCedv9jj6VkMTVMjHqfjl8O9qOL+5GVbTntzuCPo3HwUYRjnMNJRzgUA== X-Received: by 2002:a05:6e02:1b8f:b0:35f:b126:374e with SMTP id h15-20020a056e021b8f00b0035fb126374emr8256453ili.107.1703181107083; Thu, 21 Dec 2023 09:51:47 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 01/16] target/riscv/cpu_cfg.h: remove user_spec and bext_spec Date: Thu, 21 Dec 2023 14:51:22 -0300 Message-ID: <20231221175137.497379-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::129; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x129.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181247439100001 Content-Type: text/plain; charset="utf-8" They aren't being used. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu_cfg.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index f4605fb190..c67a8731d3 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -136,8 +136,6 @@ struct RISCVCPUConfig { =20 uint32_t pmu_mask; char *priv_spec; - char *user_spec; - char *bext_spec; char *vext_spec; uint16_t vlen; uint16_t elen; --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181152; cv=none; d=zohomail.com; s=zohoarc; b=IhIshM8okxtKM4pdGVHiX/u77ttrq173680ZtjwgR4NIedyS1vhR6JH7SpWrrGt7BP42QWch1uN/G0G2wGaT+8lB8WN64kdZCOQNXCc2dR7aO8+1FzTTj2+xCtumOFXp5AtxWIxlYhgUCy1+slkT+khaSgiwds28OrDuydJ8HNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181152; 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=57es9uIj9qaNcaBTGtjJpnb2VodcVdLLqcTy46mtENI=; b=fbnXzXfTXonDfIkH8AYMlr9o2L9sU4UfzBinOivAcWewzFlzdEqh/N2ptUV8jc3eVjv28kO6Va7NVCHnyKvawqKg6k1/j2ZYDiFuOS6dNNjkjwX7wf6vg26nfothF6zmYNrQ+0QzO9kZboVq1GxhDRYw/16fD/7nwEBCDmPCYec= 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 1703181152002219.2285951336305; Thu, 21 Dec 2023 09:52:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDF-0002Vm-0w; Thu, 21 Dec 2023 12:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGND7-0002Ux-Ud for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:51:53 -0500 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGND6-0007wP-DR for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:51:53 -0500 Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-35fd04ede25so4222745ab.0 for ; Thu, 21 Dec 2023 09:51:52 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181110; x=1703785910; 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=57es9uIj9qaNcaBTGtjJpnb2VodcVdLLqcTy46mtENI=; b=aKGq3oM5b44ZeBqLiXnFKq+Tecy4qE2HRcoa6ci3mMFHuFDu7mF2kPv6m/M4Oob8wR wPv3bJWqLuxq17ZLFjJJK46QPccB9ivsgfb0NLAt4knnRslR0Qntsb0UyjawuGjWZXZJ Z3zhzKcBFPigXkIEtqH9JqZhouLxNhw52nb6siMC8Vz0r7hQn9q2buCPelRhrTjyuJBv ffijczOy1FROb96C1cOu7F9/M1D9piuQ8GvGNG/a5lFEijfU8nqYIrJ2dQKFZZSQtg5b nbwD0kpaC+h4PUuImmqVZJA1ZwDEWA48JUBUsDFB7GorQFTGnmRK6O/t6RETZAjFw7KW OkBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181110; x=1703785910; 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=57es9uIj9qaNcaBTGtjJpnb2VodcVdLLqcTy46mtENI=; b=mzV/1f/HI34bd/G924x6M9C+uXYshq84un+2kiTMIYsRo1KkGLS1DNiAxd/i2guqrF HWMF04Dspn/8/cnsHCuTzNuEp3hPKifbzbC30aaLEYWCeoDYvjKH9tu/M6k+hCNWhHaO 87hefdtXqVFN8lHQFKHS6+RAIXZvv0UjmgVWwo5DpnJE4kHZOxcFSMWs4zuR9CgnwR5h ugQ5eaGDGjREDqyMifg3Kedez0KxqzzRkPXnzO/N3q+D1ckpUhulEIDRNLWdNU8sFjtW r1F+HW6ckax3Vn8HjgtKL2daXmDzke7v6j5GlVzc3gNY4GjVjjgx3XYvbftUWoZi8vHg 8IgA== X-Gm-Message-State: AOJu0YyPZ5Mk/qghbLJZHtq0RitMXmeYPn1Dw5s5t7slXztahH3cZEmw Pi0R9ZG8gI3sdgxOAdFv/EfUVnxSDQ8CsThcnjdvJw== X-Google-Smtp-Source: AGHT+IHCZT0+0QZH7S678OEziEvRLFDOfToyGch2ZMiEjR8k4WFAs1qXZrP1ncMK4b2PAk3vDqWw/A== X-Received: by 2002:a05:6e02:180c:b0:35f:d00b:236b with SMTP id a12-20020a056e02180c00b0035fd00b236bmr2622093ilv.49.1703181110170; Thu, 21 Dec 2023 09:51:50 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 02/16] target/riscv: move 'pmu-mask' and 'pmu-num' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:23 -0300 Message-ID: <20231221175137.497379-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::12c; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x12c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1703181153744100001 Content-Type: text/plain; charset="utf-8" Every property in riscv_cpu_options[] will be migrated to riscv_cpu_properties[]. This will make their default values init earlier, allowing cpu_init() functions to overwrite them. We'll also implement common getters and setters that both accelerators will use, allowing them to share validations that TCG is doing. For pmu-mask and pmu-num it's just a matter of migrating the properties from one array to the other. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 70bf10aa7c..ba62792e30 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1464,9 +1464,6 @@ const PropertyInfo prop_pmu_num =3D { }; =20 Property riscv_cpu_options[] =3D { - DEFINE_PROP_UINT32("pmu-mask", RISCVCPU, cfg.pmu_mask, MAKE_64BIT_MASK= (3, 16)), - {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), =20 @@ -1485,6 +1482,10 @@ Property riscv_cpu_options[] =3D { static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 + DEFINE_PROP_UINT32("pmu-mask", RISCVCPU, cfg.pmu_mask, + MAKE_64BIT_MASK(3, 16)), + {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181221; cv=none; d=zohomail.com; s=zohoarc; b=E3PKH+TzAPs7arSMh3RZz6WKOl/7ZOWCD+W65N8f2WP2mXWq73Q09tZqydRYhFfHFeka3D5/dqmf6cNKON9qQpvM/nWF0m7tm5WlIAw8s2glQfEHHIJ5LXWGhaefdwxlvu+8+QxwdbMG3lPiUTK1jIcCJ3c0zy4ao04AaaSZKRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181221; 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=1f8buozLrcm84P1wXk0vvyswbN0zyCAa7nTrocgX6uo=; b=nOWn2kePQY6Rek9CzaW0t8/14YhYjgRBGnaL/pj34OjiYSMM94J1zt3d5H2IqS98Ev05K9OhIQKWB2kU2ZspmgGW2gXW/rj/N+AQanu/B/ZdsL8bBBeokVxBn0O9yZN4c7UZPEUn1ZBa6sj9prGScxiyGeFbR3UwH74o2Rjm7dw= 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 1703181221433595.9979585841768; Thu, 21 Dec 2023 09:53:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDS-0002aJ-VL; Thu, 21 Dec 2023 12:52:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDF-0002WK-Uu for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:02 -0500 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 1rGNDD-0007wq-4A for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:01 -0500 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6d9344f30caso777478b3a.1 for ; Thu, 21 Dec 2023 09:51:55 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181113; x=1703785913; 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=1f8buozLrcm84P1wXk0vvyswbN0zyCAa7nTrocgX6uo=; b=bHFG2C0R5hJ/5S4X5ONNb4Tffye/6xcL3Kq7rZl95m8OIId4YSbBB7HFnMZx0BTC6r fBE6HOm1IKoyPhxHCUZKgi5IBr1/BBCitGVq+IblCrgSvoO8xLt0kGOHg5u9rrLhto36 EPHJAB941QZToUnZvmOGfPofUmnxAmL7FyULaUSe02sRW/Hlv5X/mFkXJtUflCVmc+0L bAeEfURGRWEdywHOkXD0XQZgPbBluETbhbwrKWfe1D2si5QHh8XME0nGJ5UEy6csJp9k 9XSA0q0DmrF06NaFjhWy3iDzirNYs9fJqDWXd/lKeB7XMC077OZ4G2d9YOt1zHeDwdDV HO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181113; x=1703785913; 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=1f8buozLrcm84P1wXk0vvyswbN0zyCAa7nTrocgX6uo=; b=bSSfOsNtYm6UCpTYpWUVd3bdROLaNMZE7sD/jtvECQb3YjpjmEWQN8+GMoFp8ZsTF4 G9b5S0W3IOO//3raoPOnXYrXIdC6P3uhkSDR3YcU659rO/yW1LfAoYOAZlwi9PiG2tDz Qnzhph1UDTCJiCJCLGXaLMmOA62FujqidrdeVQDve9b+pIrlrcyisUS8Wkb1S71+i1O3 OU0Sf3rQyltUQb5YVrSqJPqKAtLDEBYcHMCxj2aqIShdzLRsieUse0gnUH8CznBciCjV Gv46n7thHDtdexAjBmAt71wiMQvR4kTTMDePV5/r4nBW/KoikVRHY+Rk9IzxrK0AXLTG SzlA== X-Gm-Message-State: AOJu0YyKM2Y6iNr9s/2WtxkmSwwGj0RAJvKrLlKA29eo3COF/aGOAoUR oizh3+e4aByaT69+c+JmL/wy2poYdc0KYNlRAwG7smS1Z78LDw== X-Google-Smtp-Source: AGHT+IHKN4bPh8mSih1b/1Y0WxihZqS/BwTf5tDdQaTaon5VBvwITzvPjvsqO2pLksjAEUg12h+/wQ== X-Received: by 2002:a05:6a00:14d0:b0:6ce:bb12:cc78 with SMTP id w16-20020a056a0014d000b006cebb12cc78mr1103677pfu.5.1703181113227; Thu, 21 Dec 2023 09:51:53 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 03/16] target/riscv: make riscv_cpu_is_generic() public Date: Thu, 21 Dec 2023 14:51:24 -0300 Message-ID: <20231221175137.497379-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::42a; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181223307100003 Content-Type: text/plain; charset="utf-8" We'll use this function in target/riscv/cpu.c to implement setters that won't allow vendor CPU options to be changed. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 5 +++++ target/riscv/cpu.h | 1 + target/riscv/tcg/tcg-cpu.c | 5 ----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ba62792e30..8f68da9969 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -183,6 +183,11 @@ void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ex= t_offset, bool en) *ext_enabled =3D en; } =20 +bool riscv_cpu_is_generic(Object *cpu_obj) +{ + return object_dynamic_cast(cpu_obj, TYPE_RISCV_DYNAMIC_CPU) !=3D NULL; +} + const char * const riscv_int_regnames[] =3D { "x0/zero", "x1/ra", "x2/sp", "x3/gp", "x4/tp", "x5/t0", "x6/t1", "x7/t2", "x8/s0", "x9/s1", "x10/a0", "x11/a1", "x12/a2", "x13/a3", diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index d74b361be6..cfe965e512 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -757,6 +757,7 @@ enum riscv_pmu_event_idx { void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, bool en); bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset); void riscv_cpu_set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext); +bool riscv_cpu_is_generic(Object *cpu_obj); =20 typedef struct RISCVCPUMultiExtConfig { const char *name; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 8a35683a34..a09300e908 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -658,11 +658,6 @@ bool riscv_cpu_tcg_compatible(RISCVCPU *cpu) return object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_CPU_HOST) =3D=3D NU= LL; } =20 -static bool riscv_cpu_is_generic(Object *cpu_obj) -{ - return object_dynamic_cast(cpu_obj, TYPE_RISCV_DYNAMIC_CPU) !=3D NULL; -} - /* * We'll get here via the following path: * --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181217; cv=none; d=zohomail.com; s=zohoarc; b=klt+pwHTiph9F/h0oXaLVAxHwBpCdt22+c2UMR1hui0cwLbOcrkAlWxdNk2Jq9a+OpUF6FL4B+RzMye3xSMvYjxq9B/GOWWDkDQodA47HaZhY973nZ/OV9h6BXEbCv7OXq07ppXsGWPOfZKCbZ52PHzbUuT1qOUeJMAH9H89r0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181217; 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=fVrDBA2eoqpj3r2szEcFrStMdGViyzt8k41KgkSS3X8=; b=jdlJYAR/wG35egeIBeqv2yPQLNGzNi/lW8bwCqWwO7yRLHtgIHGv0nF6SfhTsJU1bJP0mdJ1iHK8ULpHtKCHX83VwscbrJQJyi5W1d+bt9oke/sXIfFV+MR89EtTMP2stqr8CHabMNGohcSubkjCSjnkB5fdeNlQV12Ud8oZiPo= 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 1703181217293690.9563355961352; Thu, 21 Dec 2023 09:53:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDQ-0002YS-72; Thu, 21 Dec 2023 12:52:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDF-0002W7-5z for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:01 -0500 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDD-0007wz-3e for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:00 -0500 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-35fb0dcec7aso4136015ab.3 for ; Thu, 21 Dec 2023 09:51:57 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181116; x=1703785916; 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=fVrDBA2eoqpj3r2szEcFrStMdGViyzt8k41KgkSS3X8=; b=e3HYaPWAc1msqNCUDULMyzqfHSPMsEg6K2/LtK6hGjANYqcmAR33aiUYdNUPeOrmAR VEqFstjqh3bwkVw+pknLKXwJ/P1UaqShdTFfeTtnV2Vs8DtWW4sjYDlmsWELCtf1T64G /tDORSsm2FSQ0AXkuAxJaYIdpcniyCRa7UFGLzUswfBmzvQfTOMi2Hgntdbx+ZrL7Vda YGcpNZuJNTwjc3iucUSbKmqVMrwYA8w+yiOKWB5eTQcqdmJUD9qVcxffAB9ndIwL5pO/ 7lpjUQwalvTNkxirRNrvDqyWkBowwoWddYVYThMIbztOw1SBGPV/GI9spXaHLICYIqa2 2bnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181116; x=1703785916; 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=fVrDBA2eoqpj3r2szEcFrStMdGViyzt8k41KgkSS3X8=; b=HYBR4KwC3DuQq6VZXGYJI+z467jsyAVkXHKzXLVzM63dWshXKA37gF5hqYgMiI1ohG XbQIpmW9gXFOdS+CjwRIr+ONELl1dfKB2xFqoX6C59V0Yq0isTFJzpZQYT3mShwm3UIl JifbP1Y41qHdKuv0rYIz6L60WLUJeg+9rt6hTBwyfS9rHd6iEX3tVbx7iNjT9fCWAhrr ph7rhK3VwxC8BXUZ/hYdne6hat/s1LPfwo3NvroS8j0m2G/jmhlAN3tNMKS1bDDIA34p V5Nde3G06Pg50rEFL2IIfCnWKDvJKD669t06W6DAFjGkoDIF+JKM/4QF+tTiqmq1eo+G jnLg== X-Gm-Message-State: AOJu0YwAf6RVilwPgLDPo5Hmwy7keo+5xZv76Y7WMghtsebsCjOkIwLK lF/KFhfRDNtAs9dlkJoey1zfJ4l5L/T67GyxZCSYPw== X-Google-Smtp-Source: AGHT+IH1j4JW8Tm97OL219fTwpWrYTogCAgCeADKIZCWyiEYdTPldk+58qj90CNk2nC0UST3bH4SHA== X-Received: by 2002:a05:6e02:2143:b0:35f:cd16:b58a with SMTP id d3-20020a056e02214300b0035fcd16b58amr3549538ilv.44.1703181116312; Thu, 21 Dec 2023 09:51:56 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 04/16] target/riscv: move 'mmu' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:25 -0300 Message-ID: <20231221175137.497379-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::12b; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x12b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1703181219491100003 Content-Type: text/plain; charset="utf-8" Commit 7f0bdfb5bfc ("target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()") already did some of the work by making some cpu_init() functions to explictly enable their own 'mmu' default. The generic CPUs didn't get update by that commit, so they are still relying on the defaults set by the 'mmu' option. But having 'mmu' and 'pmp' being default=3Dtrue will force CPUs that doesn't implement these options to set them to 'false' in their cpu_init(), which isn't ideal. We'll move 'mmu' to riscv_cpu_properties[] without any defaults, i.e. the default will be 'false'. Compensate it by manually setting 'mmu =3D true' to the generic CPUs that requires it. Implement a setter for it to forbid the 'mmu' setting to be changed for vendor CPUs. This will allow the option to exist for all CPUs and, at the same time, protect vendor CPUs from undesired changes: $ ./build/qemu-system-riscv64 -M virt -cpu sifive-e51,mmu=3Dtrue qemu-system-riscv64: can't apply global sifive-e51-riscv-cpu.mmu=3Dtrue: CPU 'sifive-e51' does not allow changing the value of 'mmu' Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 67 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8f68da9969..90dd2bccf6 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -410,6 +410,8 @@ static void riscv_max_cpu_init(Object *obj) CPURISCVState *env =3D &cpu->env; RISCVMXL mlx =3D MXL_RV64; =20 + cpu->cfg.mmu =3D true; + #ifdef TARGET_RISCV32 mlx =3D MXL_RV32; #endif @@ -424,7 +426,11 @@ static void riscv_max_cpu_init(Object *obj) #if defined(TARGET_RISCV64) static void rv64_base_cpu_init(Object *obj) { - CPURISCVState *env =3D &RISCV_CPU(obj)->env; + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + + cpu->cfg.mmu =3D true; + /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV64, 0); /* Set latest version of privileged specification */ @@ -542,13 +548,18 @@ static void rv64_veyron_v1_cpu_init(Object *obj) =20 static void rv128_base_cpu_init(Object *obj) { + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + if (qemu_tcg_mttcg_enabled()) { /* Missing 128-bit aligned atomics */ error_report("128-bit RISC-V currently does not work with Multi " "Threaded TCG. Please use: -accel tcg,thread=3Dsingle= "); exit(EXIT_FAILURE); } - CPURISCVState *env =3D &RISCV_CPU(obj)->env; + + cpu->cfg.mmu =3D true; + /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV128, 0); /* Set latest version of privileged specification */ @@ -560,7 +571,11 @@ static void rv128_base_cpu_init(Object *obj) #else static void rv32_base_cpu_init(Object *obj) { - CPURISCVState *env =3D &RISCV_CPU(obj)->env; + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + + cpu->cfg.mmu =3D true; + /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV32, 0); /* Set latest version of privileged specification */ @@ -1431,6 +1446,19 @@ const RISCVCPUMultiExtConfig riscv_cpu_deprecated_ex= ts[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static bool riscv_cpu_is_vendor(Object *obj) +{ + return !riscv_cpu_is_generic(obj); +} + +static void cpu_set_prop_err(RISCVCPU *cpu, const char *propname, + Error **errp) +{ + g_autofree char *cpuname =3D riscv_cpu_get_name(cpu); + error_setg(errp, "CPU '%s' does not allow changing the value of '%s'", + cpuname, propname); +} + static void prop_pmu_num_set(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -1468,8 +1496,37 @@ const PropertyInfo prop_pmu_num =3D { .set =3D prop_pmu_num_set, }; =20 +static void prop_mmu_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + bool value; + + visit_type_bool(v, name, &value, errp); + + if (cpu->cfg.mmu !=3D value && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, "mmu", errp); + return; + } + + cpu->cfg.mmu =3D value; +} + +static void prop_mmu_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool value =3D RISCV_CPU(obj)->cfg.mmu; + + visit_type_bool(v, name, &value, errp); +} + +const PropertyInfo prop_mmu =3D { + .name =3D "mmu", + .get =3D prop_mmu_get, + .set =3D prop_mmu_set, +}; + Property riscv_cpu_options[] =3D { - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), =20 DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), @@ -1491,6 +1548,8 @@ static Property riscv_cpu_properties[] =3D { MAKE_64BIT_MASK(3, 16)), {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ =20 + {.name =3D "mmu", .info =3D &prop_mmu}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181263; cv=none; d=zohomail.com; s=zohoarc; b=JFoQanqvFPbwFddn/75rkQKXspDm8+vo5EalC2zrIkkxKMnWQUFEl9KGNt6FqiMhuDurLVxZ6FoCD1FoQTGvuS0IeibHLyeyDClKQzZul1mfa4LlK3/lI1vx8J/iK0xG3rf9ho6QekscmvVfXjP0mQD0gC0vzqxurYTO9kY+SXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181263; 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=MKdlUY8svMA94b9jq+C+gEiT6a/yET6zQAAKKTsFHh8=; b=eGQxnd1WV0MPBbwIiz4c89otSIwznaUTUwCpi7hEy2c7AQEl+WoEnQlV2E/7/EGyhkpBGldVEGXaTniMWRZ/z7UuQBO2OMCOdGwydV+6oMxDG2kOK0oU3YuaBGZeWLrIyC3rCJMWewJExXAyBRHwunHfKSQ7xI6ZMh5I1wT/W3E= 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 1703181263302961.9253776328095; Thu, 21 Dec 2023 09:54:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDT-0002aL-Na; Thu, 21 Dec 2023 12:52:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDH-0002WZ-Mk for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:03 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDG-0007xi-1V for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:03 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d7e67d31caso732393b3a.1 for ; Thu, 21 Dec 2023 09:52:01 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181119; x=1703785919; 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=MKdlUY8svMA94b9jq+C+gEiT6a/yET6zQAAKKTsFHh8=; b=pj+41EAWm5bKiFX7g1uyTo1/U6as4eeeErRTXTGIROL8tpwZqcJKlmPHouI10v9krj O9LW7EEU152l0hHEQXr2Hj1jS2ulgL9Z5DrBP3TP+KXL1JasyO96t3rItu7FIjp7l8X0 +YUZhURnbHsjz/fJ1eqmO7Ir2ZZFm9xJABSy4odNB9t5xPrJzhHkVzH3mPFrTeCL78ki zuYIM181liUtk2q6i+ITrLLiONyATPVm4nc/eq55VX20C8IKWTfGfIpkCIsPZD9J+hsU zwk5jFsLlE1GcXxgX5+JfSI68idnLXXxnaEw5h7UH7iYCI1exFu4DDE7Ed1prSmEw7WB ITtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181119; x=1703785919; 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=MKdlUY8svMA94b9jq+C+gEiT6a/yET6zQAAKKTsFHh8=; b=NtKB5CrR1okiPfn6X94KbnKDVi4Z/Ep4jHb+IwonD8hAax+I0pTjFyVeCxCj4zsInG CGKDxFuV0MMtUm47PvxaXaXSUFtx4njzUpIN2fRMRcPbrrfqX75V2JhLIdkliGZTPJdv YgvJwCBuSsQIVCAhmuW0PVgSTKpwcoz7UQgIasziy3ytAAUDU3GntHc8otbSr8FDFT+8 bLGnOZcLwfx/3j2T9zmmrQU8TgY2cbvTPLP7XcNHBrA0CSBRA5uY0AFtQeEedeGOet84 ae081ZXCGkv8jwTxPEzBu7qORHtugJIHQl7HDFv/OBLdE9efjdW0kjZfRj6W8Y/XMANb xdDQ== X-Gm-Message-State: AOJu0Yx7OIHV9XfG5hZ+zBnw5NsncpV3buAz81JdogphLB/dFshnbUiE sS7GmU2a5gZ4RWo996sdQCA8JycWjy/uds/7CxYgez4x7KH6dg== X-Google-Smtp-Source: AGHT+IFyNjfk/OTikiIToyX2lPHzcyjvt0bmANJVLtxHPAB3JxmDGRx7lCUnKGoS5hwuDGEeqehi5g== X-Received: by 2002:a05:6a20:bb14:b0:194:a2e9:aa04 with SMTP id fc20-20020a056a20bb1400b00194a2e9aa04mr52154pzb.11.1703181119353; Thu, 21 Dec 2023 09:51:59 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 05/16] target/riscv: move 'pmp' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:26 -0300 Message-ID: <20231221175137.497379-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181265506100007 Content-Type: text/plain; charset="utf-8" Move 'pmp' to riscv_cpu_properties[], creating a new setter() for it that forbids 'pmp' to be changed in vendor CPUs, like we did with the 'mmu' option. We'll also have to manually set 'pmp =3D true' to generic CPUs that were still relying on the previous default to set it. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 90dd2bccf6..cd20489f1b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -411,6 +411,7 @@ static void riscv_max_cpu_init(Object *obj) RISCVMXL mlx =3D MXL_RV64; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 #ifdef TARGET_RISCV32 mlx =3D MXL_RV32; @@ -430,6 +431,7 @@ static void rv64_base_cpu_init(Object *obj) CPURISCVState *env =3D &cpu->env; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV64, 0); @@ -559,6 +561,7 @@ static void rv128_base_cpu_init(Object *obj) } =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV128, 0); @@ -575,6 +578,7 @@ static void rv32_base_cpu_init(Object *obj) CPURISCVState *env =3D &cpu->env; =20 cpu->cfg.mmu =3D true; + cpu->cfg.pmp =3D true; =20 /* We set this in the realise function */ riscv_cpu_set_misa(env, MXL_RV32, 0); @@ -1526,9 +1530,37 @@ const PropertyInfo prop_mmu =3D { .set =3D prop_mmu_set, }; =20 -Property riscv_cpu_options[] =3D { - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), +static void prop_pmp_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + bool value; + + visit_type_bool(v, name, &value, errp); =20 + if (cpu->cfg.pmp !=3D value && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + return; + } + + cpu->cfg.pmp =3D value; +} + +static void prop_pmp_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool value =3D RISCV_CPU(obj)->cfg.pmp; + + visit_type_bool(v, name, &value, errp); +} + +const PropertyInfo prop_pmp =3D { + .name =3D "pmp", + .get =3D prop_pmp_get, + .set =3D prop_pmp_set, +}; + +Property riscv_cpu_options[] =3D { DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), =20 @@ -1549,6 +1581,7 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ =20 {.name =3D "mmu", .info =3D &prop_mmu}, + {.name =3D "pmp", .info =3D &prop_pmp}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181265; cv=none; d=zohomail.com; s=zohoarc; b=MMtd49oWyk7iWQPQ530BWDVXObg4fyatxPGInfI5eKrrt1u2p5ThybR9wxYUycipbk9+kRE+QZwxTTLunYAuyFpVysC5/b3O+oRLXwp74eBfESu7kaZRAyVTiaivSsQgAZDSG/1gZ8zbT/ywP8JluLPUEGEXLG4/QehGhqt7HUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181265; 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=j91xsS9GxAzzQFt6q9VKwUiC8wXlZKnXVeK5AKolmUI=; b=Oq9uD8uIlJ//0iNJxQxuqMcsbZiBBD30DrBBJjClU7B94n4bEDX43cCjs8DACE12iB1C+JhEdxxeJ5H2GzUW+Phx36ZhAbjr8CqFwKtCUN7ILIub6AOqAdQ9EfdpJr0PETDU4KRaTV8bvKY9X0gu23MzYXlBm67M/lOP+EYhJMM= 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 1703181265265548.4856435250381; Thu, 21 Dec 2023 09:54:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDV-0002bV-Tk; Thu, 21 Dec 2023 12:52:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDN-0002Xf-99 for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:10 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDI-0007yM-LJ for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:08 -0500 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6d946beebe6so679754b3a.1 for ; Thu, 21 Dec 2023 09:52:04 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181122; x=1703785922; 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=j91xsS9GxAzzQFt6q9VKwUiC8wXlZKnXVeK5AKolmUI=; b=jmQGwoIZY4nHMlVD9DiM6YHmW0STPUilPAGfsROSrWsIBHjdPX5UkcBGIThLyAcwrF qpFB4weuWv5Jc8AZcFkKXV0K1Q2b4rq0LPxgUCaKqlZNNky2R6TYzSTkBskBHQgacoYq jhz/+Etb3dMjpbQ7b3b+mW7M8WlMhoPq62LiUEdbRPqw7AQaP7wIQTJvewyezdC9+pxr HIqR2K7md7VLu0xkbGbbbu7s5A1A4So0tuZW433ddF4ZENi4mfOoX1nUV9FhF+1ynM4+ EvWtKtAQnuv1crKrbsEe4+nHQNwhczMDl35Fnf+u9PVW1kXcDZ/7SSTAzH5VHLhSSMf9 3TEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181122; x=1703785922; 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=j91xsS9GxAzzQFt6q9VKwUiC8wXlZKnXVeK5AKolmUI=; b=JPfffV/j67ySBcuFcEJj/cnoNB/qoSi3wxR26RH7hyjB2IWFwiCUWG2E9DDFXQCYdw mo1EWNrbSbCbfJJiLbJ7qe7hx1VDsqXiis4zCUvZGWMdluPyktBcMTznbACxYKdlgKXk WilDHWBZjezEJK+xGUQEQPxxc7hixJa+x8vouMTbzUVPmxt7WcMHXWOYW/6avJWFzgTO Kpw39E8eGzUNmwy4JkiyDXrfiwjOlt7wSXydEVkSJcCEss0cinrGqpl0gRSbRwlHkAGl UfYtXg9lIonHjIM1jdhUtj1KPTf3d4Jic23/aD2s+2blwrZLzKx7X/Oda/gFG+Y3BDdu +D2w== X-Gm-Message-State: AOJu0YztfT8Lf9mEhM9kzZwOD6jJ2zk4wkAEigh+JFQkw7lLiw45WxJm 4+yq6m/eBMXqVeqpKW4PTPY9eoPNGn/GZUBUOM3St4h1l2PHOA== X-Google-Smtp-Source: AGHT+IFebWjFsfiCq8LzhTEdnsiEpDOR8NS1vIzjunvd2LY5uQRaGY4AD3rLS3ZrTIn+QoKNyusvSQ== X-Received: by 2002:a05:6a00:1d20:b0:6d9:40ad:7544 with SMTP id a32-20020a056a001d2000b006d940ad7544mr56357pfx.16.1703181122402; Thu, 21 Dec 2023 09:52:02 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 06/16] target/riscv: rework 'priv_spec' Date: Thu, 21 Dec 2023 14:51:27 -0300 Message-ID: <20231221175137.497379-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::42b; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181265528100008 Content-Type: text/plain; charset="utf-8" 'priv_spec' and 'vext_spec' are two string options used as a fancy way of setting integers in the CPU state (cpu->env.priv_ver and cpu->env.vext_ver). It requires us to deal with string parsing and to store them in cpu_cfg. We must support these string options, but we don't need to store them. We have a precedence for this kind of arrangement in target/ppc/compat.c, ppc_compat_prop_get|set, getters and setters used for the 'max-cpu-compat' class property of the pseries ppc64 machine. We'll do the same with both 'priv_spec' and 'vext_spec'. For 'priv_spec', the validation from riscv_cpu_validate_priv_spec() will be done by the prop_priv_spec_set() setter, while also preventing it to be changed for vendor CPUs. Add two helpers that converts env->priv_ver back and forth to its string representation. These helpers allow us to get a string and set 'env->priv_ver' and return a string giving the current env->priv_ver value. In other words, make the cpu->cfg.priv_spec string obsolete. Last but not the least, move the reworked 'priv_spec' option to riscv_cpu_properties[]. After all said and done, we don't need to store the 'priv_spec' string in the CPU state, and we're now protecting vendor CPUs from priv_ver changes: $ ./build/qemu-system-riscv64 -M virt -cpu sifive-e51,priv_spec=3D"v1.12.0" qemu-system-riscv64: can't apply global sifive-e51-riscv-cpu.priv_spec=3Dv1= .12.0: CPU 'sifive-e51' does not allow changing the value of 'priv_spec' Current 'priv_spec' val: v1.10.0 $ Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 72 +++++++++++++++++++++++++++++++++++++- target/riscv/cpu.h | 3 ++ target/riscv/cpu_cfg.h | 1 - target/riscv/tcg/tcg-cpu.c | 29 --------------- 4 files changed, 74 insertions(+), 31 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index cd20489f1b..4e1813eca7 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1560,8 +1560,76 @@ const PropertyInfo prop_pmp =3D { .set =3D prop_pmp_set, }; =20 +static int priv_spec_from_str(const char *priv_spec_str) +{ + int priv_version =3D -1; + + if (!g_strcmp0(priv_spec_str, PRIV_VER_1_12_0_STR)) { + priv_version =3D PRIV_VERSION_1_12_0; + } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_11_0_STR)) { + priv_version =3D PRIV_VERSION_1_11_0; + } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_10_0_STR)) { + priv_version =3D PRIV_VERSION_1_10_0; + } + + return priv_version; +} + +static const char *priv_spec_to_str(int priv_version) +{ + switch (priv_version) { + case PRIV_VERSION_1_10_0: + return PRIV_VER_1_10_0_STR; + case PRIV_VERSION_1_11_0: + return PRIV_VER_1_11_0_STR; + case PRIV_VERSION_1_12_0: + return PRIV_VER_1_12_0_STR; + default: + return NULL; + } +} + +static void prop_priv_spec_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + g_autofree char *value =3D NULL; + int priv_version =3D -1; + + visit_type_str(v, name, &value, errp); + + priv_version =3D priv_spec_from_str(value); + if (priv_version < 0) { + error_setg(errp, "Unsupported privilege spec version '%s'", value); + return; + } + + if (priv_version !=3D cpu->env.priv_ver && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + error_append_hint(errp, "Current '%s' val: %s\n", name, + object_property_get_str(obj, name, NULL)); + return; + } + + cpu->env.priv_ver =3D priv_version; +} + +static void prop_priv_spec_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + const char *value =3D priv_spec_to_str(cpu->env.priv_ver); + + visit_type_str(v, name, (char **)&value, errp); +} + +const PropertyInfo prop_priv_spec =3D { + .name =3D "priv_spec", + .get =3D prop_priv_spec_get, + .set =3D prop_priv_spec_set, +}; + Property riscv_cpu_options[] =3D { - DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), =20 DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), @@ -1583,6 +1651,8 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "mmu", .info =3D &prop_mmu}, {.name =3D "pmp", .info =3D &prop_pmp}, =20 + {.name =3D "priv_spec", .info =3D &prop_priv_spec}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index cfe965e512..e8a691ca63 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -77,6 +77,9 @@ const char *riscv_get_misa_ext_description(uint32_t bit); #define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) =20 /* Privileged specification version */ +#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" enum { PRIV_VERSION_1_10_0 =3D 0, PRIV_VERSION_1_11_0, diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index c67a8731d3..2dba1f0007 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -135,7 +135,6 @@ struct RISCVCPUConfig { bool ext_XVentanaCondOps; =20 uint32_t pmu_mask; - char *priv_spec; char *vext_spec; uint16_t vlen; uint16_t elen; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index a09300e908..4d67b72d9e 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -175,29 +175,6 @@ static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu,= Error **errp) } } =20 -static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) -{ - CPURISCVState *env =3D &cpu->env; - int priv_version =3D -1; - - if (cpu->cfg.priv_spec) { - if (!g_strcmp0(cpu->cfg.priv_spec, "v1.12.0")) { - priv_version =3D PRIV_VERSION_1_12_0; - } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) { - priv_version =3D PRIV_VERSION_1_11_0; - } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.10.0")) { - priv_version =3D PRIV_VERSION_1_10_0; - } else { - error_setg(errp, - "Unsupported privilege spec version '%s'", - cpu->cfg.priv_spec); - return; - } - - env->priv_ver =3D priv_version; - } -} - static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, Error **errp) { @@ -625,12 +602,6 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Er= ror **errp) CPURISCVState *env =3D &cpu->env; Error *local_err =3D NULL; =20 - riscv_cpu_validate_priv_spec(cpu, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } - riscv_cpu_validate_misa_priv(env, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181291; cv=none; d=zohomail.com; s=zohoarc; b=A6YoOvjvZg9qTx7eDhmwY7R4P6tYCWrV8wMHFiTVNCXAnU8X/g6ir5Y0S/fTqaXKniZKqPSd56fDFQrsR5BgqojVE3QIJR4QUYDDRfGp8d6BZOKTUMFFt/V7K1ZdNy1AnyC9W19M9x0Z5dzCvvMLgSRdLTZwCS9LsJYU+VMoBSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181291; 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=t7vNYKO+kMlnz7z6SCa5hEj3oBRvVO2J0AU4CNFrnNI=; b=hOh4A2v5jV8h0yJzSk+ZxNgiVtnjC5mI8S5Fyz7LTM+8vDUNe5LvZDkpklkIPNv1HidTji8eIJOrqJzTTmhIsFCDuPgSUU4XAvVhK4dg0fVha3CxwbWjnlZQvY3u8OwjkLGyZi4xkt6fOjfzVRhjZfs4bopYSJfYRfkL+vV4FVs= 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 1703181291065447.5789448320345; Thu, 21 Dec 2023 09:54:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDa-0002jH-UF; Thu, 21 Dec 2023 12:52:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDP-0002Yg-HP for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:11 -0500 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDL-0007yb-Tl for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:09 -0500 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5908a63a83fso656138eaf.1 for ; Thu, 21 Dec 2023 09:52:06 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181125; x=1703785925; 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=t7vNYKO+kMlnz7z6SCa5hEj3oBRvVO2J0AU4CNFrnNI=; b=cAcZfSNb4/Wb4Yq7/AX1YSS0v5vo+L7CJhZQDOYvhN9obl6ftw8wueu5ECne7DkRmq BZDfRTuKMJ3Zk07uo1iKJhr3ParBO1r5KUtr89fsk7DhuU7dqHn/Gi6Xrckz0fMxu6iq oYONYQgghEmuXepOdXewbzQJY1QxNbcb0StONy46DCFY9NqOEmE3oqgwDBXEBejp4M/m JrAirZIKqcUlQtmCS1vsuv7rlM2u563DGtrnvzGRBbBBAnik+n81Mkpt8fLCKM3Ad+yh 2vuhra3b3CeLMsEdmv70/yLzfesABN+IPUhY2qfmF6/luu/K9QAxt8WoE7FDj1FRoIxO gPyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181125; x=1703785925; 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=t7vNYKO+kMlnz7z6SCa5hEj3oBRvVO2J0AU4CNFrnNI=; b=mzDg7zbFydc+hw+1yU+F7ym6lv7zcWJ0HkF168co6K3wCISb1Ggb6glXp1FOsnziTT DaBkICL08LwOSwUCo08SCb8TAMpKfWFIoC7o+JSwZsYeOahict2EGrBUNROmVi3Lxvo7 kJe9dLxCz5Onj/Cdj107Z/x1aLKJhTwe6wSL31s6CFtu9o5hC1/ttBNFOvZP2HzW/lJw woM2iPg3afYHzzO6Q4NyLnOroeEZW90ctIM8ZTzyV+WSEd0RD5XUR86rYtSRGdsr/ZKW VFeIlepNCSmn9zdlWbTQOQMkPtz6lqc6lGP5kwr01I0Ot0KhX8+oD+B+8z2gWe0EW8Ve mn7A== X-Gm-Message-State: AOJu0Yw7MeGf7DlBYKGKFZLh0pQ9VK/MRG5hm6anU0ygMyGFMuevGJp5 paET7cFMSLdSEr8v2/0l8NqaAu3IM3cM5mPvq2iTX1LU6xgw/w== X-Google-Smtp-Source: AGHT+IFStQjqWaOnkcjzyg1zbX/02XkxNBOQSLVYZsCvvdFZSefGOguWy2BmtQX9OxpzVzFfhJ+9Cw== X-Received: by 2002:a05:6358:7215:b0:173:a62:a523 with SMTP id h21-20020a056358721500b001730a62a523mr154349rwa.15.1703181125443; Thu, 21 Dec 2023 09:52:05 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 07/16] target/riscv: rework 'vext_spec' Date: Thu, 21 Dec 2023 14:51:28 -0300 Message-ID: <20231221175137.497379-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::c36; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc36.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1703181291635100005 Content-Type: text/plain; charset="utf-8" The same rework did in 'priv_spec' is done for 'vext_spec'. This time is simpler, since we only accept one value ("v1.0") and we'll always have env->vext_ver set to VEXT_VERSION_1_00_0, thus we don't need helpers to convert string to 'vext_ver' back and forth like we needed for 'priv_spec'. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 42 ++++++++++++++++++++++++++++++++++---- target/riscv/cpu.h | 1 + target/riscv/cpu_cfg.h | 1 - target/riscv/tcg/tcg-cpu.c | 15 -------------- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4e1813eca7..05ca458177 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1237,6 +1237,8 @@ static void riscv_cpu_post_init(Object *obj) =20 static void riscv_cpu_init(Object *obj) { + RISCVCPU *cpu =3D RISCV_CPU(obj); + #ifndef CONFIG_USER_ONLY qdev_init_gpio_in(DEVICE(obj), riscv_cpu_set_irq, IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); @@ -1249,8 +1251,11 @@ static void riscv_cpu_init(Object *obj) * for all CPUs. Each accelerator will decide what to do when * users disable them. */ - RISCV_CPU(obj)->cfg.ext_zicntr =3D true; - RISCV_CPU(obj)->cfg.ext_zihpm =3D true; + cpu->cfg.ext_zicntr =3D true; + cpu->cfg.ext_zihpm =3D true; + + /* vext_spec is always 1_00_0 */ + cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; } =20 typedef struct misa_ext_info { @@ -1629,9 +1634,37 @@ const PropertyInfo prop_priv_spec =3D { .set =3D prop_priv_spec_set, }; =20 -Property riscv_cpu_options[] =3D { - DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), +static void prop_vext_spec_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + g_autofree char *value =3D NULL; + + visit_type_str(v, name, &value, errp); + + if (!g_strcmp0(value, VEXT_VER_1_00_0_STR)) { + error_setg(errp, "Unsupported vector spec version '%s'", value); + return; + } + + cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; +} + +static void prop_vext_spec_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + const char *value =3D VEXT_VER_1_00_0_STR; =20 + visit_type_str(v, name, (char **)&value, errp); +} + +const PropertyInfo prop_vext_spec =3D { + .name =3D "vext_spec", + .get =3D prop_vext_spec_get, + .set =3D prop_vext_spec_set, +}; + +Property riscv_cpu_options[] =3D { DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), =20 @@ -1652,6 +1685,7 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "pmp", .info =3D &prop_pmp}, =20 {.name =3D "priv_spec", .info =3D &prop_priv_spec}, + {.name =3D "vext_spec", .info =3D &prop_vext_spec}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e8a691ca63..53101b82c5 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,6 +89,7 @@ enum { }; =20 #define VEXT_VERSION_1_00_0 0x00010000 +#define VEXT_VER_1_00_0_STR "v1.0" =20 enum { TRANSLATE_SUCCESS, diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 2dba1f0007..7112af6c4c 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -135,7 +135,6 @@ struct RISCVCPUConfig { bool ext_XVentanaCondOps; =20 uint32_t pmu_mask; - char *vext_spec; uint16_t vlen; uint16_t elen; uint16_t cbom_blocksize; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 4d67b72d9e..6501c29d8e 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -201,21 +201,6 @@ static void riscv_cpu_validate_v(CPURISCVState *env, R= ISCVCPUConfig *cfg, "in the range [8, 64]"); return; } - - if (cfg->vext_spec) { - if (!g_strcmp0(cfg->vext_spec, "v1.0")) { - env->vext_ver =3D VEXT_VERSION_1_00_0; - } else { - error_setg(errp, "Unsupported vector spec version '%s'", - cfg->vext_spec); - return; - } - } else if (env->vext_ver =3D=3D 0) { - qemu_log("vector version is not specified, " - "use the default value v1.0\n"); - - env->vext_ver =3D VEXT_VERSION_1_00_0; - } } =20 static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu) --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181182; cv=none; d=zohomail.com; s=zohoarc; b=bka+YfqUl5QcydWyE6BRkwmsMMr7da82AXshHgBlUrkoaE6qSVn9Ap3BZ/50jvchxs9DD6bxx6ZEW7sbALVKjQtzOkRcW1yaIS0o4QcOMfUS/zC16FeuLAMLy6+eurkjCeiO5uZE8DraNNMocz5D/1DTg5kM4Nwwj2zUC3BU3Tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181182; 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=LmRiBNvSK1/WWjcJN4KBMD6UDGCABgLI6wNrc0EXRj0=; b=htDUGNrxYQ39s1U4kuWXU/WAqx//ivrOYAWOc4pTnmUsfkloQkhf99UwkzfvkqgvskDVzzTHJkEFz6vH/pqdULgFNVtMs6wkVWvTyFDkmBrbs+QvfTJ8MVHtYa0GuEfW3MNee7dnFhNAWnV0Cuq/UBAF73GDzJKjczJdlvzAZCU= 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 1703181182367933.0854975594058; Thu, 21 Dec 2023 09:53:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDY-0002bn-F6; Thu, 21 Dec 2023 12:52:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDS-0002ZX-Nr for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:14 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDQ-0007z0-0c for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:14 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6d728c75240so980052b3a.1 for ; Thu, 21 Dec 2023 09:52:11 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181128; x=1703785928; 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=LmRiBNvSK1/WWjcJN4KBMD6UDGCABgLI6wNrc0EXRj0=; b=ToFTmn3XxRw44FoUc4Kz6DFdlSlgdpo+BwrQXTXspnBW0rCFCGBPzN2lJgDKAr+KNE llck2+4Fshb+Cos996+jQ/1Y6bYXi8kxqIQAdwEYWAhO0R9WB+daSOa4/yj4VQpvixox Z4+esHYieWty3/zxx3RbM3wm4G0fSbIObqBNdC/ICTpujEyVuQv71kG83qYsnyIxVO5p fX0NBop5hAPr+HlDb2Uu8OgIbz9tJ5XehCs+xN8yKsrzpaD4JNTm+p/6Y9bNuEBx08B8 iNOmjiP6WB6xwr3AsELZtOQA0ViXHpg1k14IhFqN5N2d0eujMOzljmDKe5xGDe3PhMOq SWsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181128; x=1703785928; 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=LmRiBNvSK1/WWjcJN4KBMD6UDGCABgLI6wNrc0EXRj0=; b=wOXkQa6746AYGUnZL1sepXTCqQRitAOyjjsl2L0E9ByJbRsRk/2mUqnr1LaRCgT0y3 FM1TuYvTIjzVizVp1PqHLLkF1/AIjKS7lWDujTau/ZAr+/FWGoDJgOgPJJDOeULwrebJ nK60jgioYueWfhu1K0zJ+KPBRTWw+BCOpD3h+3oEqWKq4RL1VIOEUIYHNZNiAao645T7 lBOt2o84F723vUbdiTtISkYZ0tZTs0maaXvm2fY1g4A4WQ5DhzgjAKjFiZHxYVY93oxP 9nMKsDBfsqGbvi4E1fx2vyt4lNijJsOAKOyVVgC4OQtkrmK0kuELqvKUqZaX5aLsIro9 GGNw== X-Gm-Message-State: AOJu0YyedNjeTAULwAwHJ2l6ofMnXtUCrj/Usk0VsgoURb7FHa1Dz99B YedxdpO1eLzCrO366Nb8vzo2HX6Fly0CWr98NEbIOycqTZwQIA== X-Google-Smtp-Source: AGHT+IEgbHauXBUn0tgMbYt/Qc/Q8FzR4ou+9qB6AgogyM4M8OE90r4tIXIZKymM14A258HLYXyHzQ== X-Received: by 2002:a05:6a20:7491:b0:18f:e56b:9848 with SMTP id p17-20020a056a20749100b0018fe56b9848mr63275pzd.13.1703181128450; Thu, 21 Dec 2023 09:52:08 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 08/16] target/riscv: move 'vlen' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:29 -0300 Message-ID: <20231221175137.497379-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::432; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1703181183121100001 Content-Type: text/plain; charset="utf-8" Turning 'vlen' into a class property will allow its default value to be overwritten by cpu_init() later on, solving the issue we have now where CPU specific settings are getting overwritten by the default. For 'vlen', 'elen' and the blocksize options we need a way of tracking if the user set a value for them. This is benign for TCG since the cost of always validating these values are small, but for KVM we need syscalls to read the host values to make the validations. Knowing whether the user didn't touch the values makes a difference. We'll track user setting for these properties using a hash, like we do in the TCG driver. Common validation bits are moved from riscv_cpu_validate_v() to prop_vlen_set() to be shared with KVM. And, as done with every option we migrated to riscv_cpu_properties[], vendor CPUs can't have their 'vlen' value changed. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 63 +++++++++++++++++++++++++++++++++++++- target/riscv/tcg/tcg-cpu.c | 5 --- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 05ca458177..b75d9dee3c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -29,6 +29,7 @@ #include "qapi/visitor.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/core/qdev-prop-internal.h" #include "migration/vmstate.h" #include "fpu/softfloat-helpers.h" #include "sysemu/kvm.h" @@ -53,6 +54,15 @@ const uint32_t misa_bits[] =3D {RVI, RVE, RVM, RVA, RVF,= RVD, RVV, #define BYTE(x) (x) #endif =20 +/* Hash that stores general user set numeric options */ +static GHashTable *general_user_opts; + +static void cpu_option_add_user_setting(const char *optname, uint32_t valu= e) +{ + g_hash_table_insert(general_user_opts, (gpointer)optname, + GUINT_TO_POINTER(value)); +} + #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 @@ -1244,6 +1254,8 @@ static void riscv_cpu_init(Object *obj) IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); #endif /* CONFIG_USER_ONLY */ =20 + general_user_opts =3D g_hash_table_new(g_str_hash, g_str_equal); + /* * The timer and performance counters extensions were supported * in QEMU before they were added as discrete extensions in the @@ -1664,8 +1676,54 @@ const PropertyInfo prop_vext_spec =3D { .set =3D prop_vext_spec_set, }; =20 +static void prop_vlen_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint16_t value; + + if (!visit_type_uint16(v, name, &value, errp)) { + return; + } + + if (!is_power_of_2(value)) { + error_setg(errp, "Vector extension VLEN must be power of 2"); + return; + } + + /* Always allow setting a default value */ + if (cpu->cfg.vlen =3D=3D 0) { + cpu->cfg.vlen =3D value; + return; + } + + if (value !=3D cpu->cfg.vlen && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + error_append_hint(errp, "Current '%s' val: %u\n", + name, cpu->cfg.vlen); + return; + } + + cpu_option_add_user_setting(name, value); + cpu->cfg.vlen =3D value; +} + +static void prop_vlen_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint16_t value =3D RISCV_CPU(obj)->cfg.vlen; + + visit_type_uint16(v, name, &value, errp); +} + +const PropertyInfo prop_vlen =3D { + .name =3D "vlen", + .get =3D prop_vlen_get, + .set =3D prop_vlen_set, + .set_default_value =3D qdev_propinfo_set_default_value_uint, +}; + Property riscv_cpu_options[] =3D { - DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), =20 DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), @@ -1687,6 +1745,9 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "priv_spec", .info =3D &prop_priv_spec}, {.name =3D "vext_spec", .info =3D &prop_vext_spec}, =20 + {.name =3D "vlen", .info =3D &prop_vlen, + .set_default =3D true, .defval.u =3D 128}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 6501c29d8e..8ec858e096 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -178,11 +178,6 @@ static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu,= Error **errp) static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, Error **errp) { - if (!is_power_of_2(cfg->vlen)) { - error_setg(errp, "Vector extension VLEN must be power of 2"); - return; - } - if (cfg->vlen > RV_VLEN_MAX || cfg->vlen < 128) { error_setg(errp, "Vector extension implementation only supports VLEN " --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181240; cv=none; d=zohomail.com; s=zohoarc; b=EeCoPkV0J7B8RvM6nvxvSvKdyjVORxoupBm9VyaqH8a34Wsl/aOBcKP/lpH71qUCbdDRIDBGk/aX1xfZYnp5AW2y5ydRTEEr7edxxT540T0S3tlWfT2UzLpNV9S/OV2UO2/BV7j8NHffsb6LZ5hUvxfWw34XGiPOr8hFSC9OFhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181240; 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=HpmUU/M2F0JQBGZ1AE03p/H6VED1FMWRt3KvMis82zE=; b=d6nucukn4QhCCnnFZbfNiubRjuHp2Qd0pMxm1rGGAbNFqIrgYLl0y1JMgjyw4JLdVBBajngdOaaYA9xvaFeRCDuqLISG6gRWbB039FbHaG3t18wgKVdLITevbGFzuLhxT4x1VhhCxoXNiuUzqGWGlyGVp1IMdU35stC/hJvzkhk= 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 1703181240293272.47893913327505; Thu, 21 Dec 2023 09:54:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDk-0002xQ-1W; Thu, 21 Dec 2023 12:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDU-0002ad-LP for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:16 -0500 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDR-0007zM-CB for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:15 -0500 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-593fbe8147fso589576eaf.2 for ; Thu, 21 Dec 2023 09:52:12 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181131; x=1703785931; 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=HpmUU/M2F0JQBGZ1AE03p/H6VED1FMWRt3KvMis82zE=; b=Qf8nINca8pZt0flAkc3ua7PDJmHItW5WFCLTlgMZVwI4rttcchFrSNB4GyuGVnSKwO gh2ulIbV1dVGEeLY/WfvxMxY2+8OFUxQzzKpFStMEuE67+mcv2kWKyJ2hsA+trpHwyHy gf5fy0Nq2wWe/iSkDgBeGIvWJJM/LHlfF/fkums+bKo4bb+FOp4oqbqJKsiJ7IoZUvb9 gebKwN3pGvw6PK8PtJ04IMN5s9wkyaMaxzYmDab5N1oux3ICHwYWpFqpVfMVc8wYRkUB gEXZqmAGXQJmG8QwaHbWxxgjGC6KeO+oSWcURkSANhHjaPDq+Q2eRkqUUL713gi7PnCF WkDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181131; x=1703785931; 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=HpmUU/M2F0JQBGZ1AE03p/H6VED1FMWRt3KvMis82zE=; b=abiTZlhPMdya7VJ6QirTwJWszPaxSaaFJQkttGXGyS7cL8LLCWnq4h9P//5PLaG3fL Pq+iUNGCk702318AOHgP56BjrPF3NZencV3qkXitJJBVUu4k93pjdAXAr/mNO0SxBafE EzbIfNpDP8gHPKPhkIhckl7mpIBtxLfl9/NZtZQhauJBnvv7WIM4J2G1q7R6eKWx/oOr JlfcHTpQGLN8gFBn4AWnMAQiIlpLN8C8gcDhOsvamEcWVjwtTNn7j4XCeQ5damWCiIla Ca9RhZhR86TZQQRs4rRw+TkwQosKQQSEz3dkyMeHkCOC4lTKE08uxKxxh39QrfQjsnlt AyHg== X-Gm-Message-State: AOJu0Yy6+4ZseODRk0u7y4EtT05tM7b5+qSQHJzt2tcUGBbaiit2TIh1 D9vVEp9Xe27VU0+W47PuyGzObRYOFr8im9svJ2+VB3PB874llg== X-Google-Smtp-Source: AGHT+IGWxxo1X1OGUpvhclNrzlJGTZaDl39TCrd7+a27HyK/yBNlsCXkkxGE3MPSRX3Eu5+lnQ/Y5w== X-Received: by 2002:a05:6358:1a91:b0:173:3300:d901 with SMTP id gm17-20020a0563581a9100b001733300d901mr120519rwb.38.1703181131426; Thu, 21 Dec 2023 09:52:11 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 09/16] target/riscv: move 'elen' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:30 -0300 Message-ID: <20231221175137.497379-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::c34; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc34.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181241423100001 Content-Type: text/plain; charset="utf-8" Do the same thing we did with 'vlen' in the previous patch with 'elen'. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 52 ++++++++++++++++++++++++++++++++++++-- target/riscv/tcg/tcg-cpu.c | 5 ---- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b75d9dee3c..aec1968cad 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1723,9 +1723,54 @@ const PropertyInfo prop_vlen =3D { .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 -Property riscv_cpu_options[] =3D { - DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), +static void prop_elen_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint16_t value; + + if (!visit_type_uint16(v, name, &value, errp)) { + return; + } + + if (!is_power_of_2(value)) { + error_setg(errp, "Vector extension ELEN must be power of 2"); + return; + } + + /* Always allow setting a default value */ + if (cpu->cfg.elen =3D=3D 0) { + cpu->cfg.elen =3D value; + return; + } + + if (value !=3D cpu->cfg.elen && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + error_append_hint(errp, "Current '%s' val: %u\n", + name, cpu->cfg.elen); + return; + } + + cpu_option_add_user_setting(name, value); + cpu->cfg.elen =3D value; +} + +static void prop_elen_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint16_t value =3D RISCV_CPU(obj)->cfg.elen; =20 + visit_type_uint16(v, name, &value, errp); +} + +const PropertyInfo prop_elen =3D { + .name =3D "elen", + .get =3D prop_elen_get, + .set =3D prop_elen_set, + .set_default_value =3D qdev_propinfo_set_default_value_uint, +}; + +Property riscv_cpu_options[] =3D { DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 @@ -1748,6 +1793,9 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "vlen", .info =3D &prop_vlen, .set_default =3D true, .defval.u =3D 128}, =20 + {.name =3D "elen", .info =3D &prop_elen, + .set_default =3D true, .defval.u =3D 64}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 8ec858e096..84064ef7e0 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -185,11 +185,6 @@ static void riscv_cpu_validate_v(CPURISCVState *env, R= ISCVCPUConfig *cfg, return; } =20 - if (!is_power_of_2(cfg->elen)) { - error_setg(errp, "Vector extension ELEN must be power of 2"); - return; - } - if (cfg->elen > 64 || cfg->elen < 8) { error_setg(errp, "Vector extension implementation only supports ELEN " --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181236; cv=none; d=zohomail.com; s=zohoarc; b=Z896s/cm/NMI4u9w7LFgLR+E11mlyzAssOP2LrODQVSNRHLs/Z/+25c55+WvQnefLY/QatGCMyyNPaip7M+CgMeOaL690ZyrFg8Ec+nv/trLLOcRt7P8fdOKTLTRl8v0abv4//9HFhfwPMmnd0tSCNmOPQpWAO3SFsmviK/5a6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181236; 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=hSBipYs1ja9hQ+IdxMnaSg+JbEymd7tED/lgmeFP+2A=; b=evonM3efSDbtFMYX0VRHY41RSEfHEDksvqskA+v9aIVgU+lwUfQwKAqHLLS2vDW/AkZcRFTZww52SoSP9jUHcClPDSn0KQxg2Lff+Flcz+4OYYLUQXK0I+1zAoYQnGJE77ADNbb0zpNpSgSSV2EHLsMLzQi16XoNkjP7LrplrVI= 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 1703181236338386.2463003781496; Thu, 21 Dec 2023 09:53:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDl-00037l-Dp; Thu, 21 Dec 2023 12:52:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDZ-0002cV-7C for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:21 -0500 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 1rGNDU-000807-GW for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:20 -0500 Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-7b3b819f8a3so52811739f.1 for ; Thu, 21 Dec 2023 09:52:16 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181134; x=1703785934; 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=hSBipYs1ja9hQ+IdxMnaSg+JbEymd7tED/lgmeFP+2A=; b=Bp0BMkCdYA51wJoOD8R+U613fi9EwRoFovnn6x/ArylilaJY+9xTg0mAX4AdnVZU0N 28biYe6i/dTpkZO3tE2ILJyRArA5mtrRZlr10TwTfukhSsx9hiu++fUgBIpqQ0fB6C5H 9ssQrh6ma9L0QrRw17OUpZLpquJJLM1emj5O/zZuR13Q+AXSaYjyrSArnnXICR1Br39P +HZfmq/uhJLdfwiQv5NZ9gUU/K3woxWu1uNC2EhNGKB0r8U4rQQS275i/0VLum2J6uVj QUtX6bXbdiNHys0lRvIxNIrQn8EG/kJ9+sh/wLK4aztDPTLuWp9KdmnYhSiTpCz8n8j9 eUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181134; x=1703785934; 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=hSBipYs1ja9hQ+IdxMnaSg+JbEymd7tED/lgmeFP+2A=; b=bNaNVjwzQa99VEUPHmdrteuyexheVqNve/UvsFu9wvezxr39j0z83vC1nHKY5ivDxM DYSkRw0jew5y9388wu7hutlnLQZ+J3HmmCbPIl0PifJt9Fbo1jP88+2OSc0BqJ6/PHLX 5usOx524tIA6Qjm2EVxJ+ybJvtaK8zqFXM1J7pa8QEjhhCfid6X0ammJAF3mQrwn+194 4bwZ35Iu7lPNNSIxFbpqIxtIamoUocCr1FM3ZdFDZh0wYv32CHpF3zrionZfPbJQ+ABf o4gKDpNiHQm3uUC8eBThzVBqvZfzwLntCCQf3bAzyCO4u3967c+EauFmTQ67T8T8fmww lO4Q== X-Gm-Message-State: AOJu0YzyGaNS5Ovqf2TxrWaDm8z3m0rW85CGSytad9tsFiLV5jJfosBv ZXNN6B7X/+sbZeRe0aSUqSN4OxgILgB7wLDe0ju9Wg== X-Google-Smtp-Source: AGHT+IF2eaThLi06BT+Oyuavd5o69LImy0603i33yeqSCaUxLqAKkfKqV1cT/VGwCGpAULgo/A1lNg== X-Received: by 2002:a05:6e02:1bc6:b0:35d:59a2:bb1 with SMTP id x6-20020a056e021bc600b0035d59a20bb1mr21687163ilv.71.1703181134446; Thu, 21 Dec 2023 09:52:14 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 10/16] target/riscv: create finalize_features() for KVM Date: Thu, 21 Dec 2023 14:51:31 -0300 Message-ID: <20231221175137.497379-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::d33; envelope-from=dbarboza@ventanamicro.com; helo=mail-io1-xd33.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181237413100001 Content-Type: text/plain; charset="utf-8" To turn cbom_blocksize and cboz_blocksize into class properties we need KVM specific changes. KVM is creating its own version of these options with a customized setter() that prevents users from picking an invalid value during init() time. This comes at the cost of duplicating each option that KVM supports. This will keep happening for each new shared option KVM implements in the future. We can avoid that by using the same property TCG uses and adding specific KVM handling during finalize() time, like TCG already does with riscv_tcg_cpu_finalize_features(). To do that, the common CPU property offers a way of knowing if an option was user set or not, sparing us from doing unneeded syscalls. riscv_kvm_cpu_finalize_features() is then created using the same KVMScratch CPU we already use during init() time, since finalize() time is still too early to use the official KVM CPU for it. cbom_blocksize and cboz_blocksize are then handled during finalize() in the same way they're handled by their KVM specific setter. With this change we can proceed with the blocksize changes in the common code without breaking the KVM driver. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 16 +++++++--- target/riscv/cpu.h | 1 + target/riscv/kvm/kvm-cpu.c | 59 ++++++++++++++++++++++++++++++++++++ target/riscv/kvm/kvm_riscv.h | 1 + 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index aec1968cad..d7e74b3428 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -63,6 +63,11 @@ static void cpu_option_add_user_setting(const char *optn= ame, uint32_t value) GUINT_TO_POINTER(value)); } =20 +bool riscv_cpu_option_set(const char *optname) +{ + return g_hash_table_contains(general_user_opts, optname); +} + #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 @@ -1056,17 +1061,18 @@ void riscv_cpu_finalize_features(RISCVCPU *cpu, Err= or **errp) { Error *local_err =3D NULL; =20 - /* - * KVM accel does not have a specialized finalize() - * callback because its extensions are validated - * in the get()/set() callbacks of each property. - */ if (tcg_enabled()) { riscv_tcg_cpu_finalize_features(cpu, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); return; } + } else if (kvm_enabled()) { + riscv_kvm_cpu_finalize_features(cpu, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } } =20 #ifndef CONFIG_USER_ONLY diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 53101b82c5..988471c7ba 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -495,6 +495,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, in= t size, bool probe, uintptr_t retaddr); char *riscv_isa_string(RISCVCPU *cpu); void riscv_cpu_list(void); +bool riscv_cpu_option_set(const char *optname); =20 #define cpu_list riscv_cpu_list #define cpu_mmu_index riscv_cpu_mmu_index diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 62a1e51f0a..70fb075846 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1490,6 +1490,65 @@ static void kvm_cpu_instance_init(CPUState *cs) } } =20 +void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp) +{ + CPURISCVState *env =3D &cpu->env; + KVMScratchCPU kvmcpu; + struct kvm_one_reg reg; + uint64_t val; + int ret; + + /* short-circuit without spinning the scratch CPU */ + if (!cpu->cfg.ext_zicbom && !cpu->cfg.ext_zicboz) { + return; + } + + if (!kvm_riscv_create_scratch_vcpu(&kvmcpu)) { + error_setg(errp, "Unable to create scratch KVM cpu"); + return; + } + + if (cpu->cfg.ext_zicbom && + riscv_cpu_option_set(kvm_cbom_blocksize.name)) { + + reg.id =3D kvm_riscv_reg_id_ulong(env, KVM_REG_RISCV_CONFIG, + kvm_cbom_blocksize.kvm_reg_id); + reg.addr =3D (uint64_t)&val; + ret =3D ioctl(kvmcpu.cpufd, KVM_GET_ONE_REG, ®); + if (ret !=3D 0) { + error_setg(errp, "Unable to read cbom_blocksize, error %d", er= rno); + return; + } + + if (cpu->cfg.cbom_blocksize !=3D val) { + error_setg(errp, "Unable to set cbom_blocksize to a different " + "value than the host (%lu)", val); + return; + } + } + + if (cpu->cfg.ext_zicboz && + riscv_cpu_option_set(kvm_cboz_blocksize.name)) { + + reg.id =3D kvm_riscv_reg_id_ulong(env, KVM_REG_RISCV_CONFIG, + kvm_cboz_blocksize.kvm_reg_id); + reg.addr =3D (uint64_t)&val; + ret =3D ioctl(kvmcpu.cpufd, KVM_GET_ONE_REG, ®); + if (ret !=3D 0) { + error_setg(errp, "Unable to read cbom_blocksize, error %d", er= rno); + return; + } + + if (cpu->cfg.cboz_blocksize !=3D val) { + error_setg(errp, "Unable to set cboz_blocksize to a different " + "value than the host (%lu)", val); + return; + } + } + + kvm_riscv_destroy_scratch_vcpu(&kvmcpu); +} + static void kvm_cpu_accel_class_init(ObjectClass *oc, void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); diff --git a/target/riscv/kvm/kvm_riscv.h b/target/riscv/kvm/kvm_riscv.h index 8329cfab82..4bd98fddc7 100644 --- a/target/riscv/kvm/kvm_riscv.h +++ b/target/riscv/kvm/kvm_riscv.h @@ -27,5 +27,6 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t= group_shift, uint64_t guest_num); void riscv_kvm_aplic_request(void *opaque, int irq, int level); int kvm_riscv_sync_mpstate_to_kvm(RISCVCPU *cpu, int state); +void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp); =20 #endif --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181223; cv=none; d=zohomail.com; s=zohoarc; b=WzsEveNN6EhwFtUrMu4ukUFuk4k3T/OmrbWVAFZkTG5PmZMBQlNgV2VHuALHNr2fBZ5XyGpCuYWVaSvZ/tFnijv09ZUsXnG0NEg3I35DdlhmgZltcD2ZejR8GwagP+M9bsBuXLkLdL9u+lhk1/XlrWB3QeBdy8UE5jsMxVy3EyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181223; 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=4olk1Up+J1VxObz2v3pFn9j6hG/SkOyJiBwWz2BpzGo=; b=YUCc7vqhHjStUbLp9dqs9+WIG5mAU4t7uVZEjtPpzAx62YGzCAyb7yNitm0moNZu/Dkkc8zXXGpLd+e3UDdicSvGPXPgAlMZXTzEwFKrlEymROUdVQdjE6sU0O+PmPUoXPX05JvB5ZY0crzqlNxUgllje99RVKQKyJJBMpoXwkk= 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 1703181223183924.0202068024137; Thu, 21 Dec 2023 09:53:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDk-00034H-Sn; Thu, 21 Dec 2023 12:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDb-0002m0-4e for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:23 -0500 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDX-00080e-GM for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:21 -0500 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-35fd867fa40so2228605ab.3 for ; Thu, 21 Dec 2023 09:52:18 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181137; x=1703785937; 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=4olk1Up+J1VxObz2v3pFn9j6hG/SkOyJiBwWz2BpzGo=; b=j8/obxYMpHdmmRTlMT1RljpDMB+67a9MwmN7i3xRKO04863biKsvorFjZmMEiEngiv x4D9sAbS8tBXPfL+YZi8uZmOC4iXv3TiKciu49f36BRK4BEK/7vs/tidxOD4ryRM+dkr pW2Ls+2IslO3VLqe7jlBOUFy+4+rEw8y1QS7E/Zv5pHVIhLRabhQ036FP7OXrv1Qvqur Yu+O5VjUaSKCcvw7oCh+x5z1/Xg5dynDUHa3A5TPSIeEZDj/erjPIbTz1BMOxID3Zur7 TMLxs3n0q3cRzBLpC/V+uchojbC7GynCwMd7SrO5vyqKuPELV70ecCctpLt6WgYpNVtp jsHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181137; x=1703785937; 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=4olk1Up+J1VxObz2v3pFn9j6hG/SkOyJiBwWz2BpzGo=; b=eoH3dLEbwVny69vUcytTPD88ukTHxpuSRIIYd8B6A6C6zA9uESEGfLb9HsXau7Dg35 to8XBrUPIWU77ZCr19IOQwSrtJ9VbXvXp+wiGHDCfDxhNnn5cxVYGF/a06SNu3Vyix0T OTQS8qbGjLcd9m0P+bdBDlH/QTU0hpKf48FRKwnJUWuAhwitirLCu9fWTseJbDOEP1YK JaznPAigxuQ4fEdIdf5eVAm3GNZHd38AA6SkQYPUoG3HkXB7yuvIU8AxCMvL5zNu4bHk bOyliagiJmPE6hM7QiKUu6xd2TgcyV4vZX7V4UP+CdCmOlJfLDRtcsk1LCtRyhZCbRpn hakQ== X-Gm-Message-State: AOJu0YxEjF0BphaNp76jjdaF7dFXtg+ZmkGggANnQf0/J6LONR72sjGK joB6eMe7e6gR4gJs163GkBnypMjL83PyCVpvSK3GmaRorK1PsA== X-Google-Smtp-Source: AGHT+IFdDPOGVOQ07hoGvns3AINBcd8kQiZuGcVkoeNqSz1dHphAepjAgikUR6XCj8LIPiRNZ5hPjg== X-Received: by 2002:a92:cd89:0:b0:35f:b75f:5392 with SMTP id r9-20020a92cd89000000b0035fb75f5392mr2965ilb.5.1703181137517; Thu, 21 Dec 2023 09:52:17 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 11/16] target/riscv: move 'cbom_blocksize' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:32 -0300 Message-ID: <20231221175137.497379-12-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::12a; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x12a.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181225338100006 Content-Type: text/plain; charset="utf-8" After adding a KVM finalize() implementation, turn cbom_blocksize into a class property. Follow the same design we used with 'vlen' and 'elen'. The duplicated 'cbom_blocksize' KVM property can be removed from kvm_riscv_add_cpu_user_properties(). Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 46 +++++++++++++++++++++++++++++++++++++- target/riscv/kvm/kvm-cpu.c | 4 ---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d7e74b3428..6c17ab35c5 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1776,8 +1776,49 @@ const PropertyInfo prop_elen =3D { .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 +static void prop_cbom_blksize_set(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint16_t value; + + if (!visit_type_uint16(v, name, &value, errp)) { + return; + } + + /* Always allow setting a default value */ + if (cpu->cfg.cbom_blocksize =3D=3D 0) { + cpu->cfg.cbom_blocksize =3D value; + return; + } + + if (value !=3D cpu->cfg.cbom_blocksize && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + error_append_hint(errp, "Current '%s' val: %u\n", + name, cpu->cfg.cbom_blocksize); + return; + } + + cpu_option_add_user_setting(name, value); + cpu->cfg.cbom_blocksize =3D value; +} + +static void prop_cbom_blksize_get(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + uint16_t value =3D RISCV_CPU(obj)->cfg.cbom_blocksize; + + visit_type_uint16(v, name, &value, errp); +} + +const PropertyInfo prop_cbom_blksize =3D { + .name =3D "cbom_blocksize", + .get =3D prop_cbom_blksize_get, + .set =3D prop_cbom_blksize_set, + .set_default_value =3D qdev_propinfo_set_default_value_uint, +}; + Property riscv_cpu_options[] =3D { - DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 DEFINE_PROP_END_OF_LIST(), @@ -1802,6 +1843,9 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "elen", .info =3D &prop_elen, .set_default =3D true, .defval.u =3D 64}, =20 + {.name =3D "cbom_blocksize", .info =3D &prop_cbom_blksize, + .set_default =3D true, .defval.u =3D 64}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 70fb075846..1866b56913 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -484,10 +484,6 @@ static void kvm_riscv_add_cpu_user_properties(Object *= cpu_obj) NULL, multi_cfg); } =20 - object_property_add(cpu_obj, "cbom_blocksize", "uint16", - NULL, kvm_cpu_set_cbomz_blksize, - NULL, &kvm_cbom_blocksize); - object_property_add(cpu_obj, "cboz_blocksize", "uint16", NULL, kvm_cpu_set_cbomz_blksize, NULL, &kvm_cboz_blocksize); --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181226; cv=none; d=zohomail.com; s=zohoarc; b=gnVj4MlyipsJCuyvsDad4Z98kp9guDBBaI3qygNwUkicR0hjM80+f5ovbySp89vTKYp0eb47Nts5MVGmfqxiSmy1TOW3HS0nNX5NDPwhYsIQ8rcu9rs37YDEWIIinkx1waTWoO486sErfgPbvCS3g3zIUWWKXHdrD5e/Vf4Coxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181226; 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=/c0+chL/1/wo56zTWm7IMp8vXHjZfJ8gLBsE3lmAjX8=; b=GE9QcFzfAqT1Gg/W946zrWwt+xfXBRn3DB8F7z9ZQ9O5nC8sgeC33SJd/qaYLSb8OVsQ7CMCaahs/mE4XHxX+Og5pGX54ha8lf4WKB/XBZYB/W5VsXbCGIv5OYyteWHICKFD6wMoncQx/incXhT+8by+bcV62DSvr2GeZyhS85g= 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 1703181226745673.8468361305208; Thu, 21 Dec 2023 09:53:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDn-0003AI-08; Thu, 21 Dec 2023 12:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDd-0002qm-Es for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:26 -0500 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDa-00080y-Ma for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:24 -0500 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7b7f3eda169so51511039f.2 for ; Thu, 21 Dec 2023 09:52:21 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181140; x=1703785940; 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=/c0+chL/1/wo56zTWm7IMp8vXHjZfJ8gLBsE3lmAjX8=; b=HZovo3U1i2y1xp0iCkemedgw3YMRVhpOLpP/nn8AqlRgc1FZLLAlhtl/3Cg4/0vtHx upztLm/DzdmRWS+MSpEWHeIPHGaUIVDHQnWLHK10Patk0CvVVYUJrMSsXbAFFK5VhVIX 1YX1CnufjZ6xBYzjn7w9g1J6VZMPywYln2i9v3YmFTeD57DVQSQYjO00DzC7FfV9+ADJ nBTlJdn6+bZR0W/l9w8hUnOVOErW+yrfwBRocFQNVR6ow+fxP8xczW/WzH8kwJvIETvp JznLTCVBPoN3aIS0DgcorNjjD5pPjOZE6SirxIN0fsiVRoRgzUTB0TeFD7B6EKGGb0WY 1rCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181140; x=1703785940; 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=/c0+chL/1/wo56zTWm7IMp8vXHjZfJ8gLBsE3lmAjX8=; b=IbW2Brp0ZQAL7hdezbRGG9I2gF2WyM7Js6WVwnSLR2O01C7E5VL5LzmnyMzobOVreZ z8hOQgUFNKUkv+A9sk2u6XeeUukcSTEwAjNQDTIj2HcstXPPmJxpOqw8NlZsiA/mx8AT VF3BwWLvoF4IBngTh2vwdSgjLe+3l+mxC92enISh/X9uV7xE9BqEQaZtIHfw1KRfm3WF zUzn/1fRkK8gR64xJA1DU7UWfjlG+Zo5VJ2ihuwWIRkShTLlybVHsEy/K1wsy1UkCrCI 7NlYEEa3utSug19A041D4GgpIyF04tZzMGZNMlNlxtTxlik4SuQnX/yjnCu1GNC/oxl3 7Y8w== X-Gm-Message-State: AOJu0YxH1O5So9Js2sYmr0Vo2fGS4+vdj4La30xhMZBDd63YN6WZ3xEc Fq6FrrYZfVzyA0w3VPJHyFqdv47DwiZBVVSxKlJ8XA== X-Google-Smtp-Source: AGHT+IE9p7O/pbXL128NUqNrAPv6ABXqva0dYapgPlk/z9djf6Ktcej3ayFkuToIM41kFQfqMVFxkw== X-Received: by 2002:a05:6e02:1c8f:b0:35f:82e8:2d3 with SMTP id w15-20020a056e021c8f00b0035f82e802d3mr18522832ill.73.1703181140500; Thu, 21 Dec 2023 09:52:20 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 12/16] target/riscv: move 'cboz_blocksize' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:33 -0300 Message-ID: <20231221175137.497379-13-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::d2b; envelope-from=dbarboza@ventanamicro.com; helo=mail-io1-xd2b.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181227406100011 Content-Type: text/plain; charset="utf-8" Do the same we did with 'cbom_blocksize' in the previous patch. Remove the now unused kvm_cpu_set_cbomz_blksize() setter. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 45 +++++++++++++++++++++++++++++++++++++- target/riscv/kvm/kvm-cpu.c | 28 ------------------------ 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6c17ab35c5..d558f1f1e3 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1818,8 +1818,49 @@ const PropertyInfo prop_cbom_blksize =3D { .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 +static void prop_cboz_blksize_set(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint16_t value; + + if (!visit_type_uint16(v, name, &value, errp)) { + return; + } + + /* Always allow setting a default value */ + if (cpu->cfg.cboz_blocksize =3D=3D 0) { + cpu->cfg.cboz_blocksize =3D value; + return; + } + + if (value !=3D cpu->cfg.cboz_blocksize && riscv_cpu_is_vendor(obj)) { + cpu_set_prop_err(cpu, name, errp); + error_append_hint(errp, "Current '%s' val: %u\n", + name, cpu->cfg.cboz_blocksize); + return; + } + + cpu_option_add_user_setting(name, value); + cpu->cfg.cboz_blocksize =3D value; +} + +static void prop_cboz_blksize_get(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + uint16_t value =3D RISCV_CPU(obj)->cfg.cboz_blocksize; + + visit_type_uint16(v, name, &value, errp); +} + +const PropertyInfo prop_cboz_blksize =3D { + .name =3D "cboz_blocksize", + .get =3D prop_cboz_blksize_get, + .set =3D prop_cboz_blksize_set, + .set_default_value =3D qdev_propinfo_set_default_value_uint, +}; + Property riscv_cpu_options[] =3D { - DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -1845,6 +1886,8 @@ static Property riscv_cpu_properties[] =3D { =20 {.name =3D "cbom_blocksize", .info =3D &prop_cbom_blksize, .set_default =3D true, .defval.u =3D 64}, + {.name =3D "cboz_blocksize", .info =3D &prop_cboz_blksize, + .set_default =3D true, .defval.u =3D 64}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 1866b56913..137a8ab2bb 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -343,30 +343,6 @@ static KVMCPUConfig kvm_cboz_blocksize =3D { .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) }; =20 -static void kvm_cpu_set_cbomz_blksize(Object *obj, Visitor *v, - const char *name, - void *opaque, Error **errp) -{ - KVMCPUConfig *cbomz_cfg =3D opaque; - RISCVCPU *cpu =3D RISCV_CPU(obj); - uint16_t value, *host_val; - - if (!visit_type_uint16(v, name, &value, errp)) { - return; - } - - host_val =3D kvmconfig_get_cfg_addr(cpu, cbomz_cfg); - - if (value !=3D *host_val) { - error_report("Unable to set %s to a different value than " - "the host (%u)", - cbomz_cfg->name, *host_val); - exit(EXIT_FAILURE); - } - - cbomz_cfg->user_set =3D true; -} - static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU *cpu, CPUState *cs) { CPURISCVState *env =3D &cpu->env; @@ -484,10 +460,6 @@ static void kvm_riscv_add_cpu_user_properties(Object *= cpu_obj) NULL, multi_cfg); } =20 - object_property_add(cpu_obj, "cboz_blocksize", "uint16", - NULL, kvm_cpu_set_cbomz_blksize, - NULL, &kvm_cboz_blocksize); - riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_extensions); riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_vendor_exts); riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_experimental_e= xts); --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181168; cv=none; d=zohomail.com; s=zohoarc; b=R2WkUSPQ9mN5GaVTec8VsdC2hICBV3upT01Y64TCkathgJqy+oT+PAtijA5zKqOlhee79/ICMvmU/wMtwRpbxB55XIIwbJjNKEp8C06BhMl3W99g7FRmnxlVd2WevBUMK7O+JWTvggOuaNKmqfmuXeOHLyZlyQHnwZ7Senrje1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181168; 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=bgOCv5hvqNsl0wb4x/wspvOVZ58Wc7qh+1mml5TD4r0=; b=ixvZwnCx+t5KzEEba5dokk5+QMuu0WvoFZz3JU4rSbTCVU/7u6eVlDzNQDf2tGwaIm1HMdaxuxd2lFNZeu7opygdpN+5ZQJweLhjKNBqvO5XNuxquG9u4WikeAjivUCWMs2j6pbfJuHgMNkiDGiqeL1q3GBczs6MS9jcutS6s0A= 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 1703181168814981.9548826537666; Thu, 21 Dec 2023 09:52:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDn-0003B7-BG; Thu, 21 Dec 2023 12:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDj-0002xx-Dw for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:31 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDd-00081I-EA for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:28 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d97b7c8efdso440769b3a.0 for ; Thu, 21 Dec 2023 09:52:25 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181144; x=1703785944; 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=bgOCv5hvqNsl0wb4x/wspvOVZ58Wc7qh+1mml5TD4r0=; b=bq3FDnXVcuPqJT9RLRXWdYacUDcDoZCqxkl0ISgSwkn7b+wsCvEVTk7e230WKja8i6 CtwgnoXstAmVYuimVgyst04flvKqSgnwj7gAE8SYwIrO3T8f/wyBqkG3AMtg2kRIt544 dQkQpm7NM3DHff/kg0ZTKpHVAXJXznSnJQXdGhyRs1ZliGsDq+ygoW9hgYHxh4WwwDiq oFq/Rob1HRcqLIoGucQ5XREfr+Yb89X1RyLTRg7ce1SmgL/OTI+fD8fYogpE+nwEzkns ujpnsS7UTK2qjceUrIrnRZ9CdfxTu+SCphYofzrU2YbWImVe0PSCew8jIiZKp3im0clN H9dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181144; x=1703785944; 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=bgOCv5hvqNsl0wb4x/wspvOVZ58Wc7qh+1mml5TD4r0=; b=LutaccGlhz03DUPcFCtcmeCDpfKa2TalLWnE6X6zY85Yvg77uc2CLnc6Es6x/1HXO2 3h279NHn4EyWO3VWFMJ85/bvphU4JkWHz+CUL1hjXDnjGzIiSIjNx9H8ifjjJ2izV1/g AsTTi86RKFQgMBGVyYBU26ZN9iS5F5Lta/B5GknNYt18U/9IA/r5ilX3EYyQM/M7KACJ YroUofZKTTbEg1Veqtcsl0iKvWSrl4m0/VGmTkDXmBXyW2H3iHj1js80qAja7h+aG1AU kHkGbJvkc7CCA07b8c54EkdDTbFgTFa+e++ArOsAo6SdKYaUjYvkTwZVcZg/B+1kv1xI K3Pg== X-Gm-Message-State: AOJu0YxvV0OlqTU/vXNOl3u/rUjuuAVsqVu/XjNM59PUD7NGvmL0ik+m Yv/y2MLC5pJYFIBErmI9tDMI3qr+AP7Yk1wb6GzOe/kRrN0t6A== X-Google-Smtp-Source: AGHT+IEHMbAQyJDoNVQxZ/3bAW4FPcK8eGZAS/qtGUVwP+P4hQm8VC6vK+TO+il4OkRDjaEtosDSiw== X-Received: by 2002:a05:6a20:3945:b0:194:c8f5:6040 with SMTP id r5-20020a056a20394500b00194c8f56040mr63509pzg.1.1703181143734; Thu, 21 Dec 2023 09:52:23 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 13/16] target/riscv: remove riscv_cpu_options[] Date: Thu, 21 Dec 2023 14:51:34 -0300 Message-ID: <20231221175137.497379-14-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::431; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1703181171177100003 Content-Type: text/plain; charset="utf-8" The array is empty and can be removed. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 5 ----- target/riscv/cpu.h | 1 - target/riscv/kvm/kvm-cpu.c | 9 --------- target/riscv/tcg/tcg-cpu.c | 4 ---- 4 files changed, 19 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d558f1f1e3..11afc45103 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1860,11 +1860,6 @@ const PropertyInfo prop_cboz_blksize =3D { .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 -Property riscv_cpu_options[] =3D { - - DEFINE_PROP_END_OF_LIST(), -}; - static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 988471c7ba..f06987687a 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -774,7 +774,6 @@ extern const RISCVCPUMultiExtConfig riscv_cpu_extension= s[]; extern const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[]; extern const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[]; extern const RISCVCPUMultiExtConfig riscv_cpu_deprecated_exts[]; -extern Property riscv_cpu_options[]; =20 typedef struct isa_ext_data { const char *name; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 137a8ab2bb..5800abc9c6 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1443,19 +1443,10 @@ void kvm_riscv_aia_create(MachineState *machine, ui= nt64_t group_shift, static void kvm_cpu_instance_init(CPUState *cs) { Object *obj =3D OBJECT(RISCV_CPU(cs)); - DeviceState *dev =3D DEVICE(obj); =20 riscv_init_kvm_registers(obj); =20 kvm_riscv_add_cpu_user_properties(obj); - - for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { - /* Check if we have a specific KVM handler for the option */ - if (object_property_find(obj, prop->name)) { - continue; - } - qdev_property_add_static(dev, prop); - } } =20 void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 84064ef7e0..d3eeedc758 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -889,10 +889,6 @@ static void riscv_cpu_add_user_properties(Object *obj) riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts); =20 riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_deprecated_exts); - - for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { - qdev_property_add_static(DEVICE(obj), prop); - } } =20 /* --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181261; cv=none; d=zohomail.com; s=zohoarc; b=D11LNWWrItqniJtp3fdyC5tK5I+4pjYlJzd2uxafkTBGauW6qyebwabx3Wu04O6KfsmnHTTP09jYH3Gzvk6wVfFxZmcxVwWt+fu56tzBaX7ChRFFO+ZaHw9SrFQVTRaBwWl95iLkjUd42XbXCeVrxYdVDLveCs8PC1TrJr87NSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181261; 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=Ri6ABp0NiBYR2Dq792NvbmEixsEbJJvc7QXfGauEaUQ=; b=Qam4jrw8uzbS8y1Q2SIsQJ9XN/wwsslCkaDUODvgqPfd9O39H1s+Z0yyYrnCk16alTQzbGNZ3YLbj1IYp8wxixA7dsTnOkp/OI4D999qZmV/B19UK8O47mbw+ZAZDy2le7iRNCiPWuMsQpdT8IoOgO/TYxKllIgDm7k6gx9mkAY= 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 170318126164389.07505496376848; Thu, 21 Dec 2023 09:54:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDt-0003Ev-Bn; Thu, 21 Dec 2023 12:52:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDo-0003Dc-Ld for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:37 -0500 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 1rGNDj-00081z-D7 for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:34 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6d7f1109abcso720406b3a.3 for ; Thu, 21 Dec 2023 09:52:29 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181147; x=1703785947; 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=Ri6ABp0NiBYR2Dq792NvbmEixsEbJJvc7QXfGauEaUQ=; b=K2LTy60Klk65tJoa58cAGUtdnj1C8iM4IU2SAxlxP8uZjoTCrQuz9PzhSH8ejqeFoE ti3qn7btgtl6biQt4m0BXrv2qSLCpQVASNmGwxQQOGxc9bmFw9Uah/rOnI3QwOmp6MFI ppC6gEwvovSzVaG3mGa0YZmZZZKVzP4ArxMvIwZHf4oP/j6HilZYew/o9qpKrvQZ6llj FvfThjm9UUGMcKBCdTyGOLy6RqEpLmkCXtTAYuVHhnKaI40kIw8qzBUD5g0CJFmEMfUa r0XTRbDPMNmHCNECIpDidH9e+bBp8pTdLzgl49ysX36ZmuB97WM73kycjryU213Jc6MQ HuTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181147; x=1703785947; 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=Ri6ABp0NiBYR2Dq792NvbmEixsEbJJvc7QXfGauEaUQ=; b=Tp3is1GiXAdPOT/dW2xEBWRjw1VffLHV0JDtpWGFL9pmhTIZUWph3ms7vd5vbrLmfj LZgH6tnatR4SJSKcVHbhWKlrAUGcOwpwzqDKfZL+DHTZ0D9aiGqwvRQfzNlkwTTrMTXQ +VKQZIgWYuZKdYwU+kxtiXUPVCbgY98bubawmN1IuTuUg6mieDX1oRvJoN6eJefVnC08 iJsvG87LPOZLZT2xDvzkZVRFBB0ZGsLz+vnCenqmbXRzNi/KP8X1e527LrJ9enNJa1Sa haklJtIDwjlgWlE5h/Or5aABUiL0vzUQ0AMwb+uOl6x4iyOjO2dQs4PFg2bGCzzpWXKh lQSg== X-Gm-Message-State: AOJu0Ywu2k1YIxtmSJcT5v6FLb1+CNzRIZz7fabkNjXam4prvYP7FdGB Gr3XKfgE7RGigf80hXBE6CVDKOSJKQat6VlU3TtQYa6rXoPDKA== X-Google-Smtp-Source: AGHT+IFJrrSVkPiYl9Xio/B3yK34/W7FnWPAk5Yl0IwsY+G+wyAHJXonbOpT1XA4/YIpdaJocQc11g== X-Received: by 2002:aa7:814d:0:b0:6d9:6e51:8f7b with SMTP id d13-20020aa7814d000000b006d96e518f7bmr39170pfn.27.1703181146721; Thu, 21 Dec 2023 09:52:26 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 14/16] target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:35 -0300 Message-ID: <20231221175137.497379-15-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::436; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x436.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181263546100003 Content-Type: text/plain; charset="utf-8" Keep all class properties in riscv_cpu_properties[]. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 11afc45103..b5f754309a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1860,6 +1860,41 @@ const PropertyInfo prop_cboz_blksize =3D { .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 +static void prop_mvendorid_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint32_t prev_val =3D cpu->cfg.mvendorid; + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + if (!dynamic_cpu && prev_val !=3D value) { + error_setg(errp, "Unable to change %s mvendorid (0x%x)", + object_get_typename(obj), prev_val); + return; + } + + cpu->cfg.mvendorid =3D value; +} + +static void prop_mvendorid_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint32_t value =3D RISCV_CPU(obj)->cfg.mvendorid; + + visit_type_uint32(v, name, &value, errp); +} + +const PropertyInfo prop_mvendorid =3D { + .name =3D "mvendorid", + .get =3D prop_mvendorid_get, + .set =3D prop_mvendorid_set, +}; + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -1884,6 +1919,8 @@ static Property riscv_cpu_properties[] =3D { {.name =3D "cboz_blocksize", .info =3D &prop_cboz_blksize, .set_default =3D true, .defval.u =3D 64}, =20 + {.name =3D "mvendorid", .info =3D &prop_mvendorid}, + #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), #endif @@ -1948,35 +1985,6 @@ static const struct SysemuCPUOps riscv_sysemu_ops = =3D { }; #endif =20 -static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); - RISCVCPU *cpu =3D RISCV_CPU(obj); - uint32_t prev_val =3D cpu->cfg.mvendorid; - uint32_t value; - - if (!visit_type_uint32(v, name, &value, errp)) { - return; - } - - if (!dynamic_cpu && prev_val !=3D value) { - error_setg(errp, "Unable to change %s mvendorid (0x%x)", - object_get_typename(obj), prev_val); - return; - } - - cpu->cfg.mvendorid =3D value; -} - -static void cpu_get_mvendorid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - uint32_t value =3D RISCV_CPU(obj)->cfg.mvendorid; - - visit_type_uint32(v, name, &value, errp); -} - static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2086,9 +2094,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_arch_name =3D riscv_gdb_arch_name; cc->gdb_get_dynamic_xml =3D riscv_gdb_get_dynamic_xml; =20 - object_class_property_add(c, "mvendorid", "uint32", cpu_get_mvendorid, - cpu_set_mvendorid, NULL, NULL); - object_class_property_add(c, "mimpid", "uint64", cpu_get_mimpid, cpu_set_mimpid, NULL, NULL); =20 --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181277; cv=none; d=zohomail.com; s=zohoarc; b=VZQe9vGQE5J4NmTmU1szVyYhsuL7SE/dKoa7cjTtzsLLTQZB0veh+UpWiIkzRjICmGPogDI9DDD+3cMrRTjYU0JaKvZC0YCQfZHiLEJwQ3PUOfR8RGHFo/gaaVjJYtgWgpKw6A+LNhoNr39gCMSzaY4lPCszZF+rekYJwdtOCQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181277; 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=mnYG+RqvMTi/pQeH4pKLxq6sOIF0puqGCKnpXQ6tWZ0=; b=XeDZ+V/ZlkvUnpcJq2giY0ju8+yGz+vb3xQnwBouiel1Y+S4K9Bea2k1M3S6kGvP0JQoKP2Q65QwECKZBw/ZbxAVU7CHD3odqRmh3tPIdP+5o/6nRIrboK2z+3YyyTsAxHOvMBpMw+wOw0DuX/EXZX7f311H8DDNPWT7cs3J0Ys= 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 1703181277761834.5651154605582; Thu, 21 Dec 2023 09:54:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDt-0003Ez-DO; Thu, 21 Dec 2023 12:52:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDp-0003Dl-Ab for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:37 -0500 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDl-000826-Ec for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:35 -0500 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-35fcab43a29so3695695ab.3 for ; Thu, 21 Dec 2023 09:52:30 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181150; x=1703785950; 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=mnYG+RqvMTi/pQeH4pKLxq6sOIF0puqGCKnpXQ6tWZ0=; b=O0LATwL/V4Ai8zUzwSoPdAHL4/zMXSbePaBoCsDPfURe64JKOGxFLkGSSuFsCezN3b PnvmqHolIg/1sNaBh0Pw6jN/HwtXp8YFD3T78dhBfd7aCsBad8ycCellp7teMIap7vrq prR7G6gdrwgAIc22ok0Owz1J2cV7V1g8NRtO5VFkqGOYnRiW8lwHXiKZ9WIU5UjtpMo0 CLXQBP/Pn52ndjnihCg2mCaI7S3EETrh166fWASkjIGYm5e4iO7+V9pJAs6WfqC9e4/Y hByKUu/be02dziUxpSPpAuT7MMFPW9K494YWYmmqqMg2URt8Yg/1++rvfk64lANwamKi EqaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181150; x=1703785950; 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=mnYG+RqvMTi/pQeH4pKLxq6sOIF0puqGCKnpXQ6tWZ0=; b=f0ru1pBSsdPAfbYBUpwSR8p++47pOHL8dhuORkl1AA2l1KCezMiOX5GAq5czDXVT72 OEFTXUMtFttB8iC1wTChGIuNawm+zb9mL902r+hy7FabuJcgjGOD5K9/Rpxq68ickfem I02DZ4b8aUyV6e01j85gKK+6R2mu0Q/M+m2NCORzLNsP0tA5Djm+522ajsvGg3pcj1fB k4adJBRh/AnLFZ7tw7KSU2dZ9sEz/+HoUdA1BH6ebTTURHxZnArQbUFeYmCqHavYQZka zS0/XJaX0SH9fu1FzwxEpbZlumZ/PfZcNlExFGkzV5KnDQZ79tiBa9vCRDZl94gBma2T I4FA== X-Gm-Message-State: AOJu0YyFkwgFUY6g2v1/FhFgfMSQQtPLECc5KLrbradc8mkvxuJuvom/ b/Qo1K+Tss6yAeCIOua1ypIUS9Zi96V3Oy94YbkoGA== X-Google-Smtp-Source: AGHT+IEYPoBSr/A9sQj7qyHROq6U5z+mUBQ1VJZJVfqMBul65sAPgLs1Y11nHx3Tc8x3mS8y+8TJHA== X-Received: by 2002:a05:6e02:198d:b0:35f:d860:a07e with SMTP id g13-20020a056e02198d00b0035fd860a07emr1040909ilf.65.1703181149801; Thu, 21 Dec 2023 09:52:29 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 15/16] target/riscv/cpu.c: move 'mimpid' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:36 -0300 Message-ID: <20231221175137.497379-16-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::12d; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x12d.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181279523100003 Content-Type: text/plain; charset="utf-8" Keep all class properties in riscv_cpu_properties[]. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b5f754309a..a5607bf1d0 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1895,6 +1895,41 @@ const PropertyInfo prop_mvendorid =3D { .set =3D prop_mvendorid_set, }; =20 +static void prop_mimpid_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint64_t prev_val =3D cpu->cfg.mimpid; + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + if (!dynamic_cpu && prev_val !=3D value) { + error_setg(errp, "Unable to change %s mimpid (0x%" PRIu64 ")", + object_get_typename(obj), prev_val); + return; + } + + cpu->cfg.mimpid =3D value; +} + +static void prop_mimpid_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint64_t value =3D RISCV_CPU(obj)->cfg.mimpid; + + visit_type_uint64(v, name, &value, errp); +} + +const PropertyInfo prop_mimpid =3D { + .name =3D "mimpid", + .get =3D prop_mimpid_get, + .set =3D prop_mimpid_set, +}; + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -1920,6 +1955,7 @@ static Property riscv_cpu_properties[] =3D { .set_default =3D true, .defval.u =3D 64}, =20 {.name =3D "mvendorid", .info =3D &prop_mvendorid}, + {.name =3D "mimpid", .info =3D &prop_mimpid}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), @@ -1985,35 +2021,6 @@ static const struct SysemuCPUOps riscv_sysemu_ops = =3D { }; #endif =20 -static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); - RISCVCPU *cpu =3D RISCV_CPU(obj); - uint64_t prev_val =3D cpu->cfg.mimpid; - uint64_t value; - - if (!visit_type_uint64(v, name, &value, errp)) { - return; - } - - if (!dynamic_cpu && prev_val !=3D value) { - error_setg(errp, "Unable to change %s mimpid (0x%" PRIu64 ")", - object_get_typename(obj), prev_val); - return; - } - - cpu->cfg.mimpid =3D value; -} - -static void cpu_get_mimpid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - uint64_t value =3D RISCV_CPU(obj)->cfg.mimpid; - - visit_type_uint64(v, name, &value, errp); -} - static void cpu_set_marchid(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2094,9 +2101,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_arch_name =3D riscv_gdb_arch_name; cc->gdb_get_dynamic_xml =3D riscv_gdb_get_dynamic_xml; =20 - object_class_property_add(c, "mimpid", "uint64", cpu_get_mimpid, - cpu_set_mimpid, NULL, NULL); - object_class_property_add(c, "marchid", "uint64", cpu_get_marchid, cpu_set_marchid, NULL, NULL); =20 --=20 2.43.0 From nobody Tue Nov 26 22:18:41 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=1703181288; cv=none; d=zohomail.com; s=zohoarc; b=Vv85783Br1EmpAOERlrVSvh94cz8y9EjirNRJM6L6B90op0uGWnm0KiTPiDZVqNgGAtK5whRgK9PNnP4u8W8B8zJWzcrHYTbpJO9JKKVx+gcHt4Dp5cJmp96HPxF4hRK+uF0f9YtxzXBb7OMXpAK7QearA3vR/hxhn6EOCjrAK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703181288; 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=mswE0zppO3OysD2b+plzhkt95Fl+qbU2PSVuPZMwMGc=; b=KnsOCw0OkzwDOja9KKlwCVmXpNReJofjXsCSZZxtW3rCOjNIZBBs9+vyBiwQoO5vFOrd+GhE1W8rPaMZ9BC8WeDGdZ3QP8s/f5oziUtnchOik5TcQ83KbyOPFSQfAX9Zm66rHFTgmntXAF1Y9G6zZpXecPjEvcQdbEUq7+z6PEQ= 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 1703181288594171.04248755097058; Thu, 21 Dec 2023 09:54:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGNDu-0003FS-6P; Thu, 21 Dec 2023 12:52:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGNDr-0003Eo-W8 for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:40 -0500 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGNDn-00082U-CK for qemu-devel@nongnu.org; Thu, 21 Dec 2023 12:52:38 -0500 Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-35fc1a1b52bso3694155ab.2 for ; Thu, 21 Dec 2023 09:52:34 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([179.93.21.205]) by smtp.gmail.com with ESMTPSA id w10-20020a63f50a000000b005b18c53d73csm1806261pgh.16.2023.12.21.09.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1703181153; x=1703785953; 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=mswE0zppO3OysD2b+plzhkt95Fl+qbU2PSVuPZMwMGc=; b=Ke+UXSPlbEJlfAw1Vov8HazwyMyE2Mc3XZqVXq5UFTZZGdQm4z/RtJyqW7sfJ3Hll7 10l4N5N7E+vvDyTvKva9lF3KO7j1phfHut7HMsOZXOKhbBwPztj8a5cOfup8SMvoxKoS qfd2cfNBwib7E8Ori9N4VOssLY2d52JllLS283TpYju0Qj0wJkQ9Vw1ajec2gZODJa0Z Iezes/uqhRsFEacaEhRdaFZKaFCyfAtq4R1Lr1t1dV5B1Tnhtd+VHsJIsiafXI/NaQCu YysNNYOhFl6Zkh+8ZyZesvYQ7B5pwoqhIVZUnEi5hxY1eY33/OAwsFvu3H10V7eEE/kd fMyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181153; x=1703785953; 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=mswE0zppO3OysD2b+plzhkt95Fl+qbU2PSVuPZMwMGc=; b=rifaqDxp9MVOSZhWSx/6tz+QSDhfUHdfDenu1vehYkIBOgWsfpniW9+IQUnKhM8Uby pErJXKycvRQ1pedeNCLYWM+8A2tQYGdofS6MFUgFJK4ou0whfRTzOzN1k312OGKdSlzM FIeORmA9sZhbXAM838uLHZh4Y7QqcKAD7PWY5gGsPjHP73GT19RwBhe1BjKxQVrz2eKj SV7dNnOCxO5sGoBfrq1rh1cVGhFtnlCMSIR9JPXNTxBYSN+onZJgVT3ASr8mXyZkdcJO wao34Zv8K0Y4ROxfVKow2W9BWsL+IvRZZpmccZQX702/qfrYEnK30ncyVlOoo+ZrWBtw UobQ== X-Gm-Message-State: AOJu0YxqyAKlC5j8MedYd5v5dva3Pqk++e0hqOyKgq4fHXMFGEhBfmIF geoF9snua3hJOVyX3Twlf4xtAQLxgdFHGWkOj+0Bxdrf9+XJSQ== X-Google-Smtp-Source: AGHT+IGeBRCHuCaV1S5HuDw9SUVN5QpZvj9NLD/xzAVIh24WhFvv3GvzOv1oGZpZjBdUfU1iON0Q4A== X-Received: by 2002:a05:6e02:1947:b0:35f:cbe0:a3e9 with SMTP id x7-20020a056e02194700b0035fcbe0a3e9mr3677ilu.4.1703181152849; Thu, 21 Dec 2023 09:52:32 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH 16/16] target/riscv/cpu.c: move 'marchid' to riscv_cpu_properties[] Date: Thu, 21 Dec 2023 14:51:37 -0300 Message-ID: <20231221175137.497379-17-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221175137.497379-1-dbarboza@ventanamicro.com> References: <20231221175137.497379-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::12e; envelope-from=dbarboza@ventanamicro.com; helo=mail-il1-x12e.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1703181289648100001 Content-Type: text/plain; charset="utf-8" Keep all class properties in riscv_cpu_properties[]. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 110 +++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a5607bf1d0..0bcaf7818c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1930,6 +1930,62 @@ const PropertyInfo prop_mimpid =3D { .set =3D prop_mimpid_set, }; =20 +static void prop_marchid_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); + RISCVCPU *cpu =3D RISCV_CPU(obj); + uint64_t prev_val =3D cpu->cfg.marchid; + uint64_t value, invalid_val; + uint32_t mxlen =3D 0; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + if (!dynamic_cpu && prev_val !=3D value) { + error_setg(errp, "Unable to change %s marchid (0x%" PRIu64 ")", + object_get_typename(obj), prev_val); + return; + } + + switch (riscv_cpu_mxl(&cpu->env)) { + case MXL_RV32: + mxlen =3D 32; + break; + case MXL_RV64: + case MXL_RV128: + mxlen =3D 64; + break; + default: + g_assert_not_reached(); + } + + invalid_val =3D 1LL << (mxlen - 1); + + if (value =3D=3D invalid_val) { + error_setg(errp, "Unable to set marchid with MSB (%u) bit set " + "and the remaining bits zero", mxlen); + return; + } + + cpu->cfg.marchid =3D value; +} + +static void prop_marchid_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint64_t value =3D RISCV_CPU(obj)->cfg.marchid; + + visit_type_uint64(v, name, &value, errp); +} + +const PropertyInfo prop_marchid =3D { + .name =3D "marchid", + .get =3D prop_marchid_get, + .set =3D prop_marchid_set, +}; + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -1956,6 +2012,7 @@ static Property riscv_cpu_properties[] =3D { =20 {.name =3D "mvendorid", .info =3D &prop_mvendorid}, {.name =3D "mimpid", .info =3D &prop_mimpid}, + {.name =3D "marchid", .info =3D &prop_marchid}, =20 #ifndef CONFIG_USER_ONLY DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), @@ -2021,56 +2078,6 @@ static const struct SysemuCPUOps riscv_sysemu_ops = =3D { }; #endif =20 -static void cpu_set_marchid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - bool dynamic_cpu =3D riscv_cpu_is_dynamic(obj); - RISCVCPU *cpu =3D RISCV_CPU(obj); - uint64_t prev_val =3D cpu->cfg.marchid; - uint64_t value, invalid_val; - uint32_t mxlen =3D 0; - - if (!visit_type_uint64(v, name, &value, errp)) { - return; - } - - if (!dynamic_cpu && prev_val !=3D value) { - error_setg(errp, "Unable to change %s marchid (0x%" PRIu64 ")", - object_get_typename(obj), prev_val); - return; - } - - switch (riscv_cpu_mxl(&cpu->env)) { - case MXL_RV32: - mxlen =3D 32; - break; - case MXL_RV64: - case MXL_RV128: - mxlen =3D 64; - break; - default: - g_assert_not_reached(); - } - - invalid_val =3D 1LL << (mxlen - 1); - - if (value =3D=3D invalid_val) { - error_setg(errp, "Unable to set marchid with MSB (%u) bit set " - "and the remaining bits zero", mxlen); - return; - } - - cpu->cfg.marchid =3D value; -} - -static void cpu_get_marchid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - uint64_t value =3D RISCV_CPU(obj)->cfg.marchid; - - visit_type_uint64(v, name, &value, errp); -} - static void riscv_cpu_class_init(ObjectClass *c, void *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); @@ -2101,9 +2108,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_arch_name =3D riscv_gdb_arch_name; cc->gdb_get_dynamic_xml =3D riscv_gdb_get_dynamic_xml; =20 - object_class_property_add(c, "marchid", "uint64", cpu_get_marchid, - cpu_set_marchid, NULL, NULL); - device_class_set_props(dc, riscv_cpu_properties); } =20 --=20 2.43.0