From patchwork Mon Jan 22 14:55:53 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: 13525581 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62AE34176C for ; Mon, 22 Jan 2024 14:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935378; cv=none; b=mJrqR1xtVJ/XvcgJb3rFoiZJAxdcU+6tiVdb5r2uqOGN3p3V7W3uKjpFpOtd6S3dKC8WAZ7Zje7d2hPxhyEdKeVTs9/xy/zua97MRnlxVDA/t8CB32lC5bKWja4nTGyTV0vBrh8JU6Ey/prSGDW0Mj/bjPvEPg1bJD8RSTcIuxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935378; c=relaxed/simple; bh=UE2RXJlgo5iDyR2v3ndi2mz0jJ23Nbhao7KZ3eROpuw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=X5nmnFouabWuj+OHAOIwslzaWz3Ou8cNyZNqX/c0vUyWBe5cNz5/ZleAZrOrgw+KnOjyUp01lCWFsF4fM30KqYwse3vAFQDpo4I5puVOnKje4hKAnw6RPp5hafEs1LzOBH48vGytL2mMVq00Rkqpj5wUAwhSJaDTqZHGr09WyCw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=BIiSjM9K; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BIiSjM9K" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40e775695c6so32564945e9.3 for ; Mon, 22 Jan 2024 06:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705935374; x=1706540174; darn=vger.kernel.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=sMNaDAt2JCjIWxO3MmU6Jb8mcwK8LOwQChx2t1zdH94=; b=BIiSjM9KASNpamsxn9GQ9Pi2AK71Bletc5yQZtVAN4FDCwHaLEviGH0VUDQ3xg6wnK 0zxWjPuFYXMdc5NDX9QyoB52d6m0Xxw6PzhDDpURbvMcd67Hf3fnytzm/QPDp8R4IKFN VJBl4v9ofLpq9CvrrDD9J00V4mzLHJuyB8OVkhSElxv2Itn5RgqkCrjE1SC+AnkQvp1r YABpBkaJHONjc1B3u//5R0pkPfU2uWuT29XFE8aVfJ4WG7LZ5TbbUUC5e9RXhiCFfE7b Ly5nVLnHRxNMWMFOzu7iFyAdaSWIJ1aXh0R2GE9nMl/dWcRgI/8FYmjP5jptqhA/srak RDFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705935374; x=1706540174; 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=sMNaDAt2JCjIWxO3MmU6Jb8mcwK8LOwQChx2t1zdH94=; b=rCyTdtVKdoFeX735Elu87LXr1unvF0U5dwCmKUHYtoJQNWkvgv0IChIodVrw77iumg Sr0yn/Paue2fDP9IlnNgQFeJytM5Mn7kagU4mofUgaM95Cpu5ZkBP0gOdAh9WyARsrwX sY6tVL0+VmZWQmyMvQ8DuXfuf0SeoH88bpCKZcoEDHEohW+DQjb1V0wIOm05TM8Ampl8 r4pSCHBDQZttZgZGvo3aE8Gp0X9u2y1cOIF2FE524vYIbkUzUcwK8Tx0M1ORnmG2sppd ka0Jw/rCq8SZ7YXCCmHbETnNRRLph6pPzDmG0RVD1yhg5ummSoDSm1zj6AQuoKpHbVoH qgnA== X-Gm-Message-State: AOJu0YytXf8ryZ7k9NsTwuHUdjkCSl/ffb/LKTd4GEVQHMFYMlpFDrT8 3jOETxptXrEnE3hq+excsTXirxq4vVLVPaybFUzmNNO7+uCjr54kqoDmP7Sci44= X-Google-Smtp-Source: AGHT+IEfILSkibBL9fJPeuMVflOuYCV1qum61VKv3PfXp+sAySvICn0TrA7ViU92Dl3TYqFVYpEhwg== X-Received: by 2002:a05:600c:3b96:b0:40e:70c0:5054 with SMTP id n22-20020a05600c3b9600b0040e70c05054mr3229863wms.2.1705935374582; Mon, 22 Jan 2024 06:56:14 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f6-20020a05600c154600b0040e880ac6ecsm19550208wmg.35.2024.01.22.06.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 06:56:11 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 339205F8FC; Mon, 22 Jan 2024 14:56:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Michael Rolnik , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , kvm@vger.kernel.org, Yoshinori Sato , Pierrick Bouvier , Palmer Dabbelt , Liu Zhiwei , Laurent Vivier , Yanan Wang , qemu-ppc@nongnu.org, Weiwei Li , qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Peter Maydell , Alexandre Iooss , John Snow , Mahmoud Mandour , Wainer dos Santos Moschetta , Richard Henderson , Ilya Leoshkevich , Alistair Francis , David Woodhouse , Cleber Rosa , Beraldo Leal , Bin Meng , Nicholas Piggin , Aurelien Jarno , Daniel Henrique Barboza , Daniel Henrique Barboza , Thomas Huth , David Hildenbrand , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Paolo Bonzini , Song Gao , Eduardo Habkost , Brian Cain , Paul Durrant , Akihiko Odaki Subject: [PATCH v3 04/21] target/riscv: Validate misa_mxl_max only once Date: Mon, 22 Jan 2024 14:55:53 +0000 Message-Id: <20240122145610.413836-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122145610.413836-1-alex.bennee@linaro.org> References: <20240122145610.413836-1-alex.bennee@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: <20240103173349.398526-26-alex.bennee@linaro.org> 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 dcc09a10875..7ee4f8520f9 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1292,6 +1292,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; @@ -1833,6 +1853,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 30f0a22a481..1cd659d992e 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -268,27 +268,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; @@ -935,8 +914,6 @@ static bool riscv_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;