From nobody Tue Nov 26 22:33:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704304242; cv=none; d=zohomail.com; s=zohoarc; b=TXgVOPU+7jGsEW9KoEMWj4/kfOSdQpYWZC3wIwiHe00VFyYpkBJ1ttqvh8uRh9OH032F4v6+ic4TsEb9bMWZB7oa71Ev/UcG3TbCsKvjlXISHa4IGtHr1P7tTh6q9lbaZwDa7dwokgyRwphNZMly8NAb1UoVM/+u27in4I34tw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704304242; h=Content-Type: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=Fv8i/ZD80zCUMWCrsFxA5ec1+Ry+9mZct9W/s18lf+Y=; b=AT6DXfAB8ooKyI6WKrqBQAvyKPLrCaS93d9V6DM8cw4iwVTavFvaiw7VVToNrSAPhb64CYjt2NmSJ5RFLKsX/GgZhLBktFuAHQANKvcgJ6CE39gOJAvynM7vUDxFl4JwBaeELtEdVEED4NPZGGQy4o5Tg9sj3an9w2xzknGGE4w= 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 1704304242951819.077462644655; Wed, 3 Jan 2024 09:50:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL5Mq-0001ef-OD; Wed, 03 Jan 2024 12:49: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 1rL5Mi-0000kM-Ns for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:49:16 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rL5Mb-0000Np-Eb for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:49:16 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40d4f5d902dso94638525e9.2 for ; Wed, 03 Jan 2024 09:49:08 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i15-20020a05600c354f00b0040d604dea3bsm2997934wmq.4.2024.01.03.09.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:49:05 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A20015F932; Wed, 3 Jan 2024 17:33:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704304148; x=1704908948; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fv8i/ZD80zCUMWCrsFxA5ec1+Ry+9mZct9W/s18lf+Y=; b=G78EPmVktKbIv9aRfMYWcGuncKKUdxZasPSjFpTgqrb+DrFgX9g2dcN/aM0RClDe+A 8hThxFFvrXbxtZjQ59YVjJcaL4d99Qec9oMBzNc5VsC4ANAu9sy4mGGHtHnHGOcd52FT xC7z4n1erfL2CRRhSkd4ymCn9KDeL655Z6Ow6RccrK2GPlt1GCgfTroWXcO3Uql13oAy HGhD7PA6g6s3przpW6aBmmoFQs08JdxN1QfRGDcDPEumPJHK+iCXkOjHhxrjsb5981U9 Kh3+DjpEoBCItbI8+sYhh9zxNuXIK69KFmyC0fX8kcP6/62GZhAjAR/scHBIQYu0+bf5 jdOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704304148; x=1704908948; 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=Fv8i/ZD80zCUMWCrsFxA5ec1+Ry+9mZct9W/s18lf+Y=; b=tYZrCo+JTZiU6wHvPm4+Q4lpwxzFemTFGAFP7nzeYt9bOT2tAj5m7EPHP4LpmmRYEN ovMWCT4Uzldv9ofWbC2lbD+FO9uGiWhwfE93kFRGgWBNzdVL81iUA5ql0cXUoTM6v4kR Nv+va3LoqhyYaBFgi7hWZBNA5OtHJrSpR1I66c9JdNv0fcVjq8+gqttfFK0cRZVogyHl s/dXm3NMR7dGZ6AS16D7tISDmoJicdPYk1iiYfYAuRKgm7QxQ99niZl9Hl8BPtMhm9SS 5x80eKeCGrdbEx2hGaoO3CP0kScIGCfL6Y7G0Cry9QXfXqc6kdzq7lVZKoK4SbGaZjI0 8cHQ== X-Gm-Message-State: AOJu0Yy7E/c9bWNMCCOBRMM1ryonlpnli4hG+vwv7cqX2JBoeK8huqfr p+p3tC72Wr5HFcjs3ybXb7zT+hd/tW3uuw== X-Google-Smtp-Source: AGHT+IHB2womVRGJeKyIZRLuutqaVIEZpbMeA2e0zso0qnpDk3i078lV3hSK2mrnROOwDfbSnHP0EQ== X-Received: by 2002:a1c:7718:0:b0:40d:5bf5:c8ce with SMTP id t24-20020a1c7718000000b0040d5bf5c8cemr6378521wmi.126.1704304147711; Wed, 03 Jan 2024 09:49:07 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , Song Gao , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , Aurelien Jarno , Yoshinori Sato , Yanan Wang , Bin Meng , Laurent Vivier , Michael Rolnik , Alexandre Iooss , David Woodhouse , Laurent Vivier , Paolo Bonzini , Brian Cain , Daniel Henrique Barboza , Beraldo Leal , Paul Durrant , Mahmoud Mandour , Thomas Huth , Liu Zhiwei , Cleber Rosa , kvm@vger.kernel.org, Peter Maydell , Wainer dos Santos Moschetta , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, Weiwei Li , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Daniel Henrique Barboza , Nicholas Piggin , Palmer Dabbelt , Marcel Apfelbaum , Ilya Leoshkevich , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , "Edgar E. Iglesias" , Eduardo Habkost , Pierrick Bouvier , qemu-riscv@nongnu.org, Alistair Francis , Akihiko Odaki Subject: [PATCH v2 25/43] target/riscv: Validate misa_mxl_max only once Date: Wed, 3 Jan 2024 17:33:31 +0000 Message-Id: <20240103173349.398526-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103173349.398526-1-alex.bennee@linaro.org> References: <20240103173349.398526-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704304243930100001 From: Akihiko Odaki misa_mxl_max is now a class member and initialized only once for each class. This also moves the initialization of gdb_core_xml_file which will be referenced before realization in the future. Signed-off-by: Akihiko Odaki Message-Id: <20231213-riscv-v7-4-a760156a337f@daynix.com> Signed-off-by: Alex Benn=C3=A9e Acked-by: Alistair Francis --- target/riscv/cpu.c | 21 +++++++++++++++++++++ target/riscv/tcg/tcg-cpu.c | 23 ----------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 2ab61df2217..b799f133604 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1247,6 +1247,26 @@ static const MISAExtInfo misa_ext_info_arr[] =3D { MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"), }; =20 +static void riscv_cpu_validate_misa_mxl(RISCVCPUClass *mcc) +{ + CPUClass *cc =3D CPU_CLASS(mcc); + + /* Validate that MISA_MXL is set properly. */ + switch (mcc->misa_mxl_max) { +#ifdef TARGET_RISCV64 + case MXL_RV64: + case MXL_RV128: + cc->gdb_core_xml_file =3D "riscv-64bit-cpu.xml"; + break; +#endif + case MXL_RV32: + cc->gdb_core_xml_file =3D "riscv-32bit-cpu.xml"; + break; + default: + g_assert_not_reached(); + } +} + static int riscv_validate_misa_info_idx(uint32_t bit) { int idx; @@ -1695,6 +1715,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; + riscv_cpu_validate_misa_mxl(mcc); } =20 static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 7f6712c81a4..eb243e011ca 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -148,27 +148,6 @@ static void riscv_cpu_validate_misa_priv(CPURISCVState= *env, Error **errp) } } =20 -static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu) -{ - RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(cpu); - CPUClass *cc =3D CPU_CLASS(mcc); - - /* Validate that MISA_MXL is set properly. */ - switch (mcc->misa_mxl_max) { -#ifdef TARGET_RISCV64 - case MXL_RV64: - case MXL_RV128: - cc->gdb_core_xml_file =3D "riscv-64bit-cpu.xml"; - break; -#endif - case MXL_RV32: - cc->gdb_core_xml_file =3D "riscv-32bit-cpu.xml"; - break; - default: - g_assert_not_reached(); - } -} - static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) { CPURISCVState *env =3D &cpu->env; @@ -676,8 +655,6 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp) return false; } =20 - riscv_cpu_validate_misa_mxl(cpu); - #ifndef CONFIG_USER_ONLY CPURISCVState *env =3D &cpu->env; Error *local_err =3D NULL; --=20 2.39.2