From nobody Sat May 18 12:47:45 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=fungible.com ARC-Seal: i=1; a=rsa-sha256; t=1676474416; cv=none; d=zohomail.com; s=zohoarc; b=TA+b0aWkLJfw5rxo18NN8fqakdBBeRxAszK9rW8oyCbCVlTH6EKCtiuzS/4zFjvm2AaT0BRTNYYwpB9tA4X02FuR3jLaFibvi1V/tl4x1tSVk7dbb6Q5myLM3gz1ZskVB0TPVDnN78wDcj7seHCyPGUAbBwKCMnrWfYAQ9eMbCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676474416; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=peZWXJ9TIqhJZN5pvOyZFjZ+4SZzBi3MO1y+d3SOb5A=; b=W2Cz2GLLCz5QAaFhoI6huohNeIon6XQikxKwq+o0AhdXmLfAiJIegUWKYQ+N6oP153d3Z2uN6DtIvKKtOXtMEmpkTS6HrxruXZQ6EhbhU7GG2QFE7dbSlVjqSklGWS4q6TMa3w2Y9PKkok7influE/xxLfL/PAqK3iW45mR1yVs= 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 1676474416822932.5449838240769; Wed, 15 Feb 2023 07:20:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSJYK-0002TF-Et; Wed, 15 Feb 2023 10:18: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 1pSDSV-0006xd-QK for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:12 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSDSU-00071a-8E for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:11 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-15ff0a1f735so22150413fac.5 for ; Wed, 15 Feb 2023 00:48:09 -0800 (PST) Received: from WR-NOWAKOWSKI.fungible.local (77-255-255-121.adsl.inetia.pl. [77.255.255.121]) by smtp.gmail.com with ESMTPSA id a9-20020a056870d60900b0013bc40b09dasm6788811oaq.17.2023.02.15.00.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 00:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fungible.com; s=google; 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=peZWXJ9TIqhJZN5pvOyZFjZ+4SZzBi3MO1y+d3SOb5A=; b=Otvt20unFuGO+xtKAl695C1dnrGKC3qktJGHBQswuAMTSRVMB+avbd/5E8fecEaKdL ZSfFYpw6oUtzdvvdTKZzXJHdqFhXp/BxaKrvb+ZdwdSXqZm+a0FOT/shRmg3ZOsYuJSi KUysxbCBW+SUZP1eX9VSrJPGxy0HLuxwDNszE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=peZWXJ9TIqhJZN5pvOyZFjZ+4SZzBi3MO1y+d3SOb5A=; b=ox+9PCGXDsGbe7lIbNm+M9VFTtUsPKeCOT0K5jbE4EMKbJ1MgB5upa/GdfKmSbgDCp TIid3mnyqjxue/l1Le7OPsVkXSIJmtK7yzZqBmJ2S1PnKiQAvGsuV0WSVoR6Ppf2vE++ 8Mu++jidPSiI+uZNc1WMb0kK1uKnGK6OBe0XGJKBRXdFveiVOHIb4hWhqR/TfHP39V2H 5XadX4rPIty1k9fVDa0Bgsaqgq5RxB5vhLh/INF1v9fwdyobyMTsy+W44Jk8YU9jDWBL rsJAAJ7wbTTP6PsfP3SaKmuYeWpc2nXE9FwZIyK1i4GJzljmHIVr/BLcyIlL4YPhXJFb zDDw== X-Gm-Message-State: AO0yUKXqajM7YlNHiBiaPnstAVd8rAKRjC0A/5EDEYftzo/A4HDekq8V FsfaWiUJ0+oI9FY7/UWjxeOPmuRD2lQilVlp X-Google-Smtp-Source: AK7set/bbz/rYXvAJXZ+Iyw3JYddYn86EVArSf/rOhyzaspLFTY534QldtShWP/qboNUD58JmBn1Pg== X-Received: by 2002:a05:6871:6a9:b0:16e:116e:1c36 with SMTP id l41-20020a05687106a900b0016e116e1c36mr703102oao.3.1676450888661; Wed, 15 Feb 2023 00:48:08 -0800 (PST) From: Marcin Nowakowski To: qemu-devel@nongnu.org Cc: marcin.nowakowski@fungible.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH 1/3] target/mips: fix JALS32/J32 instruction handling for microMIPS Date: Wed, 15 Feb 2023 09:47:52 +0100 Message-Id: <20230215084754.3816747-2-marcin.nowakowski@fungible.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230215084754.3816747-1-marcin.nowakowski@fungible.com> References: <20230215084754.3816747-1-marcin.nowakowski@fungible.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=2001:4860:4864:20::2d; envelope-from=marcin.nowakowski@fungible.com; helo=mail-oa1-x2d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 15 Feb 2023 10:18:35 -0500 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 @fungible.com) X-ZM-MESSAGEID: 1676474417537100001 Content-Type: text/plain; charset="utf-8" microMIPS J & JAL instructions perform a jump in a 128MB region and 5 top bits of the address need to be preserved. This is different behavior compared to standard mips systems, where the jump is executed within a 256MB region. Note that microMIPS32 instruction set documentation appears to have inconsistent information regarding JALX32 instruction - it is written in the doc that: "To execute a procedure call within the current 256 MB-aligned region (...) The low 26 bits of the target address is the target field shifted left 2 bits." But the target address is already 26 bits. Moreover, the operation description indicates that 28 bits are copied, so the statement about use of 26 bits is _most likely_ incorrect and the corresponding code remains the same as for standard mips instruction set. Signed-off-by: Marcin Nowakowski Reviewed-by: Richard Henderson --- target/mips/tcg/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 624e6b7786..5d46f24141 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -4860,6 +4860,7 @@ static void gen_compute_branch(DisasContext *ctx, uin= t32_t opc, target_ulong btgt =3D -1; int blink =3D 0; int bcond_compute =3D 0; + int jal_mask =3D 0; TCGv t0 =3D tcg_temp_new(); TCGv t1 =3D tcg_temp_new(); =20 @@ -4917,6 +4918,11 @@ static void gen_compute_branch(DisasContext *ctx, ui= nt32_t opc, break; case OPC_J: case OPC_JAL: + /* Jump to immediate */ + jal_mask =3D ctx->hflags & MIPS_HFLAG_M16 ? 0xF8000000 : 0xF000000= 0; + btgt =3D ((ctx->base.pc_next + insn_bytes) & jal_mask) | + (uint32_t)offset; + break; case OPC_JALX: /* Jump to immediate */ btgt =3D ((ctx->base.pc_next + insn_bytes) & (int32_t)0xF0000000) | --=20 2.25.1 From nobody Sat May 18 12:47:45 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=fungible.com ARC-Seal: i=1; a=rsa-sha256; t=1676474409; cv=none; d=zohomail.com; s=zohoarc; b=MfUuVQlU1vqCdjw6vjiYlSTwNUWDQs9m4HivKoowedS+N8l1HkEA9Y6mz4p0E72apICbjc+VXruosLp0PSTzUyhmJZs3Jno36JqDHpY1NSGWbnnarfLy6dQDBVwBmBGJsETDH9WmD183RuPYrzCjF+Fmm6XLMzE1gbCiNg2V+es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676474409; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sIH7K1DDuKRwsNfFS8vI4Hl70V/+l27EFqfoP6TzJWo=; b=ZeJbgazZT26OmoP+ETiEV62XCLDwWHt/6gJBXuJmP8PE1WWaAIBzJNdB5MfmgPj+jAtYTkWpeKg/ri0w2S0PUS9vUroVBnmjx4zXqYnL2qoTTtrVMdIOurcOJrrAksn762XTvp6Xie23CFjP7LI3HSc60jrhBCfdKhxdfePooeQ= 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 1676474409513434.6707589933203; Wed, 15 Feb 2023 07:20:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSJYK-0002SM-Ap; Wed, 15 Feb 2023 10:18: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 1pSDSX-0006xl-Pk for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:14 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSDSW-00071l-8E for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:13 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-16e353ce458so4576287fac.9 for ; Wed, 15 Feb 2023 00:48:11 -0800 (PST) Received: from WR-NOWAKOWSKI.fungible.local (77-255-255-121.adsl.inetia.pl. [77.255.255.121]) by smtp.gmail.com with ESMTPSA id a9-20020a056870d60900b0013bc40b09dasm6788811oaq.17.2023.02.15.00.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 00:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fungible.com; s=google; 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=sIH7K1DDuKRwsNfFS8vI4Hl70V/+l27EFqfoP6TzJWo=; b=ZLH8CSJW7e/iH8C/aRz4+H/i08F/baspPZZElIF3+10T7aiHhSuWzxubx+vGkmX9cF t6Ersoj99a+2id+m2Ljo1PalvhDNHIiMQoEa4vaH1P7BBbjvG0ala8CaxVyv1BT2C2EN egkZ2boPDalPN/4uPvmwxb6bMZqgpsKZE0/l8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sIH7K1DDuKRwsNfFS8vI4Hl70V/+l27EFqfoP6TzJWo=; b=bI0qXAY5OvC1Z+HtZ09tn/UtXvn+eOcW26kczf/fnny7h9ZOtO/v0wYtiHom3PtF1h iUKhAG1aNSoRJnM38pYxkIfLITSKIs4Mriym8YOmPq95Vh2jm8Q7iy9waAo044I4bgNB 2HnjK/6HescSbDoRZxDWK1oJL5gyeQk3G0OCHJiKTIdau4nDFFuBPaMdKMAjZLKVnQuD 68Bkn7tjkhXShUf970jSwBP9qRdOA/jxFmrlPZw/38M2MRSwbI8G1LCE+0TrKciaEBWk r9Rj6loi/53Os9GdYzbI8OvEFXXoUmcZ30QFzeHj+IH4pQfmoEYT6QPfjsNRy0n+j8RU /GYw== X-Gm-Message-State: AO0yUKWzdSDkNXQqCB7N2ax/E3oW16JwDkyur5gRp8yLn4XX2/jdcTIt bCmnbf3RUUoWZg5NKi2FW3dj3RdU3KQk3oiB X-Google-Smtp-Source: AK7set8gDJleoiAOwe10u465wD6EUyTdxGJK/hhWZ7HR7Fd+fqHE+FZ9ZkhWjl1i4ABFe7uT6qA5wg== X-Received: by 2002:a05:6871:204:b0:16a:a8af:1cd0 with SMTP id t4-20020a056871020400b0016aa8af1cd0mr760817oad.5.1676450890692; Wed, 15 Feb 2023 00:48:10 -0800 (PST) From: Marcin Nowakowski To: qemu-devel@nongnu.org Cc: marcin.nowakowski@fungible.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH 2/3] target/mips: fix SWM32 handling for micromips Date: Wed, 15 Feb 2023 09:47:53 +0100 Message-Id: <20230215084754.3816747-3-marcin.nowakowski@fungible.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230215084754.3816747-1-marcin.nowakowski@fungible.com> References: <20230215084754.3816747-1-marcin.nowakowski@fungible.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=2001:4860:4864:20::33; envelope-from=marcin.nowakowski@fungible.com; helo=mail-oa1-x33.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 15 Feb 2023 10:18:35 -0500 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 @fungible.com) X-ZM-MESSAGEID: 1676474411466100001 Content-Type: text/plain; charset="utf-8" SWM32 should store a sequence of 32-bit words from the GPRs, but it was incorrectly coded to store 16-bit words only. As a result, an LWM32 that usually follows would restore invalid register values. Signed-off-by: Marcin Nowakowski Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/tcg/ldst_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/mips/tcg/ldst_helper.c b/target/mips/tcg/ldst_helper.c index d0bd0267b2..c1a8380e34 100644 --- a/target/mips/tcg/ldst_helper.c +++ b/target/mips/tcg/ldst_helper.c @@ -248,14 +248,14 @@ void helper_swm(CPUMIPSState *env, target_ulong addr,= target_ulong reglist, target_ulong i; =20 for (i =3D 0; i < base_reglist; i++) { - cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[= i]], + cpu_stl_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[= i]], mem_idx, GETPC()); addr +=3D 4; } } =20 if (do_r31) { - cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETP= C()); + cpu_stl_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETP= C()); } } =20 --=20 2.25.1 From nobody Sat May 18 12:47:45 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=fungible.com ARC-Seal: i=1; a=rsa-sha256; t=1676474384; cv=none; d=zohomail.com; s=zohoarc; b=THYIli8IsgfUfm9I4ge+G5KQ7jITarkGmYMDdwasS8pObdKw/G+2qAvdS14PRS+sx068q82D2I0lp0ldAXIySrVjPoT56cDy9xmsTypPphansKvEK6Bkva7zfpZsgfd7nNzrFFIrYS7fvtFwApNbGel9CbR06SclUef4Siw6894= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676474384; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ooA3RfAvBE8YoFTL0liD39KM6/U3xfuZBPasSLp8UkA=; b=Aq1b+JcTtM2xu0mU8SZif9sl6zcmSlmdIQQfoYWJ4cLC+zj5p0OlbwU/wBzkYXMM/5XOxHvaWdkB7igpI8sUYcsWdlTqMwhqkPRxlsmxzZyTsxtTBDZ1K4ddiy4BiH5x/pyloqxvQrvOkmnMsvS3TLiLgVCfW5ac7IFix8L3yQ4= 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 1676474384029447.22955062383517; Wed, 15 Feb 2023 07:19:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSJYQ-0002ch-Uy; Wed, 15 Feb 2023 10:18:42 -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 1pSDSZ-0006xu-JU for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:15 -0500 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSDSY-00071x-1Z for qemu-devel@nongnu.org; Wed, 15 Feb 2023 03:48:15 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-16cc1e43244so17860991fac.12 for ; Wed, 15 Feb 2023 00:48:13 -0800 (PST) Received: from WR-NOWAKOWSKI.fungible.local (77-255-255-121.adsl.inetia.pl. [77.255.255.121]) by smtp.gmail.com with ESMTPSA id a9-20020a056870d60900b0013bc40b09dasm6788811oaq.17.2023.02.15.00.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 00:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fungible.com; s=google; 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=ooA3RfAvBE8YoFTL0liD39KM6/U3xfuZBPasSLp8UkA=; b=PvWMIo4D7VwfiDcJDl+LOYxsq8frwxMbUVoCfCJ4IVtdCIyS9Rh8XHc+g4HFxKtYxD KuCiUdscKgguHP/UhaXMyMcTw5cY1jKQ8GCC17sGs3joYnKK0QACUuIj03ZQrJphTiXU wNFSG9x0JwuyIA+qJPgE/rDekDBfvfla2L0zA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ooA3RfAvBE8YoFTL0liD39KM6/U3xfuZBPasSLp8UkA=; b=VFgQPHxx0LV6MbNU6i1gTS/kyJrEEljXT/K8eiDUhv+q4dtOcAF5bl/oF9X/aTB48e ERp4UdBUGhAaOR6TkpN+sxFu7zDJUlkFgiURT4Eb+t4+Lk989RJjNmL7IRyHqKU5EzsZ jJPxN6u+J0dSq9nUaUlqWj4XGRr+Ao0bvPY9FFYzRu2NDcqZO2jNlZhWFbccl59QGALm OT5IFKicRQdDsQWt+HdOf0+qqSSIPcIVxkwm8nuzxRCQhwaaTOYeSdC0ZdmhJpDOLXIY QocdtarG8reh3a6z3i+j6KRcbPEQDs22C/x+tk1Y3gkuf38i2vfQARCSxz7GhKnDxN9E 7KcA== X-Gm-Message-State: AO0yUKWJQM7JPsy9e/lXd9E5MdIf9nLsxOEQpG8vffP2eIQ5cGnQnNG8 eaQM+HOBS+tt0kkR7BqTt+d3XZusDgKngcNg X-Google-Smtp-Source: AK7set+OOrrXoIBH3SsD/bRwtlzJ/NxA+JWDWJc1t3VhHxPZhJx3ghl7KiCMNSlT1BQWq+AGlNGrjQ== X-Received: by 2002:a05:6870:a11d:b0:16d:c064:1a9 with SMTP id m29-20020a056870a11d00b0016dc06401a9mr703905oae.10.1676450892576; Wed, 15 Feb 2023 00:48:12 -0800 (PST) From: Marcin Nowakowski To: qemu-devel@nongnu.org Cc: marcin.nowakowski@fungible.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH 3/3] target/mips: implement CP0.Config7.WII bit support Date: Wed, 15 Feb 2023 09:47:54 +0100 Message-Id: <20230215084754.3816747-4-marcin.nowakowski@fungible.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230215084754.3816747-1-marcin.nowakowski@fungible.com> References: <20230215084754.3816747-1-marcin.nowakowski@fungible.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=2001:4860:4864:20::2e; envelope-from=marcin.nowakowski@fungible.com; helo=mail-oa1-x2e.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 15 Feb 2023 10:18:35 -0500 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 @fungible.com) X-ZM-MESSAGEID: 1676474385835100002 Content-Type: text/plain; charset="utf-8" Some older cores use CP0.Config7.WII bit to indicate that a disabled interrupt should wake up a sleeping CPU. Enable this bit by default for M14Kc, which supports that. There are potentially other cores that support this feature, but I do not have a complete list. Signed-off-by: Marcin Nowakowski --- target/mips/cpu-defs.c.inc | 1 + target/mips/cpu.c | 6 ++++-- target/mips/cpu.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc index 480e60aeec..57856e2e72 100644 --- a/target/mips/cpu-defs.c.inc +++ b/target/mips/cpu-defs.c.inc @@ -354,6 +354,7 @@ const mips_def_t mips_defs[] =3D (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), .CP0_Config2 =3D MIPS_CONFIG2, .CP0_Config3 =3D MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_V= Int), + .CP0_Config7 =3D 0x1 << CP0C7_WII, .CP0_LLAddr_rw_bitmask =3D 0, .CP0_LLAddr_shift =3D 4, .SYNCI_Step =3D 32, diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 7a565466cb..7ba359696f 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -144,12 +144,14 @@ static bool mips_cpu_has_work(CPUState *cs) /* * Prior to MIPS Release 6 it is implementation dependent if non-enabl= ed * interrupts wake-up the CPU, however most of the implementations only - * check for interrupts that can be taken. + * check for interrupts that can be taken. For pre-release 6 CPUs, + * check for CP0 Config7 'Wait IE ignore' bit. */ if ((cs->interrupt_request & CPU_INTERRUPT_HARD) && cpu_mips_hw_interrupts_pending(env)) { if (cpu_mips_hw_interrupts_enabled(env) || - (env->insn_flags & ISA_MIPS_R6)) { + (env->insn_flags & ISA_MIPS_R6) || + (env->CP0_Config7 & (1 << CP0C7_WII))) { has_work =3D true; } } diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 0a085643a3..abee7a99d7 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -980,6 +980,7 @@ typedef struct CPUArchState { #define CP0C6_DATAPREF 0 int32_t CP0_Config7; int64_t CP0_Config7_rw_bitmask; +#define CP0C7_WII 31 #define CP0C7_NAPCGEN 2 #define CP0C7_UNIMUEN 1 #define CP0C7_VFPUCGEN 0 --=20 2.25.1