From nobody Wed Nov 19 00:15:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) client-ip=209.85.128.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1613326335; cv=none; d=zohomail.com; s=zohoarc; b=Kv/zDZO7dH96cpcA4d56GrRru3EVR71KEVtUfdf/oRGHwHgi1oJN6whN4exSa2lUj2KKYbNDm9F0p9kXf8D2iAfLGDKAUvq//SUfbYvTLXG/sZ+fdOYvTihY7wRN2aPRtqT6jhGf6EvaYWbvROWzJtWQbvyslILSu92d3XOq828= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613326335; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d546qymlao/rzWtR36sSyopsQgU3D8u3O18dLCPSATQ=; b=Ly1+Yy81rMgZgIaiwFLJOQqbQfmFUevYxeEHn2eL3iREOsh+9m4hgDLizfVXI5zmr6LwBl4GGfGUM5IZOiwut++/2IXmJj+olFOD0GcJQHUNkpxr2WrADbcyh27Ua41KlIlNiJgVLHe03xoHi7F+LzyPvzFp7osbEJocBPU4/Zw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.zohomail.com with SMTPS id 1613326335961164.80734161510725; Sun, 14 Feb 2021 10:12:15 -0800 (PST) Received: by mail-wm1-f43.google.com with SMTP id n10so5857823wmq.0 for ; Sun, 14 Feb 2021 10:12:15 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id c3sm7167927wrr.29.2021.02.14.10.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 10:01:34 -0800 (PST) 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=d546qymlao/rzWtR36sSyopsQgU3D8u3O18dLCPSATQ=; b=ZMjnLcRY1+EILKAApUubkZ0uzZnVCg5UfW1UOttGln5PJ5eR2aAQoWXTkcuBIbUeQG /fGFj4raEFC4n4aOP92hwOTIzhIm4cgAZcWb1hwUvd8AMIZoZ82WgTLef/nhIq1TOE+r UEs7dhEnhaNj9CYtTc2FGMgdTYcUu+QwZMKOtuXblLvl/KhYpXcKPANdD41BDdnZqJOv TIdbqzqAvPid0aO2EOsy2U6LnfLcV3t1wwEHXL3/OZdxiuBL7Qq9V2mMwLIIbvo2+nZZ 2exF/t0zNoroX61qmi9sbqD+xU9yL+J3VJFw/yHkGs3NBoCtwdjxhNgR7YsTNMFCb5Jg nGJw== 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=d546qymlao/rzWtR36sSyopsQgU3D8u3O18dLCPSATQ=; b=Yim2t53Wn0Oxg+rxkINABnDcFkkWSgaYDd5HiXzBU8o/32lnhqnVBvyZ+ru2D4QP+/ B2k4/YGbKUwwdoNLwEU1N+t8roRel4RgtDm/VWy/mSXM1xR1EZFKQmQauBWrKTZFPAWo ANL4+pi+B5kLesPvy89LRh4oHyxRnAv/SK1lQrjBFPnUT9+dISNOMStNqPjuDLXaEvWO KfkdSrxQhfdKhEXkfnbqiFtTdqNCx17rAilka3RihLHm/C0U4UWSJZUOqK+KDxWEi0N9 FDzpQybDYyh0s2wgyOQsWuIWtQHKZCHYwLzeH7Yrca1B5/OdJOlQ+JrXs5HFS9dVk3Yk D3Ng== X-Gm-Message-State: AOAM530NjV+/D94u9wnUbPhWGdeyCbRw6Faufn61HafySmYweJMcKf8b dUUG66zfIfgLxmQKrlv6EA3/Dy8Os+U= X-Google-Smtp-Source: ABdhPJzIEuXfnUmiISWhrN/Tu/rLJ0f60OjCGa57Eq49WB5yvf3BShtly44I8uakgAerqc4H+Jjf+A== X-Received: by 2002:a7b:cf33:: with SMTP id m19mr11031041wmg.53.1613325695015; Sun, 14 Feb 2021 10:01:35 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Fredrik Noring , Laurent Vivier , Jiaxun Yang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Maciej W. Rozycki" , Thomas Huth , Aurelien Jarno , Richard Henderson , Aleksandar Rikalo Subject: [RFC PATCH 28/42] target/mips/tx79: Move RDHWR usermode kludge to trans_SQ() Date: Sun, 14 Feb 2021 18:58:58 +0100 Message-Id: <20210214175912.732946-29-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210214175912.732946-1-f4bug@amsat.org> References: <20210214175912.732946-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) Now than SQ is properly implemented, we can move the RDHWR kludge required to have usermode working with recent glibc. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/translate.c | 56 ------------------------------------ target/mips/tx79_translate.c | 34 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 57 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index c1d07a4591d..0fa2b3bcc15 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -1780,7 +1780,6 @@ enum { =20 enum { MMI_OPC_CLASS_MMI =3D 0x1C << 26, /* Same as OPC_SPECIAL2 */ - MMI_OPC_SQ =3D 0x1F << 26, /* Same as OPC_SPECIAL3 */ }; =20 /* @@ -27330,53 +27329,6 @@ static void decode_mmi(CPUMIPSState *env, DisasCon= text *ctx) } } =20 -static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset) -{ - gen_reserved_instruction(ctx); /* TODO: MMI_OPC_SQ */ -} - -/* - * The TX79-specific instruction Store Quadword - * - * +--------+-------+-------+------------------------+ - * | 011111 | base | rt | offset | SQ - * +--------+-------+-------+------------------------+ - * 6 5 5 16 - * - * has the same opcode as the Read Hardware Register instruction - * - * +--------+-------+-------+-------+-------+--------+ - * | 011111 | 00000 | rt | rd | 00000 | 111011 | RDHWR - * +--------+-------+-------+-------+-------+--------+ - * 6 5 5 5 5 6 - * - * that is required, trapped and emulated by the Linux kernel. However, all - * RDHWR encodings yield address error exceptions on the TX79 since the SQ - * offset is odd. Therefore all valid SQ instructions can execute normally. - * In user mode, QEMU must verify the upper and lower 11 bits to distingui= sh - * between SQ and RDHWR, as the Linux kernel does. - */ -static void decode_mmi_sq(CPUMIPSState *env, DisasContext *ctx) -{ - int base =3D extract32(ctx->opcode, 21, 5); - int rt =3D extract32(ctx->opcode, 16, 5); - int offset =3D extract32(ctx->opcode, 0, 16); - -#ifdef CONFIG_USER_ONLY - uint32_t op1 =3D MASK_SPECIAL3(ctx->opcode); - uint32_t op2 =3D extract32(ctx->opcode, 6, 5); - - if (base =3D=3D 0 && op2 =3D=3D 0 && op1 =3D=3D OPC_RDHWR) { - int rd =3D extract32(ctx->opcode, 11, 5); - - gen_rdhwr(ctx, rt, rd, 0); - return; - } -#endif - - gen_mmi_sq(ctx, base, rt, offset); -} - #endif =20 static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx) @@ -27561,15 +27513,7 @@ static bool decode_opc_legacy(CPUMIPSState *env, D= isasContext *ctx) } break; case OPC_SPECIAL3: -#if defined(TARGET_MIPS64) - if (ctx->insn_flags & INSN_R5900) { - decode_mmi_sq(env, ctx); /* MMI_OPC_SQ */ - } else { - decode_opc_special3(env, ctx); - } -#else decode_opc_special3(env, ctx); -#endif break; case OPC_REGIMM: op1 =3D MASK_REGIMM(ctx->opcode); diff --git a/target/mips/tx79_translate.c b/target/mips/tx79_translate.c index 386bae7808b..2aa3182d21d 100644 --- a/target/mips/tx79_translate.c +++ b/target/mips/tx79_translate.c @@ -411,7 +411,7 @@ static bool trans_LQ(DisasContext *ctx, arg_itype *a) return true; } =20 -static bool trans_SQ(DisasContext *ctx, arg_itype *a) +static bool trans_SQ_real(DisasContext *ctx, arg_itype *a) { TCGv_i64 t0 =3D tcg_temp_new_i64(); TCGv addr =3D tcg_temp_new(); @@ -438,6 +438,38 @@ static bool trans_SQ(DisasContext *ctx, arg_itype *a) return true; } =20 +static bool trans_SQ(DisasContext *ctx, arg_itype *a) +{ + /* + * The TX79-specific instruction Store Quadword + * + * +--------+-------+-------+------------------------+ + * | 011111 | base | rt | offset | SQ + * +--------+-------+-------+------------------------+ + * 6 5 5 16 + * + * has the same opcode as the Read Hardware Register instruction + * + * +--------+-------+-------+-------+-------+--------+ + * | 011111 | 00000 | rt | rd | 00000 | 111011 | RDHWR + * +--------+-------+-------+-------+-------+--------+ + * 6 5 5 5 5 6 + * + * that is required, trapped and emulated by the Linux kernel. However= , all + * RDHWR encodings yield address error exceptions on the TX79 since th= e SQ + * offset is odd. Therefore all valid SQ instructions can execute norm= ally. + * In user mode, QEMU must verify the upper and lower 13 bits to disti= nguish + * between SQ and RDHWR, as the Linux kernel does. + */ +#if defined(CONFIG_USER_ONLY) + if (!a->base && extract32(a->offset, 0, 11) =3D=3D 0b00000111011) { + gen_rdhwr(ctx, a->rt, extract32(ctx->opcode, 11, 5), 0); + return true; + } +#endif + return trans_SQ_real(ctx, a); +} + /* * Multiply and Divide (19 instructions) * ------------------------------------- --=20 2.26.2