From nobody Sat Nov 15 22:33:48 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747739279; cv=none; d=zohomail.com; s=zohoarc; b=JyCrfaN+7kKKNGrpkvgnV/w4sDqXJSOiRdSee3/QbEwQ38f7AOSpf4LvmT97hFn9mbS9bAmzisuvHED08LgPSjWfJunCRKghp7mgYRtCUfeSHTw/v8dntGLkkkRiFI4ZOGWeW/pAnytaGdNM5KmN3MeGfJieEd9QA9OfauIJjBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747739279; 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=vI4DnVjNkhsHegIRh504HY8E3e3XL3fmDWImMxQ9guA=; b=Kfd6dwYhJNmrtvbatl2CDF/BT6+THURpuI8PpK1XCJn5Lkuw+xUS21tJG9pgVPXhPK/s8t32/LYawp+cJlOewJ6ByzEf7I2P4iRknp8DIdlY8105+QV9q4lWNrYr5aeDKTowm+QBF6WVQn2P09QI2EZ7KJ5imTJD/u8t3bCf3Js= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747739279521872.38199032209; Tue, 20 May 2025 04:07:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHKo4-0001Vx-Ma; Tue, 20 May 2025 07:06:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHKny-0001An-Ke for qemu-devel@nongnu.org; Tue, 20 May 2025 07:06:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHKnw-0003JZ-Tv for qemu-devel@nongnu.org; Tue, 20 May 2025 07:06:42 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-DudTQ1HtMZufkiprzKPkzA-1; Tue, 20 May 2025 07:06:37 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-601f918c628so1933236a12.3 for ; Tue, 20 May 2025 04:06:37 -0700 (PDT) Received: from [192.168.122.1] ([151.95.46.79]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6005ae3940fsm6978321a12.74.2025.05.20.04.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 04:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747739200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vI4DnVjNkhsHegIRh504HY8E3e3XL3fmDWImMxQ9guA=; b=h4cfOo0yvJ/FXqvj4XihpJcEqhYjFKVKYqoFKtlPGmsvx8YbJkU9Nd4i2AezuWjOe3U8Y8 U0d4JOw6gGBbpcTLcMdnJOmKdPOyx+DTXPmnAr68XkQkcMpRm1ao5Gu/9AbUOzwdD7dpcZ nwcYZCV6RmDNZzRotR1XdJQbITx2F2k= X-MC-Unique: DudTQ1HtMZufkiprzKPkzA-1 X-Mimecast-MFC-AGG-ID: DudTQ1HtMZufkiprzKPkzA_1747739197 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747739195; x=1748343995; 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=vI4DnVjNkhsHegIRh504HY8E3e3XL3fmDWImMxQ9guA=; b=Dk02hkUChCqgqPfzTB2pMpC78RwORn3P/w84641iTvkf3I6r/78Iod4CQ6lqmQFB0u QG2t8VTsWzgNs+xZ/HQn3zNqZraQZxXjwRYc7RVKDnhhAWdnDknPH8Ryud93+mntHzlK gWhFWqmLm/IWZEX9CLwmTpGoFKwZtdjyOHzlHeq4xJv+KgYMAG6b3fW9W66ID3TMHwCc HJCK2cL6bzef5lA1BcFtuU2STFCVaUsLjfgtKEgeYFuwEgbmFD15YLxXC09ipCSPizKj 7MhHss0l5+BlKSB/M8nVZ/cem0rQRad8nlkaSAZS3wRV+bqgssMJSY2NalQj3fliAf/A ERiw== X-Gm-Message-State: AOJu0YzvqetDLmh9ViRTHkNEF0Jc8ORMal9f8tATRSmjnf+OToEj70Zp KzBNPzo5kFFHrhiF9Yc1jrdCAYuiHJvmv06llC4XDavJrGw1I5kNMBF6M7TOOH8+yAakz28CdMi 3MUshcjw0peoJwN0WhwE+L4PusH5zZt8c+sJ6iZwrQJT1MNzJOAuCXD1DaFWw+fE4mhG3I7xlgU xQ69dwrXVnOV+ked5KZux0SQPJB/Hbn/+6u6mcHKYb X-Gm-Gg: ASbGnctXtmP+te5EnG6R1zchbShyrvnGC+s5bU72PfHdZBT7rDtYnjHTovYa9UHt33K lAOkL0I9YwSLvw/3vcZftNjKP5WxzFohSH5Vfh5exTLjpMA4HjDLV+haOJjXo+9oG9NnV4Wvpxr 8MtdNzSqvADAnJe+AVeKg5kccuL2jLT4J0l73t0RlncVX0wMHrGMq8YvTLTmescmj/3Y7ftQIZo wmSiYK4KwXtC2Z3unyrtg076HgJOJGJq2Wjzgspzo9B+FVzDffHG3BIb7MmYMpVmtB2ssG8m0B4 8N26a2aGh/tV2w== X-Received: by 2002:a05:6402:520f:b0:5fe:7b09:9e27 with SMTP id 4fb4d7f45d1cf-60114088719mr12589620a12.12.1747739195450; Tue, 20 May 2025 04:06:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGQaUpDWbzrYSsRJHvQHkHpTLD/3Qu8vlVNid6J0mL9p8Hk95pdkj3ugJi1ucDuzjtI0y7ag== X-Received: by 2002:a05:6402:520f:b0:5fe:7b09:9e27 with SMTP id 4fb4d7f45d1cf-60114088719mr12589594a12.12.1747739194968; Tue, 20 May 2025 04:06:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alistair Francis Subject: [PULL 28/35] target/riscv: th: make CSR insertion test a bit more intuitive Date: Tue, 20 May 2025 13:05:23 +0200 Message-ID: <20250520110530.366202-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250520110530.366202-1-pbonzini@redhat.com> References: <20250520110530.366202-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747739279863116600 Content-Type: text/plain; charset="utf-8" In preparation for generalizing the custom CSR functionality, make the test return bool instead of int. Make the insertion_test optional, too. Reviewed-by: Alistair Francis Signed-off-by: Paolo Bonzini --- target/riscv/th_csr.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/target/riscv/th_csr.c b/target/riscv/th_csr.c index 6c970d4e813..969a9fe3c80 100644 --- a/target/riscv/th_csr.c +++ b/target/riscv/th_csr.c @@ -29,7 +29,7 @@ =20 typedef struct { int csrno; - int (*insertion_test)(RISCVCPU *cpu); + bool (*insertion_test)(RISCVCPU *cpu); riscv_csr_operations csr_ops; } riscv_csr; =20 @@ -42,13 +42,9 @@ static RISCVException smode(CPURISCVState *env, int csrn= o) return RISCV_EXCP_ILLEGAL_INST; } =20 -static int test_thead_mvendorid(RISCVCPU *cpu) +static bool test_thead_mvendorid(RISCVCPU *cpu) { - if (cpu->cfg.mvendorid !=3D THEAD_VENDOR_ID) { - return -1; - } - - return 0; + return cpu->cfg.mvendorid =3D=3D THEAD_VENDOR_ID; } =20 static RISCVException read_th_sxstatus(CPURISCVState *env, int csrno, @@ -66,13 +62,12 @@ static riscv_csr th_csr_list[] =3D { .csr_ops =3D { "th.sxstatus", smode, read_th_sxstatus } } }; - void th_register_custom_csrs(RISCVCPU *cpu) { for (size_t i =3D 0; i < ARRAY_SIZE(th_csr_list); i++) { int csrno =3D th_csr_list[i].csrno; riscv_csr_operations *csr_ops =3D &th_csr_list[i].csr_ops; - if (!th_csr_list[i].insertion_test(cpu)) { + if (!th_csr_list[i].insertion_test || th_csr_list[i].insertion_tes= t(cpu)) { riscv_set_csr_ops(csrno, csr_ops); } } --=20 2.49.0