From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866549; cv=none; d=zohomail.com; s=zohoarc; b=FlLgTTFaL0i89x4eXlNSHCM9Qj9OVlacETgOwIXs0hsSpwHctvGxSNCqrGXIhJHZTaCAa/wIGe2igOQU1YZUDUJX3uFV+KN6+84C1x8m+U4EuLICy1O75oOR+G5lOjqr/u7WUjN3i60sfC3XrZgVWoJIK69EnJx4ocsA6LdA5R4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866549; 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=8oMYSQ42CGFvDLdo/ZO8SVNdZmL4BuNaNRyk3rvfP3A=; b=UFX/kNiIPs3imzt69ACSB/OuU+OajapP8x7y4cJqLfCZWwOt7JEla2FN/XvHAUkaV0oWYx9p56Tlj6ALTOzY0MarPx5S67qjPGs6EoHCM77sgPgbsO99GgfLv3QmZ9Ut2igg3THDS4ZTuS4DwDCSZxPzOtzNLSwpKJ/87rcCWyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866549897841.0484830086993; Thu, 6 Feb 2025 10:29:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6ay-00017j-CM; Thu, 06 Feb 2025 13:27:24 -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 1tg6av-000174-EI for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:21 -0500 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 1tg6au-0000y8-2o for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:21 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-XI3TJoQJMFq4SjSaj6eawg-1; Thu, 06 Feb 2025 13:27:17 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4362b9c15d8so6243975e9.3 for ; Thu, 06 Feb 2025 10:27:17 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd3856fsm2323316f8f.28.2025.02.06.10.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866439; 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=8oMYSQ42CGFvDLdo/ZO8SVNdZmL4BuNaNRyk3rvfP3A=; b=cPgm2M7xmm0BPHCA2cT6an5XtJo9+XT1zEDrAzvEx9FhmFHoJsFkcmxJvs/wSSaByulkhB 08z+7VPQFJo2hJ7OWI7xEAY/pyrhLoTryeBnVDMKg/dZ0vY6ilDgIkix1c2t8mhiH0tejS 8fVjuS8mDVTba0Lwcc+ZLm7Tv0Ki3LE= X-MC-Unique: XI3TJoQJMFq4SjSaj6eawg-1 X-Mimecast-MFC-AGG-ID: XI3TJoQJMFq4SjSaj6eawg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866436; x=1739471236; 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=8oMYSQ42CGFvDLdo/ZO8SVNdZmL4BuNaNRyk3rvfP3A=; b=B5oTDWjf6ErJrNeGmLPi6JPcAUJsqphhpdM9xOAa2yFst485fpgc1E8CZJuj+kBLLD s1CwBv5fzDVt2BMBqjCwxEUZrcY+FTUm2r91o6H2FYSsJlCP9DH4b2jhlL1NF73JQP/q c+voKSMwSHjnnRpW71VqzZsirQ9itcU+6j+FGa8nAL5brvTB0BiwYfUuQoVgKJYjf6M/ UBbatDczDHXDoBJCfjHAHoZ3gy2WMlGAqC7WkdZxis5gzKQ47YeHsZYe5wnUim3hAEln Un64pn56Ur+UsQzowu7Gg+ef764ckiTK4oEoHuTEgB3WS1JuYEf1WR6ouLbVVe7ez/WF S6aw== X-Gm-Message-State: AOJu0YzHCEPH3kAyHfZnZOpx3rayl6GW9eJRZYvWZ+rNJMhBr7T7gQ62 3aN9joEF/248O8gO88ek9pNOW7q6jVKO137tsqeFl47i+veGzIl8j0ReEa7muMEKb6gskfyVBnr AmJNnMpD2dqkzd5LEct26+q85Na+gdsVZM6xL8Gi+64QioJKnMceg0ZEacuMbfxnii88tjN92qC uHRp5UfcQ1vWdIYGexA7v+L7r4/TSIrzg0xBiRIwc= X-Gm-Gg: ASbGncu07OKwUoWJRTdyke16lC9eISz57iFqDE4OdJWEFluqA7pkrj1+R7p2OjjInax pYcFgeSbXgYld288VoCd8+QDPwnGqh00XbVOsGyWgZww1So6Q3mLIIrydJTrHCil6X+iuXBLE52 JEcB4x/d7Kj97BlZXDoTFND6opcmeOx29rU7/iXcvuRzx4rXJZipuXc5Mhd1EJY5SkJqRxCksqn hK7X/Sc5lfVUQ9K1gwE8aiYhy8SV6lV3ytrsWMExuk21cd9N200LeykfafOqOWkl2/U1iLsPfFD +WPB9y8= X-Received: by 2002:a05:600c:35c5:b0:435:136:75f6 with SMTP id 5b1f17b1804b1-439248c324dmr5377375e9.0.1738866435888; Thu, 06 Feb 2025 10:27:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IH84iD+gK3it3Q2F0aadBNLJJkHqpcM1qY8/yN1UjQlqz0ienVdvQgQhlmVljPyDtkJ37rUOw== X-Received: by 2002:a05:600c:35c5:b0:435:136:75f6 with SMTP id 5b1f17b1804b1-439248c324dmr5377125e9.0.1738866435485; Thu, 06 Feb 2025 10:27:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 01/22] target/riscv: remove unused macro DEFINE_CPU Date: Thu, 6 Feb 2025 19:26:49 +0100 Message-ID: <20250206182711.2420505-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866551495019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3d4bd157d2c..ed9da692030 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3051,15 +3051,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) } #endif =20 -#define DEFINE_CPU(type_name, misa_mxl_max, initfn) \ - { \ - .name =3D (type_name), \ - .parent =3D TYPE_RISCV_CPU, \ - .instance_init =3D (initfn), \ - .class_init =3D riscv_cpu_class_init, \ - .class_data =3D (void *)(misa_mxl_max) \ - } - #define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max, initfn) \ { \ .name =3D (type_name), \ --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866516; cv=none; d=zohomail.com; s=zohoarc; b=W9mfmM21EdZsTRT6hXzhxn8EWxnjXs0qPtSd3nRLlK/71cbEupJDw7pQPjd9DbUvvjzPV5wg6lRFLI6WhrDusRwCyLDEtHzUVBLliBw95L24sfeLqGgCP1spdCzi5dvmKDwc6+sbwQU0z1VgwBWl6liJoVhaZWNkneUKDnnABwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866516; 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=JjrCBWCNmpmL3kd1wohdPboFRNnStVvOZdacUSI6T3U=; b=hUJNSUK/I+m6FElX+z+NnxubtHLjcOoRQbvb56QKk69hSTx6wRLVM+ZeV7n6TcXZ9j39HHzaiHX8EJ5R9D9FmVtV57jVO5PIR54yQIXvv5BzJ98rRuTrGVMMpPRSxNfGw/LFptZQIuYapD4d+hceitiFscVEvUMX+6gWtp/HxQ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866516272886.1656045146192; Thu, 6 Feb 2025 10:28:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6az-00018A-Nq; Thu, 06 Feb 2025 13:27:25 -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 1tg6ax-00017X-PT for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:23 -0500 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 1tg6aw-0000z3-3R for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:23 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-ksB0ogtWNVGzU2u5n_Kthw-1; Thu, 06 Feb 2025 13:27:19 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-436379713baso6525375e9.2 for ; Thu, 06 Feb 2025 10:27:19 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390daf3c70sm62509995e9.26.2025.02.06.10.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866441; 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=JjrCBWCNmpmL3kd1wohdPboFRNnStVvOZdacUSI6T3U=; b=iJy1eQYUfNXLw4pcJloKWHkLocNPT3vb1ljDidyBf5wdgREUlIk7gpIVD8t4iBYPlWRIdN CInrysjRD/cKCUV1eH9vk5Lah3Z7jQhML+TmQxJ7IieaJEtbsGJL+NxtaX3MZvhhGTa6Us CTdoQrukzv1jP+9GwaZ67VVHLDQkKN8= X-MC-Unique: ksB0ogtWNVGzU2u5n_Kthw-1 X-Mimecast-MFC-AGG-ID: ksB0ogtWNVGzU2u5n_Kthw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866438; x=1739471238; 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=JjrCBWCNmpmL3kd1wohdPboFRNnStVvOZdacUSI6T3U=; b=jIFULvw0J3GEUvdULw8glIuV/iXGWD/uKLo7lNilGyShf7jHVe4PzUTTC67pFRnfNt VBYYILth1N3czfCBMgEBXcIHVXWOE62wHPzucqe0vkc/NQvHwFLq6GxGDL+0wLtPvlCe 29Jo4wrauchRJpNLlLo5xF0VWl6XQZtq/tl7CLaXR0ueS6jH2NS00yWg5g4jSf0YQXFU MmHKJS8SIR8hZJx5AEM6xXdtsb0ZgAWwQMUJjSx5h41oLlSJvr1eiyMDl1s4lpxffHDn XsqwiqJv3j5/UkInD//96fxe+J3DLvUxlLu8AznFBqIN/S0eeXNRI7u9gePsu7R4xjxr EfVg== X-Gm-Message-State: AOJu0YwvFO3SCaF1pK5Ps0uaJIpznCCTciGkjvCuFAVUh9MY+7NMa7UW X9q3gPK62zOMoeYrUOnheciZ2MVCAe/bF4IPrdOYcZF9gNGZ9jaO1VWB+TFHlYVFMUUn4TYvaE6 JMv7K/BTVlTpPtEyeziR0xzZ8mh6Fxz4EBB+qfxmLeqjbxtFW3/WcVKRKzJRc+Q+GDZqsXfvTA0 GVFEjnpOoPbNKCbvs0xhBizTYkjfcLOgwL66pXo4Y= X-Gm-Gg: ASbGncukGWo2DYKZIG5gNWRErc6KWKyp1k29D4g0DzRTxen2SXKp5qnC7ZIuEDQowh4 GSjuxUydw1aXNPD6GaTp0gTl8FY8eM4UcDQFzvr24mASDKBlrpCAJ8u2plc8MIcUK1J3E8YWYg8 XpfngNhrLKZg7WSk5rmFIi4XppOj1Vtc6RtuSPSjlik56TJg3w/+O8i+Askj1p36Mm7FEcVEYr5 CfLelFoAN5pvJVABT5oTRRROSp6AA3RzUfAZTlT8LyQU+olOnoRetyNPtiV//aHy/xE6d5rik9t /VIdNDE= X-Received: by 2002:a5d:6485:0:b0:38a:41b6:d685 with SMTP id ffacd0b85a97d-38dc8dc2fbemr50544f8f.3.1738866437951; Thu, 06 Feb 2025 10:27:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXXHhqcteKNnjj7DQCQ4q4JEuDkuctqD2ZKT5HM6GIMMQAy/xgLHbLq6/DmLHdHc9ZD2gMAw== X-Received: by 2002:a5d:6485:0:b0:38a:41b6:d685 with SMTP id ffacd0b85a97d-38dc8dc2fbemr50522f8f.3.1738866437485; Thu, 06 Feb 2025 10:27:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 02/22] target/riscv: introduce RISCVCPUDef Date: Thu, 6 Feb 2025 19:26:50 +0100 Message-ID: <20250206182711.2420505-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866517757019000 Content-Type: text/plain; charset="utf-8" Start putting all the CPU definitions in a struct. Later this will replace instance_init functions with declarative code, for now just remove the ugly cast of class_data. Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 4 ++++ target/riscv/cpu.c | 26 +++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 97713681cbe..b2c9302634d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -517,6 +517,10 @@ struct ArchCPU { const GPtrArray *decoders; }; =20 +typedef struct RISCVCPUDef { + RISCVMXL misa_mxl_max; /* max mxl for this cpu */ +} RISCVCPUDef; + /** * RISCVCPUClass: * @parent_realize: The parent class' realize handler. diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ed9da692030..29cfae38b75 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2955,7 +2955,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); =20 - mcc->misa_mxl_max =3D (uint32_t)(uintptr_t)data; + mcc->misa_mxl_max =3D ((RISCVCPUDef *)data)->misa_mxl_max; riscv_cpu_validate_misa_mxl(mcc); } =20 @@ -3051,40 +3051,48 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, = char *nodename) } #endif =20 -#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_DYNAMIC_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D (void *)(misa_mxl_max) \ + .class_data =3D &((RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_VENDOR_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D (void *)(misa_mxl_max) \ + .class_data =3D &((RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_BARE_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_BARE_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D (void *)(misa_mxl_max) \ + .class_data =3D &((RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 -#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max, initfn) \ +#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ .class_init =3D riscv_cpu_class_init, \ - .class_data =3D (void *)(misa_mxl_max) \ + .class_data =3D &((RISCVCPUDef) { \ + .misa_mxl_max =3D (misa_mxl_max_), \ + }), \ } =20 static const TypeInfo riscv_cpu_type_infos[] =3D { --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866463; cv=none; d=zohomail.com; s=zohoarc; b=ga4Un5GaacFcTRMzQpdiCvAPPmrLHd0ZagybT8A58bsDRm1r848Q8g5ViBcUg1vlfAOKVwonXb6r+1NsQNIMT0WAfSqtp+vhToegtd1MosWQ9227mo3kCsIyBN7pagS7hnLuaWEdnCSnrJ3sM+uHxiHs+D91p3bU2JRWoGzUEqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866463; 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=rMw2+TmEGfavV7m05Y9g8KdZOtwRpmpqXo3xQzrie9s=; b=CaKXwERzYt8qgUbWBWeX8tPLKE3XXLEEett2/140DgQkKZZi0yiLUQ8SRgKw9EZCfhZVBMoQlWzoeHVEycCsrBe8fdFNRonynD4iiftziFfgMZBN5h4bK6fFOQSJ43F7oT8D1SM3PmOiDC1KZnp28fbzxhSYthaBrvB5qc9Nv5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866463070490.23604484287887; Thu, 6 Feb 2025 10:27:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6b2-00018S-Ga; Thu, 06 Feb 2025 13:27:28 -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 1tg6b0-00018H-UQ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6az-00010U-2F for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:26 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-vUhZ9_T6M1G_THDkLNZSRQ-1; Thu, 06 Feb 2025 13:27:22 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4388eee7073so11299545e9.0 for ; Thu, 06 Feb 2025 10:27:21 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43907f19247sm58433535e9.1.2025.02.06.10.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866444; 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=rMw2+TmEGfavV7m05Y9g8KdZOtwRpmpqXo3xQzrie9s=; b=VGeump76ECeFKo5QrbDpvBXHB21594j4q0W1WSK40QdA7AEWas4NnWr0YwnpYQJx1gPYNM aSzXdJiPiPZJv0OakRj8vqBt24QXrrzyocBsTrpmMBtIOohqb7hSqRtJmJKziGJGnUcy7w uUTh3m/xM0ZwHcTl9DbNRrfUOtdFmwQ= X-MC-Unique: vUhZ9_T6M1G_THDkLNZSRQ-1 X-Mimecast-MFC-AGG-ID: vUhZ9_T6M1G_THDkLNZSRQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866440; x=1739471240; 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=rMw2+TmEGfavV7m05Y9g8KdZOtwRpmpqXo3xQzrie9s=; b=KnSGhX/tl4/hYuonSXrWXl5JmDjYBXlUaVGAr6Y5oS5OlXbckrAxC5xx0eRw4B5Enq 6KiSFTYaSc2LKsLOUwIdITs7kltSHlK0JjKAjpVOjuTSSvsSJzemWw8Ho1XCwIzeuarB D5/rylusmoiUycdKbMR35rjvIRgY2nghixyjb6od+ZhJQHQUP7mzYaVcEQuMdYXG3HzJ qLBlA+dYpa+d6Y6YJ6oT8abVer2A5+2FKV0EdgxFsJg/PrI5KBgb/5WWTljtbjsU0FH2 6H34aFszzrMWSaFD5yvEO/htuGXQp/Jb/uRykhmXOBElEJlfpyv/w/vl2eBzZl8X99Fz dk6w== X-Gm-Message-State: AOJu0YzQULzsk8x8ZH0RjrdUYZFmNWG6Bw4iAMhmWaOQDYiExpjCiI07 Y6hEywfhLAEvHEUSnnlWtPAgJ3V7iZUkUH2OhaRYHE+rbS2+ICSUADpTq5k8LJ+sOaLS5V8mH9y T7leqBvPjSKWhIMbdkTKgwYNjqqIiK4FaPNCqBntk1OT2G+A6+uduW3CcNvtIR/xR0vAlaaoMX+ 72YI970aahl3roCynWmMHqP9wCNrP2BY9QrGfEH50= X-Gm-Gg: ASbGnctgqGhK6LsxuJ3TqaJN+C/8Fxv8hzP5CBS1B3GrnpNxzMCjWcNsEURc8PmRJLI QTEbR9xI/XHxKDcLmULlGDJCXAcwrWuoGyOpsee6uLjqcH7Oxb/E/GnQWVIm5oFQTx9UKgyPopI K7KCcjuKqGB/OEbSfvAJuvSXKip3/WlU3Zx3t0bBJaekMHTGeNdy+QOWJk0l6nWy4lVYspgSNo3 zZ68TX6q6kFVzMqxe1nc7NjitDXBtUwL0I/Jqn7Qcd2NGeYu5ju9KJh14bM+iLCNN4THF22d2tP 1CZAByg= X-Received: by 2002:a05:600c:4f50:b0:438:a313:cda9 with SMTP id 5b1f17b1804b1-43912d3ef66mr33433615e9.10.1738866440135; Thu, 06 Feb 2025 10:27:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk+UEYR2RxDeuOZyIwHKUzg8T7WWP5AhtfbwRR2NChA4D8rP7yY18tIPjSp5UEN0GoRqcjdg== X-Received: by 2002:a05:600c:4f50:b0:438:a313:cda9 with SMTP id 5b1f17b1804b1-43912d3ef66mr33433435e9.10.1738866439580; Thu, 06 Feb 2025 10:27:19 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 03/22] target/riscv: store RISCVCPUDef struct directly in the class Date: Thu, 6 Feb 2025 19:26:51 +0100 Message-ID: <20250206182711.2420505-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866465126019100 Content-Type: text/plain; charset="utf-8" Prepare for adding more fields to RISCVCPUDef and reading them in riscv_cpu_init: instead of storing the misa_mxl_max field in RISCVCPUClass, ensure that there's always a valid RISCVCPUDef struct and go through it. Signed-off-by: Paolo Bonzini Reviewed-by: Alistair Francis --- target/riscv/cpu.h | 2 +- hw/riscv/boot.c | 2 +- target/riscv/cpu.c | 24 +++++++++++++++++++----- target/riscv/gdbstub.c | 6 +++--- target/riscv/kvm/kvm-cpu.c | 21 +++++++++------------ target/riscv/machine.c | 2 +- target/riscv/tcg/tcg-cpu.c | 8 ++++---- target/riscv/translate.c | 2 +- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index b2c9302634d..f757f0b6210 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -533,7 +533,7 @@ struct RISCVCPUClass { =20 DeviceRealize parent_realize; ResettablePhases parent_phases; - uint32_t misa_mxl_max; /* max mxl for this cpu */ + RISCVCPUDef *def; }; =20 static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index c309441b7d8..13728e137c4 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -37,7 +37,7 @@ bool riscv_is_32bit(RISCVHartArrayState *harts) { RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(&harts->harts[0]); - return mcc->misa_mxl_max =3D=3D MXL_RV32; + return mcc->def->misa_mxl_max =3D=3D MXL_RV32; } =20 /* diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 29cfae38b75..803b2a7c3f4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -354,7 +354,7 @@ void riscv_cpu_set_misa_ext(CPURISCVState *env, uint32_= t ext) =20 int riscv_cpu_max_xlen(RISCVCPUClass *mcc) { - return 16 << mcc->misa_mxl_max; + return 16 << mcc->def->misa_mxl_max; } =20 #ifndef CONFIG_USER_ONLY @@ -1047,7 +1047,7 @@ static void riscv_cpu_reset_hold(Object *obj, ResetTy= pe type) mcc->parent_phases.hold(obj, type); } #ifndef CONFIG_USER_ONLY - env->misa_mxl =3D mcc->misa_mxl_max; + env->misa_mxl =3D mcc->def->misa_mxl_max; env->priv =3D PRV_M; env->mstatus &=3D ~(MSTATUS_MIE | MSTATUS_MPRV); if (env->misa_mxl > MXL_RV32) { @@ -1447,7 +1447,7 @@ static void riscv_cpu_init(Object *obj) RISCVCPU *cpu =3D RISCV_CPU(obj); CPURISCVState *env =3D &cpu->env; =20 - env->misa_mxl =3D mcc->misa_mxl_max; + env->misa_mxl =3D mcc->def->misa_mxl_max; =20 #ifndef CONFIG_USER_ONLY qdev_init_gpio_in(DEVICE(obj), riscv_cpu_set_irq, @@ -1538,7 +1538,7 @@ static void riscv_cpu_validate_misa_mxl(RISCVCPUClass= *mcc) CPUClass *cc =3D CPU_CLASS(mcc); =20 /* Validate that MISA_MXL is set properly. */ - switch (mcc->misa_mxl_max) { + switch (mcc->def->misa_mxl_max) { #ifdef TARGET_RISCV64 case MXL_RV64: case MXL_RV128: @@ -2951,11 +2951,24 @@ static void riscv_cpu_common_class_init(ObjectClass= *c, void *data) device_class_set_props(dc, riscv_cpu_properties); } =20 +static void riscv_cpu_class_base_init(ObjectClass *c, void *data) +{ + RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); + RISCVCPUClass *pcc =3D RISCV_CPU_CLASS(object_class_get_parent(c)); + + if (pcc->def) { + mcc->def =3D g_memdup2(pcc->def, sizeof(*pcc->def)); + } else { + mcc->def =3D g_new0(RISCVCPUDef, 1); + } +} + static void riscv_cpu_class_init(ObjectClass *c, void *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); + RISCVCPUDef *def =3D data; =20 - mcc->misa_mxl_max =3D ((RISCVCPUDef *)data)->misa_mxl_max; + mcc->def->misa_mxl_max =3D def->misa_mxl_max; riscv_cpu_validate_misa_mxl(mcc); } =20 @@ -3106,6 +3119,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .abstract =3D true, .class_size =3D sizeof(RISCVCPUClass), .class_init =3D riscv_cpu_common_class_init, + .class_base_init =3D riscv_cpu_class_base_init, }, { .name =3D TYPE_RISCV_DYNAMIC_CPU, diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 18e88f416af..1934f919c01 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -62,7 +62,7 @@ int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray = *mem_buf, int n) return 0; } =20 - switch (mcc->misa_mxl_max) { + switch (mcc->def->misa_mxl_max) { case MXL_RV32: return gdb_get_reg32(mem_buf, tmp); case MXL_RV64: @@ -82,7 +82,7 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) int length =3D 0; target_ulong tmp; =20 - switch (mcc->misa_mxl_max) { + switch (mcc->def->misa_mxl_max) { case MXL_RV32: tmp =3D (int32_t)ldl_p(mem_buf); length =3D 4; @@ -359,7 +359,7 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) ricsv_gen_dynamic_vector_feature(cs, cs->= gdb_num_regs), 0); } - switch (mcc->misa_mxl_max) { + switch (mcc->def->misa_mxl_max) { case MXL_RV32: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 23ce7793594..0ea5219890e 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1985,22 +1985,19 @@ static void kvm_cpu_accel_register_types(void) } type_init(kvm_cpu_accel_register_types); =20 -static void riscv_host_cpu_class_init(ObjectClass *c, void *data) -{ - RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); - -#if defined(TARGET_RISCV32) - mcc->misa_mxl_max =3D MXL_RV32; -#elif defined(TARGET_RISCV64) - mcc->misa_mxl_max =3D MXL_RV64; -#endif -} - static const TypeInfo riscv_kvm_cpu_type_infos[] =3D { { .name =3D TYPE_RISCV_CPU_HOST, .parent =3D TYPE_RISCV_CPU, - .class_init =3D riscv_host_cpu_class_init, +#if defined(TARGET_RISCV32) + .class_data =3D &((RISCVCPUDef) { + .misa_mxl_max =3D MXL_RV32, + }, +#elif defined(TARGET_RISCV64) + .class_data =3D &((RISCVCPUDef) { + .misa_mxl_max =3D MXL_RV64, + }, +#endif } }; =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index d8445244ab2..b34fc5f6aa5 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -170,7 +170,7 @@ static bool rv128_needed(void *opaque) { RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(opaque); =20 - return mcc->misa_mxl_max =3D=3D MXL_RV128; + return mcc->def->misa_mxl_max =3D=3D MXL_RV128; } =20 static const VMStateDescription vmstate_rv128 =3D { diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 0a137281de1..1cbdef73dc3 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -579,7 +579,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, E= rror **errp) return; } =20 - if (mcc->misa_mxl_max !=3D MXL_RV32 && cpu->cfg.ext_zcf) { + if (mcc->def->misa_mxl_max !=3D MXL_RV32 && cpu->cfg.ext_zcf) { error_setg(errp, "Zcf extension is only relevant to RV32"); return; } @@ -676,7 +676,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, E= rror **errp) return; } =20 - if (mcc->misa_mxl_max =3D=3D MXL_RV32 && cpu->cfg.ext_svukte) { + if (mcc->def->misa_mxl_max =3D=3D MXL_RV32 && cpu->cfg.ext_svukte) { error_setg(errp, "svukte is not supported for RV32"); return; } @@ -890,7 +890,7 @@ static void cpu_enable_zc_implied_rules(RISCVCPU *cpu) cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); =20 - if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max =3D=3D MXL_RV32) { + if (riscv_has_ext(env, RVF) && mcc->def->misa_mxl_max =3D=3D MXL_R= V32) { cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } } @@ -899,7 +899,7 @@ static void cpu_enable_zc_implied_rules(RISCVCPU *cpu) if (riscv_has_ext(env, RVC) && env->priv_ver >=3D PRIV_VERSION_1_12_0)= { cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); =20 - if (riscv_has_ext(env, RVF) && mcc->misa_mxl_max =3D=3D MXL_RV32) { + if (riscv_has_ext(env, RVF) && mcc->def->misa_mxl_max =3D=3D MXL_R= V32) { cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } =20 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 698b74f7a8f..782e724a648 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1234,7 +1234,7 @@ static void riscv_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cs) ctx->cfg_vta_all_1s =3D cpu->cfg.rvv_ta_all_1s; ctx->vstart_eq_zero =3D FIELD_EX32(tb_flags, TB_FLAGS, VSTART_EQ_ZERO); ctx->vl_eq_vlmax =3D FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); - ctx->misa_mxl_max =3D mcc->misa_mxl_max; + ctx->misa_mxl_max =3D mcc->def->misa_mxl_max; ctx->xl =3D FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->address_xl =3D FIELD_EX32(tb_flags, TB_FLAGS, AXL); ctx->cs =3D cs; --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866463; cv=none; d=zohomail.com; s=zohoarc; b=k67QE2Ry0aFCZckqo3OFPU0S3JQg9D9Qy7Y10oJegIz7os3asSdHol/3LB+VdTXqIx11Lrxsv4dyFyCZDS1XCladsqYdh331YRgZ2pANOOyrI5v3OEFtozQnCtzNP6kyOhMgapM9vMuf7o7EGbgry6p3ezd8N+q8tLGEDQsYhws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866463; 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=1Tf0PLSlRzchwCQav+NNO3Tn8pSn6RVnflJVUhvKZHc=; b=QMyq5Th85hVhjQ6twQ+PWp/yqWmeMY5QY24D12pgsdOa/RDqpiL8AquuuMHEW0F5WvJ/XrXf6K+VIxxFnbAda/eS9/iX6F0ostyyO0DHuK3xglD/y0OfiBym6euTwvnN0D+q1F//6JFj/EEu31FQIvbJLHthz/L4nNM31InvQ1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866463069517.0985171289544; Thu, 6 Feb 2025 10:27:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6b5-00019T-8q; Thu, 06 Feb 2025 13:27:31 -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 1tg6b3-00018v-Be for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:29 -0500 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 1tg6b1-00011m-QN for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:29 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-xR2LCKqpMTOUoU4TOOL7VA-1; Thu, 06 Feb 2025 13:27:24 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4359206e1e4so10561755e9.2 for ; Thu, 06 Feb 2025 10:27:24 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9656fsm28597865e9.3.2025.02.06.10.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866447; 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=1Tf0PLSlRzchwCQav+NNO3Tn8pSn6RVnflJVUhvKZHc=; b=VKwB407QYYWysXsoVazfQWNR/IJKIc3Sy62YjiBXjNhQPaE/xmeN5sba8oGU5PSLxLVDgE L5CqexoRM7CZQ1gjf5iZLoi2u6GOP86Jqrxk54ewexAyz1QvzmqPtiQL2aCKzWi6Y0bfdj yIZo9v+/MmzCbs0qeKaam3tzpqSoXqM= X-MC-Unique: xR2LCKqpMTOUoU4TOOL7VA-1 X-Mimecast-MFC-AGG-ID: xR2LCKqpMTOUoU4TOOL7VA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866442; x=1739471242; 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=1Tf0PLSlRzchwCQav+NNO3Tn8pSn6RVnflJVUhvKZHc=; b=cVcfoDBJsLNeaEYk7Ch3GNuir59R+eBBtjXa7etQsqugq5/CJ9stURtq0iuVMYqbG8 s4KxXaeHTW1EM4lb/B/y+VfL3+1CV2ivu0zqaQqHJP71Ld77R0J3QxdReMDCN0klju6p 3sFJ1AwMiHnv3RtZdQIf5ZkEmL+XgWAo+CbFcdICSMKw1oF3uBwhDVYl0OaM2/5UkEYA VMSjXWACEMnMJ66of2EhMagD0/T8WK09MnF1d8bf2OJD6R8HumqRbQl/PgO/U+zPmdM7 UGP6N2zRqMBwuZU25/XENH3+J9oVgtrCXCHuRfkjKGVLAo8b2u20DCb/y2bm4bjXvKvC eu4g== X-Gm-Message-State: AOJu0Yw93h3DhDFytrxWwI0WcjXoj54cE7TRIGc0u+ppNbrY1IvhxGAn y4oYZ0SSu+S8gsLt9UdFMsR7EBMQp7M2b0DDOrtxlebawOslXwGe6hVoHkMrgWkYErW4SZcq0OQ Ri8aU+o3QThskVF1Q+6q8RVyoTlHUzPO33AeEPt10ThBFqGV9pzDQISXXOSiDgyp55mOlJV5dlh hM0qfPqryn/xclrEisvP1Wrx0OugGurqFqJ5bQv/E= X-Gm-Gg: ASbGncsUKWoqpY4ISEI4FHJTKnLdUB/Ro3PpOfW94KCpesAgswn98EJB/FOb71kg2Jj w1maOSlux4XpA3ZfBvEtQ5jaxb50E0NaqIa8sdhmshVRZNWDLljf4lKNPAPx2oJfgerSKfvKJnN Z6XU08wdmLxbw3Ww4lD7ObjZU6bdqKn2MXEgBxlWAzhlEBclsvUyYwm3D/OF2sEtgWpbQfFKSqP U7jVku67pcfIb4kltKuckJgvtX5ayXU3nystW1TzWDw9u1UAk+VjUhe7tK9vwXJxzTWEy++mNDd CxU2VgY= X-Received: by 2002:a7b:c319:0:b0:434:f586:7520 with SMTP id 5b1f17b1804b1-43924a27e47mr4460165e9.6.1738866442365; Thu, 06 Feb 2025 10:27:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFv0yp6Pc/17tva9qeYrjmWryHjjb8YNY48mesuOMfENJWxQ+RpIT6xhMdNRBcgzkuWqpZJw== X-Received: by 2002:a7b:c319:0:b0:434:f586:7520 with SMTP id 5b1f17b1804b1-43924a27e47mr4459935e9.6.1738866441856; Thu, 06 Feb 2025 10:27:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 04/22] target/riscv: merge riscv_cpu_class_init with the class_base function Date: Thu, 6 Feb 2025 19:26:52 +0100 Message-ID: <20250206182711.2420505-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866465116019100 Content-Type: text/plain; charset="utf-8" Since all TYPE_RISCV_CPU subclasses support a class_data of type RISCVCPUDef, process it even before calling the .class_init function for the subclasses. Signed-off-by: Paolo Bonzini Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 803b2a7c3f4..baf4dd017b2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2961,15 +2961,18 @@ static void riscv_cpu_class_base_init(ObjectClass *= c, void *data) } else { mcc->def =3D g_new0(RISCVCPUDef, 1); } -} =20 -static void riscv_cpu_class_init(ObjectClass *c, void *data) -{ - RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); - RISCVCPUDef *def =3D data; + if (data) { + RISCVCPUDef *def =3D data; + if (def->misa_mxl_max) { + assert(def->misa_mxl_max <=3D MXL_RV128); + mcc->def->misa_mxl_max =3D def->misa_mxl_max; + } + } =20 - mcc->def->misa_mxl_max =3D def->misa_mxl_max; - riscv_cpu_validate_misa_mxl(mcc); + if (!object_class_is_abstract(c)) { + riscv_cpu_validate_misa_mxl(mcc); + } } =20 static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, @@ -3069,7 +3072,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, ch= ar *nodename) .name =3D (type_name), \ .parent =3D TYPE_RISCV_DYNAMIC_CPU, \ .instance_init =3D (initfn), \ - .class_init =3D riscv_cpu_class_init, \ .class_data =3D &((RISCVCPUDef) { \ .misa_mxl_max =3D (misa_mxl_max_), \ }), \ @@ -3080,7 +3082,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, ch= ar *nodename) .name =3D (type_name), \ .parent =3D TYPE_RISCV_VENDOR_CPU, \ .instance_init =3D (initfn), \ - .class_init =3D riscv_cpu_class_init, \ .class_data =3D &((RISCVCPUDef) { \ .misa_mxl_max =3D (misa_mxl_max_), \ }), \ @@ -3091,7 +3092,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, ch= ar *nodename) .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ - .class_init =3D riscv_cpu_class_init, \ .class_data =3D &((RISCVCPUDef) { \ .misa_mxl_max =3D (misa_mxl_max_), \ }), \ @@ -3102,7 +3102,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, ch= ar *nodename) .name =3D (type_name), \ .parent =3D TYPE_RISCV_BARE_CPU, \ .instance_init =3D (initfn), \ - .class_init =3D riscv_cpu_class_init, \ .class_data =3D &((RISCVCPUDef) { \ .misa_mxl_max =3D (misa_mxl_max_), \ }), \ --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866469; cv=none; d=zohomail.com; s=zohoarc; b=NPpdKp4bGY7DxbNkG/n3hTtMdmQI7G3Jz3E9zXI4H3FoH0ntJ/vi2g+/Iw2CuWgL3IjOw5nxXzTUkgDAzYeEY4Jiyv11zi0dTmpmHSH8HCGuOWIelEagiOAbrl3tvo2NoS7kuaFyJkGOPZFFm0UxrCQ4WVT8pdqWXJQIc1VircA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866469; 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=8Jd2GBAgmmNc4YTLVxZcDZq5z/Io+fhp6KfK4NhBnTk=; b=Kc6DjNQmelmtskbxxHfcFJN7zC4pq1fe99P5ELDheeHtoC6InqbgBP7TMzeWDxAiZ9FIY0fWtBq0DjohdZo+KTFU0PbtpwTjR0+DKhaKYM6jk7k/y6TG0ROlS3VTBnaHjk868PA4uELz16hCoO9tuSh6UMgGrTnxeaxK8mZHf1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173886646971172.94344666080906; Thu, 6 Feb 2025 10:27:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6b9-0001A0-FA; Thu, 06 Feb 2025 13:27: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 1tg6b7-00019i-FZ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6b5-00013H-EE for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:33 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-phx49kFSNbOGCXbAKGO4AQ-1; Thu, 06 Feb 2025 13:27:27 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38dc32f753dso272141f8f.3 for ; Thu, 06 Feb 2025 10:27:27 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390da70fbesm63563605e9.24.2025.02.06.10.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866450; 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=8Jd2GBAgmmNc4YTLVxZcDZq5z/Io+fhp6KfK4NhBnTk=; b=E1+vnLHYQJOjh0hBsGxRwIkrQ146DnQllDzHQA+pYj9uvEo0oU776KpH3ULzzxmIHHtQHj fi2uehemlizDX2l/tObTs5+NyObXfB+8SM43HPsP1bQgVv4bUHBDfaKkVNN54OvbnYaaY5 IxhYf0J9V3na01HKuD+343TQ5vlzdtE= X-MC-Unique: phx49kFSNbOGCXbAKGO4AQ-1 X-Mimecast-MFC-AGG-ID: phx49kFSNbOGCXbAKGO4AQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866445; x=1739471245; 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=8Jd2GBAgmmNc4YTLVxZcDZq5z/Io+fhp6KfK4NhBnTk=; b=Dm9Kszq0HygnnLivIwqZk1sJLj7sCdiGRYhJOuQDvcOCflNRhwI2KXxNXOG9gbkTlY LbuJtgdMyBBb0YrsrnIRnEeR/fjrA+oJ70m8E8Dq9dKUliMK1zABlpn+XQv3jJFAFdLG Uc184RiXInRZ+AKz/j81mOY4ymVn4+mdv7S6R097ahHHmqWn0JYJKf2swIIdrH2DY6m7 JwKqlIgtCMeDggVXckbQYc7mJl8BvE8kTkwEHGaCESa9+GdawEz4ZXioTyRH5e77F8BC 9a6AiCKctrPg3uUSDiZQU86jnF5WZSZtjpNR4Q4iuCKXPw0QBojlpqzqzYvLWRpoOQqx gJMQ== X-Gm-Message-State: AOJu0YwJdz/0fIPdDIBWKsFJHEtP59xJNckcaC/+EcJlg+Qrcxv3B6Yl AeQRa1xNzbsnPRIBw3TLAxCkYu4Ny3jVMWWeigxPr6w7+r8YPEHWKHy+akDtpCml/Ll4MnArX+Z IJC+SZPG7ExAOGGUGeKdQY48C345IXBT3zHmsv4Fe6OIO034qL3Mz7g4FiDBNuMp/dmXPxrebeP 9g6/71GyAjZuxUu93M14c0+7cXuCrO+ZliNRapSKQ= X-Gm-Gg: ASbGncum/AsHdp1cnIq6qV2vgFiG9MYDLQ1FR2GKWYPiHnLoBk+2N3t7UMmUpcQrmqI vBXxxVhXy9YokMDvhRg7S7a91QWIYiCcKFChsQoLs9FLNjjnHtmJemFVPgReRnH/0EBDKWzVppT B24BCSekJH3tYAryXgid4mz1i0syqOY8LiANu0sMFPVs9+tBUg+Nhsvm9XVEkyB51fvdioyVdK2 f6fya0ZX22MrF7dnIkrSnmIrZGhrFuqEJ5fF6KRviGWv/nzaa5Iqr4VvM2n5L/nQiTdZUU5HKLp uTUFBbU= X-Received: by 2002:a5d:55cb:0:b0:38c:5ba4:48a3 with SMTP id ffacd0b85a97d-38dc959b64fmr5967f8f.46.1738866444970; Thu, 06 Feb 2025 10:27:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLsiuNm14o/e9XpDVkcYLkiCtnxN/mNk8GgKfXiFHLnfJK/rdjbMiJZIUHAr2lPtgSl+UKNw== X-Received: by 2002:a5d:55cb:0:b0:38c:5ba4:48a3 with SMTP id ffacd0b85a97d-38dc959b64fmr5953f8f.46.1738866444553; Thu, 06 Feb 2025 10:27:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 05/22] target/riscv: move RISCVCPUConfig fields to a header file Date: Thu, 6 Feb 2025 19:26:53 +0100 Message-ID: <20250206182711.2420505-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866471466019100 Content-Type: text/plain; charset="utf-8" To support merging a subclass's RISCVCPUDef into the superclass, a list of all the CPU features is needed. Put them into a header file that can be included multiple times, expanding the macros BOOL_FIELD and TYPE_FIELD to different operations. Signed-off-by: Paolo Bonzini Reviewed-by: Alistair Francis --- target/riscv/cpu_cfg.h | 160 +--------------------------- target/riscv/cpu_cfg_fields.h.inc | 167 ++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 157 deletions(-) create mode 100644 target/riscv/cpu_cfg_fields.h.inc diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index b410b1e6038..ad02693fa66 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -37,163 +37,9 @@ typedef struct { } RISCVSATPMap; =20 struct RISCVCPUConfig { - bool ext_zba; - bool ext_zbb; - bool ext_zbc; - bool ext_zbkb; - bool ext_zbkc; - bool ext_zbkx; - bool ext_zbs; - bool ext_zca; - bool ext_zcb; - bool ext_zcd; - bool ext_zce; - bool ext_zcf; - bool ext_zcmp; - bool ext_zcmt; - bool ext_zk; - bool ext_zkn; - bool ext_zknd; - bool ext_zkne; - bool ext_zknh; - bool ext_zkr; - bool ext_zks; - bool ext_zksed; - bool ext_zksh; - bool ext_zkt; - bool ext_zifencei; - bool ext_zicntr; - bool ext_zicsr; - bool ext_zicbom; - bool ext_zicbop; - bool ext_zicboz; - bool ext_zicfilp; - bool ext_zicfiss; - bool ext_zicond; - bool ext_zihintntl; - bool ext_zihintpause; - bool ext_zihpm; - bool ext_zimop; - bool ext_zcmop; - bool ext_ztso; - bool ext_smstateen; - bool ext_sstc; - bool ext_smcdeleg; - bool ext_ssccfg; - bool ext_smcntrpmf; - bool ext_smcsrind; - bool ext_sscsrind; - bool ext_ssdbltrp; - bool ext_smdbltrp; - bool ext_svadu; - bool ext_svinval; - bool ext_svnapot; - bool ext_svpbmt; - bool ext_svvptc; - bool ext_svukte; - bool ext_zdinx; - bool ext_zaamo; - bool ext_zacas; - bool ext_zama16b; - bool ext_zabha; - bool ext_zalrsc; - bool ext_zawrs; - bool ext_zfa; - bool ext_zfbfmin; - bool ext_zfh; - bool ext_zfhmin; - bool ext_zfinx; - bool ext_zhinx; - bool ext_zhinxmin; - bool ext_zve32f; - bool ext_zve32x; - bool ext_zve64f; - bool ext_zve64d; - bool ext_zve64x; - bool ext_zvbb; - bool ext_zvbc; - bool ext_zvkb; - bool ext_zvkg; - bool ext_zvkned; - bool ext_zvknha; - bool ext_zvknhb; - bool ext_zvksed; - bool ext_zvksh; - bool ext_zvkt; - bool ext_zvkn; - bool ext_zvknc; - bool ext_zvkng; - bool ext_zvks; - bool ext_zvksc; - bool ext_zvksg; - bool ext_zmmul; - bool ext_zvfbfmin; - bool ext_zvfbfwma; - bool ext_zvfh; - bool ext_zvfhmin; - bool ext_smaia; - bool ext_ssaia; - bool ext_sscofpmf; - bool ext_smepmp; - bool ext_smrnmi; - bool ext_ssnpm; - bool ext_smnpm; - bool ext_smmpm; - bool ext_sspm; - bool ext_supm; - bool rvv_ta_all_1s; - bool rvv_ma_all_1s; - bool rvv_vl_half_avl; - - uint32_t mvendorid; - uint64_t marchid; - uint64_t mimpid; - - /* Named features */ - bool ext_svade; - bool ext_zic64b; - bool ext_ssstateen; - bool ext_sha; - - /* - * Always 'true' booleans for named features - * TCG always implement/can't be user disabled, - * based on spec version. - */ - bool has_priv_1_13; - bool has_priv_1_12; - bool has_priv_1_11; - - /* Vendor-specific custom extensions */ - bool ext_xtheadba; - bool ext_xtheadbb; - bool ext_xtheadbs; - bool ext_xtheadcmo; - bool ext_xtheadcondmov; - bool ext_xtheadfmemidx; - bool ext_xtheadfmv; - bool ext_xtheadmac; - bool ext_xtheadmemidx; - bool ext_xtheadmempair; - bool ext_xtheadsync; - bool ext_XVentanaCondOps; - - uint32_t pmu_mask; - uint16_t vlenb; - uint16_t elen; - uint16_t cbom_blocksize; - uint16_t cbop_blocksize; - uint16_t cboz_blocksize; - bool mmu; - bool pmp; - bool debug; - bool misa_w; - - bool short_isa_string; - -#ifndef CONFIG_USER_ONLY - RISCVSATPMap satp_mode; -#endif +#define BOOL_FIELD(x) bool x; +#define TYPED_FIELD(type, x) type x; +#include "cpu_cfg_fields.h.inc" }; =20 typedef struct RISCVCPUConfig RISCVCPUConfig; diff --git a/target/riscv/cpu_cfg_fields.h.inc b/target/riscv/cpu_cfg_field= s.h.inc new file mode 100644 index 00000000000..56fffb5f177 --- /dev/null +++ b/target/riscv/cpu_cfg_fields.h.inc @@ -0,0 +1,167 @@ +#ifndef BOOL_FIELD +#define BOOL_FIELD(x) +#endif +#ifndef TYPED_FIELD +#define TYPED_FIELD(type, x) +#endif + +BOOL_FIELD(ext_zba) +BOOL_FIELD(ext_zbb) +BOOL_FIELD(ext_zbc) +BOOL_FIELD(ext_zbkb) +BOOL_FIELD(ext_zbkc) +BOOL_FIELD(ext_zbkx) +BOOL_FIELD(ext_zbs) +BOOL_FIELD(ext_zca) +BOOL_FIELD(ext_zcb) +BOOL_FIELD(ext_zcd) +BOOL_FIELD(ext_zce) +BOOL_FIELD(ext_zcf) +BOOL_FIELD(ext_zcmp) +BOOL_FIELD(ext_zcmt) +BOOL_FIELD(ext_zk) +BOOL_FIELD(ext_zkn) +BOOL_FIELD(ext_zknd) +BOOL_FIELD(ext_zkne) +BOOL_FIELD(ext_zknh) +BOOL_FIELD(ext_zkr) +BOOL_FIELD(ext_zks) +BOOL_FIELD(ext_zksed) +BOOL_FIELD(ext_zksh) +BOOL_FIELD(ext_zkt) +BOOL_FIELD(ext_zifencei) +BOOL_FIELD(ext_zicntr) +BOOL_FIELD(ext_zicsr) +BOOL_FIELD(ext_zicbom) +BOOL_FIELD(ext_zicbop) +BOOL_FIELD(ext_zicboz) +BOOL_FIELD(ext_zicfilp) +BOOL_FIELD(ext_zicfiss) +BOOL_FIELD(ext_zicond) +BOOL_FIELD(ext_zihintntl) +BOOL_FIELD(ext_zihintpause) +BOOL_FIELD(ext_zihpm) +BOOL_FIELD(ext_zimop) +BOOL_FIELD(ext_zcmop) +BOOL_FIELD(ext_ztso) +BOOL_FIELD(ext_smstateen) +BOOL_FIELD(ext_sstc) +BOOL_FIELD(ext_smcdeleg) +BOOL_FIELD(ext_ssccfg) +BOOL_FIELD(ext_smcntrpmf) +BOOL_FIELD(ext_smcsrind) +BOOL_FIELD(ext_sscsrind) +BOOL_FIELD(ext_ssdbltrp) +BOOL_FIELD(ext_smdbltrp) +BOOL_FIELD(ext_svadu) +BOOL_FIELD(ext_svinval) +BOOL_FIELD(ext_svnapot) +BOOL_FIELD(ext_svpbmt) +BOOL_FIELD(ext_svvptc) +BOOL_FIELD(ext_svukte) +BOOL_FIELD(ext_zdinx) +BOOL_FIELD(ext_zaamo) +BOOL_FIELD(ext_zacas) +BOOL_FIELD(ext_zama16b) +BOOL_FIELD(ext_zabha) +BOOL_FIELD(ext_zalrsc) +BOOL_FIELD(ext_zawrs) +BOOL_FIELD(ext_zfa) +BOOL_FIELD(ext_zfbfmin) +BOOL_FIELD(ext_zfh) +BOOL_FIELD(ext_zfhmin) +BOOL_FIELD(ext_zfinx) +BOOL_FIELD(ext_zhinx) +BOOL_FIELD(ext_zhinxmin) +BOOL_FIELD(ext_zve32f) +BOOL_FIELD(ext_zve32x) +BOOL_FIELD(ext_zve64f) +BOOL_FIELD(ext_zve64d) +BOOL_FIELD(ext_zve64x) +BOOL_FIELD(ext_zvbb) +BOOL_FIELD(ext_zvbc) +BOOL_FIELD(ext_zvkb) +BOOL_FIELD(ext_zvkg) +BOOL_FIELD(ext_zvkned) +BOOL_FIELD(ext_zvknha) +BOOL_FIELD(ext_zvknhb) +BOOL_FIELD(ext_zvksed) +BOOL_FIELD(ext_zvksh) +BOOL_FIELD(ext_zvkt) +BOOL_FIELD(ext_zvkn) +BOOL_FIELD(ext_zvknc) +BOOL_FIELD(ext_zvkng) +BOOL_FIELD(ext_zvks) +BOOL_FIELD(ext_zvksc) +BOOL_FIELD(ext_zvksg) +BOOL_FIELD(ext_zmmul) +BOOL_FIELD(ext_zvfbfmin) +BOOL_FIELD(ext_zvfbfwma) +BOOL_FIELD(ext_zvfh) +BOOL_FIELD(ext_zvfhmin) +BOOL_FIELD(ext_smaia) +BOOL_FIELD(ext_ssaia) +BOOL_FIELD(ext_sscofpmf) +BOOL_FIELD(ext_smepmp) +BOOL_FIELD(ext_smrnmi) +BOOL_FIELD(ext_ssnpm) +BOOL_FIELD(ext_smnpm) +BOOL_FIELD(ext_smmpm) +BOOL_FIELD(ext_sspm) +BOOL_FIELD(ext_supm) +BOOL_FIELD(rvv_ta_all_1s) +BOOL_FIELD(rvv_ma_all_1s) +BOOL_FIELD(rvv_vl_half_avl) +/* Named features */ +BOOL_FIELD(ext_svade) +BOOL_FIELD(ext_zic64b) +BOOL_FIELD(ext_ssstateen) +BOOL_FIELD(ext_sha) + +/* + * Always 'true' booleans for named features + * TCG always implement/can't be user disabled, + * based on spec version. + */ +BOOL_FIELD(has_priv_1_13) +BOOL_FIELD(has_priv_1_12) +BOOL_FIELD(has_priv_1_11) + +/* Vendor-specific custom extensions */ +BOOL_FIELD(ext_xtheadba) +BOOL_FIELD(ext_xtheadbb) +BOOL_FIELD(ext_xtheadbs) +BOOL_FIELD(ext_xtheadcmo) +BOOL_FIELD(ext_xtheadcondmov) +BOOL_FIELD(ext_xtheadfmemidx) +BOOL_FIELD(ext_xtheadfmv) +BOOL_FIELD(ext_xtheadmac) +BOOL_FIELD(ext_xtheadmemidx) +BOOL_FIELD(ext_xtheadmempair) +BOOL_FIELD(ext_xtheadsync) +BOOL_FIELD(ext_XVentanaCondOps) + +BOOL_FIELD(mmu) +BOOL_FIELD(pmp) +BOOL_FIELD(debug) +BOOL_FIELD(misa_w) + +BOOL_FIELD(short_isa_string) + +TYPED_FIELD(uint32_t, mvendorid) +TYPED_FIELD(uint64_t, marchid) +TYPED_FIELD(uint64_t, mimpid) + +TYPED_FIELD(uint32_t, pmu_mask) +TYPED_FIELD(uint16_t, vlenb) +TYPED_FIELD(uint16_t, elen) +TYPED_FIELD(uint16_t, cbom_blocksize) +TYPED_FIELD(uint16_t, cbop_blocksize) +TYPED_FIELD(uint16_t, cboz_blocksize) + +#ifndef CONFIG_USER_ONLY +TYPED_FIELD(RISCVSATPMap, satp_mode); +#endif + +#undef BOOL_FIELD +#undef TYPED_FIELD --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866483; cv=none; d=zohomail.com; s=zohoarc; b=WsudsAjxkcXg0Y/3bJLBzqCyWxeMMIwzfF8gnY+kmgxdwrwykrOFkcRL3ywSw+imVsVI0Z1ntaH1LOCxUpdI5B39PPQIr2hbcXK5k0IRiom7QfMljFm0beCUIqeJxZU+QsNvSC9LAFKSeiNcAncb9FewKlvj4BeJZXTTjJUYRro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866483; 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=1GllRVwZqikZ6I8SMf3iZgKJhB7/mY0TuIcEQDqVnWg=; b=ZtC8NEo8OsV1qSLo/5QotQjZbX0WHcFJfqr3oifNkSKgBfsmWg7FajaBBIi8nh7Qxky8jpvuKswhqjIBSfUrASI3+IgNhfiE72uBJPRwa2zPuSaJQKsr7VDeaDJvG94thKNfivKlBeadsK6kv6I4Vq6EXNW7RjKYfpGFYi//o3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866483176414.5705362081428; Thu, 6 Feb 2025 10:28:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6b9-0001A1-TP; Thu, 06 Feb 2025 13:27:36 -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 1tg6b7-00019j-GT for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6b5-00013N-LO for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:33 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-k_bsiNLpMnG6EOOgr7UcoQ-1; Thu, 06 Feb 2025 13:27:29 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-438e4e9a53fso9925775e9.1 for ; Thu, 06 Feb 2025 10:27:29 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dc7711bbbsm204063f8f.47.2025.02.06.10.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866451; 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=1GllRVwZqikZ6I8SMf3iZgKJhB7/mY0TuIcEQDqVnWg=; b=Rrt0SqARUlzSAP4I4LO1814kCPmDCKLUauZeekmDhk28SvrIFHG2tLiZU2TWxAf0/gxL2J tlX8g2cIHgz7iaz77S+LFxfio9P/f328UFXnXaa8raUSzOV8LncDb+4pSBtiCTBwYnctP8 lj6qBML8XHvKvwNt1KuAVEpbK69akGM= X-MC-Unique: k_bsiNLpMnG6EOOgr7UcoQ-1 X-Mimecast-MFC-AGG-ID: k_bsiNLpMnG6EOOgr7UcoQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866448; x=1739471248; 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=1GllRVwZqikZ6I8SMf3iZgKJhB7/mY0TuIcEQDqVnWg=; b=k/M7sYQXrSj4zTBbTnL8BwOEwKpMw0R3PwgXN0ER5tNstrka0rVUHXAx150R1A5mkj udNnvVf3ab30AxHlWhqx9Cp5EAOXzoETHVtziZ5TXqOjctBQICmzLqCM25WdWjwlzgED tRnv15VMr7v2G+TGSYgwY5DyoGT00t/qQf2r8PVAFI4xlRcc9JxucQ1/yN2Lz7cE3kiA Ih9ffUOglcfysIpjcnDnh9PEiwJTA9z5zHbW3/+zJ5mZ7Zk6QzQ4chbI4pWielsZsDSm 19RcLOEQE+hrmwe8AxlnFWgawsmVMOGDHcgCYYr301rsDdDIqJuJcMCVOR+UL+2QSMMl hNnQ== X-Gm-Message-State: AOJu0YzRw+gZcdm92j29oRljHReniKMSnqfYFU7lEjqRCbugd7ethBHW opWbuSSqqbGJw6480L9N5EKVQpVpoztVq0noNOOZQvYJsIUmO4E7y7XtMWI1TrKRnoUDUr2Sit3 3SoF4Uu/AFAgIDjjYAEniK6Jl2i+FpEUueNB3eoNBXm7B/6BIquCQio3gIT2GRqQ3WxOkD6eRE+ p2dCbTJIBV0ghU5jYXcdvRPxC5h9KAyujLljlYSQM= X-Gm-Gg: ASbGncu076upbqoh38GW58y1mDZeNVif/k0mo+2TP1DMeDY4qqsJ4wMcuA1n8nbEwnn dypdA3mprAjtuxM1WsWvaxdtUdhabCj4Rj6MK+EYirgYVffonEsEOWpBHTbaTnHoEqjEBztqOaw SnlM1Nu9ZXxAfw26BZmTcxR2/vDGMVqdrkIsybJiDcCC9KTDC2TTQwkOWLE8MMg2imh0IHnOhzi eEAVlCOYIu9ucxW2o1cIrOfvcf9e0I8XOW6hEtq8vv5rAYhCI5EWQM06phJviUwC4HzL9/vLfRT +ZKfkC4= X-Received: by 2002:a5d:5f96:0:b0:385:df4e:3645 with SMTP id ffacd0b85a97d-38dc937496bmr9359f8f.50.1738866447862; Thu, 06 Feb 2025 10:27:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNz1GWZl59mNs7sjrOqXZ1GHXyKr7cCp7aQfBprVEfIDSKYXmb73BGCcAG8dYZQnLN7o7Ehg== X-Received: by 2002:a5d:5f96:0:b0:385:df4e:3645 with SMTP id ffacd0b85a97d-38dc937496bmr9344f8f.50.1738866447482; Thu, 06 Feb 2025 10:27:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 06/22] target/riscv: add more RISCVCPUDef fields Date: Thu, 6 Feb 2025 19:26:54 +0100 Message-ID: <20250206182711.2420505-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866485365019100 Content-Type: text/plain; charset="utf-8" Allow using RISCVCPUDef to replicate all the logic of custom .instance_init functions. To simulate inheritance, merge the child's RISCVCPUDef with the parent and then finally move it to the CPUState at the end of TYPE_RISCV_CPU's own instance_init function. STRUCT_FIELD is introduced here because I am not sure it is needed; it is a bit ugly and I wanted not to have it in the patch that introduces cpu_cfg_fields.h.inc. I don't really understand why satp_mode is included in RISCVCPUConfig; therefore, the end of the series includes a patch to move satp_mode directly in RISCVCPU, thus removing the need for STRUCT_FIELD; it can be moved before this one in a non-RFC posting. Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 6 ++++ target/riscv/cpu_cfg.h | 1 + target/riscv/cpu_cfg_fields.h.inc | 6 +++- target/riscv/cpu.c | 48 ++++++++++++++++++++++++++++++- 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index f757f0b6210..9b25c0c889b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -519,6 +519,12 @@ struct ArchCPU { =20 typedef struct RISCVCPUDef { RISCVMXL misa_mxl_max; /* max mxl for this cpu */ + uint32_t misa_ext; + int priv_spec; + int32_t vext_spec; + int satp_mode32; + int satp_mode64; + RISCVCPUConfig cfg; } RISCVCPUDef; =20 /** diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index ad02693fa66..07789a9de88 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -39,6 +39,7 @@ typedef struct { struct RISCVCPUConfig { #define BOOL_FIELD(x) bool x; #define TYPED_FIELD(type, x) type x; +#define STRUCT_FIELD(type, x) type x; #include "cpu_cfg_fields.h.inc" }; =20 diff --git a/target/riscv/cpu_cfg_fields.h.inc b/target/riscv/cpu_cfg_field= s.h.inc index 56fffb5f177..cbedf0a703b 100644 --- a/target/riscv/cpu_cfg_fields.h.inc +++ b/target/riscv/cpu_cfg_fields.h.inc @@ -4,6 +4,9 @@ #ifndef TYPED_FIELD #define TYPED_FIELD(type, x) #endif +#ifndef STRUCT_FIELD +#define STRUCT_FIELD(type, x) +#endif =20 BOOL_FIELD(ext_zba) BOOL_FIELD(ext_zbb) @@ -160,8 +163,9 @@ TYPED_FIELD(uint16_t, cbop_blocksize) TYPED_FIELD(uint16_t, cboz_blocksize) =20 #ifndef CONFIG_USER_ONLY -TYPED_FIELD(RISCVSATPMap, satp_mode); +STRUCT_FIELD(RISCVSATPMap, satp_mode) #endif =20 #undef BOOL_FIELD #undef TYPED_FIELD +#undef STRUCT_FIELD diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index baf4dd017b2..1d999488465 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -74,6 +74,15 @@ bool riscv_cpu_option_set(const char *optname) return g_hash_table_contains(general_user_opts, optname); } =20 +static void riscv_cpu_cfg_merge(RISCVCPUConfig *dest, RISCVCPUConfig *src) +{ +#define BOOL_FIELD(x) dest->x |=3D src->x; +#define TYPED_FIELD(type, x) if (src->x) dest->x =3D src->x; + /* only satp_mode, which is initialized by instance_init */ +#define STRUCT_FIELD(type, x) +#include "cpu_cfg_fields.h.inc" +} + #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 @@ -432,7 +441,7 @@ const char *satp_mode_str(uint8_t satp_mode, bool is_32= _bit) } =20 static void set_satp_mode_max_supported(RISCVCPU *cpu, - uint8_t satp_mode) + int satp_mode) { bool rv32 =3D riscv_cpu_mxl(&cpu->env) =3D=3D MXL_RV32; const bool *valid_vm =3D rv32 ? valid_vm_1_10_32 : valid_vm_1_10_64; @@ -1476,6 +1485,24 @@ static void riscv_cpu_init(Object *obj) cpu->cfg.cbop_blocksize =3D 64; cpu->cfg.cboz_blocksize =3D 64; cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; + + env->misa_ext_mask =3D env->misa_ext =3D mcc->def->misa_ext; + riscv_cpu_cfg_merge(&cpu->cfg, &mcc->def->cfg); + + if (mcc->def->priv_spec !=3D RISCV_PROFILE_ATTR_UNUSED) { + cpu->env.priv_ver =3D mcc->def->priv_spec; + } + if (mcc->def->vext_spec !=3D RISCV_PROFILE_ATTR_UNUSED) { + cpu->env.vext_ver =3D mcc->def->vext_spec; + } +#ifndef CONFIG_USER_ONLY + if (riscv_cpu_mxl(env) =3D=3D MXL_RV32 && mcc->def->satp_mode32 !=3D R= ISCV_PROFILE_ATTR_UNUSED) { + set_satp_mode_max_supported(RISCV_CPU(obj), mcc->def->satp_mode32); + } + if (riscv_cpu_mxl(env) >=3D MXL_RV64 && mcc->def->satp_mode64 !=3D RIS= CV_PROFILE_ATTR_UNUSED) { + set_satp_mode_max_supported(RISCV_CPU(obj), mcc->def->satp_mode64); + } +#endif } =20 static void riscv_bare_cpu_init(Object *obj) @@ -2968,6 +2995,25 @@ static void riscv_cpu_class_base_init(ObjectClass *c= , void *data) assert(def->misa_mxl_max <=3D MXL_RV128); mcc->def->misa_mxl_max =3D def->misa_mxl_max; } + if (def->priv_spec !=3D RISCV_PROFILE_ATTR_UNUSED) { + assert(def->priv_spec <=3D PRIV_VERSION_LATEST); + mcc->def->priv_spec =3D def->priv_spec; + } + if (def->vext_spec !=3D RISCV_PROFILE_ATTR_UNUSED) { + assert(def->vext_spec !=3D 0); + mcc->def->vext_spec =3D def->vext_spec; + } + if (def->satp_mode32 !=3D RISCV_PROFILE_ATTR_UNUSED) { + assert(def->satp_mode32 <=3D VM_1_10_SV32); + mcc->def->satp_mode32 =3D def->satp_mode32; + } + if (def->satp_mode64 !=3D RISCV_PROFILE_ATTR_UNUSED) { + assert(def->satp_mode64 <=3D VM_1_10_SV64); + mcc->def->satp_mode64 =3D def->satp_mode64; + } + mcc->def->misa_ext |=3D def->misa_ext; + + riscv_cpu_cfg_merge(&mcc->def->cfg, &def->cfg); } =20 if (!object_class_is_abstract(c)) { --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866503; cv=none; d=zohomail.com; s=zohoarc; b=K2OWnUJe1Dc0Cj9CCp3N8rpHwT69O50sCQP7E55MIgP+GklyxdBPhNuOESvQrhL44Hb4kgacv9vGcbHeb8NcbNuerC0VsnDfJIKOfUFsFYqaah7wwvY/9GYGJ0fMSp1qK7IEc2ElYScHPpxo3mSOoxnyz5Vq3Ld5U84WXv2nUmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866503; 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=51WHnmv/yyWpO4/EKeMo7butDirvPsrNKxtMwcf9yAM=; b=fnTTPl9sWAAR3KfXnFmKXBP7rUMpzquXJYiMV2z1t03CRoE9ZO4VkPP6uDk3Iz8++feV37i8aDeXUqKbVtK5ZBZE1I9F3LMszPQbdOj3BBtMNWOIVJSEeaaGWhEZJGKkt+OEk/VnSabDRzBgeNYgr50mVNQ9AT/fhMl2TtL+QYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866503947915.8973611841772; Thu, 6 Feb 2025 10:28:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bD-0001Bg-Az; Thu, 06 Feb 2025 13:27:39 -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 1tg6bA-0001Ax-So for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:36 -0500 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 1tg6b9-00015D-0T for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:36 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-B2P6-W9OOPyEzPNScHk7lQ-1; Thu, 06 Feb 2025 13:27:32 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-436225d4389so11225075e9.1 for ; Thu, 06 Feb 2025 10:27:31 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9648dsm28122195e9.7.2025.02.06.10.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866454; 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=51WHnmv/yyWpO4/EKeMo7butDirvPsrNKxtMwcf9yAM=; b=C2N3CXCHKFGig6Ltiwo7AO4sFxi0ykWe+qAZUKPqWisDiX10hAUb7P5lhkTxUv/UdrIbtL YziGtTFtrINKvrgn6dCMoEUJnSU6y5iw6e87wRv76LZXmptGs1gPLv2jYKADcUyEXCUBXK IZSFdyyJtbtt1289brmfKa0ym6tyZ5M= X-MC-Unique: B2P6-W9OOPyEzPNScHk7lQ-1 X-Mimecast-MFC-AGG-ID: B2P6-W9OOPyEzPNScHk7lQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866450; x=1739471250; 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=51WHnmv/yyWpO4/EKeMo7butDirvPsrNKxtMwcf9yAM=; b=FAfu4qdv9p7ay+ttfNN0s2TMGCy6fkv61lIdgKVZu9KLJI6uzpoH7QB4LI+LcpE3rl HTxHffA20f7X26oBGIwolwk7lR01Sjuwz1sIhkT0PT65Fn3qYe/umVawpq3i6N1sLgkL fjZzjZxFHjbIJUST9sXtmYxzfWc+XTzPw4+gnxcBwnvwHXyx7YFvhwnHWSbYj4ZTTB5Y 0klqLnOT3BtP4ot5Z+t1P162b6ZxJqH69T8H5DOtECdyrJaHxiCOZbk1cgtewrjpy4Lg iWay8AjLmRr/hBd/3xIFBCyEDA5X067/Rtu9AAAjBynxwByYHBvEVSOP/LaqFFBvTKtk yFsA== X-Gm-Message-State: AOJu0YxVGjFNNheAEqb17ca2wix7LZlw0XX9NgaCmxlWCITk4W1EzQle 1QAK+uK/A+fLAMNHTfBzcZTCVhs0PdM6bVWU7MWGKs7BxaPqHmRfkJdSpDyxtSDAeAzzL7NOiFU yQ0EM5wwuTu0jOaBEKGADqbR9eB/A7D3Fw0xv2jJYGqNyfxE2Zz6efabnWVZoG3iGn0yQKoK6V/ Yifpc1MWivoB6MNhDLu8HUBsxpevxuQzDRnXIL5Es= X-Gm-Gg: ASbGncsIwSI/cMN8k3Zd7WNGvcXTklO0BdpSbBb3Xf/zCTD3qXCxkp3PIJdAY58ovKF BTnAlUbSbkQ/kXTAIhI0R5uilLxyg5ziDbpAaFp9xLewoO+BjwdEDV4feLy0Zjd3gns9qd3JV3G 0q4Cy/vQqH9cLV6puNPF2kaZ5K2BETVAi6dX8592GcsN1evGagj0ACKE/5rqbrmbwCkjbKsUoeb qwEaPMCPdP5jO1JQZwkybWhEb6njnN59SNMMj/9xYVaQKIVnXaOuX5NIWnnvMiCUL4p1kMRKajH AMzSUE0= X-Received: by 2002:a05:600c:5807:b0:434:9e17:190c with SMTP id 5b1f17b1804b1-43912c61fb8mr32872085e9.0.1738866449985; Thu, 06 Feb 2025 10:27:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGedhDH+J+OfrtwBhuinLG/w+u0E9ub7kpuAn9HIyGsFs5zyGthAz+Ge/fp9/joFaDgSg5aPg== X-Received: by 2002:a05:600c:5807:b0:434:9e17:190c with SMTP id 5b1f17b1804b1-43912c61fb8mr32871875e9.0.1738866449549; Thu, 06 Feb 2025 10:27:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 07/22] target/riscv: convert abstract CPU classes to RISCVCPUDef Date: Thu, 6 Feb 2025 19:26:55 +0100 Message-ID: <20250206182711.2420505-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866505515019100 Content-Type: text/plain; charset="utf-8" Start from the top of the hierarchy: dynamic and vendor CPUs are just markers, whereas bare CPUs can have their instance_init function replaced by RISCVCPUDef. The only difference is that the maximum supported SATP mode has to be specified separately for 32-bit and 64-bit modes. Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 89 ++++++++++++++++++++++------------------------ 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9b25c0c889b..1363a081c30 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -525,6 +525,7 @@ typedef struct RISCVCPUDef { int satp_mode32; int satp_mode64; RISCVCPUConfig cfg; + bool bare; } RISCVCPUDef; =20 /** diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1d999488465..1cb091ddb0c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1474,8 +1474,8 @@ 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; + RISCV_CPU(obj)->cfg.ext_zicntr =3D !mcc->def->bare; + RISCV_CPU(obj)->cfg.ext_zihpm =3D !mcc->def->bare; =20 /* Default values for non-bool cpu properties */ cpu->cfg.pmu_mask =3D MAKE_64BIT_MASK(3, 16); @@ -1505,34 +1505,6 @@ static void riscv_cpu_init(Object *obj) #endif } =20 -static void riscv_bare_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - - /* - * Bare CPUs do not inherit the timer and performance - * counters from the parent class (see riscv_cpu_init() - * for info on why the parent enables them). - * - * Users have to explicitly enable these counters for - * bare CPUs. - */ - cpu->cfg.ext_zicntr =3D false; - cpu->cfg.ext_zihpm =3D false; - - /* Set to QEMU's first supported priv version */ - cpu->env.priv_ver =3D PRIV_VERSION_1_10_0; - - /* - * Support all available satp_mode settings. The default - * value will be set to MBARE if the user doesn't set - * satp_mode manually (see set_satp_mode_default()). - */ -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_SV64); -#endif -} - typedef struct misa_ext_info { const char *name; const char *description; @@ -2991,6 +2963,7 @@ static void riscv_cpu_class_base_init(ObjectClass *c,= void *data) =20 if (data) { RISCVCPUDef *def =3D data; + mcc->def->bare |=3D def->bare; if (def->misa_mxl_max) { assert(def->misa_mxl_max <=3D MXL_RV128); mcc->def->misa_mxl_max =3D def->misa_mxl_max; @@ -3143,6 +3116,20 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) }), \ } =20 +#define DEFINE_ABSTRACT_RISCV_CPU(type_name, parent_type_name, ...) \ + { \ + .name =3D (type_name), \ + .parent =3D (parent_type_name), \ + .abstract =3D true, \ + .class_data =3D &((RISCVCPUDef) { \ + .priv_spec =3D RISCV_PROFILE_ATTR_UNUSED, \ + .vext_spec =3D RISCV_PROFILE_ATTR_UNUSED, \ + .satp_mode32 =3D RISCV_PROFILE_ATTR_UNUSED, \ + .satp_mode64 =3D RISCV_PROFILE_ATTR_UNUSED, \ + __VA_ARGS__ \ + }), \ + } + #define DEFINE_PROFILE_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ @@ -3166,22 +3153,32 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .class_init =3D riscv_cpu_common_class_init, .class_base_init =3D riscv_cpu_class_base_init, }, - { - .name =3D TYPE_RISCV_DYNAMIC_CPU, - .parent =3D TYPE_RISCV_CPU, - .abstract =3D true, - }, - { - .name =3D TYPE_RISCV_VENDOR_CPU, - .parent =3D TYPE_RISCV_CPU, - .abstract =3D true, - }, - { - .name =3D TYPE_RISCV_BARE_CPU, - .parent =3D TYPE_RISCV_CPU, - .instance_init =3D riscv_bare_cpu_init, - .abstract =3D true, - }, + + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_DYNAMIC_CPU, TYPE_RISCV_CPU), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_VENDOR_CPU, TYPE_RISCV_CPU), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_BARE_CPU, TYPE_RISCV_CPU, + /* + * Bare CPUs do not inherit the timer and performance + * counters from the parent class (see riscv_cpu_init() + * for info on why the parent enables them). + * + * Users have to explicitly enable these counters for + * bare CPUs. + */ + .bare =3D true, + + /* Set to QEMU's first supported priv version */ + .priv_spec =3D PRIV_VERSION_1_10_0, + + /* + * Support all available satp_mode settings. The default + * value will be set to MBARE if the user doesn't set + * satp_mode manually (see set_satp_mode_default()). + */ + .satp_mode32 =3D VM_1_10_SV32, + .satp_mode64 =3D VM_1_10_SV64 + ), + #if defined(TARGET_RISCV32) DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, MXL_RV32, riscv_max_cpu_= init), #elif defined(TARGET_RISCV64) --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866536; cv=none; d=zohomail.com; s=zohoarc; b=dCF6VQdOZqWD1U5HxLOHvwb/G2kMyslBUWtyCIX47kz1CvPiTlHEBUPt5xjVByq31+5PohMT1Sgy+DTCzNj4w0+9I5oYk8HxyD+ncbVBeZh4mdQ32OMOAzqVwopoPkKRop4ficRaCnCgZ680afxPxhhGPeyopi2EZOIDAEH+IfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866536; 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=UABiNyKZ/bmzmvGkR8mvTpjEe+8Lf7G4PtnKvqxLI9I=; b=Ggk6Y66dNOitkR2Ybv6ADQMrhdtGuHI677Vem99ON2d1jp80LAaAFm2DOLomj278tWXkh0C32ZEG6I7MbKOQhElcF1VrWSPLL9KayV6GBYF3nd4pzF1divsn4BWXd9Ol5TZYvWxz6YKe2h+Seu+pZSWvgU8gwrZOF/Y4djzhzWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866536195747.1726314771702; Thu, 6 Feb 2025 10:28:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bE-0001C9-W4; Thu, 06 Feb 2025 13:27: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 1tg6bB-0001B5-IS for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:37 -0500 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 1tg6b9-00015Z-Qv for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:37 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-XGEvwHVuPDmTfYV9lc8S2Q-1; Thu, 06 Feb 2025 13:27:34 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361ac8b25fso7443215e9.2 for ; Thu, 06 Feb 2025 10:27:33 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391dfc8897sm26502715e9.31.2025.02.06.10.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866455; 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=UABiNyKZ/bmzmvGkR8mvTpjEe+8Lf7G4PtnKvqxLI9I=; b=hzvA9bRygNIV0COENRt1GDwXn5iPGh7CYTcr3dpnv9xBXOe8mqnZ5aE8TJLZI/V3FStfCl /muFJxrPbBZd+dYcr21JIpDtrEhKZM7/Rd2QwHpT8HHbYtEuE8FpxQs07jqFpJ6+ROF/dX P1dvaE9blhXm6Fq3QB4+OPhaRhoIvDM= X-MC-Unique: XGEvwHVuPDmTfYV9lc8S2Q-1 X-Mimecast-MFC-AGG-ID: XGEvwHVuPDmTfYV9lc8S2Q X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866452; x=1739471252; 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=UABiNyKZ/bmzmvGkR8mvTpjEe+8Lf7G4PtnKvqxLI9I=; b=L6ECjT5cMu/4egSpsbAmmc+Hzqevhe08i+VAEucxHitETmvXUPqDUqO+WbwA09msfA e9N4QeRGhJV5S0yfiWkYcvwp/o7ZAZV0W9jT0GQlq8V0QK+SZvi29nmQgxkrf/qtnNaS 8ZYJT2GT6yQ/ZWfTNd60ZwhZzIqFMzG0OjOUuslCevJjqedF3lyvTH2EG0OFhr72DEfC NJ0dB9MH+ZGnNPW82xfdHqna/pfR/caYKJXe4okWRZbmbyX9jyGURje0HipPAiCiHiNY OEYigWe05sFG2SKmGf20HMTPA4usx30Fq0yBh6MAGIK1vQOlcKzpWkCp0lcWCNw2ZAoT v8sw== X-Gm-Message-State: AOJu0YxuS7GdsotjBB397JrvM9X1o9Yqyvaq3Vfwv/dJJHY3EoRZ+Jjz 1nRBMClseergNEwGW3sPIYH5kmju/bPF+MAjLU/7TUVYf8q9vwdMt2kqDum0N9PDjew5HaYvmze 5gLpoXsiv6o+c+/IF8O0FtqFVkczfgZ1HKE/SALLFeGBY84ZuH22uoHJHuXi729LwjVujOj/aHk kGZ8ecIhwcPsxERbaWRPOE4BqzqOk3/hDqHWMak74= X-Gm-Gg: ASbGncvSszIDcmWhf9ZJP1kzAywHc+0qiJ8l62U6HoAlj4kTi0H2pxYyLJ2BrvRpHZC Q4jZqBe5+GFXYgulsT2xBsrHCIYLSwJBisQ+SmibRlOGnWz4SYDPxzBucTQQsJXV61LuIx3rR2Y ux8pfFqkTbmbCHh/zBz8k2RG2z6iM2At6xiPFGH3LpDdjhYVerxCNnNscP7me+qT4qgn1Sy8QJ2 +QUiOroJ2p3Buf9GLsGAVwiQOULH1FQwoWLtI36vs+Q8x4D9lcKlW36XjwbSc5bNXRQxcR8W3V1 AY3SIX0= X-Received: by 2002:a05:600c:3b20:b0:434:fec5:4ef5 with SMTP id 5b1f17b1804b1-4392498fe53mr4665785e9.14.1738866452003; Thu, 06 Feb 2025 10:27:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSpdlN0CPi4WDVY595nEKOIqxIr4ckz9wUgr0CLtJ06JH9+3iZr86CNLoiz/OdIaA8EHwigQ== X-Received: by 2002:a05:600c:3b20:b0:434:fec5:4ef5 with SMTP id 5b1f17b1804b1-4392498fe53mr4665615e9.14.1738866451608; Thu, 06 Feb 2025 10:27:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 08/22] target/riscv: convert profile CPU models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:26:56 +0100 Message-ID: <20250206182711.2420505-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866537391019100 Content-Type: text/plain; charset="utf-8" Profile CPUs reuse the instance_init function for bare CPUs; make them proper subclasses instead. Enabling a profile is now done based on the RISCVCPUDef struct: even though there is room for only one in RISCVCPUDef, subclasses check that the parent class's profile is enabled through the parent profile mechanism. Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 61 +++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 1363a081c30..66ce72f7d41 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -519,6 +519,7 @@ struct ArchCPU { =20 typedef struct RISCVCPUDef { RISCVMXL misa_mxl_max; /* max mxl for this cpu */ + RISCVCPUProfile *profile; uint32_t misa_ext; int priv_spec; int32_t vext_spec; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1cb091ddb0c..253ed5132c4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1486,6 +1486,10 @@ static void riscv_cpu_init(Object *obj) cpu->cfg.cboz_blocksize =3D 64; cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; =20 + if (mcc->def->profile) { + mcc->def->profile->enabled =3D true; + } + env->misa_ext_mask =3D env->misa_ext =3D mcc->def->misa_ext; riscv_cpu_cfg_merge(&cpu->cfg, &mcc->def->cfg); =20 @@ -2868,22 +2872,6 @@ static const Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("x-misa-w", RISCVCPU, cfg.misa_w, false), }; =20 -#if defined(TARGET_RISCV64) -static void rva22u64_profile_cpu_init(Object *obj) -{ - rv64i_bare_cpu_init(obj); - - RVA22U64.enabled =3D true; -} - -static void rva22s64_profile_cpu_init(Object *obj) -{ - rv64i_bare_cpu_init(obj); - - RVA22S64.enabled =3D true; -} -#endif - static const gchar *riscv_gdb_arch_name(CPUState *cs) { RISCVCPU *cpu =3D RISCV_CPU(cs); @@ -2950,6 +2938,22 @@ static void riscv_cpu_common_class_init(ObjectClass = *c, void *data) device_class_set_props(dc, riscv_cpu_properties); } =20 +static bool profile_has_parent(RISCVCPUProfile *trial, RISCVCPUProfile *pa= rent) +{ + if (!parent) { + return true; + } + + while (parent !=3D trial) { + trial =3D trial->parent; + if (!trial) { + return false; + } + } + + return true; +} + static void riscv_cpu_class_base_init(ObjectClass *c, void *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); @@ -2964,6 +2968,11 @@ static void riscv_cpu_class_base_init(ObjectClass *c= , void *data) if (data) { RISCVCPUDef *def =3D data; mcc->def->bare |=3D def->bare; + if (def->profile) { + assert(profile_has_parent(def->profile, mcc->def->profile)); + assert(mcc->def->bare); + mcc->def->profile =3D def->profile; + } if (def->misa_mxl_max) { assert(def->misa_mxl_max <=3D MXL_RV128); mcc->def->misa_mxl_max =3D def->misa_mxl_max; @@ -3130,16 +3139,23 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, = char *nodename) }), \ } =20 -#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max_, initfn) \ +#define DEFINE_RISCV_CPU(type_name, parent_type_name, ...) \ { \ .name =3D (type_name), \ - .parent =3D TYPE_RISCV_BARE_CPU, \ - .instance_init =3D (initfn), \ + .parent =3D (parent_type_name), \ .class_data =3D &((RISCVCPUDef) { \ - .misa_mxl_max =3D (misa_mxl_max_), \ + .priv_spec =3D RISCV_PROFILE_ATTR_UNUSED, \ + .vext_spec =3D RISCV_PROFILE_ATTR_UNUSED, \ + .satp_mode32 =3D RISCV_PROFILE_ATTR_UNUSED, \ + .satp_mode64 =3D RISCV_PROFILE_ATTR_UNUSED, \ + __VA_ARGS__ \ }), \ } =20 +#define DEFINE_PROFILE_CPU(type_name, parent_type_name, profile_) \ + DEFINE_RISCV_CPU(type_name, parent_type_name, \ + .profile =3D &(profile_)) + static const TypeInfo riscv_cpu_type_infos[] =3D { { .name =3D TYPE_RISCV_CPU, @@ -3215,8 +3231,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif /* CONFIG_TCG */ DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV64I, MXL_RV64, rv64i_bare_cpu= _init), DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV64E, MXL_RV64, rv64e_bare_cpu= _init), - DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22U64, MXL_RV64, rva22u64_profi= le_cpu_init), - DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22S64, MXL_RV64, rva22s64_profi= le_cpu_init), + + DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22U64, TYPE_RISCV_CPU_RV64I, RV= A22U64), + DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22S64, TYPE_RISCV_CPU_RV64I, RV= A22S64), #endif /* TARGET_RISCV64 */ }; =20 --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866575; cv=none; d=zohomail.com; s=zohoarc; b=KoQY2tK3o/GBJ70sW+tP01Tvdp70bKpxKPtA7GD24yYDaL7QjiS3/yxntiUXgWYlYUGK+fuTMxaXI7uuMPZ5BPVeApP7h1t4aNb+1RMNIfGK6h3/dgSZmwD8ksTUkz4KgkkY5t4jcciNwetfcso3Gg7AxxjZ6j71SVCRHpDnUPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866575; 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=7pcCO4SpQ971o0wNrM6zoJJ66x7a3+5UaNoshD/fIRI=; b=aUV9sf1iTpQeBki9q17jE2DvuH8OqZorZtvaVFPKL2wDnhHtmzdzrpYGqII8dxqI9B79VTqSvVWn39Cl3ZFLD2aOfNiE1Y0TPAimixQsAPN31debPw41ixlfHCs5y+d/oDNdv3rkArVpJsyoh0by9C8/s11bkdeY+9vWWvVDKN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866574793442.68462072575505; Thu, 6 Feb 2025 10:29:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bM-0001K8-V5; Thu, 06 Feb 2025 13:27:48 -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 1tg6bG-0001GQ-Vl for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bF-0001BA-5Y for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:42 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-cLBfy0XMOjerpA6oF0iJxA-1; Thu, 06 Feb 2025 13:27:35 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-38dc88ed9c0so11591f8f.1 for ; Thu, 06 Feb 2025 10:27:35 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbde1e197sm2391223f8f.91.2025.02.06.10.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866460; 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=7pcCO4SpQ971o0wNrM6zoJJ66x7a3+5UaNoshD/fIRI=; b=WZHH679OVeGW4pgngRI8PAwvT34J33GjkThdp2m9QopAIDvpYzYcrP+bKHrKZfQQd1GxjV bjiVMJVzRhTf257i5t4RMLTtL1lMIZOhUsIai+chCLC/Nn+ZET/N+/ULf5N9MVJ6RTUqpR 6Q0hS9+rP9w03wkTvrz5IA3UhkAbMcg= X-MC-Unique: cLBfy0XMOjerpA6oF0iJxA-1 X-Mimecast-MFC-AGG-ID: cLBfy0XMOjerpA6oF0iJxA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866454; x=1739471254; 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=7pcCO4SpQ971o0wNrM6zoJJ66x7a3+5UaNoshD/fIRI=; b=HSdTXAeiTArt+CRELRlaOcNkhY1WElVK94jVmNEIOiZ0uyWRcaMG3/+uoprk6rYXHT fOmftdymstKFItXzIGssxzvqzsMugfML2eCZyeL35dg/OJRkr+DbTeZ6XCiuAbGVtTkB Ys6E5kAdcz7pfGVWNRZoxFwLs+Px3aW/yLBKh4PnvrmJOkgBL2zUJ8w3jODC2GUDHzb4 6IsHxXjVZPwIDYfKibzRkCcm7WQnui7wY+MFzZp4w5/5IZZY/ouNQlaGzUAWbnDED5Cs 2JrHumn3raeaafJ5FIBULqEdljISsP1PJMe7bwF9VzgBdKa3RdB8Z74v0sZWu9/Cpa1s weSw== X-Gm-Message-State: AOJu0YzCXt4ZgJ8n3NqBziKzh7q0QpeqS5Ru5eDfS2bk/Qtcb2RyTTtF jva8H+T9/euhSs3uRTAwOIvMwz4gezXa2Ow6hOXBfFMdJpi4n5+kTlRlRwJXFJsMU3dlZsrP/2r 1v/TXiCHMe4deUUnVx4NyHpsMQIMlfDZNXVlgrgY3SCuI/2WvYMpqYKY80BoZlaDvZYWR2aY+QG ZW5m+dc5+BH/lNUnLiCHx5IY4Z2JxpcoR+Ix/EWRY= X-Gm-Gg: ASbGnctB8bOWyzMXYnfhAr2Co3KgHV0msGMysCTeIYpXZhI1kHAjazT4O5vaCN+XbkL 1srbdAn4MWnUfHj5+Rtrolu7bZQ/VJVIHw1UX430Nay/pOwlgyRcQ7Oa/8Ps1E99rTu60RpyA7W P7ZE9JmEMGbfFl2pC3fSwHRg1a0P3Vf/S+xp/3b4nMPXPglHG9ewso/yiSB/+DZY+hluul0wQVr st2zXHgoVVBUrZq+Hg5WxGkdtBEAcv0YYh2YERyr/L5s3FWTrCmyw1fxa5EwtOT1MKhe0ikO9GH z9KRX1M= X-Received: by 2002:a05:6000:1865:b0:38c:5fbf:10d6 with SMTP id ffacd0b85a97d-38dc90e19e9mr31393f8f.7.1738866454017; Thu, 06 Feb 2025 10:27:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuskJhfYhKgy/vpY0wl2WD/MWu7slN4RhBY3/+DJkuYkUt9DRpfgXeebnMnsbwCvngNYT5UA== X-Received: by 2002:a05:6000:1865:b0:38c:5fbf:10d6 with SMTP id ffacd0b85a97d-38dc90e19e9mr31379f8f.7.1738866453619; Thu, 06 Feb 2025 10:27:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 09/22] target/riscv: convert bare CPU models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:26:57 +0100 Message-ID: <20250206182711.2420505-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866576003019000 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 55 ++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 253ed5132c4..5c6ba511ef2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -727,18 +727,6 @@ static void rv128_base_cpu_init(Object *obj) } #endif /* CONFIG_TCG */ =20 -static void rv64i_bare_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - riscv_cpu_set_misa_ext(env, RVI); -} - -static void rv64e_bare_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - riscv_cpu_set_misa_ext(env, RVE); -} - #endif /* !TARGET_RISCV64 */ =20 #if defined(TARGET_RISCV32) || \ @@ -831,18 +819,6 @@ static void rv32_imafcu_nommu_cpu_init(Object *obj) cpu->cfg.ext_zicsr =3D true; cpu->cfg.pmp =3D true; } - -static void rv32i_bare_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - riscv_cpu_set_misa_ext(env, RVI); -} - -static void rv32e_bare_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - riscv_cpu_set_misa_ext(env, RVE); -} #endif =20 static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) @@ -3115,16 +3091,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) }), \ } =20 -#define DEFINE_BARE_CPU(type_name, misa_mxl_max_, initfn) \ - { \ - .name =3D (type_name), \ - .parent =3D TYPE_RISCV_BARE_CPU, \ - .instance_init =3D (initfn), \ - .class_data =3D &((RISCVCPUDef) { \ - .misa_mxl_max =3D (misa_mxl_max_), \ - }), \ - } - #define DEFINE_ABSTRACT_RISCV_CPU(type_name, parent_type_name, ...) \ { \ .name =3D (type_name), \ @@ -3208,8 +3174,15 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E31, MXL_RV32, rv32_sifive_e_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E34, MXL_RV32, rv32_imafcu_no= mmu_cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U34, MXL_RV32, rv32_sifive_u_= cpu_init), - DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV32I, MXL_RV32, rv32i_bare_cpu= _init), - DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV32E, MXL_RV32, rv32e_bare_cpu= _init), + + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV32I, TYPE_RISCV_BARE_CPU, + .misa_mxl_max =3D MXL_RV32, + .misa_ext =3D RVI + ), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV32E, TYPE_RISCV_BARE_CPU, + .misa_mxl_max =3D MXL_RV32, + .misa_ext =3D RVE + ), #endif =20 #if (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) @@ -3229,8 +3202,14 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #ifdef CONFIG_TCG DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE128, MXL_RV128, rv128_base_cpu= _init), #endif /* CONFIG_TCG */ - DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV64I, MXL_RV64, rv64i_bare_cpu= _init), - DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV64E, MXL_RV64, rv64e_bare_cpu= _init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV64I, TYPE_RISCV_BARE_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVI + ), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV64E, TYPE_RISCV_BARE_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVE + ), =20 DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22U64, TYPE_RISCV_CPU_RV64I, RV= A22U64), DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22S64, TYPE_RISCV_CPU_RV64I, RV= A22S64), --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866515; cv=none; d=zohomail.com; s=zohoarc; b=HcY2sG0JvN5TkbvjXlbD8K8uHshHDajfHA4I2jkytZYd1Ch840/3Hb6UJcG/kM+prvH159DMPfqkKinZ34jEllJ00XsMRMbjzOVugWs3bLgPcTR47e9g3Cw/n2anhG8rOOGzG0WYjOsrlHbRVPtChHcxv+5JCyhqxwSWnplf5jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866515; 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=yDa/P6A4hBHQJCiarxStLpV2pO+dqpAl69C6M2CZXUM=; b=VBunmbXgDdQlfW3TnMnTXtaXwOKwYmuOrhXMKL+nHan7APOFqt1NLND6jUNTd+RmKUfPoTGnV7NFSo2Lh3cemARA9YeshNduQi/8Zfk7pXglGit9A99dJ5HkBAJUo9XmvNNNPpC11ffx6orMkwrP4sgkPvxFhXNVGHciVdkf+Wo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866515304825.7002560448708; Thu, 6 Feb 2025 10:28:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bJ-0001Go-5J; Thu, 06 Feb 2025 13:27:47 -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 1tg6bF-0001CI-Cz for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bD-000195-P7 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:41 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-OUmqGXvCPrS8jv0c09cIhw-1; Thu, 06 Feb 2025 13:27:37 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38db0b5405bso599830f8f.1 for ; Thu, 06 Feb 2025 10:27:37 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391dfc8a4asm27499975e9.32.2025.02.06.10.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866459; 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=yDa/P6A4hBHQJCiarxStLpV2pO+dqpAl69C6M2CZXUM=; b=baNUEVsOzGM8ZL6+ct9ycYsBCEoDVGxvsefwt49QYwRnMZOsP45o8fZkYi1yNZ6Eq3KF95 TMD5cis8ipMHAl9IDdug0f8vtbLuW4ofFW7kjUKIgpE8Uojivh3595q4WGunPfx71YpTDR hPcmARJyRfSpPsBaF3X9VSBUJMhMXJo= X-MC-Unique: OUmqGXvCPrS8jv0c09cIhw-1 X-Mimecast-MFC-AGG-ID: OUmqGXvCPrS8jv0c09cIhw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866456; x=1739471256; 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=yDa/P6A4hBHQJCiarxStLpV2pO+dqpAl69C6M2CZXUM=; b=wnnppcuXNfj+/r3DPFX5A5Sm7H28zy68qFlCoVz8dQTjQsAFbhVUw6i6Ft4GAXd5LM sWiwQCC6EeX8f2vrppSjXVU6OX4QoeuVidZJ9ABkDfS4QS0Eyi4YIaonH8O3fqJi/3KT dmgM55IDFNu+mpCNGKEQjZgnu3VknIzyreMW8F3d2hLSR+spyCTBc1/R3cdQ6ezK4gkE JA+WWRVrGX+cXyCnTzbqQy+YxAFSzc6J7TPFYKzejH2RkNTiS4oiTKIZLwWc8xv0zPpM VR03HMnx3LCHjPkV3OTgt2WyPGMkOpwHLZWMkR3GejejyxW6VeUpzwrcj3e78Uw0fcnj b6dQ== X-Gm-Message-State: AOJu0YzX4gMk5i1qf/iLWL6M2PndqmF0zkw9QkZCpAXX9FTiJ+iM2xpC aJ6/CJYLFE2g+rVAqhqajkZVHyMA5y7rIeWrZ4wHl0jGUVLyaLHFxNI//eAmf1hvKgbuCxn9b7n PL/DGwhFDYOAsc7wCGXprLeItFmGEx+ahdr0sZ+Og2Ce5zSHuvCb8JXxQL9ymAqmumtGo0qNhYZ jAlx8UAqEoohTkINghz/gHLIdaP8hx+IdgWVJtoa8= X-Gm-Gg: ASbGncvboP7r3949gCZU1FcRXZcMSClZAUlG3XfVxGsrM2yZOfcXauMLSZTGtf39vPu Do9N8dP7k353SAAYBFyKFNffg3BO5a9iKoGBTmAC65i0o8MzF2ScjmEHEvlaWLESjXp/INU7j44 S498/jMTls4D7FTD6EMO+aoJMVsm//06XG6AJjOrQe5U6wjGx/fnLy/giuUqrBvh6J2ljsL8Whe 4/ZjGdUvB8qpiGz2FxIcsOiKqLD7IaaEmwflYfdFgI9/kMj7PhJHIpuGZL8DDucFJsh4I0VEkW4 sClFzVE= X-Received: by 2002:a5d:5f4e:0:b0:386:3bde:9849 with SMTP id ffacd0b85a97d-38dbb251efdmr3159524f8f.12.1738866455993; Thu, 06 Feb 2025 10:27:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGsaQ7qF5N2Fe6k1kvfu7fWbq1iH8InINZsDwOQR7jSy51LQ4+33N5jJFCKSfX4cQhE8M0UA== X-Received: by 2002:a5d:5f4e:0:b0:386:3bde:9849 with SMTP id ffacd0b85a97d-38dbb251efdmr3159511f8f.12.1738866455640; Thu, 06 Feb 2025 10:27:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 10/22] target/riscv: move 128-bit check to TCG realize Date: Thu, 6 Feb 2025 19:26:58 +0100 Message-ID: <20250206182711.2420505-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866517363019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 7 ------- target/riscv/tcg/tcg-cpu.c | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5c6ba511ef2..8fa05912698 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -709,13 +709,6 @@ static void rv128_base_cpu_init(Object *obj) RISCVCPU *cpu =3D RISCV_CPU(obj); CPURISCVState *env =3D &cpu->env; =20 - 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); - } - cpu->cfg.mmu =3D true; cpu->cfg.pmp =3D true; =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 1cbdef73dc3..46cd8032c79 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -1014,6 +1014,7 @@ static bool riscv_cpu_is_generic(Object *cpu_obj) static bool riscv_tcg_cpu_realize(CPUState *cs, Error **errp) { RISCVCPU *cpu =3D RISCV_CPU(cs); + RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(cpu); =20 if (!riscv_cpu_tcg_compatible(cpu)) { g_autofree char *name =3D riscv_cpu_get_name(cpu); @@ -1022,6 +1023,14 @@ static bool riscv_tcg_cpu_realize(CPUState *cs, Erro= r **errp) return false; } =20 + if (mcc->def->misa_mxl_max >=3D MXL_RV128 && qemu_tcg_mttcg_enabled())= { + /* Missing 128-bit aligned atomics */ + error_setg(errp, + "128-bit RISC-V currently does not work with Multi " + "Threaded TCG. Please use: -accel tcg,thread=3Dsingle"); + return false; + } + #ifndef CONFIG_USER_ONLY CPURISCVState *env =3D &cpu->env; =20 --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866560; cv=none; d=zohomail.com; s=zohoarc; b=VqF+fqI75RiGd40xphpynfJfwi/T4ykI6qdg3xmD4BdCuncPgTWAzuFyjLGLKB4UNMFdolHhS0YAejbK4ZzjRikrwmR14a5RCbeTmHAdusl5K6/T0VIUp6i0+O3FN2aCJK5vMzfEXRcRoL1A8QR9V+PLFBYzfQzzreWC/dzvOu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866560; 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=WfQdeCQldvCzU2bB21S1eT25+I26YnRTxVCOSd/76gs=; b=fWmFDeKqOWXZjlZPToTxYh3VHKCAXa6WcyxMRs3uI+ho8h23QegkBwHT5anbnDIj6qH5jJ9CkAGbx2ZHLeIYlbhkjOrcm96t1PSUlnuFKgI3C7Kwqscqjw+8oxf2ifzIfuyVirkvAaqQl/7d3dHnvOwkoaoClHc8I85ab3Lxons= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866560469289.79436162112825; Thu, 6 Feb 2025 10:29:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6cQ-0006hk-CP; Thu, 06 Feb 2025 13:28:54 -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 1tg6cN-0006PQ-8a for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:51 -0500 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 1tg6cL-0001je-Bi for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:50 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-7jiWc187MKKS8Xs4T7Bq0Q-1; Thu, 06 Feb 2025 13:27:41 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38dbe50b2d0so467703f8f.2 for ; Thu, 06 Feb 2025 10:27:41 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d94d40csm62479165e9.9.2025.02.06.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866528; 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=WfQdeCQldvCzU2bB21S1eT25+I26YnRTxVCOSd/76gs=; b=NzxyaLoil/DXv4g9I+Ivp32yCcPBcstLtMoJyK0I2zxYxmLIOs17CqnUlpMTO/L3pO8sYd 2RuvfwocNBywVq5BXOOvnR1LxwqFJDmDKP+g5YcaOtWTZZDyXafoQ7a+zTczdcPXSu6IbO EEGZlNZSvZud7SCYhJIkf9z7P04VjE8= X-MC-Unique: 7jiWc187MKKS8Xs4T7Bq0Q-1 X-Mimecast-MFC-AGG-ID: 7jiWc187MKKS8Xs4T7Bq0Q X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866459; x=1739471259; 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=WfQdeCQldvCzU2bB21S1eT25+I26YnRTxVCOSd/76gs=; b=vTO3L2VV1/k+0MCXC/LLJ0CVa4Y311EAixvKapRtIDR3J/SzoEJ+3424cGdeQ7tEWS 1Rv2PKyflEXNhJUiX9IB2jK7QEJNhZbnQdqCu+Q8PsBLRN+A/FkSKWgtG3pfZhGBcQWz Nx2wWG1xS4lnLPBet6XyIJEJaJ/J+KwbFaVHTHhZeTMlLRh3Gc9avbJ5fHMWXKS1Py+k vn6oWwSMn+cOl93fL5rAXGrpHC0bK7rHvPWTezewFJt5pO7SLAS43b6Z2II1hHyAQpJB Rw+qb6uGxy0qzLsjBNnSiLcuwhWPfwZJ8OYjKY7fVNLIr7D5VgQ4UE8ARSiZRr9ozwCa r2Yw== X-Gm-Message-State: AOJu0Yw7+zovAIES3Lnk0bJx3WQ+wDzFM93jG/RWPHW5+SGIUXu23PJs qdih5dObqJI8CUDa3nttKgtYcid3VzXvr5+DfvG0AOZSvAKJGWN+sF3OlEF5yxGdwY5d+dj6Bc2 hIrr/jfdHy9BSCKYmkwVSLr/9SnjTdNIv5LPmXdexIKb7b+5765f3fw0ebVF9jXQ29EvrO/Wsvt 5h/ZHxtZBT1E2638Op6ZicXIjDxcsuoNZ2VdX96jI= X-Gm-Gg: ASbGncuva2SUq92gDT8w/Ac83gH1JATRqbuf5fcXNg/UWzgFqQlrUfx1oDQnEGKDwiL lAzCQsqqhi7jCbat0dCURd9XSbzIkCL4c0ruQ5xuKKZ6jwqovFdB7fvgldwlGxlrFR5AfGbYfTl 0KA9Obri+jenTit9yBuw3jGyVz9VfYCW9sj8/zRykb0lbMl+494ApBRdchFbVt05dgeJWhdtFsV O46EVtPPbyL4xbXyRuw1SG8ScXt2QWpnqgfheLtsjg1yDp0YfPtq9OtR1vjmNfM9gT5kmbyA5uB pCi1/nE= X-Received: by 2002:a05:6000:1865:b0:386:1cd3:8a03 with SMTP id ffacd0b85a97d-38dc9346494mr20517f8f.32.1738866458909; Thu, 06 Feb 2025 10:27:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+c4opaFVEZmdjft9gm5GyTM7YgJ0k5g+8F9RZ0jBDk7frQA6OT3tYGuvjy4kzd4jo7mOdag== X-Received: by 2002:a05:6000:1865:b0:386:1cd3:8a03 with SMTP id ffacd0b85a97d-38dc9346494mr20476f8f.32.1738866457987; Thu, 06 Feb 2025 10:27:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 11/22] target/riscv: convert dynamic CPU models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:26:59 +0100 Message-ID: <20250206182711.2420505-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866561981019000 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 110 +++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 80 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8fa05912698..ce439f1159d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -471,38 +471,7 @@ static void set_satp_mode_default_map(RISCVCPU *cpu) } #endif =20 -static void riscv_max_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), - riscv_cpu_mxl(&RISCV_CPU(obj)->env) =3D=3D MXL_RV32 ? - VM_1_10_SV32 : VM_1_10_SV57); -#endif -} - #if defined(TARGET_RISCV64) -static void rv64_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57); -#endif -} - static void rv64_sifive_u_cpu_init(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); @@ -703,43 +672,11 @@ static void rv64_xiangshan_nanhu_cpu_init(Object *obj) #endif } =20 -#ifdef CONFIG_TCG -static void rv128_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV57); -#endif -} -#endif /* CONFIG_TCG */ - #endif /* !TARGET_RISCV64 */ =20 #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) =20 -static void rv32_base_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - - /* Set latest version of privileged specification */ - env->priv_ver =3D PRIV_VERSION_LATEST; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32); -#endif -} - static void rv32_sifive_u_cpu_init(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); @@ -3064,16 +3001,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) } #endif =20 -#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max_, initfn) \ - { \ - .name =3D (type_name), \ - .parent =3D TYPE_RISCV_DYNAMIC_CPU, \ - .instance_init =3D (initfn), \ - .class_data =3D &((RISCVCPUDef) { \ - .misa_mxl_max =3D (misa_mxl_max_), \ - }), \ - } - #define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \ { \ .name =3D (type_name), \ @@ -3129,7 +3056,12 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .class_base_init =3D riscv_cpu_class_base_init, }, =20 - DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_DYNAMIC_CPU, TYPE_RISCV_CPU), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_DYNAMIC_CPU, TYPE_RISCV_CPU, + .cfg.mmu =3D true, + .cfg.pmp =3D true, + .priv_spec =3D PRIV_VERSION_LATEST, + ), + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_VENDOR_CPU, TYPE_RISCV_CPU), DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_BARE_CPU, TYPE_RISCV_CPU, /* @@ -3154,15 +3086,23 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .satp_mode64 =3D VM_1_10_SV64 ), =20 + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_MAX, TYPE_RISCV_DYNAMIC_CPU, + .satp_mode32 =3D VM_1_10_SV32, #if defined(TARGET_RISCV32) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, MXL_RV32, riscv_max_cpu_= init), + .misa_mxl_max =3D MXL_RV32, #elif defined(TARGET_RISCV64) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, MXL_RV64, riscv_max_cpu_= init), + .satp_mode64 =3D VM_1_10_SV57, + .misa_mxl_max =3D MXL_RV64, #endif + ), =20 #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE32, MXL_RV32, rv32_base_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE32, TYPE_RISCV_DYNAMIC_CPU, + .satp_mode32 =3D VM_1_10_SV32, + .misa_mxl_max =3D MXL_RV32, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_IBEX, MXL_RV32, rv32_ibex_cpu_= init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E31, MXL_RV32, rv32_sifive_e_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E34, MXL_RV32, rv32_imafcu_no= mmu_cpu_init), @@ -3179,11 +3119,18 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif =20 #if (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX32, MXL_RV32, riscv_max_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_MAX32, TYPE_RISCV_DYNAMIC_CPU, + .satp_mode32 =3D VM_1_10_SV32, + .misa_mxl_max =3D MXL_RV32, + ), #endif =20 #if defined(TARGET_RISCV64) - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE64, MXL_RV64, rv64_base_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE64, TYPE_RISCV_DYNAMIC_CPU, + .satp_mode64 =3D VM_1_10_SV57, + .misa_mxl_max =3D MXL_RV64, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E51, MXL_RV64, rv64_sifive_e_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U54, MXL_RV64, rv64_sifive_u_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SHAKTI_C, MXL_RV64, rv64_sifive_u_= cpu_init), @@ -3193,7 +3140,10 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, MXL_RV64, rv64_xiangshan_= nanhu_cpu_init), #ifdef CONFIG_TCG - DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE128, MXL_RV128, rv128_base_cpu= _init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE128, TYPE_RISCV_DYNAMIC_CPU, + .satp_mode64 =3D VM_1_10_SV57, + .misa_mxl_max =3D MXL_RV128, + ), #endif /* CONFIG_TCG */ DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV64I, TYPE_RISCV_BARE_CPU, .misa_mxl_max =3D MXL_RV64, --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866552; cv=none; d=zohomail.com; s=zohoarc; b=kXETawSk6NW5aX+N9vFTX2HAWepA2VpRFIoTfoEZNxjRSC0qDUnlNtBsDoH5haoqSZVg1u0U7Bxdlcdd+lEII/qxYRP9SYZ5JXoB+LhMUpdehHCPyZqwwnp7eXSuszi+f56sGuX6mC2skKmAMaz3Tzccx/CbvrofpZwwxVI+LZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866552; 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=8S/fFckl2GPx1zzTTImVbffXXhjNwHps1sJHArnKbZU=; b=OZ8QHFIXAlWqCJeMVYQOfukRHKVlRRcSapHPwEb+FkCQW0+BBZe6xvnnNhv+nU0RKAbMwHH5LTRarNUcHZg0Zqnug+pLqtyJAWuqxf8rMcGev8DV6Hah2fjanCRJRNJiy7vMJTbeUdmsfoI2KvoFtxY+toDu6e4g1p2rUrLXlZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866552868374.42681498410934; Thu, 6 Feb 2025 10:29:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bO-0001Mj-6B; Thu, 06 Feb 2025 13:27:50 -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 1tg6bJ-0001Hn-VX for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:47 -0500 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 1tg6bI-0001D2-BP for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:45 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-qOCXJ6UIPIWxYjdHjHJd6Q-1; Thu, 06 Feb 2025 13:27:42 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-38db560edc3so597042f8f.3 for ; Thu, 06 Feb 2025 10:27:41 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbde0fd3csm2381751f8f.62.2025.02.06.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866463; 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=8S/fFckl2GPx1zzTTImVbffXXhjNwHps1sJHArnKbZU=; b=M2xPRiA15l8OhYz7jIFlPgScXVumAPkYhfIvX+qo8fwDa4S6VIn9zxlLObSQDe/AeOxdiC 5NDYyi42cfSfq89muuhY9f4Bh9s9olquajmjsnxOCBtAMXPK6gQ411wBd7CSjgLCe97fef 7oIxHAeAJ04/Lwo8gACdFzjmKhMBRpA= X-MC-Unique: qOCXJ6UIPIWxYjdHjHJd6Q-1 X-Mimecast-MFC-AGG-ID: qOCXJ6UIPIWxYjdHjHJd6Q X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866460; x=1739471260; 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=8S/fFckl2GPx1zzTTImVbffXXhjNwHps1sJHArnKbZU=; b=tWKBSuoNTkv24mI+veYqX1v1hXPCDuCNwNcR3n1M8/pGMTtqY5UOodQ0ZmaW/57tez fLihTvlEj4zESztFUCSMAOmDr2anFLP1ggX6wEQ5UHFvnUH2l56s5tDymrOi/m4fa4Cb 2NW9Kk+MIi12ITYNFySY4V81u02KAfcysuPVoa6YbcaPdlKU4qcvFZoAp586La6Kow19 7rsTskQwLdT9OgUKiwVMCft+rE9mfOXAVJrg1YCLQrikeoOUcWR5YBz3bE4o1qCybD1p N3OdVeGmOJjxpOtHrRJ9op6Nmp1I7XUhRPuEG1kpjZXLssaJF0q/kUJOMNdkwyYc5SXr dnmA== X-Gm-Message-State: AOJu0YwkCyucnb6PhMA7WdIsrJQ+EsdqbiDNPXwKp0c2pmKTtFaU4z2a PtTKxhFD+8BOn//adcIYvY83ko6mIYNVacCT++NFG8Hhsgq+NyArjURNIQpC7FmoKpSiwon9Ddb Kj91jJaniwP6KxUsvE9YzCqegutWcd3xd9QCdTWj1AYH3P6X0bcW+eDfaB9TD94fxoTxl9RFHRI Qb1W+uDkg1Qkxm4DZOFkpZDeiHkv/CjGDkTCEf3ko= X-Gm-Gg: ASbGncsC8MbjW+xu+qypiG1CdSDDQfB7Etqs9912P1Lga0aVVhexD4FaNVi82hiyx/2 MGWgmGqZXKzI3Z0fRfD8yitvSykk8aTp3d02PefKPgPT9ylihvhUmoRuqYb1g0wk0GPjJVEMgoA 8XgDDkWsNrB4w/gER0FCVvAiqmCVf9MS+94AqtpcJJD9luyPvGtcO6GYHPxNsT6Kar2VeWRdN7j r4G4NZsYddzhnOLhraRd0WWFFYuMrUBHWM8VenvBNJp/yrsh97uGvcQS00x+U0fxJETHELJFaSz BTt8IIM= X-Received: by 2002:a5d:5848:0:b0:38d:b2b8:fadd with SMTP id ffacd0b85a97d-38dc90ff5c2mr29878f8f.32.1738866459868; Thu, 06 Feb 2025 10:27:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcpXI0zvy385GdXXeHyLFZf/9EFhdyCf8uVQ8ZUHSgnFpdMYqD+JDgypUk/9iBWaq53ivnHg== X-Received: by 2002:a5d:5848:0:b0:38d:b2b8:fadd with SMTP id ffacd0b85a97d-38dc90ff5c2mr29860f8f.32.1738866459482; Thu, 06 Feb 2025 10:27:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 12/22] target/riscv: convert SiFive E CPU models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:00 +0100 Message-ID: <20250206182711.2420505-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866555453019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 75 ++++++++++++------------------------------ 2 files changed, 22 insertions(+), 54 deletions(-) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index d56b067bf24..bfe1455254c 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -42,6 +42,7 @@ #define TYPE_RISCV_CPU_RVA22S64 RISCV_CPU_TYPE_NAME("rva22s64") #define TYPE_RISCV_CPU_IBEX RISCV_CPU_TYPE_NAME("lowrisc-ibex") #define TYPE_RISCV_CPU_SHAKTI_C RISCV_CPU_TYPE_NAME("shakti-c") +#define TYPE_RISCV_CPU_SIFIVE_E RISCV_CPU_TYPE_NAME("sifive-e") #define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") #define TYPE_RISCV_CPU_SIFIVE_E34 RISCV_CPU_TYPE_NAME("sifive-e34") #define TYPE_RISCV_CPU_SIFIVE_E51 RISCV_CPU_TYPE_NAME("sifive-e51") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ce439f1159d..b47ca531503 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -489,23 +489,6 @@ static void rv64_sifive_u_cpu_init(Object *obj) cpu->cfg.pmp =3D true; } =20 -static void rv64_sifive_e_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVI | RVM | RVA | RVC | RVU); - env->priv_ver =3D PRIV_VERSION_1_10_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_MBARE); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.pmp =3D true; -} - static void rv64_thead_c906_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -694,23 +677,6 @@ static void rv32_sifive_u_cpu_init(Object *obj) cpu->cfg.pmp =3D true; } =20 -static void rv32_sifive_e_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVI | RVM | RVA | RVC | RVU); - env->priv_ver =3D PRIV_VERSION_1_10_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_MBARE); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.pmp =3D true; -} - static void rv32_ibex_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -732,23 +698,6 @@ static void rv32_ibex_cpu_init(Object *obj) cpu->cfg.ext_zbc =3D true; cpu->cfg.ext_zbs =3D true; } - -static void rv32_imafcu_nommu_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVI | RVM | RVA | RVF | RVC | RVU); - env->priv_ver =3D PRIV_VERSION_1_10_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_MBARE); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.pmp =3D true; -} #endif =20 static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) @@ -3096,6 +3045,16 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif ), =20 + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E, TYPE_RISCV_VENDOR_C= PU, + .misa_ext =3D RVI | RVM | RVA | RVC | RVU, + .priv_spec =3D PRIV_VERSION_1_10_0, + .satp_mode32 =3D VM_1_10_MBARE, + .satp_mode64 =3D VM_1_10_MBARE, + .cfg.ext_zifencei =3D true, + .cfg.ext_zicsr =3D true, + .cfg.pmp =3D true + ), + #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE32, TYPE_RISCV_DYNAMIC_CPU, @@ -3104,8 +3063,14 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { ), =20 DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_IBEX, MXL_RV32, rv32_ibex_cpu_= init), - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E31, MXL_RV32, rv32_sifive_e_= cpu_init), - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E34, MXL_RV32, rv32_imafcu_no= mmu_cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E31, TYPE_RISCV_CPU_SIFIVE_E, + .misa_mxl_max =3D MXL_RV32 + ), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E34, TYPE_RISCV_CPU_SIFIVE_E, + .misa_mxl_max =3D MXL_RV32, + .misa_ext =3D RVF, /* IMAFCU */ + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U34, MXL_RV32, rv32_sifive_u_= cpu_init), =20 DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV32I, TYPE_RISCV_BARE_CPU, @@ -3131,7 +3096,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .misa_mxl_max =3D MXL_RV64, ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_E51, MXL_RV64, rv64_sifive_e_= cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E51, TYPE_RISCV_CPU_SIFIVE_E, + .misa_mxl_max =3D MXL_RV64 + ), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U54, MXL_RV64, rv64_sifive_u_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SHAKTI_C, MXL_RV64, rv64_sifive_u_= cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_THEAD_C906, MXL_RV64, rv64_thead_c90= 6_cpu_init), --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866516; cv=none; d=zohomail.com; s=zohoarc; b=G33jHx6pVbIQM0Q5+VyLY10/i6HisT1O8wos9ij7HnGKdU3XbWo6rlP9ed+85FZSok00NEjA+I1CTXSkm1CsQO7gLnoiV4tuy2NQhcO4/uJfKO2kFnhQIRLaGj0KaQXhJnJDI9FpNPbIGQ58Cxwr6cVMMcL1h6X8c15JKUEL8QU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866516; 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=cM7JNJwSeGWDoIYZTZ4Zvcb/tG+r9uq48v256te/cKk=; b=Zej5C74bqXxXVZsnypBXs1CVsdowKlpwuPQVpTQM0HYQ/pgQ7dkua4RSfyQ/RvnYECy3SF9YZbkj19CCiyX6SxMGfc434TSI5OG98EDmUgDhu0ZLPINvevMvD9yNqRw9r+bfmSjeE6l/dBDjoyasp1k4jD3ztMh6nNFcxKd0kA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866516293940.3781473314009; Thu, 6 Feb 2025 10:28:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bP-0001Nm-2E; Thu, 06 Feb 2025 13:27:51 -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 1tg6bL-0001I0-Or for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:47 -0500 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 1tg6bK-0001Dj-Bc for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:47 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-mniwpRCPMXm2cuDmof27YA-1; Thu, 06 Feb 2025 13:27:44 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43626224274so7416685e9.0 for ; Thu, 06 Feb 2025 10:27:44 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390daf4438sm64232165e9.25.2025.02.06.10.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866465; 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=cM7JNJwSeGWDoIYZTZ4Zvcb/tG+r9uq48v256te/cKk=; b=LmEJ/KJLI1elOQ4FgzbGC+1BwOOe9Pm2LU3hLWvrEE6pzNvhW/L/O7Qc02+EOm896hNXmJ cAB9V0MsVPcW0SChwsdg0mjSByR/V5dVL5gne3uEfdt2HWm/JJx4AGgM1q71ZAXeofDRAo sZThq/z+5CReU0IoE9taWJynKLrjRvY= X-MC-Unique: mniwpRCPMXm2cuDmof27YA-1 X-Mimecast-MFC-AGG-ID: mniwpRCPMXm2cuDmof27YA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866462; x=1739471262; 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=cM7JNJwSeGWDoIYZTZ4Zvcb/tG+r9uq48v256te/cKk=; b=YR9YW3CkdavBnQYuDL/ltjrjrm/sxhP/eFEuK2ydxw4zF8BTSrG86sR5M6qrjXXvim X0FMni53TTtUjbGPLlYonmA5pbrslgwEygQw1Jwi3sKIZ/vKEw8jN3EnQei3ZCN9FmX4 FMFWlmh8UFxhpm/fuwgAp6Ka7Qzw60xrhNAUJmmVWORHA7GrF1KgAhcL15qi9UjHKIRq m+DYWdylQIQkp4IX0VG0cvPxF007l4zhV3tUZvLTminELY1/k9OMojCSxsLxU8tqQvSn ky6Q2fY7Ehe1KbMZJKw1BWVfCtmI0fAEzvTPDuq0tr/vK+AZUKvpDyC2EyUiDSpVSrdG qJcw== X-Gm-Message-State: AOJu0YwwIHH23yFoDHDELx35QGPjWWKcpZLlhFRNcRx0sMQlW2Qf7CsK vU6cBdxO/RIS3el2WkMZxZaTHDrOGfZFsQf2LahdvqAyGqRD+Yu89CYSKn+LPqXXM049RaQiiOX wTIDIwkmswyHjdMQIFnP9xCQAGs19A5pvZpCjinzgEawHHvgZTMTk6aSIeOI4XPRN4jBgL9YbqG Fic/rbLCsEpGpIyUejM5+HZiV9IOrFgtdeeISq1wI= X-Gm-Gg: ASbGncvRAlaBCjzuCRc90LkpLkyUmmQIul8xE4ViPn+ajzeiESSVuWHPAMTRE7WmifQ qvvJe60FMF96i4O9O/3E480Uj+jZNIiS2Dtxl2lBx1YY31XGfkipDJ550bYyMajgC0sA0X/IOaq NKOql8Rs2Zo87/ZOPJa2Bp/1W9U6OLKm5FlJclqifHBniqdo72tScRloP1WwlBzw9cfLgX1986y 13kSKl3nN+quhrsTeGaG8GxiY3f+uw6pKmfCOzPJcZAyT8v3hYU0LYoTD4dd+deKpj3EDRQduy6 oPZyn1Q= X-Received: by 2002:a05:600c:3c9b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-439249c385cmr3841135e9.29.1738866462469; Thu, 06 Feb 2025 10:27:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IELSxSf5A1j6D88ps+tF189RdUgec1FxTuWL2gDrc7qTLKOw5Z43sWg1MX84GKBIbv8fRykVQ== X-Received: by 2002:a05:600c:3c9b:b0:436:5fc9:30ba with SMTP id 5b1f17b1804b1-439249c385cmr3840955e9.29.1738866462079; Thu, 06 Feb 2025 10:27:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 13/22] target/riscv: convert ibex CPU models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:01 +0100 Message-ID: <20250206182711.2420505-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866517753019000 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b47ca531503..a8aaa65f56e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -676,28 +676,6 @@ static void rv32_sifive_u_cpu_init(Object *obj) cpu->cfg.mmu =3D true; cpu->cfg.pmp =3D true; } - -static void rv32_ibex_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVI | RVM | RVC | RVU); - env->priv_ver =3D PRIV_VERSION_1_12_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_MBARE); -#endif - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.pmp =3D true; - cpu->cfg.ext_smepmp =3D true; - - cpu->cfg.ext_zba =3D true; - cpu->cfg.ext_zbb =3D true; - cpu->cfg.ext_zbc =3D true; - cpu->cfg.ext_zbs =3D true; -} #endif =20 static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) @@ -3062,7 +3040,23 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .misa_mxl_max =3D MXL_RV32, ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_IBEX, MXL_RV32, rv32_ibex_cpu_= init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_IBEX, TYPE_RISCV_VENDOR_CPU, + .misa_mxl_max =3D MXL_RV32, + .misa_ext =3D RVI | RVM | RVC | RVU, + .priv_spec =3D PRIV_VERSION_1_12_0, + .satp_mode32 =3D VM_1_10_MBARE, + .satp_mode64 =3D VM_1_10_MBARE, + .cfg.ext_zifencei =3D true, + .cfg.ext_zicsr =3D true, + .cfg.pmp =3D true, + .cfg.ext_smepmp =3D true, + + .cfg.ext_zba =3D true, + .cfg.ext_zbb =3D true, + .cfg.ext_zbc =3D true, + .cfg.ext_zbs =3D true + ), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E31, TYPE_RISCV_CPU_SIFIVE_E, .misa_mxl_max =3D MXL_RV32 ), --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866549; cv=none; d=zohomail.com; s=zohoarc; b=Z4i6me6nN/Y4gDdPNlI2abUqdi16ITBBqBnRDGVvqn1X5OW7DtcRqMTFr1nuHjJLjhY78kJjuvVJo1H6ZH97tLliFs2NqiuWSugaA8+m7jdjl/6z7Js0BDPzcSX0XX00HYIKu6aSgUd/TNERhNmMRKF9uT8rpiC2Dviln1dvObE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866549; 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=IJKfw6fd4TEfoHjZHwoe08S2vp+Xy0Ju/mqgD1gDQwQ=; b=aSTttFSFaURIm1NCRzgvvfypTvoa8b3zRZGgKWmSsysnExCBaxuoJNrYdKL0YX3uwnaylTYbSAMcL3IQPyO4/abb1aVbqIpCKcAkT7v0r6EHvJ+YYqy+zjTUWTXMzksdNBdujLxmUGs7yZh3qGLdmeEVDjPOGddCw0nBN1B5stE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866549857172.95778145737916; Thu, 6 Feb 2025 10:29:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bP-0001SZ-GK; Thu, 06 Feb 2025 13:27:51 -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 1tg6bN-0001Mf-Oj for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bM-0001EA-4i for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:49 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-Ie8Bc1Q-MzS9KvTxhiU5lA-1; Thu, 06 Feb 2025 13:27:46 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4361b090d23so7193775e9.0 for ; Thu, 06 Feb 2025 10:27:45 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390daf4438sm64233475e9.25.2025.02.06.10.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866467; 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=IJKfw6fd4TEfoHjZHwoe08S2vp+Xy0Ju/mqgD1gDQwQ=; b=N4A19pfyhWozOrmwqGR+/+sszhZWs683lrAuTeOJyTyYLMf32P+Kct7TzAR0SNF3J30BP7 bb+X+XglAR1AB82wuqVgOARuYJOK4JOvRuqg7pV35XZTTq5vayVuKPfI3DoSZooDAA2vAf e+CS4CS8LxpceVgSDZaLG/6akyWwZfY= X-MC-Unique: Ie8Bc1Q-MzS9KvTxhiU5lA-1 X-Mimecast-MFC-AGG-ID: Ie8Bc1Q-MzS9KvTxhiU5lA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866464; x=1739471264; 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=IJKfw6fd4TEfoHjZHwoe08S2vp+Xy0Ju/mqgD1gDQwQ=; b=ibog2dfvVLEKxzQF8cQ7uLlqvDGdp78JLK3tBaiTeoEKQFR0h3ZCg+QLWYuzylPU8u PBz5PoZGEBSSDtjJcB+NGqhHKBV4OOwGRegEx8Yx3jRWWCdw8wEFq1r0rXZXvrxzAtFb IpInsIwz3Wyn+ruy5Dq0UopK+wRc6WPu2+0iLqSYkXH7NduaqpMJ/rX9MyNXb6OfXc7Q 86BB54tFEy70wPUpg40s+M8BgAG8f21nOjkr/AFHxbNLwpzAXGoFF8ShfnSk2bDXOuCK NExk+9TLTZvfsFVmrJKQQKhJbWT+4uUpMUJudondj0qe0198PFgby/rDH7LjXtylMvpH A8ZQ== X-Gm-Message-State: AOJu0YyLeleFMfFtlXhGFrnFbGZJJIPGbJ60+jJrnGbQn4m4krtkZtGC N5GbX3ftZnGugZMgMWVdN/5O1H1D+nvFp28AXLGNv0jJe0iAHtj2trKjxC6DaeTi5XVRQ80QnOe /gUDv1uzkz4QhUItzEu+Flb29IIxHJ/DyfAmTsPSSVpdWb/9iOGVk47gRDbWsoeNF2avc3xe3DY kOzU7Duj3Pd6d6eRg9SE1PCOWHfxZzCUVcWSydQQA= X-Gm-Gg: ASbGncte3vMHktxgffTzoO81UHvdBpVC7XsLxZho4Yc6uC9EkvTPpuOmFIhy7Xjl+S/ IeEoZGZ0NStGkEwQsdkw9o9+YZfhnhJnG+GsWOKbibL6uXV3rs7bLTSE8Dgq28lw+o0+KekDU0D PG/J1jhSGRfc0Fa1cq/tQZFwGaGGKrnBdBd/n/ABcu7Y+w+pTXqah+XzN90Swd5DvF9X8L/TIrO og0aKGOFzgWmHROqjEajBiPiw6GCXjKdhbrc9LapmnOlG4uwke58Sy5zRVj3hdDaflNub2BV6Wk iNsqAxs= X-Received: by 2002:a05:600c:c19:b0:436:fb02:e68 with SMTP id 5b1f17b1804b1-4392497f9cbmr4102005e9.2.1738866464488; Thu, 06 Feb 2025 10:27:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IELX6PJ8fR4xbxmyVyvONwyIDSjNgJ4/qkTLalF5MajmAx0SizdjgSFl3XtTgiW7mPW1akbVA== X-Received: by 2002:a05:600c:c19:b0:436:fb02:e68 with SMTP id 5b1f17b1804b1-4392497f9cbmr4101895e9.2.1738866464145; Thu, 06 Feb 2025 10:27:44 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 14/22] target/riscv: convert SiFive U models to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:02 +0100 Message-ID: <20250206182711.2420505-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866551499019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 65 ++++++++++++++++-------------------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index bfe1455254c..398cb4f583c 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -46,6 +46,7 @@ #define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") #define TYPE_RISCV_CPU_SIFIVE_E34 RISCV_CPU_TYPE_NAME("sifive-e34") #define TYPE_RISCV_CPU_SIFIVE_E51 RISCV_CPU_TYPE_NAME("sifive-e51") +#define TYPE_RISCV_CPU_SIFIVE_U RISCV_CPU_TYPE_NAME("sifive-u") #define TYPE_RISCV_CPU_SIFIVE_U34 RISCV_CPU_TYPE_NAME("sifive-u34") #define TYPE_RISCV_CPU_SIFIVE_U54 RISCV_CPU_TYPE_NAME("sifive-u54") #define TYPE_RISCV_CPU_THEAD_C906 RISCV_CPU_TYPE_NAME("thead-c906") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a8aaa65f56e..18c59633d76 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -472,23 +472,6 @@ static void set_satp_mode_default_map(RISCVCPU *cpu) #endif =20 #if defined(TARGET_RISCV64) -static void rv64_sifive_u_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - riscv_cpu_set_misa_ext(env, RVI | RVM | RVA | RVF | RVD | RVC | RVS | = RVU); - env->priv_ver =3D PRIV_VERSION_1_10_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV39); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; -} - static void rv64_thead_c906_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -657,27 +640,6 @@ static void rv64_xiangshan_nanhu_cpu_init(Object *obj) =20 #endif /* !TARGET_RISCV64 */ =20 -#if defined(TARGET_RISCV32) || \ - (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) - -static void rv32_sifive_u_cpu_init(Object *obj) -{ - RISCVCPU *cpu =3D RISCV_CPU(obj); - CPURISCVState *env =3D &cpu->env; - riscv_cpu_set_misa_ext(env, RVI | RVM | RVA | RVF | RVD | RVC | RVS | = RVU); - env->priv_ver =3D PRIV_VERSION_1_10_0; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(RISCV_CPU(obj), VM_1_10_SV32); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; -} -#endif - static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; @@ -3033,6 +2995,18 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .cfg.pmp =3D true ), =20 + DEFINE_ABSTRACT_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_U, TYPE_RISCV_VENDOR_C= PU, + .misa_ext =3D RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU, + .priv_spec =3D PRIV_VERSION_1_10_0, + .satp_mode32 =3D VM_1_10_SV32, + .satp_mode64 =3D VM_1_10_SV39, + + .cfg.ext_zifencei =3D true, + .cfg.ext_zicsr =3D true, + .cfg.mmu =3D true, + .cfg.pmp =3D true + ), + #if defined(TARGET_RISCV32) || \ (defined(TARGET_RISCV64) && !defined(CONFIG_USER_ONLY)) DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE32, TYPE_RISCV_DYNAMIC_CPU, @@ -3065,7 +3039,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .misa_ext =3D RVF, /* IMAFCU */ ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U34, MXL_RV32, rv32_sifive_u_= cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_U34, TYPE_RISCV_CPU_SIFIVE_U, + .misa_mxl_max =3D MXL_RV32 + ), =20 DEFINE_RISCV_CPU(TYPE_RISCV_CPU_RV32I, TYPE_RISCV_BARE_CPU, .misa_mxl_max =3D MXL_RV32, @@ -3093,8 +3069,15 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_E51, TYPE_RISCV_CPU_SIFIVE_E, .misa_mxl_max =3D MXL_RV64 ), - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SIFIVE_U54, MXL_RV64, rv64_sifive_u_= cpu_init), - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_SHAKTI_C, MXL_RV64, rv64_sifive_u_= cpu_init), + + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SIFIVE_U54, TYPE_RISCV_CPU_SIFIVE_U, + .misa_mxl_max =3D MXL_RV64 + ), + + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_SHAKTI_C, TYPE_RISCV_CPU_SIFIVE_U, + .misa_mxl_max =3D MXL_RV64 + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_THEAD_C906, MXL_RV64, rv64_thead_c90= 6_cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_TT_ASCALON, MXL_RV64, rv64_tt_ascalo= n_cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_VEYRON_V1, MXL_RV64, rv64_veyron_v1= _cpu_init), --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866508; cv=none; d=zohomail.com; s=zohoarc; b=W21QxbpSCbj/t4iPpvZZBUxFeA/KDjQAMTViABqkjztzup5GqbNoyaTu2tjAWBNYo00YWf5KlWShZFuLWCtfFZuqDKpOSZSX0HUn/0SVS4XZQxgdm6QDLroDAGE51lafCdeFac+REsLVTqdBfnyQpvYELYaBZBJPvLEPmh4XHbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866508; 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=k5Ryak/eSgMhX/XO70jUySJ3C1G++x3e5P9ppqfL1HQ=; b=RjV2vOT409ETlAETyl8WqoWlq2aRFvTppXztRf/l5FPQQTk9Brnxzxf81b0MsQqCHqFOrlEfBoVRkPRij+3sHiq8wK42S70In8wnH4Pflr7NHxNNsModvC+K52aKOcw+MkJeMSW63DydKDl13lGqxjntMyqPirKSPBQDxmocRnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866508358538.6658924590673; Thu, 6 Feb 2025 10:28:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bS-0001hT-Vb; Thu, 06 Feb 2025 13:27:55 -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 1tg6bQ-0001ZO-L8 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bP-0001En-2O for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:52 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-5kymxGJ8PLiJpiGPPyymAg-1; Thu, 06 Feb 2025 13:27:48 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-436723bf7ffso10548345e9.3 for ; Thu, 06 Feb 2025 10:27:48 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dc565d62dsm1009650f8f.93.2025.02.06.10.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866470; 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=k5Ryak/eSgMhX/XO70jUySJ3C1G++x3e5P9ppqfL1HQ=; b=h3W2IZVt8K0dF83hGvMX6G1JDSRrC3VDgS69rIrMAMbUtiXYmTqP68Mf0aKpxn0eTFq8dR i+FpONCx+H6qQd/PJ+mCSO6KDfN0Q/ao5KfwRIJcYWJHkENJxbokmRmJ/2dLlKRmlvGB81 YRT2SSNIyxw+Msw62ipjqQdEbZpEcfQ= X-MC-Unique: 5kymxGJ8PLiJpiGPPyymAg-1 X-Mimecast-MFC-AGG-ID: 5kymxGJ8PLiJpiGPPyymAg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866466; x=1739471266; 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=k5Ryak/eSgMhX/XO70jUySJ3C1G++x3e5P9ppqfL1HQ=; b=oDv86KV7eJVpT3D5bMf0L8FcHNKdibGnmhnh7hKilDAjsXr/WNaX7worg4uiZ7+77C DTVTl79hffebJ1fDnIMY/XpGxLeeRokiANBArdkQ6ryaAFtvu1YCB18juoJJoCAe9iHK Y7SyslG36qU55eKJkRMGaPZUBitws2upDF75QyW3PCiMOr6blT6f+5Tr+D4HJPlxCRzU jTl6jCIUy7tJq+8VY3sFuX+IwGYZOJwY4GNQiLM2tyypyfCuPf5qAk+g417Zq2tYqf94 xfqHHpwNJXU9/wP/BF+7i6rIj/HWNdaN5fSarGmlbTe7UgZ3xkGM6rSeONxsya/IRvJd aWNA== X-Gm-Message-State: AOJu0Yzev58qSA3+hEkVy9Lo+8JMYpflUPmtglfwMJkHuXbUw6Ma1iP4 KaMx07iR/HZV50F4wEaS7hyvWE8Sz1OR7lOnbgg2K6TbRxcOXuTJxxtp/vPPNXILZZfQkWtdibp TTJQcFtTE5VpL78sG8nCMgwyzBdXVDMavTxZCoh3eSl9yw1Jt7eGMNGA0aLCzJe7whKs7DpHpHh 0UQz0A9Hk4QEDq1+Kz9M84qVMeVxojxLN283ihn4k= X-Gm-Gg: ASbGncsyRxT9TZxCqmLJc80Pe4g82Ru2l/3Rp6lH3nRekuj2hg97mDxdETZgA0Nxqpo w5RowY3CUfejNltGo5aS6p2MER0hhL2ITqy05ov00ActU5Eq+mg1uNHc9qwc66z2JQhr8CRYnbK 0iqVe8KLq/Pn9/1de2k4DBWR/J9SbeIiNN/B/dbCRXR07HuQjA5maoH1d77YZFq1JPtUi6tUZPp DHlVmkdKGi4LQ3lzdbz8wM/e+R45jRG2AD6VkprytBxXh52eAoeCYLod2bjXgNvEx3ivjQAnQts u5zwp6k= X-Received: by 2002:a5d:6d8a:0:b0:38d:b8a2:1944 with SMTP id ffacd0b85a97d-38dc90e9bfdmr43116f8f.26.1738866466502; Thu, 06 Feb 2025 10:27:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoqrvrbB0emFX+8ybIiU0I5dG34YbXmKCjBqqxUxEnpbLwlNXexzje15bm8p7HzINjrpHw7A== X-Received: by 2002:a5d:6d8a:0:b0:38d:b8a2:1944 with SMTP id ffacd0b85a97d-38dc90e9bfdmr43099f8f.26.1738866466082; Thu, 06 Feb 2025 10:27:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 15/22] target/riscv: th: make CSR insertion test a bit more intuitive Date: Thu, 6 Feb 2025 19:27:03 +0100 Message-ID: <20250206182711.2420505-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866509855019000 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. Signed-off-by: Paolo Bonzini --- target/riscv/th_csr.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/target/riscv/th_csr.c b/target/riscv/th_csr.c index 6c970d4e813..990453e080e 100644 --- a/target/riscv/th_csr.c +++ b/target/riscv/th_csr.c @@ -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.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866561; cv=none; d=zohomail.com; s=zohoarc; b=HlQfDCeR5XXIt/cEEdxlnMXpt0zvpwsU4+gk2ZQdQZH4rdbTLpCKJ+A8DTAxnQ86BMyOQdPmbYDs4pkMCOn9j95QnnQ6cMMBGYHfQHgMgxH6e+RdduXk85J63Vjg5v7idq61hy4u0fMVnVyBjU2vaOF7K+6MKTAorTPk03NilRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866561; 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=b3tTPLiwfh9LGGq/8MlcVHCC5GAi1lzXby/r6Gg7rX0=; b=FnBj3GrqVJ9vNhJIZ/PdMPaNW8y0K5ogtY2g5647eWfucwbXI8EXhObScK95HC0X+piLhyKRbiFiOO0oVpM5J46hBc0GDABEkgs9hJryyfN4vfUtWaV4aWr/90gTjm30T+xwAeIFq86JcEOlSukSFQti8mn9u9sdHSucN1LzUhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866561183515.1742997833101; Thu, 6 Feb 2025 10:29:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bU-0001k1-6i; Thu, 06 Feb 2025 13:27:56 -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 1tg6bS-0001hU-77 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bQ-0001GU-GP for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:53 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-GWVzAE6gP5miuEw48FN1cw-1; Thu, 06 Feb 2025 13:27:50 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43625ceae52so7561815e9.0 for ; Thu, 06 Feb 2025 10:27:49 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d93374csm65416215e9.8.2025.02.06.10.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866471; 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=b3tTPLiwfh9LGGq/8MlcVHCC5GAi1lzXby/r6Gg7rX0=; b=GOiF8zW+rSJ5Sne9boPshA3z8HAxQkxigweFVLOmMLLy/ag2WtbFPFy0OeQVu29DxeMTiY IoL4zT8PCGFgDluyx/6D5CLJX8daqiPRfni6O7Ej1YDGfyf7Etoh/ak+9SJ8Uy/bji1oVQ lNOBx89JOEftHhUS5FW0e/ZcgRRQJcg= X-MC-Unique: GWVzAE6gP5miuEw48FN1cw-1 X-Mimecast-MFC-AGG-ID: GWVzAE6gP5miuEw48FN1cw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866468; x=1739471268; 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=b3tTPLiwfh9LGGq/8MlcVHCC5GAi1lzXby/r6Gg7rX0=; b=kob6gD1V4GrvWmsOF7yf7HE7sMPiLnKtRRbEW7Q6bvy9Iqo3EJ3AwpWcvp++jEEgRp iXFRiKACS3fzNrCK1okuRJUdS8GaSZqqlfvMVwr9aik7r46IPeSAmPtQfarvfig3BbP7 5ujAdvGoR7Wx3zJ6g7omzn9zQQopdUVXAdhkuXH2YGo8yw+p0hSQa1mizGViTdVb4mZU FP0jC2l1JOd1ov2Z9I+KY7XwL5cXyk1jr6MyJmINz/buGzjXPBmpAltkcrS2Xa+D/8Nk SdCGufKr6gc2LroQCRiUNCzn8dQf7P8vO74q0AhwFEdY3uxP2a1dY2tBPVf95ruWyHgR DGaA== X-Gm-Message-State: AOJu0YxTGCQnX3E9nl+0XXZ4MaenlwTeEVFB7UP0F4yF2g6rgX7Jr/Kp o62GrOxJyr1GM8osCgDYXNGgDW3B4JNA4AwdwHIcu7Drm9UPqycQcuy6qhv3vBOLsMmFKkDy36l U3DAyXMJEbWO4oMGRQsDVxf/s+Ww1Jd2914Xs/pkW32lAPEyiqemypu9CUAkbQCGmugnQTnXMTJ hxMA4gSjuVmGKVHvlV4wUVp5NwzY3x0W7jq9SfBqw= X-Gm-Gg: ASbGncvNwfCvWcbSWpM5VnbvT8tZEN0WaQMRBG+NV44tLDtEarRvmK+5iFWreiuiqnZ 2feFI74bp4AbanmWw5XnaSveV1sEgdNozZEszatJXZK1ZwrVPOV1KV3iUz4BL1D4a2IlMPanOQT r1j2eaO3DxwnfZwSxaACqlZLy7be0AwZeWhHB0pNyCkjuSdiUG1eAHEDoOP1I38UywwXJqrInBA EWpbMo1h3DEBzPhxtnrZ5plCc9B4vaddd35iuY4X/ilCmEL5f5PTzswK1N0z4k1LakNJSzNI9Yz LV+krQQ= X-Received: by 2002:a05:600c:524c:b0:434:a59c:43c6 with SMTP id 5b1f17b1804b1-439249c03d0mr3141975e9.26.1738866468516; Thu, 06 Feb 2025 10:27:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEz72ERuOBVebdjdS+rWt0cw7xdItuS0WxgX+9mvY+5Tre5mZiLMPC2jNuNOXhWnDVvTkGoEw== X-Received: by 2002:a05:600c:524c:b0:434:a59c:43c6 with SMTP id 5b1f17b1804b1-439249c03d0mr3141825e9.26.1738866468158; Thu, 06 Feb 2025 10:27:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 16/22] target/riscv: generalize custom CSR functionality Date: Thu, 6 Feb 2025 19:27:04 +0100 Message-ID: <20250206182711.2420505-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866563578019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 13 +++++++++++-- target/riscv/cpu.c | 23 ++++++++++++++++++++++- target/riscv/th_csr.c | 21 +++------------------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 66ce72f7d41..00ec475fbba 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -517,6 +517,8 @@ struct ArchCPU { const GPtrArray *decoders; }; =20 +typedef struct RISCVCSR RISCVCSR; + typedef struct RISCVCPUDef { RISCVMXL misa_mxl_max; /* max mxl for this cpu */ RISCVCPUProfile *profile; @@ -527,6 +529,7 @@ typedef struct RISCVCPUDef { int satp_mode64; RISCVCPUConfig cfg; bool bare; + RISCVCSR *custom_csrs; } RISCVCPUDef; =20 /** @@ -862,6 +865,12 @@ typedef struct { uint32_t min_priv_ver; } riscv_csr_operations; =20 +struct RISCVCSR { + int csrno; + bool (*insertion_test)(RISCVCPU *cpu); + riscv_csr_operations csr_ops; +}; + /* CSR function table constants */ enum { CSR_TABLE_SIZE =3D 0x1000 @@ -926,8 +935,8 @@ target_ulong riscv_new_csr_seed(target_ulong new_value, uint8_t satp_mode_max_from_map(uint32_t map); const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); =20 -/* Implemented in th_csr.c */ -void th_register_custom_csrs(RISCVCPU *cpu); +/* In th_csr.c */ +extern RISCVCSR th_csr_list[]; =20 const char *priv_spec_to_str(int priv_version); #endif /* RISCV_CPU_H */ diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 18c59633d76..6c898cef625 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -471,6 +471,19 @@ static void set_satp_mode_default_map(RISCVCPU *cpu) } #endif =20 +#ifndef CONFIG_USER_ONLY +static void riscv_register_custom_csrs(RISCVCPU *cpu, RISCVCSR *csr_list) +{ + for (size_t i =3D 0; csr_list[i].csr_ops.name; i++) { + int csrno =3D csr_list[i].csrno; + riscv_csr_operations *csr_ops =3D &csr_list[i].csr_ops; + if (!csr_list[i].insertion_test || csr_list[i].insertion_test(cpu)= ) { + riscv_set_csr_ops(csrno, csr_ops); + } + } +} +#endif + #if defined(TARGET_RISCV64) static void rv64_thead_c906_cpu_init(Object *obj) { @@ -497,7 +510,7 @@ static void rv64_thead_c906_cpu_init(Object *obj) cpu->cfg.mvendorid =3D THEAD_VENDOR_ID; #ifndef CONFIG_USER_ONLY set_satp_mode_max_supported(cpu, VM_1_10_SV39); - th_register_custom_csrs(cpu); + riscv_register_custom_csrs(cpu, th_csr_list); #endif =20 /* inherited from parent obj via riscv_cpu_init() */ @@ -1301,6 +1314,9 @@ static void riscv_cpu_init(Object *obj) if (riscv_cpu_mxl(env) >=3D MXL_RV64 && mcc->def->satp_mode64 !=3D RIS= CV_PROFILE_ATTR_UNUSED) { set_satp_mode_max_supported(RISCV_CPU(obj), mcc->def->satp_mode64); } + if (mcc->def->custom_csrs) { + riscv_register_custom_csrs(cpu, mcc->def->custom_csrs); + } #endif } =20 @@ -2791,6 +2807,11 @@ static void riscv_cpu_class_base_init(ObjectClass *c= , void *data) mcc->def->misa_ext |=3D def->misa_ext; =20 riscv_cpu_cfg_merge(&mcc->def->cfg, &def->cfg); + + if (def->custom_csrs) { + assert(!mcc->def->custom_csrs); + mcc->def->custom_csrs =3D def->custom_csrs; + } } =20 if (!object_class_is_abstract(c)) { diff --git a/target/riscv/th_csr.c b/target/riscv/th_csr.c index 990453e080e..b648004dbc6 100644 --- a/target/riscv/th_csr.c +++ b/target/riscv/th_csr.c @@ -27,12 +27,6 @@ #define TH_SXSTATUS_MAEE BIT(21) #define TH_SXSTATUS_THEADISAEE BIT(22) =20 -typedef struct { - int csrno; - int (*insertion_test)(RISCVCPU *cpu); - riscv_csr_operations csr_ops; -} riscv_csr; - static RISCVException smode(CPURISCVState *env, int csrno) { if (riscv_has_ext(env, RVS)) { @@ -55,20 +49,11 @@ static RISCVException read_th_sxstatus(CPURISCVState *e= nv, int csrno, return RISCV_EXCP_NONE; } =20 -static riscv_csr th_csr_list[] =3D { +RISCVCSR th_csr_list[] =3D { { .csrno =3D CSR_TH_SXSTATUS, .insertion_test =3D test_thead_mvendorid, .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 || th_csr_list[i].insertion_tes= t(cpu)) { - riscv_set_csr_ops(csrno, csr_ops); - } - } -} --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866527; cv=none; d=zohomail.com; s=zohoarc; b=nXntrjTE8qA/T0fKkMgBIEP719PyKzfkEqUlPUA9sc3fPxSdu+ykBNRt5d49mMs/T/+s2WyG06p9mNM5zU4yLvlw4vuheZ1c1JO9UlfqXSU/c67SIoL1Ndh574QMgic9PVKG+IgBJJyP+DJQ07HYgCWJUNvvBjcvRN6sJiVyomI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866527; 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=c2S1as4YXy95cFcQ6YBPnTB/vNXzAgi97rZfPSkkbmU=; b=KWufokdzKZszNhaogMNMg+Z1cl1+No4eCI3fsU78E/5Ob+pjj9aTdaE1FRE1WuUcuq9MkxKScf+q1/Hjs0VOmm7z6kuStfLmriK/ODBMFRhIqOvZY6+oSRIzryX61NZyboueeQ5AyiQBj/8ntM6bbMfwUUIYw8JnSHM3FwUQ0v4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866527448446.53089728925033; Thu, 6 Feb 2025 10:28:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bV-0001nr-Cn; Thu, 06 Feb 2025 13:27:57 -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 1tg6bT-0001j4-PP for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:55 -0500 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 1tg6bS-0001H7-AI for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:55 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-Xa31aoSKMf28X9Z5I2drag-1; Thu, 06 Feb 2025 13:27:52 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-38db560edc3so597134f8f.3 for ; Thu, 06 Feb 2025 10:27:52 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd1bde0sm2354889f8f.9.2025.02.06.10.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866473; 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=c2S1as4YXy95cFcQ6YBPnTB/vNXzAgi97rZfPSkkbmU=; b=FR/60JKmtShRBbZU6yks7PgQg4m8R+SNoCIiMpS97VggqG5Q8LpKxU1BmC5J0TrumOzmAf T8r65CPGpu6MJ3bYbIWCitmiCv2iDWWXz0jTpYX4Lq2G/lWbogCmgp5BHkc5XUvAWcIGiu gOU76I7MXE6YBIbGNRiu4TTFuOIG9Hk= X-MC-Unique: Xa31aoSKMf28X9Z5I2drag-1 X-Mimecast-MFC-AGG-ID: Xa31aoSKMf28X9Z5I2drag X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866470; x=1739471270; 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=c2S1as4YXy95cFcQ6YBPnTB/vNXzAgi97rZfPSkkbmU=; b=qIjQ7cyxUKoXp0bOmLXEpLbMpLx2J392p+T3QF7V+53gcxwv4sdtNURoFNYM2qo1LU xksFaeWBqXg0Mu9AUNsIN8xhwy7bLsabKQeIq5j7ew8ZKXnnJ24+s7PJn/pDc2Pc0xT2 zLp7EGuzB0gaYBK2FjyD02xnCULx42VGT9o6ZA+1FMjk9/cEnkKCPLnjh/Ab+NYG68J3 rWavU8aRjKKpJk2q+tbzJTyzWIg6OEoI9tnlhK27N1hXY0eMECR6GmOdtYCmMc+YlziQ 6F4CWJSSJqxz6VrGJZgPNVjELzQcd/N2Z0qMMGyun/7wOZ1Re7rR2qli2V1eyHv2Vmph iHRQ== X-Gm-Message-State: AOJu0Yxu5baGJX4LvYi+fCSBzDlIz1EVto0hzmsVrdT9w0g7+Udp2ni9 Sz0ChzX8fM4gbQ1KskbGCvcn14L2xd+7p4C7WC0dmh02mGouf4TGel7dufpInFZs8HCDAhso/QX UeF6I9IjVmNxAFzbbLaV5u+nSTqzqZzpeVWZlAmfxGGMz9+7YO4bZzxh96ylo7GeGlFOD3rRlQ5 rcU5jHmYPeN7OQk6OWopk6KoYa5QQC2aodEyJFzUw= X-Gm-Gg: ASbGnctH62YBI4RszkrILSkyynsLGsWpO3hupdzZpiB0FLrJFAIQmcyfW9FRTTuceGg ozRh5OekctOAzqcNZOtDM6IyERD2GhhtAXDfiiUz6Epb5aw4W5c51+w88Y32imKRvn0gdOQ0zCq pAIzQv82KwWgNC/BZAzAaj67mXZCgp+9EuUlMpUxNmP1TAQY4ut4RYSUep+7M85MrmrIeEt4a8K eIsvEUscAS7YCHV9inW0sSrhV5MjZAWfDeKqieoEORKmr+13QUGz54BQTpLpJI9eBAq7opMLBYM RnwRwzQ= X-Received: by 2002:a5d:47af:0:b0:38b:ed7b:f77d with SMTP id ffacd0b85a97d-38dc937c3b9mr11946f8f.52.1738866470637; Thu, 06 Feb 2025 10:27:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsjsJTh/Iz9hNgXFuEgV4OZ4I2YwkRxO3Jlome3/VDG5bv/JzkTp715EB8pMFvYX/D80hUFA== X-Received: by 2002:a5d:47af:0:b0:38b:ed7b:f77d with SMTP id ffacd0b85a97d-38dc937c3b9mr11927f8f.52.1738866470176; Thu, 06 Feb 2025 10:27:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 17/22] target/riscv: convert TT C906 to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:05 +0100 Message-ID: <20250206182711.2420505-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866529353019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 61 +++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6c898cef625..b0bc5e4503f 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -485,38 +485,6 @@ static void riscv_register_custom_csrs(RISCVCPU *cpu, = RISCVCSR *csr_list) #endif =20 #if defined(TARGET_RISCV64) -static void rv64_thead_c906_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVG | RVC | RVS | RVU); - env->priv_ver =3D PRIV_VERSION_1_11_0; - - cpu->cfg.ext_zfa =3D true; - cpu->cfg.ext_zfh =3D true; - cpu->cfg.mmu =3D true; - cpu->cfg.ext_xtheadba =3D true; - cpu->cfg.ext_xtheadbb =3D true; - cpu->cfg.ext_xtheadbs =3D true; - cpu->cfg.ext_xtheadcmo =3D true; - cpu->cfg.ext_xtheadcondmov =3D true; - cpu->cfg.ext_xtheadfmemidx =3D true; - cpu->cfg.ext_xtheadmac =3D true; - cpu->cfg.ext_xtheadmemidx =3D true; - cpu->cfg.ext_xtheadmempair =3D true; - cpu->cfg.ext_xtheadsync =3D true; - - cpu->cfg.mvendorid =3D THEAD_VENDOR_ID; -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_SV39); - riscv_register_custom_csrs(cpu, th_csr_list); -#endif - - /* inherited from parent obj via riscv_cpu_init() */ - cpu->cfg.pmp =3D true; -} - static void rv64_veyron_v1_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -3099,7 +3067,34 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .misa_mxl_max =3D MXL_RV64 ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_THEAD_C906, MXL_RV64, rv64_thead_c90= 6_cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_THEAD_C906, TYPE_RISCV_VENDOR_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVG | RVC | RVS | RVU, + .priv_spec =3D PRIV_VERSION_1_11_0, + + .cfg.ext_zfa =3D true, + .cfg.ext_zfh =3D true, + .cfg.mmu =3D true, + .cfg.ext_xtheadba =3D true, + .cfg.ext_xtheadbb =3D true, + .cfg.ext_xtheadbs =3D true, + .cfg.ext_xtheadcmo =3D true, + .cfg.ext_xtheadcondmov =3D true, + .cfg.ext_xtheadfmemidx =3D true, + .cfg.ext_xtheadmac =3D true, + .cfg.ext_xtheadmemidx =3D true, + .cfg.ext_xtheadmempair =3D true, + .cfg.ext_xtheadsync =3D true, + .cfg.pmp =3D true, + + .cfg.mvendorid =3D THEAD_VENDOR_ID, + + .satp_mode64 =3D VM_1_10_SV39, +#ifndef CONFIG_USER_ONLY + .custom_csrs =3D th_csr_list, +#endif + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_TT_ASCALON, MXL_RV64, rv64_tt_ascalo= n_cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_VEYRON_V1, MXL_RV64, rv64_veyron_v1= _cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866572; cv=none; d=zohomail.com; s=zohoarc; b=VZCxoy15ipvKy+4hi8BYQB423DdgnvGBqMDTTvLqs8MhTNmPSNV7ySW/8/8+gYYyzSgxh7U5kI15ozlwsLcVoK4UbCy6/B0/44jFgrD8d4pONLo2C5Qecz3flsoSaf7zg4yHSr/matJsYmCCibSoHtrZFYfUxYD+2O1BbgPlAXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866572; 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=STyq72ML7rT9FicVBWSXnXvAyx/ZuheSNXOOWJ1gL0M=; b=AAKKuZGWjTrlz5hVjZzUnUzi+k/oN0IwsEkMoPEQBXIL0UgA1m1YDiYWHkuigUDMv2UYge1+EAevusbnFZ9873ihHMK5u9BEaf5K5w5aT00WLaajswhehoMDN4v+zp4kgxQKSiOcW33EwWQN9up+BlnLR8LNuuMOZGHuqyC5y80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17388665722941011.4196738334431; Thu, 6 Feb 2025 10:29:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bd-0001xa-1l; Thu, 06 Feb 2025 13:28:05 -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 1tg6bZ-0001rN-6W for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:01 -0500 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 1tg6bX-0001WA-I7 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:00 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-54-Q0z4apgWOI-Si5GVFCfbmQ-1; Thu, 06 Feb 2025 13:27:54 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4361ecebc5bso7086485e9.1 for ; Thu, 06 Feb 2025 10:27:54 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd36967sm2393506f8f.37.2025.02.06.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866478; 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=STyq72ML7rT9FicVBWSXnXvAyx/ZuheSNXOOWJ1gL0M=; b=jVbzQLkxDIexvhHkKoejkvkT76WBNY9V0edkEkCTrJr/+Unv5iU6TBBZXqfaqA+pLD6Ebm MqTxYX/GDs6O3tb5hauMm98v6VB6xzFbBJ0QnUww3qjpcEOgOKAeqAqc6kkcJypkbRt9Mi AbmLab6NTpeyqQrs2/oiKahdSOOd/hc= X-MC-Unique: Q0z4apgWOI-Si5GVFCfbmQ-1 X-Mimecast-MFC-AGG-ID: Q0z4apgWOI-Si5GVFCfbmQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866473; x=1739471273; 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=STyq72ML7rT9FicVBWSXnXvAyx/ZuheSNXOOWJ1gL0M=; b=b+WjCHHELhYm4uq4TPlXWNG2Prt/ePz2zaKrg7qYRi3rxl8yO9Vf0LpUDqiGmsJcqr 5lC92ic4s6HEd3Is1Uee5WC3F0cqT4GCsrL5NbTQ8En53xXeTWaqb7/odU2VLxXFAPZA 607f6qVJiXwzor1H4oz63iOWC9w7qHikPPdzz1FY+XGXhQVodjy7Km2tujc4ja9shbbm fLirR+klJdyPXfZpMTeExdCGLWtcolc2BJzCHT1O3jGZROM9Sz9mXJ8nun93GbOFvLou Fr0YmBab2wY2THTKZPush2ewlXHsGj1Sn3Wf4MFXNtXOVKc2Xs63g3U6z5v+QEVPQfu2 fHrw== X-Gm-Message-State: AOJu0Yyo7qxtjc4tcuwijJAdkg7yTAygqC5ljtBmaeO4IJpe6mZa3cH0 cnN5245sw0wbCouL5FLE0x7w6XBNyBVebD1B4OS1cmLDC2U16q3y2z5iHOhsKvNoB85YYydpvch y7VlvLoQ8Tkj1aaobmAcE7nIpWhpBfjihRpdNS+IWG43+1IkbQwJKfhBD8T7j5J8PRzAoEoO436 6MFFmyDn3mi6HNwI2Bp4EdOnepCJmgKjcBDxa/lTw= X-Gm-Gg: ASbGncv5O/HhPyToTSa2X/uKivBSNZm3Hdr5rX5bfpu70GN373vLxV9XI4ZxZNetJ10 qzIftDze5MHGqjhcQYmElpnVejwsCFtOhMB+9ILDRZEQi1Bxz9v/UPtzrpf6hmQOCbD5X1Tn9vI km83OGi7Jj+izxYh1qfYQRgl+QegxgV/2anGR0h9Q2tdFBP659DZhKYP4elwat4PVSm5kC16icL Q5BEH6B9SIPORQBQ79vrH1w+klkDo4cY3n3EyHKeQlhrUFBI1e1diJlNQqEeTssRWFcz4SnymgL 3PkZleY= X-Received: by 2002:a05:600c:4748:b0:434:e9ee:c1e with SMTP id 5b1f17b1804b1-439249e6676mr4050435e9.31.1738866472670; Thu, 06 Feb 2025 10:27:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMSizYmKgIPyTmJ6wZJxCyoK28lewewEd9WDUduFDWqDH0CLO5NNmT7Lqkn+mPAyOLMB3ObA== X-Received: by 2002:a05:600c:4748:b0:434:e9ee:c1e with SMTP id 5b1f17b1804b1-439249e6676mr4050255e9.31.1738866472210; Thu, 06 Feb 2025 10:27:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 18/22] target/riscv: convert TT Ascalon to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:06 +0100 Message-ID: <20250206182711.2420505-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866575546019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 127 +++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b0bc5e4503f..b2b9b4f6e39 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -525,72 +525,6 @@ static void rv64_veyron_v1_cpu_init(Object *obj) #endif } =20 -/* Tenstorrent Ascalon */ -static void rv64_tt_ascalon_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVG | RVC | RVS | RVU | RVH | RVV); - env->priv_ver =3D PRIV_VERSION_1_13_0; - - /* Enable ISA extensions */ - cpu->cfg.mmu =3D true; - cpu->cfg.vlenb =3D 256 >> 3; - cpu->cfg.elen =3D 64; - cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; - cpu->cfg.rvv_ma_all_1s =3D true; - cpu->cfg.rvv_ta_all_1s =3D true; - cpu->cfg.misa_w =3D true; - cpu->cfg.pmp =3D true; - cpu->cfg.cbom_blocksize =3D 64; - cpu->cfg.cbop_blocksize =3D 64; - cpu->cfg.cboz_blocksize =3D 64; - cpu->cfg.ext_zic64b =3D true; - cpu->cfg.ext_zicbom =3D true; - cpu->cfg.ext_zicbop =3D true; - cpu->cfg.ext_zicboz =3D true; - cpu->cfg.ext_zicntr =3D true; - cpu->cfg.ext_zicond =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zihintntl =3D true; - cpu->cfg.ext_zihintpause =3D true; - cpu->cfg.ext_zihpm =3D true; - cpu->cfg.ext_zimop =3D true; - cpu->cfg.ext_zawrs =3D true; - cpu->cfg.ext_zfa =3D true; - cpu->cfg.ext_zfbfmin =3D true; - cpu->cfg.ext_zfh =3D true; - cpu->cfg.ext_zfhmin =3D true; - cpu->cfg.ext_zcb =3D true; - cpu->cfg.ext_zcmop =3D true; - cpu->cfg.ext_zba =3D true; - cpu->cfg.ext_zbb =3D true; - cpu->cfg.ext_zbs =3D true; - cpu->cfg.ext_zkt =3D true; - cpu->cfg.ext_zvbb =3D true; - cpu->cfg.ext_zvbc =3D true; - cpu->cfg.ext_zvfbfmin =3D true; - cpu->cfg.ext_zvfbfwma =3D true; - cpu->cfg.ext_zvfh =3D true; - cpu->cfg.ext_zvfhmin =3D true; - cpu->cfg.ext_zvkng =3D true; - cpu->cfg.ext_smaia =3D true; - cpu->cfg.ext_smstateen =3D true; - cpu->cfg.ext_ssaia =3D true; - cpu->cfg.ext_sscofpmf =3D true; - cpu->cfg.ext_sstc =3D true; - cpu->cfg.ext_svade =3D true; - cpu->cfg.ext_svinval =3D true; - cpu->cfg.ext_svnapot =3D true; - cpu->cfg.ext_svpbmt =3D true; - -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_SV57); -#endif -} - static void rv64_xiangshan_nanhu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -3095,7 +3029,66 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #endif ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_TT_ASCALON, MXL_RV64, rv64_tt_ascalo= n_cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_TT_ASCALON, TYPE_RISCV_VENDOR_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVG | RVC | RVS | RVU | RVH | RVV, + .priv_spec =3D PRIV_VERSION_1_13_0, + .vext_spec =3D VEXT_VERSION_1_00_0, + + /* ISA extensions */ + .cfg.mmu =3D true, + .cfg.vlenb =3D 256 >> 3, + .cfg.elen =3D 64, + .cfg.rvv_ma_all_1s =3D true, + .cfg.rvv_ta_all_1s =3D true, + .cfg.misa_w =3D true, + .cfg.pmp =3D true, + .cfg.cbom_blocksize =3D 64, + .cfg.cbop_blocksize =3D 64, + .cfg.cboz_blocksize =3D 64, + .cfg.ext_zic64b =3D true, + .cfg.ext_zicbom =3D true, + .cfg.ext_zicbop =3D true, + .cfg.ext_zicboz =3D true, + .cfg.ext_zicntr =3D true, + .cfg.ext_zicond =3D true, + .cfg.ext_zicsr =3D true, + .cfg.ext_zifencei =3D true, + .cfg.ext_zihintntl =3D true, + .cfg.ext_zihintpause =3D true, + .cfg.ext_zihpm =3D true, + .cfg.ext_zimop =3D true, + .cfg.ext_zawrs =3D true, + .cfg.ext_zfa =3D true, + .cfg.ext_zfbfmin =3D true, + .cfg.ext_zfh =3D true, + .cfg.ext_zfhmin =3D true, + .cfg.ext_zcb =3D true, + .cfg.ext_zcmop =3D true, + .cfg.ext_zba =3D true, + .cfg.ext_zbb =3D true, + .cfg.ext_zbs =3D true, + .cfg.ext_zkt =3D true, + .cfg.ext_zvbb =3D true, + .cfg.ext_zvbc =3D true, + .cfg.ext_zvfbfmin =3D true, + .cfg.ext_zvfbfwma =3D true, + .cfg.ext_zvfh =3D true, + .cfg.ext_zvfhmin =3D true, + .cfg.ext_zvkng =3D true, + .cfg.ext_smaia =3D true, + .cfg.ext_smstateen =3D true, + .cfg.ext_ssaia =3D true, + .cfg.ext_sscofpmf =3D true, + .cfg.ext_sstc =3D true, + .cfg.ext_svade =3D true, + .cfg.ext_svinval =3D true, + .cfg.ext_svnapot =3D true, + .cfg.ext_svpbmt =3D true, + + .satp_mode64 =3D VM_1_10_SV57, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_VEYRON_V1, MXL_RV64, rv64_veyron_v1= _cpu_init), DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, MXL_RV64, rv64_xiangshan_= nanhu_cpu_init), --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866519; cv=none; d=zohomail.com; s=zohoarc; b=V37ZsaHEB9tRsnUSU7+xXK5CiEs1Mw0Iih2Kh9VHc6lVlEZ5+fstosyaVV6KFLwtZgupzqDmFupeU65Oe/IjNt01k8a+kCbeV1EdjmJReR9ef263hBz0jfzk9AmZzAoxRQywpSWjMl4A3m+vGA+KPhcclq2n/mPNL7m3gB59zPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866519; 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=J7bt7RebNOzgP3cdASvIHwhn5WFSysOm0Db/LmQL+l8=; b=kRzEG9o+g1QJRJ8Tnt8pKpg2U+soboxgEc0X2WCa0KG9ZcA8S5saemLPVr0RLcfYmyn4eauwEthhHEBOns4UjlhkhUdx/tP7vCFD3tzCgSaXZmr+qqnUw77M1wvssLhsPK8KfRAR3+pgk2xQkL6tBuvvP2sNTT7KsexiFAkpco0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866519936990.1282280815922; Thu, 6 Feb 2025 10:28:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bc-0001u6-Is; Thu, 06 Feb 2025 13:28:04 -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 1tg6bX-0001r7-Or for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bW-0001Um-5f for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:27:59 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-oIxild_HODiKlYv0LSUviw-1; Thu, 06 Feb 2025 13:27:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-38c24ac3706so801179f8f.0 for ; Thu, 06 Feb 2025 10:27:56 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dc6b89ef5sm476311f8f.31.2025.02.06.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866477; 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=J7bt7RebNOzgP3cdASvIHwhn5WFSysOm0Db/LmQL+l8=; b=InQ7OIp1YW/xr9kObei7IQAGFVYp1ge+Drrjbj7rCZse3P3tk+X6tBaze4ScojOKMRAGO3 C8ey4zuCo3+PcMy3uUJLbuByPxk72xweg9lBdk7PG6pgyc2fvi9HEg8+NSt+5yRoIKs6iU e1vJOwAyfS0nY/lk4Ec4fH0CHsCD0bU= X-MC-Unique: oIxild_HODiKlYv0LSUviw-1 X-Mimecast-MFC-AGG-ID: oIxild_HODiKlYv0LSUviw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866475; x=1739471275; 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=J7bt7RebNOzgP3cdASvIHwhn5WFSysOm0Db/LmQL+l8=; b=Omy0zXIVFY52RISjCuQx7RO+DuAklaOWavEYJfqt7aYGg8DGhv5/ttCVWYxb0WnNfd K3n7LUjFAsFbN8G4AWWcJ57CMoQhx0NjVFRy+M7tXIaamYSmxdO9n8RBPqCFW1Qqt7/5 2/bp/M0MKde6J0VhA+jxIVB4as7PPYpy885CMG/xl9c8huP7G41sdYtSygZ9InlSP33V Lj5ZfjVdd8RgwfgUm3uZFD5Ai3H6cQQCiW2/5l+SoDVzKYofoghocqNo2PX5BdB1Uil8 kVua07JDLnSNjwM/fdgvXxiN589Nps0g7Y57/yWifZC+kPPD5w+P9cXxSBlh8yWgeC46 LApQ== X-Gm-Message-State: AOJu0YxB0Heri2VNFiHfHC84baPF1m/4ScKXx6sF1FyauhvCc+EVfcso 4DPNBitsleTd7J7zZQkjEtnZcsQj3C0OG9Rge9pMwjxNORuofF+Py973GAmkikKDfeSebEDymxd KDCPlHkaJ23Qk7irM6DIMNWHTwu4H2F1x/yr+OfCVqelfNj8QzxE6BkJ9jldaDblDiIB1LYGb0a l9GMe7njoiVOLHWUZi2dX+jXWZ2w2ILiJ8vcZzI6Q= X-Gm-Gg: ASbGnctxLeSP1Fg+cJoWWWaWM48oxyLYt1nqfit+eE8fA/TUNAR9exI7HHgd9bAP/VM I+IRegF0RXZCryOLcUgdCVoFJ0mAaPPDicKqPRHy24cfbvvMvSkoo63jwEO/UoPTVRK+b6klR5N O/LNBjYXWjA1Pr4v/eLl6hyEMczny5cfJszBsTh10CCHoZ86JbM0TovevbAhDDsF9Wb/0D8DuEV D90Ww07o0xN9oXToT9f7X/rJn+aqdOU9jI7dmRbmwdEOZk9u4+Ikd8ZdiEKmKvgmi7BzH16EASa AAKj2ys= X-Received: by 2002:a5d:5f83:0:b0:38d:b448:8ffc with SMTP id ffacd0b85a97d-38dc90eec01mr33020f8f.27.1738866474835; Thu, 06 Feb 2025 10:27:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzkbcYQaf93l9fGWaCxhmD/L/pjlBdNO8JU64gqlRixFqQIVNLLoASpdsEHUVmdku8OPY48A== X-Received: by 2002:a5d:5f83:0:b0:38d:b448:8ffc with SMTP id ffacd0b85a97d-38dc90eec01mr33007f8f.27.1738866474426; Thu, 06 Feb 2025 10:27:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 19/22] target/riscv: convert Ventana V1 to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:07 +0100 Message-ID: <20250206182711.2420505-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866521334019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 75 ++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b2b9b4f6e39..7ebf007c129 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -485,45 +485,6 @@ static void riscv_register_custom_csrs(RISCVCPU *cpu, = RISCVCSR *csr_list) #endif =20 #if defined(TARGET_RISCV64) -static void rv64_veyron_v1_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVG | RVC | RVS | RVU | RVH); - env->priv_ver =3D PRIV_VERSION_1_12_0; - - /* Enable ISA extensions */ - cpu->cfg.mmu =3D true; - cpu->cfg.ext_zifencei =3D true; - cpu->cfg.ext_zicsr =3D true; - cpu->cfg.pmp =3D true; - cpu->cfg.ext_zicbom =3D true; - cpu->cfg.cbom_blocksize =3D 64; - cpu->cfg.cboz_blocksize =3D 64; - cpu->cfg.ext_zicboz =3D true; - cpu->cfg.ext_smaia =3D true; - cpu->cfg.ext_ssaia =3D true; - cpu->cfg.ext_sscofpmf =3D true; - cpu->cfg.ext_sstc =3D true; - cpu->cfg.ext_svinval =3D true; - cpu->cfg.ext_svnapot =3D true; - cpu->cfg.ext_svpbmt =3D true; - cpu->cfg.ext_smstateen =3D true; - cpu->cfg.ext_zba =3D true; - cpu->cfg.ext_zbb =3D true; - cpu->cfg.ext_zbc =3D true; - cpu->cfg.ext_zbs =3D true; - cpu->cfg.ext_XVentanaCondOps =3D true; - - cpu->cfg.mvendorid =3D VEYRON_V1_MVENDORID; - cpu->cfg.marchid =3D VEYRON_V1_MARCHID; - cpu->cfg.mimpid =3D VEYRON_V1_MIMPID; - -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_SV48); -#endif -} =20 static void rv64_xiangshan_nanhu_cpu_init(Object *obj) { @@ -3089,7 +3050,41 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .satp_mode64 =3D VM_1_10_SV57, ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_VEYRON_V1, MXL_RV64, rv64_veyron_v1= _cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_VEYRON_V1, TYPE_RISCV_VENDOR_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVG | RVC | RVS | RVU | RVH, + .priv_spec =3D PRIV_VERSION_1_12_0, + + /* ISA extensions */ + .cfg.mmu =3D true, + .cfg.ext_zifencei =3D true, + .cfg.ext_zicsr =3D true, + .cfg.pmp =3D true, + .cfg.ext_zicbom =3D true, + .cfg.cbom_blocksize =3D 64, + .cfg.cboz_blocksize =3D 64, + .cfg.ext_zicboz =3D true, + .cfg.ext_smaia =3D true, + .cfg.ext_ssaia =3D true, + .cfg.ext_sscofpmf =3D true, + .cfg.ext_sstc =3D true, + .cfg.ext_svinval =3D true, + .cfg.ext_svnapot =3D true, + .cfg.ext_svpbmt =3D true, + .cfg.ext_smstateen =3D true, + .cfg.ext_zba =3D true, + .cfg.ext_zbb =3D true, + .cfg.ext_zbc =3D true, + .cfg.ext_zbs =3D true, + .cfg.ext_XVentanaCondOps =3D true, + + .cfg.mvendorid =3D VEYRON_V1_MVENDORID, + .cfg.marchid =3D VEYRON_V1_MARCHID, + .cfg.mimpid =3D VEYRON_V1_MIMPID, + + .satp_mode64 =3D VM_1_10_SV48, + ), + DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, MXL_RV64, rv64_xiangshan_= nanhu_cpu_init), #ifdef CONFIG_TCG --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866528; cv=none; d=zohomail.com; s=zohoarc; b=aoW5EPUP3njwS1pRsulRoyDf0V2V0S+GKx+ZvDPThXerNrpa9QrUKXNpkllwpqEUB+g0AF0oEY6FcJH0Pqt7hjReN6yJIlKCdA6V0oWlnawdc6nW0CFoZJZm/byZzbHsD/ZFrlU+DZQNKVgTUpHYx+/eWGCeYEz1UGzmkm8CzhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866528; 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=k3S3yGqQ9QU2FGjgCTSwMFrG+Hoe0VCtezT6QvrKUI0=; b=fZydldWg1jDw8fstZ/3DGcG58w/3s7XUeAFZ7XEFYxfOD2Cot93GZB0nXqnLpoL0pWYBifeQelAboERp2S+9QHOt72Gz6wDqi5rFwfPIWFbPR9nzhaCxbIaI6CA9BvwIdREsUGeosiHlliWDa2ReuE6++JzZkAINlevsN5MGm3E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866528034315.7023506897764; Thu, 6 Feb 2025 10:28:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6be-00021u-BE; Thu, 06 Feb 2025 13:28:06 -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 1tg6ba-0001ro-08 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:04 -0500 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 1tg6bY-0001WR-Gx for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:01 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-CB_kVQvcNj67eRzuHCQSPg-1; Thu, 06 Feb 2025 13:27:58 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38dc6aad9f8so151889f8f.1 for ; Thu, 06 Feb 2025 10:27:58 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd35e88sm2316112f8f.26.2025.02.06.10.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866479; 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=k3S3yGqQ9QU2FGjgCTSwMFrG+Hoe0VCtezT6QvrKUI0=; b=a+Gp1uLjnAMdQ0PVpT4plKrUKCCsewuc4Y2vCnIg4kV9tIfEDIUSmHk5I7v02CyGtXbI8g WM9yKuzTgF8ELsm5QAU1TA8qICoE04Vdhxx8CaCotoOj7P6FkpDMEgAi1WL5pnWu1ks/k7 bZRoYWu/pXEpWzwdU4nr5Syo1kZS1T0= X-MC-Unique: CB_kVQvcNj67eRzuHCQSPg-1 X-Mimecast-MFC-AGG-ID: CB_kVQvcNj67eRzuHCQSPg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866477; x=1739471277; 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=k3S3yGqQ9QU2FGjgCTSwMFrG+Hoe0VCtezT6QvrKUI0=; b=Ay4RgRT58AICrgHu167ee+S76bWhtEr5CPvCNa2QW2KksAGSU5+gKQi+KDGbL9bLk7 Fg5fMvXuVxbecbs+2YFMkwVfuyMKCfkgXfr9/7xuOWAkocvapsZL/ToP3KXNhmuSzz10 6j4uKRlUcv7iWqlOxjGYF+D1FOq5dG+yJVgHaFDStSBa2zVn92cPZsU6sz0LzH+guCxS nycA6sNivGX4YZH2V9WGkdTn043g/HpFV3dOpVMA+eyoeOSmUPBO0bbQGd5+2cXNwSkk rsc3QAcPrrYbMQBY5H3LMVgUC0P4gYbWSF+E1I7fx6orcBpFAbNo2e9dzE9tlYilRWC/ fAOA== X-Gm-Message-State: AOJu0YzKLj06ISkW+03BvK/4qDRB6Yha3fWVBqBhGPwA6J1x2g0i/++8 XSDWiUSCR53BL7c3bBia1ufanHiaRZww07oj/QIR8uyDF3vRmi3xQ6LjPNo0aj70sUK220rt8K2 8ktJGu8q4ygqMzftwBbNbod3pAjKe1mOhTcc7tdcTbhwIc2WRFMXhpLKSNhhZo2xos1BWoawyzN rBb8BpAvvW0fTQ/45CMn9Us/Dw3VfGzttvKaWyquc= X-Gm-Gg: ASbGnctOxZHj2CqYOHslcj9RTOCQ44FKqR8yVqpKC+d5mhUobxfzgNMoVSr+TbDzRU2 K7lvd704tFCohtkq16aFZpEpAfjAfj5ES7SGxHZ3zZXA87y+ZhV+BPg+5U9/MwuM79NGizPbIgH eUAFx8eVziXnBGVf/cpHslDrlgovj0nD19OncXKIJjxL+AEGAx5vycwCM6SVKmxp8YhMST5okNF NMGhcmfICBphPobcLylG3ULy2C4AEvZv7csaaQ192itDla+6eHMZJ6dkiY1drK1X/LZbjhWQ8Ax goxN0ac= X-Received: by 2002:a5d:47af:0:b0:38d:ae4e:2267 with SMTP id ffacd0b85a97d-38dbb27096fmr3006874f8f.11.1738866476790; Thu, 06 Feb 2025 10:27:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP6/F6a3Hjl9MhhgsQNY7MLJAsWPe2v+xT1+JOn352HAZLFbCqaanUixJhqh2peDJGMQAZqw== X-Received: by 2002:a5d:47af:0:b0:38d:ae4e:2267 with SMTP id ffacd0b85a97d-38dbb27096fmr3006857f8f.11.1738866476451; Thu, 06 Feb 2025 10:27:56 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 20/22] target/riscv: convert Xiangshan Nanhu to RISCVCPUDef Date: Thu, 6 Feb 2025 19:27:08 +0100 Message-ID: <20250206182711.2420505-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866530809019000 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 67 ++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7ebf007c129..b0a28c065e1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -484,38 +484,6 @@ static void riscv_register_custom_csrs(RISCVCPU *cpu, = RISCVCSR *csr_list) } #endif =20 -#if defined(TARGET_RISCV64) - -static void rv64_xiangshan_nanhu_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - RISCVCPU *cpu =3D RISCV_CPU(obj); - - riscv_cpu_set_misa_ext(env, RVG | RVC | RVB | RVS | RVU); - env->priv_ver =3D PRIV_VERSION_1_12_0; - - /* Enable ISA extensions */ - cpu->cfg.ext_zbc =3D true; - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zknd =3D true; - cpu->cfg.ext_zkne =3D true; - cpu->cfg.ext_zknh =3D true; - cpu->cfg.ext_zksed =3D true; - cpu->cfg.ext_zksh =3D true; - cpu->cfg.ext_svinval =3D true; - - cpu->cfg.mmu =3D true; - cpu->cfg.pmp =3D true; - -#ifndef CONFIG_USER_ONLY - set_satp_mode_max_supported(cpu, VM_1_10_SV39); -#endif -} - -#endif /* !TARGET_RISCV64 */ - static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; @@ -2774,16 +2742,6 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, c= har *nodename) } #endif =20 -#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \ - { \ - .name =3D (type_name), \ - .parent =3D TYPE_RISCV_VENDOR_CPU, \ - .instance_init =3D (initfn), \ - .class_data =3D &((RISCVCPUDef) { \ - .misa_mxl_max =3D (misa_mxl_max_), \ - }), \ - } - #define DEFINE_ABSTRACT_RISCV_CPU(type_name, parent_type_name, ...) \ { \ .name =3D (type_name), \ @@ -3085,8 +3043,29 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .satp_mode64 =3D VM_1_10_SV48, ), =20 - DEFINE_VENDOR_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, - MXL_RV64, rv64_xiangshan_= nanhu_cpu_init), + DEFINE_RISCV_CPU(TYPE_RISCV_CPU_XIANGSHAN_NANHU, TYPE_RISCV_VENDOR_CPU, + .misa_mxl_max =3D MXL_RV64, + .misa_ext =3D RVG | RVC | RVB | RVS | RVU, + .priv_spec =3D PRIV_VERSION_1_12_0, + + /* ISA extensions */ + .cfg.ext_zbc =3D true, + .cfg.ext_zbkb =3D true, + .cfg.ext_zbkc =3D true, + .cfg.ext_zbkx =3D true, + .cfg.ext_zknd =3D true, + .cfg.ext_zkne =3D true, + .cfg.ext_zknh =3D true, + .cfg.ext_zksed =3D true, + .cfg.ext_zksh =3D true, + .cfg.ext_svinval =3D true, + + .cfg.mmu =3D true, + .cfg.pmp =3D true, + + .satp_mode64 =3D VM_1_10_SV39, + ), + #ifdef CONFIG_TCG DEFINE_RISCV_CPU(TYPE_RISCV_CPU_BASE128, TYPE_RISCV_DYNAMIC_CPU, .satp_mode64 =3D VM_1_10_SV57, --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866533; cv=none; d=zohomail.com; s=zohoarc; b=Yl4JUvcp/PSsJ/CfmEbnTscoeBh7xyet3+UO09ISQOzCbMGbMxxg7uiFlEjBUn4aAM+EtGAKxMpIRDJXQ+ZFNmKSIvn3zbihQvR+7BaRlL8YWg3clmZ5rmCgEru8uAW/mXmZPPzMHE068tZy4tC3hIlTBzVESzPsjB5kihTTroA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866533; 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=mzg4G+B9CUg3Ih4BbOgM+Ll0JBlL3MkCPC46o9u780Q=; b=As86OvY6kuGUp6o666UUTcSGHnbEHEUZLG5gnexWZ+yWdEhwmb0D+5sfQOYm5/WFFRLXPbooyjpDZaAgCvgE+KnDdSPk3CEsp0/3ZPPbSUBVY5wFrkzWDT9y+HBZj8JU55hCc93NisBhF227oU9+Qi2nnmPN7OU/n2UblPPG8yM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866533356154.52027471913573; Thu, 6 Feb 2025 10:28:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bf-00023h-Nr; Thu, 06 Feb 2025 13:28:07 -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 1tg6bc-0001wN-A8 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6ba-0001XO-TE for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:04 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-uVCsIMuiP2SW5OIddV0M2g-1; Thu, 06 Feb 2025 13:28:00 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-436723db6c4so10415085e9.3 for ; Thu, 06 Feb 2025 10:28:00 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390d933794sm64995405e9.7.2025.02.06.10.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866482; 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=mzg4G+B9CUg3Ih4BbOgM+Ll0JBlL3MkCPC46o9u780Q=; b=iuiUazTYQRPtNAKWpRsEVUZa9CmcGcxv1qDifdbqmcCOOPW5mVypHJlVpw8aKGNuQPPkE1 UvNLiXma9wlF9eEIBn0l8nkkydck2hMfXUe3EZjZsUxV+oWLNLGLqRhQp9qUxLDFkwv+sL XCic7j0UfSq0KMw1zD2goT4Qwpso4uw= X-MC-Unique: uVCsIMuiP2SW5OIddV0M2g-1 X-Mimecast-MFC-AGG-ID: uVCsIMuiP2SW5OIddV0M2g X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866479; x=1739471279; 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=mzg4G+B9CUg3Ih4BbOgM+Ll0JBlL3MkCPC46o9u780Q=; b=xDJ7BtkQe6Qt/XF+3LqY9hFn1ADEeTh5WQA2LlJjd/KROSbdRV8WuRmGaS8ZfB4eeg Eg0AWqscMw0w33g8oaNfUb8P2bRco00qEHObeZTMyKLzpjwKktD/rMa+8t9lTPcMuiot YP8wL+euECDIk5MfGH6HuNQ5MiN4dS8EbyrTHr9U4t7GiuR8eKspNvQjlKMRrro+ExF7 Q5fLwLMsS2FbQbxDAzYoz6k0kT6L80NqZRbU4UhwBrZwuKkHaaZkrqMdqpS560hlmVET nHi1d6/AK1wJoBV/N7vCHnfqNP2wGBFGrgHzpUdhp7cCrOtmihNKs5+PwFOiDL3kdvsm 1ifA== X-Gm-Message-State: AOJu0YwXGpSU9QE0X7WH7NGyJkLnqcoIfBHSN5wYc6EcN8nQtqxISJ11 r7k0RdBdl85Q015qkgFZetuDU3tkiF7RSHhY8jUws9NVYYn3Fb2AKK8WIZmk3UUTXwGZ6I9YD2n PrmJimYB1UIDEEtjUgsxlsZ/Q2ljmuh+1ix6GIeGJGT9P6/wiOgVDzDhXyYncE+9EzuOdikC+EK WVXMpxoS3l+xc39dB93xIzIcIC4MDKfFcMTTLOWhk= X-Gm-Gg: ASbGncv3Dng/25ySqr+MbJ7Cr9+OtVkXgVGvebn3dqqRUNQtnsUSs2Rzxx289kTWfzM NHwSzsRWL7NpOXJk4qgcH38LFPL8J9yWkFCjLVJs5wzpZD0ecbbxcIfvk4zGS47KdmgNt8kDeUP NlIlh6ZnsipDJfuDoyYakjD2fipLnK7UeYrB35BH7njjMZszhvz2i3GVnARB2n0+BfWpMwRwCi0 yWWGTAZtaVisJSYeSKV44dDWcyok35PuD3olk6Vl41U6ssoodmKlF+9M3oA5Gd5K7ur9p5jx9DU NuXoXmw= X-Received: by 2002:a05:600c:4687:b0:434:fa61:fdfb with SMTP id 5b1f17b1804b1-43924991398mr4588195e9.18.1738866478821; Thu, 06 Feb 2025 10:27:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEImlL96q9n+S+yuGxnqHkXwAljSTc0bco23rCK0vHAO8DG8vnwJVm4tYqwy+cC0lGOqcThhQ== X-Received: by 2002:a05:600c:4687:b0:434:fa61:fdfb with SMTP id 5b1f17b1804b1-43924991398mr4587975e9.18.1738866478336; Thu, 06 Feb 2025 10:27:58 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 21/22] target/riscv: remove .instance_post_init Date: Thu, 6 Feb 2025 19:27:09 +0100 Message-ID: <20250206182711.2420505-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866535402019100 Content-Type: text/plain; charset="utf-8" Unlike other uses of .instance_post_init, accel_cpu_instance_init() *registers* properties, and therefore must be run before device_post_init() which sets them to their values from -global. In order to move all registration of properties to .instance_init, call accel_cpu_instance_init() at the end of riscv_cpu_init(). Signed-off-by: Paolo Bonzini --- target/riscv/cpu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b0a28c065e1..006d8696216 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1084,11 +1084,6 @@ static bool riscv_cpu_is_dynamic(Object *cpu_obj) return object_dynamic_cast(cpu_obj, TYPE_RISCV_DYNAMIC_CPU) !=3D NULL; } =20 -static void riscv_cpu_post_init(Object *obj) -{ - accel_cpu_instance_init(CPU(obj)); -} - static void riscv_cpu_init(Object *obj) { RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(obj); @@ -1149,6 +1144,8 @@ static void riscv_cpu_init(Object *obj) riscv_register_custom_csrs(cpu, mcc->def->custom_csrs); } #endif + + accel_cpu_instance_init(CPU(obj)); } =20 typedef struct misa_ext_info { @@ -2780,7 +2777,6 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .instance_size =3D sizeof(RISCVCPU), .instance_align =3D __alignof(RISCVCPU), .instance_init =3D riscv_cpu_init, - .instance_post_init =3D riscv_cpu_post_init, .abstract =3D true, .class_size =3D sizeof(RISCVCPUClass), .class_init =3D riscv_cpu_common_class_init, --=20 2.48.1 From nobody Sat Apr 5 01:23:11 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1738866578; cv=none; d=zohomail.com; s=zohoarc; b=H+/edbOTPf7AuXvQzztz4RMztihA9oTX/0dDe4swkhjw6Yv01xmbHIT7Ntege1aKWoOuMzrt5nyy2uDnB9u+VDGk3qynsbk93+PXZeWIRDbZhnTHL365iFV45+L/ljto6913UhF4HMh/zMeUqtjPWMW194Qnn8YEYAUgWhMF0t8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738866578; 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=UeZ54cd4QT2QzCN3ymHN6MRSpqc20i7oyquy6KA3VTI=; b=RrUeLWj9miZ3b7uvlHbGITucYMQPBWaH5BxK2kKG8FksB/Y0nj1S97G9zKXCsSPVgBD8LUcp89i33hv9KNQIUTq9t7lL8f+3s9oW+woiiziUyfPpv73w8yPDhG+1VvC9xQ6V9I/PylOFpCxDbQ2BDJbCcNsgHs9pPs59kpNtQ7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738866578625652.6818506791576; Thu, 6 Feb 2025 10:29:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg6bi-0002B3-C3; Thu, 06 Feb 2025 13:28:10 -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 1tg6bg-00027Q-DJ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg6bd-0001YN-VF for qemu-devel@nongnu.org; Thu, 06 Feb 2025 13:28:07 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-49-CWGIXMZ9PXigdMVU2NVMiQ-1; Thu, 06 Feb 2025 13:28:03 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4361efc9d1fso9850805e9.2 for ; Thu, 06 Feb 2025 10:28:02 -0800 (PST) Received: from [192.168.1.84] ([93.56.163.127]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbde1e034sm2328841f8f.89.2025.02.06.10.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 10:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738866484; 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=UeZ54cd4QT2QzCN3ymHN6MRSpqc20i7oyquy6KA3VTI=; b=Yz09Cu0LDLoajQzoKnxe6e6b6Y8Fgnrs5DsExW/lfsaYz4Yn+x05tEpm+p/e2FGIFxknf/ snMJ5lueS7JA/I9UvDWxYGgAy2sLiAwGWK9Jc9Mqev5DobMvSOkoOM0feW6fBRJmyUz5qf FZ8QbL43NueX5rroTPrg+gydjagJfiY= X-MC-Unique: CWGIXMZ9PXigdMVU2NVMiQ-1 X-Mimecast-MFC-AGG-ID: CWGIXMZ9PXigdMVU2NVMiQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738866481; x=1739471281; 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=UeZ54cd4QT2QzCN3ymHN6MRSpqc20i7oyquy6KA3VTI=; b=rFjYy5h9saLZZCFoSbYl/H1awXLraMOALYU5iEr5nw/LXfg5+h6Dt/2smBz715xAHg szMmCp8ZBA1rgY0WLEiHFas99tpTB7WyEIpnMsZNeBy5dN35dkz1UgeLn+sSnd47hOAm rP02X1IYH1W4rKFS8PyvmBcKEc+O4nmIfW69WbQJQaTnKulW5pvmam2PzF0WR9PBNzHc ShusDonn/9i0eIxhglr8PbnRBsrlVldkvgFeuAxD6hl43VUk85FikkSs+wNSJDZAhxDV A5EKQZk5Hrhb06IbWRPf6b8mj7jcbKoUR4/yn3XsR9cF3use74jb8KAgxlnXJS4SXOYF TZ1A== X-Gm-Message-State: AOJu0YzlGYadTAmTyZLEUzmACj6P91W7QLdlrzqZKhdMsuZEqfuIjpAd K457gSF8NBN8Hm0LUhB7tqvEx57SxUFI4zWYmJ0DU3oHEv2sPpMPCTAoodOaGFC37ugn0dG9E6L NKsHIpZsG95As5XihhFQ6ojfy8pwLFMZyT1u3RXzMWW/sAvFEb89h5xh+gW86FJLtPFfeshFmNl uoKIyuKt8fMxFJ6fHWzugqv5cGvbZL3nlns32V6pc= X-Gm-Gg: ASbGncuGHkWS2rV5VpBz+JEMFAXrJ1CTd9vINVtHK1pTPZJFXhQfS7SVjdQdEga0hNF AZkjM3cVwhGFkOZ/IggoxgyNq6dOFmAajXPu8/u5xYFQ+OhXhAAUiggsZ7uIiPZlCYuXSLFkNDK fpcUqBc6xrJuFAGlbvc4xxHyDDUWYq+m/yaFfx49fU0UraVt6FNrOKm3bRP9SjZzz7UhjqoH/C0 qqz8fuj/5LqBFbY3gYlCH+bcOFkmWrttYSWo5eGDoyXQdbg/5ZPpVM5lpjYT7Po7z1MOhghmB4H okEmZ2Q= X-Received: by 2002:a05:600c:45ca:b0:438:a20b:6a2a with SMTP id 5b1f17b1804b1-43924992049mr4964425e9.14.1738866481541; Thu, 06 Feb 2025 10:28:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+7zd71QrkxBIb3BPYbVEWxknwIgl9+IDgQ6Qb08AJasCfk1fGysNioECv+LF/bXi8qdxZmQ== X-Received: by 2002:a05:600c:45ca:b0:438:a20b:6a2a with SMTP id 5b1f17b1804b1-43924992049mr4964105e9.14.1738866480874; Thu, 06 Feb 2025 10:28:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com Subject: [PATCH 22/22] target/riscv: move SATP modes out of CPUConfig Date: Thu, 6 Feb 2025 19:27:10 +0100 Message-ID: <20250206182711.2420505-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250206182711.2420505-1-pbonzini@redhat.com> References: <20250206182711.2420505-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1738866579538019100 Content-Type: text/plain; charset="utf-8" They are never accessed together with the rest of the CPUConfig data, so just store it in the ArchCPU struct. Signed-off-by: Paolo Bonzini --- target/riscv/cpu.h | 16 +++++++++ target/riscv/cpu_cfg.h | 16 --------- target/riscv/cpu_cfg_fields.h.inc | 8 ----- hw/riscv/virt-acpi-build.c | 6 ++-- hw/riscv/virt.c | 4 +-- target/riscv/cpu.c | 56 +++++++++++++++---------------- target/riscv/csr.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- 8 files changed, 50 insertions(+), 60 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 00ec475fbba..7f6c4fd138c 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -492,6 +492,21 @@ struct CPUArchState { uint64_t rnmi_excpvec; }; =20 +/* + * map is a 16-bit bitmap: the most significant set bit in map is the maxi= mum + * satp mode that is supported. It may be chosen by the user and must resp= ect + * what qemu implements (valid_1_10_32/64) and what the hw is capable of + * (supported bitmap below). + * + * init is a 16-bit bitmap used to make sure the user selected a correct + * configuration as per the specification. + * + * supported is a 16-bit bitmap used to reflect the hw capabilities. + */ +typedef struct { + uint16_t map, init, supported; +} RISCVSATPModes; + /* * RISCVCPU: * @env: #CPURISCVState @@ -508,6 +523,7 @@ struct ArchCPU { =20 /* Configuration Settings */ RISCVCPUConfig cfg; + RISCVSATPModes satp_modes; =20 QEMUTimer *pmu_timer; /* A bitmask of Available programmable counters */ diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 07789a9de88..e9bf75730a6 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -21,25 +21,9 @@ #ifndef RISCV_CPU_CFG_H #define RISCV_CPU_CFG_H =20 -/* - * map is a 16-bit bitmap: the most significant set bit in map is the maxi= mum - * satp mode that is supported. It may be chosen by the user and must resp= ect - * what qemu implements (valid_1_10_32/64) and what the hw is capable of - * (supported bitmap below). - * - * init is a 16-bit bitmap used to make sure the user selected a correct - * configuration as per the specification. - * - * supported is a 16-bit bitmap used to reflect the hw capabilities. - */ -typedef struct { - uint16_t map, init, supported; -} RISCVSATPMap; - struct RISCVCPUConfig { #define BOOL_FIELD(x) bool x; #define TYPED_FIELD(type, x) type x; -#define STRUCT_FIELD(type, x) type x; #include "cpu_cfg_fields.h.inc" }; =20 diff --git a/target/riscv/cpu_cfg_fields.h.inc b/target/riscv/cpu_cfg_field= s.h.inc index cbedf0a703b..b8cadf02a4e 100644 --- a/target/riscv/cpu_cfg_fields.h.inc +++ b/target/riscv/cpu_cfg_fields.h.inc @@ -4,9 +4,6 @@ #ifndef TYPED_FIELD #define TYPED_FIELD(type, x) #endif -#ifndef STRUCT_FIELD -#define STRUCT_FIELD(type, x) -#endif =20 BOOL_FIELD(ext_zba) BOOL_FIELD(ext_zbb) @@ -162,10 +159,5 @@ TYPED_FIELD(uint16_t, cbom_blocksize) TYPED_FIELD(uint16_t, cbop_blocksize) TYPED_FIELD(uint16_t, cboz_blocksize) =20 -#ifndef CONFIG_USER_ONLY -STRUCT_FIELD(RISCVSATPMap, satp_mode) -#endif - #undef BOOL_FIELD #undef TYPED_FIELD -#undef STRUCT_FIELD diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 1ad68005085..60e607d12ac 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -281,7 +281,7 @@ static void build_rhct(GArray *table_data, num_rhct_nodes++; } =20 - if (cpu->cfg.satp_mode.supported !=3D 0) { + if (cpu->satp_modes.supported !=3D 0) { num_rhct_nodes++; } =20 @@ -341,8 +341,8 @@ static void build_rhct(GArray *table_data, } =20 /* MMU node structure */ - if (cpu->cfg.satp_mode.supported !=3D 0) { - satp_mode_max =3D satp_mode_max_from_map(cpu->cfg.satp_mode.map); + if (cpu->satp_modes.supported !=3D 0) { + satp_mode_max =3D satp_mode_max_from_map(cpu->satp_modes.map); mmu_offset =3D table_data->len - table.table_offset; build_append_int_noprefix(table_data, 2, 2); /* Type */ build_append_int_noprefix(table_data, 8, 2); /* Length */ diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 241389d72f8..41f0a9c4caf 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -251,8 +251,8 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, i= nt socket, s->soc[socket].hartid_base + cpu); qemu_fdt_add_subnode(ms->fdt, cpu_name); =20 - if (cpu_ptr->cfg.satp_mode.supported !=3D 0) { - satp_mode_max =3D satp_mode_max_from_map(cpu_ptr->cfg.satp_mod= e.map); + if (cpu_ptr->satp_modes.supported !=3D 0) { + satp_mode_max =3D satp_mode_max_from_map(cpu_ptr->satp_modes.m= ap); sv_name =3D g_strdup_printf("riscv,%s", satp_mode_str(satp_mode_max, is_32_b= it)); qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", sv_name= ); diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 006d8696216..d9f06e3f0c4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -78,8 +78,6 @@ static void riscv_cpu_cfg_merge(RISCVCPUConfig *dest, RIS= CVCPUConfig *src) { #define BOOL_FIELD(x) dest->x |=3D src->x; #define TYPED_FIELD(type, x) if (src->x) dest->x =3D src->x; - /* only satp_mode, which is initialized by instance_init */ -#define STRUCT_FIELD(type, x) #include "cpu_cfg_fields.h.inc" } =20 @@ -448,7 +446,7 @@ static void set_satp_mode_max_supported(RISCVCPU *cpu, =20 for (int i =3D 0; i <=3D satp_mode; ++i) { if (valid_vm[i]) { - cpu->cfg.satp_mode.supported |=3D (1 << i); + cpu->satp_modes.supported |=3D (1 << i); } } } @@ -463,11 +461,11 @@ static void set_satp_mode_default_map(RISCVCPU *cpu) */ if (object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_BARE_CPU) !=3D NULL) { warn_report("No satp mode set. Defaulting to 'bare'"); - cpu->cfg.satp_mode.map =3D (1 << VM_1_10_MBARE); + cpu->satp_modes.map =3D (1 << VM_1_10_MBARE); return; } =20 - cpu->cfg.satp_mode.map =3D cpu->cfg.satp_mode.supported; + cpu->satp_modes.map =3D cpu->satp_modes.supported; } #endif =20 @@ -826,15 +824,15 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cp= u, Error **errp) uint8_t satp_mode_map_max, satp_mode_supported_max; =20 /* The CPU wants the OS to decide which satp mode to use */ - if (cpu->cfg.satp_mode.supported =3D=3D 0) { + if (cpu->satp_modes.supported =3D=3D 0) { return; } =20 satp_mode_supported_max =3D - satp_mode_max_from_map(cpu->cfg.satp_mode.supported); + satp_mode_max_from_map(cpu->satp_modes.supported); =20 - if (cpu->cfg.satp_mode.map =3D=3D 0) { - if (cpu->cfg.satp_mode.init =3D=3D 0) { + if (cpu->satp_modes.map =3D=3D 0) { + if (cpu->satp_modes.init =3D=3D 0) { /* If unset by the user, we fallback to the default satp mode.= */ set_satp_mode_default_map(cpu); } else { @@ -844,11 +842,11 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cp= u, Error **errp) * valid_vm_1_10_32/64. */ for (int i =3D 1; i < 16; ++i) { - if ((cpu->cfg.satp_mode.init & (1 << i)) && - (cpu->cfg.satp_mode.supported & (1 << i))) { + if ((cpu->satp_modes.init & (1 << i)) && + (cpu->satp_modes.supported & (1 << i))) { for (int j =3D i - 1; j >=3D 0; --j) { - if (cpu->cfg.satp_mode.supported & (1 << j)) { - cpu->cfg.satp_mode.map |=3D (1 << j); + if (cpu->satp_modes.supported & (1 << j)) { + cpu->satp_modes.map |=3D (1 << j); break; } } @@ -858,7 +856,7 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu,= Error **errp) } } =20 - satp_mode_map_max =3D satp_mode_max_from_map(cpu->cfg.satp_mode.map); + satp_mode_map_max =3D satp_mode_max_from_map(cpu->satp_modes.map); =20 /* Make sure the user asked for a supported configuration (HW and qemu= ) */ if (satp_mode_map_max > satp_mode_supported_max) { @@ -874,9 +872,9 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu,= Error **errp) */ if (!rv32) { for (int i =3D satp_mode_map_max - 1; i >=3D 0; --i) { - if (!(cpu->cfg.satp_mode.map & (1 << i)) && - (cpu->cfg.satp_mode.init & (1 << i)) && - (cpu->cfg.satp_mode.supported & (1 << i))) { + if (!(cpu->satp_modes.map & (1 << i)) && + (cpu->satp_modes.init & (1 << i)) && + (cpu->satp_modes.supported & (1 << i))) { error_setg(errp, "cannot disable %s satp mode if %s " "is enabled", satp_mode_str(i, false), satp_mode_str(satp_mode_map_max, false)); @@ -887,8 +885,8 @@ static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu,= Error **errp) =20 /* Finally expand the map so that all valid modes are set */ for (int i =3D satp_mode_map_max - 1; i >=3D 0; --i) { - if (cpu->cfg.satp_mode.supported & (1 << i)) { - cpu->cfg.satp_mode.map |=3D (1 << i); + if (cpu->satp_modes.supported & (1 << i)) { + cpu->satp_modes.map |=3D (1 << i); } } } @@ -968,11 +966,11 @@ bool riscv_cpu_accelerator_compatible(RISCVCPU *cpu) static void cpu_riscv_get_satp(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - RISCVSATPMap *satp_map =3D opaque; + RISCVSATPModes *satp_modes =3D opaque; uint8_t satp =3D satp_mode_from_str(name); bool value; =20 - value =3D satp_map->map & (1 << satp); + value =3D satp_modes->map & (1 << satp); =20 visit_type_bool(v, name, &value, errp); } @@ -980,7 +978,7 @@ static void cpu_riscv_get_satp(Object *obj, Visitor *v,= const char *name, static void cpu_riscv_set_satp(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - RISCVSATPMap *satp_map =3D opaque; + RISCVSATPModes *satp_modes =3D opaque; uint8_t satp =3D satp_mode_from_str(name); bool value; =20 @@ -988,8 +986,8 @@ static void cpu_riscv_set_satp(Object *obj, Visitor *v,= const char *name, return; } =20 - satp_map->map =3D deposit32(satp_map->map, satp, 1, value); - satp_map->init |=3D 1 << satp; + satp_modes->map =3D deposit32(satp_modes->map, satp, 1, value); + satp_modes->init |=3D 1 << satp; } =20 void riscv_add_satp_mode_properties(Object *obj) @@ -998,16 +996,16 @@ void riscv_add_satp_mode_properties(Object *obj) =20 if (cpu->env.misa_mxl =3D=3D MXL_RV32) { object_property_add(obj, "sv32", "bool", cpu_riscv_get_satp, - cpu_riscv_set_satp, NULL, &cpu->cfg.satp_mode); + cpu_riscv_set_satp, NULL, &cpu->satp_modes); } else { object_property_add(obj, "sv39", "bool", cpu_riscv_get_satp, - cpu_riscv_set_satp, NULL, &cpu->cfg.satp_mode); + cpu_riscv_set_satp, NULL, &cpu->satp_modes); object_property_add(obj, "sv48", "bool", cpu_riscv_get_satp, - cpu_riscv_set_satp, NULL, &cpu->cfg.satp_mode); + cpu_riscv_set_satp, NULL, &cpu->satp_modes); object_property_add(obj, "sv57", "bool", cpu_riscv_get_satp, - cpu_riscv_set_satp, NULL, &cpu->cfg.satp_mode); + cpu_riscv_set_satp, NULL, &cpu->satp_modes); object_property_add(obj, "sv64", "bool", cpu_riscv_get_satp, - cpu_riscv_set_satp, NULL, &cpu->cfg.satp_mode); + cpu_riscv_set_satp, NULL, &cpu->satp_modes); } } =20 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index afb7544f078..1000fe1f07f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1862,7 +1862,7 @@ static RISCVException read_mstatus(CPURISCVState *env= , int csrno, =20 static bool validate_vm(CPURISCVState *env, target_ulong vm) { - uint64_t mode_supported =3D riscv_cpu_cfg(env)->satp_mode.map; + uint64_t mode_supported =3D env_archcpu(env)->satp_modes.map; return get_field(mode_supported, (1 << vm)); } =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 46cd8032c79..d30d9f427ab 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -693,7 +693,7 @@ static bool riscv_cpu_validate_profile_satp(RISCVCPU *c= pu, RISCVCPUProfile *profile, bool send_warn) { - int satp_max =3D satp_mode_max_from_map(cpu->cfg.satp_mode.supported); + int satp_max =3D satp_mode_max_from_map(cpu->satp_modes.supported); =20 if (profile->satp_mode > satp_max) { if (send_warn) { --=20 2.48.1