From patchwork Wed Jan 3 17:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 759653 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp6615982wrw; Wed, 3 Jan 2024 09:50:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3HQfCCtIuc8ehXokZFajrU4qBh8taCKQhP/TcpqjfUm01tTfUfVMXNLk/4MUH/v+d0D6c X-Received: by 2002:a05:6830:349e:b0:6dc:3c65:2a7f with SMTP id c30-20020a056830349e00b006dc3c652a7fmr5990791otu.63.1704304243187; Wed, 03 Jan 2024 09:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704304243; cv=none; d=google.com; s=arc-20160816; b=oPy4p8zYh2GI1PW+Rg849BAXdtTUBJdTI4tIuqu+f70wPVuPQVESmJXhvhIsv9HxcZ Zr0qbKU3RHf1yNKn+2QqilAzE6jM9RQXzHl47fd4Nu8X0TJ33Or6cOJ4eUuA/XDnsRef fcS4I/RbdI0TUqK2DePgu28rcQDQZGWy6SS6zhThHIhwV7bNZ2xIedQC4l+HWYuSVQKK bf13fcuKKDWnL+ruOqz4Vuj6DFf1VcuB6xYzSOOI/SMB5fi9FjCAOyqpcKh1cJv1cYmO mZzMgZaaiiFRnDoQbvKf3y0B6O24cEdu1LeUOFuEQj1LqXOOjuw8y2foT4dt1gqANFTF KTQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fv8i/ZD80zCUMWCrsFxA5ec1+Ry+9mZct9W/s18lf+Y=; fh=MptfaR+7adpcaME/63X0fm8Oaab8Ri8YJu2OQMap89k=; b=0GUTQ79OPUM25yM58YcMm7+Obwl7D9h9lsibtAOcsjDY2tWJLmQ2vRru8Sdr7oTIWf ZOMDgPDI7pR5o/TTE1iJGaJO1W/F942IXlEBXYkiSOlR71mDIfv1Vfe1HK6reb3H6KpI S+U98FTfXpyfGD2eBCNMyw/iFtw3qJi8mH8TbAKyoO/RU/ajJIBg+Yd7WA0xM9u0AbLP aKNDK/+GbErG4B5tGEr0xRUvUX5rE4TRefVOaXFoArMg3W8IRF+QJMGZALVwvdKI+xFq tgW4N4ARl0E2vRi3HAIC2+BLi+PtMIPYVNXBEVK8aD3CWf9p1GIXm9xnv5txfFvau686 p02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G78EPmVk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q18-20020a05622a031200b004236d74e060si29799185qtw.416.2024.01.03.09.50.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2024 09:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G78EPmVk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Lureau?= , 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_Benn?= =?utf-8?q?=C3=A9e?= , qemu-arm@nongnu.org, Weiwei Li , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Daniel Henrique Barboza , Nicholas Piggin , Palmer Dabbelt , Marcel Apfelbaum , Ilya Leoshkevich , =?utf-8?q?C=C3=A9dric_Le_Goater?= , "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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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[] = { MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"), }; +static void riscv_cpu_validate_misa_mxl(RISCVCPUClass *mcc) +{ + CPUClass *cc = 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 = "riscv-64bit-cpu.xml"; + break; +#endif + case MXL_RV32: + cc->gdb_core_xml_file = "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 = RISCV_CPU_CLASS(c); mcc->misa_mxl_max = (uint32_t)(uintptr_t)data; + riscv_cpu_validate_misa_mxl(mcc); } 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) } } -static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu) -{ - RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu); - CPUClass *cc = 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 = "riscv-64bit-cpu.xml"; - break; -#endif - case MXL_RV32: - cc->gdb_core_xml_file = "riscv-32bit-cpu.xml"; - break; - default: - g_assert_not_reached(); - } -} - static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) { CPURISCVState *env = &cpu->env; @@ -676,8 +655,6 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp) return false; } - riscv_cpu_validate_misa_mxl(cpu); - #ifndef CONFIG_USER_ONLY CPURISCVState *env = &cpu->env; Error *local_err = NULL;