From nobody Tue Feb 10 07:43:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) client-ip=209.85.128.50; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f50.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1618860023; cv=none; d=zohomail.com; s=zohoarc; b=TcQeDSbyqsSj8mAI0XfHwEo2KcJrtwD2QTzai92/nArKLzlkDs7zAnvOVaIKDBLeitIjpY8/3Q0bbV0B9JKnPAHk5GalqsE6cwbrS/O+ONlUDsfrh4y5U0JTcbAelViZNJkSexfRXZrvnG8glX8A9CcRauHr/2iwk6d5CjJigFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618860023; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3GmUY9SDQTId+vurOXkEi+R4oq195U5WUEXrZHtw3SI=; b=bxfAL9QtwoqJYsC73kppJFcKcip7IdsG+L/j52WQDfY/rEzFT0M2KYOE7LLUppJJe83riX1oRt/MtpJiOedAFeOrHnFJMm/PLh7RG7CRp6QZCg20crzv5RV7QcZVScedSjq8CqtKfsQI7s69GKWrunOI1HtHonIaURAypk+LiXY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.zohomail.com with SMTPS id 1618860023831840.7820872774884; Mon, 19 Apr 2021 12:20:23 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id k128so18820721wmk.4 for ; Mon, 19 Apr 2021 12:20:23 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id n2sm576962wmb.32.2021.04.19.12.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 12:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3GmUY9SDQTId+vurOXkEi+R4oq195U5WUEXrZHtw3SI=; b=X4tfoBv7tBb5Qf0R7bkPWA26R6oo/e1rjXD7Xil9C7UGGl2D/slWuphIsOa7Ofxzcf BYAZzxCpWM5auKPNuvVQcyh92nwoY+9t9MUKmaGFn1mSm/XgGaBQ3dQ3/0oaK0LBtBhY f4ev6hHJ7Pb5GZhqBlkxeagOw1DtA0Yd2HEZbknriFJ2WcWJKxIi/BzmayUZnhNYPE9O mANc6JPAiei+m0Q9gSG/vhks8Z/BuCzE0m3roOj71wQE9Bf2nG90hWwzCwWzigVH9Fii eywuTPp37YIwQkdlMTmlQmLpfeMumEQI++Gt2M495EnmosZMrSdc4GS6QdBBlT4BK61F UlRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3GmUY9SDQTId+vurOXkEi+R4oq195U5WUEXrZHtw3SI=; b=tPxtsLs+d1lHMytVtk3OSReXoD1rlFJlSgzxhIVBHjCDyV0bCws/CcYyzD/ooJ7VxH 5g+Nthe1Ot28/p/k0PeT0KoBZ0xUn2bDKlzCHG1u8bzhu3JQrRzupQNihKW2/W0tRoxz RSL54CC3JQXI2bROKisubv862CmcziuuLa/hQYS8WES2y81lyFjWxRqGHmOKm/K28hbo hga5nFXMhHbGNQMQrmhrElLz4I7beoE+gfCp5rEL8Row3EIIXhcEXNxV/aHkr55YSoQP lnmMlgD0vepujHLFNjWHe/iidl7cy1cGkKyrGFN6sLWVk5b/hicjyshF2kYlHLYVT3Nz 5siw== X-Gm-Message-State: AOAM531TYGlaZwj/pKTgNDdJDX7YQ+KMZxeKwigCdRxiSJ+4ZoXvFdqA A53zOStLwitOWVgqDBII5jI= X-Google-Smtp-Source: ABdhPJy4e9wEv3y24dXmX9Uq0hlcu8QOTBRWF1j3uCnN2j72Cb4F+M2GPANZglnWUPk9XCpAgx/ZCA== X-Received: by 2002:a1c:1b41:: with SMTP id b62mr580604wmb.170.1618860021999; Mon, 19 Apr 2021 12:20:21 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aleksandar Rikalo , Aurelien Jarno , Huacai Chen Subject: [PATCH v3 24/30] target/mips: Move helper_cache() to tcg/sysemu/special_helper.c Date: Mon, 19 Apr 2021 21:18:17 +0200 Message-Id: <20210419191823.1555482-25-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210419191823.1555482-1-f4bug@amsat.org> References: <20210419191823.1555482-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Move helper_cache() to tcg/sysemu/special_helper.c. The CACHE opcode is privileged and is not accessible in user emulation. However we get a link failure when restricting the symbol to sysemu. For now, add a stub helper to satisfy linking, which abort if ever called. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: Use STUB_HELPER() :) (rth) --- target/mips/helper.h | 2 -- target/mips/tcg/sysemu_helper.h.inc | 1 + target/mips/op_helper.c | 35 ------------------------- target/mips/tcg/sysemu/special_helper.c | 33 +++++++++++++++++++++++ target/mips/translate.c | 13 +++++++++ 5 files changed, 47 insertions(+), 37 deletions(-) diff --git a/target/mips/helper.h b/target/mips/helper.h index 4ee7916d8b2..d49620f9282 100644 --- a/target/mips/helper.h +++ b/target/mips/helper.h @@ -614,8 +614,6 @@ DEF_HELPER_FLAGS_3(dmthlip, 0, void, tl, tl, env) DEF_HELPER_FLAGS_3(wrdsp, 0, void, tl, tl, env) DEF_HELPER_FLAGS_2(rddsp, 0, tl, tl, env) =20 -DEF_HELPER_3(cache, void, env, tl, i32) - #ifndef CONFIG_USER_ONLY #include "tcg/sysemu_helper.h.inc" #endif /* !CONFIG_USER_ONLY */ diff --git a/target/mips/tcg/sysemu_helper.h.inc b/target/mips/tcg/sysemu_h= elper.h.inc index 38e55cbf118..1ccbf687237 100644 --- a/target/mips/tcg/sysemu_helper.h.inc +++ b/target/mips/tcg/sysemu_helper.h.inc @@ -173,3 +173,4 @@ DEF_HELPER_1(ei, tl, env) DEF_HELPER_1(eret, void, env) DEF_HELPER_1(eretnc, void, env) DEF_HELPER_1(deret, void, env) +DEF_HELPER_3(cache, void, env, tl, i32) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index a077535194b..a7fe1de8c42 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -788,38 +788,3 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwad= dr physaddr, } } #endif /* !CONFIG_USER_ONLY */ - -void helper_cache(CPUMIPSState *env, target_ulong addr, uint32_t op) -{ -#ifndef CONFIG_USER_ONLY - static const char *const type_name[] =3D { - "Primary Instruction", - "Primary Data or Unified Primary", - "Tertiary", - "Secondary" - }; - uint32_t cache_type =3D extract32(op, 0, 2); - uint32_t cache_operation =3D extract32(op, 2, 3); - target_ulong index =3D addr & 0x1fffffff; - - switch (cache_operation) { - case 0b010: /* Index Store Tag */ - memory_region_dispatch_write(env->itc_tag, index, env->CP0_TagLo, - MO_64, MEMTXATTRS_UNSPECIFIED); - break; - case 0b001: /* Index Load Tag */ - memory_region_dispatch_read(env->itc_tag, index, &env->CP0_TagLo, - MO_64, MEMTXATTRS_UNSPECIFIED); - break; - case 0b000: /* Index Invalidate */ - case 0b100: /* Hit Invalidate */ - case 0b110: /* Hit Writeback */ - /* no-op */ - break; - default: - qemu_log_mask(LOG_UNIMP, "cache operation:%u (type: %s cache)\n", - cache_operation, type_name[cache_type]); - break; - } -#endif -} diff --git a/target/mips/tcg/sysemu/special_helper.c b/target/mips/tcg/syse= mu/special_helper.c index 927a640d076..ffd5d0086b6 100644 --- a/target/mips/tcg/sysemu/special_helper.c +++ b/target/mips/tcg/sysemu/special_helper.c @@ -138,3 +138,36 @@ void helper_deret(CPUMIPSState *env) =20 debug_post_eret(env); } + +void helper_cache(CPUMIPSState *env, target_ulong addr, uint32_t op) +{ + static const char *const type_name[] =3D { + "Primary Instruction", + "Primary Data or Unified Primary", + "Tertiary", + "Secondary" + }; + uint32_t cache_type =3D extract32(op, 0, 2); + uint32_t cache_operation =3D extract32(op, 2, 3); + target_ulong index =3D addr & 0x1fffffff; + + switch (cache_operation) { + case 0b010: /* Index Store Tag */ + memory_region_dispatch_write(env->itc_tag, index, env->CP0_TagLo, + MO_64, MEMTXATTRS_UNSPECIFIED); + break; + case 0b001: /* Index Load Tag */ + memory_region_dispatch_read(env->itc_tag, index, &env->CP0_TagLo, + MO_64, MEMTXATTRS_UNSPECIFIED); + break; + case 0b000: /* Index Invalidate */ + case 0b100: /* Hit Invalidate */ + case 0b110: /* Hit Writeback */ + /* no-op */ + break; + default: + qemu_log_mask(LOG_UNIMP, "cache operation:%u (type: %s cache)\n", + cache_operation, type_name[cache_type]); + break; + } +} diff --git a/target/mips/translate.c b/target/mips/translate.c index 8702f9220be..c2e60178d05 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -39,6 +39,19 @@ #include "fpu_helper.h" #include "translate.h" =20 +/* + * Many sysemu-only helpers are not reachable for user-only. + * Define stub generators here, so that we need not either sprinkle + * ifdefs through the translator, nor provide the helper function. + */ +#define STUB_HELPER(NAME, ...) \ + static inline void gen_helper_##NAME(__VA_ARGS__) \ + { qemu_build_not_reached(); } + +#ifdef CONFIG_USER_ONLY +STUB_HELPER(cache, TCGv_env env, TCGv val, TCGv_i32 reg) +#endif + enum { /* indirect opcode tables */ OPC_SPECIAL =3D (0x00 << 26), --=20 2.26.3