From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 778283858C5E for ; Thu, 10 Nov 2022 17:23:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 778283858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62a.google.com with SMTP id f27so6797112eje.1 for ; Thu, 10 Nov 2022 09:23:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0MniA7WYX9BUdFPGD+pIEfpQdqIoumJ3phKBf2ZFO4U=; b=MJwAFwpoo9OYCXu76FGkHmTddAdkp30DvUPNjh1YWPDhhDOktjLGb5RZgZXT5Hd86H 11oSu3ad5PRuFclPge+Z3sqIBA72JRvXb4wTFN15HN8EFLhOih7jtsLxvbBD8MPj8s5Z fOx0FBM8Wi6OQaLM9HupzWPFdQjL1GAYKQ55TAkTA7klZ+jFTzTmDBB8POiCvrzK9sic VddgOOA6Bd4CmgZVE2SR5SHZLP2M9+L3EWfVKzj17JU2U6dzPX6n8QIzbJf+7gV8kr5Y KdQmKiVk6SV14JacC5yrog0AHHQP62wOEj2Xl1vMUvVK1O5SJ5mpsE/o0iGAFW9OkczB yI+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0MniA7WYX9BUdFPGD+pIEfpQdqIoumJ3phKBf2ZFO4U=; b=yfPGbKpxAu4D16ByzaTqhIM4fnPHTLNHDs/nRK4LrIVYGFTzAABKXIeMlJPDeDbR6A Z47ObgwOdrPUntf5GFr4wBSdafv3fpAzx9Z3n5F+fNaV3wjAAL1MViiRm5uEvPGCU6+8 RX8zhxiQnGEHCD7rgH5YysnBgGXUR54PLJRLK2+gpXPuiJy/2uLGlvOotkKSkKxiWdaE btiQlmondKaHWm5P0yQyA/2lyZ56QDuIQ9JUjc+Zr3MJmAEAiYxgOCVTFMcMpp8ux85N KkD6aUCwujv6162zjxIAwUHRrMGun4jdUMWxXKVAb23uvw9rTX4HFmvHZ2tC0kJT2+2t FQ3g== X-Gm-Message-State: ACrzQf3u6+SSqhN8FVniw221KyO8Oh1yEAD96ZT7kimukLJwACcHXZoQ YI5gZcmSv174P9iOQf1m7L2Mg9ijggHo+/OfDjanKj66 X-Google-Smtp-Source: AMsMyM5tFyq4TE8vqc3UMlcjcoSsrTcO1WVYgcRZBLjA+zyJjCv53k5V/ZGhpbFg/SftZMTTdr0PNZNL01oh08qPsxw= X-Received: by 2002:a17:907:a581:b0:78d:a632:59d2 with SMTP id vs1-20020a170907a58100b0078da63259d2mr3234390ejc.459.1668100994062; Thu, 10 Nov 2022 09:23:14 -0800 (PST) MIME-Version: 1.0 References: <20221104205547.3728827-1-hjl.tools@gmail.com> <781ed098-079c-212e-7e46-a375c27f5486@suse.com> <73b15165-8615-282a-560f-30049b1963a1@suse.com> <6c7794ee-49fa-68d0-e659-435512da64fe@suse.com> <5e2a1d31-546f-23bd-bd2d-2de39af81ce8@suse.com> <3475fab2-3f5c-b761-2aa8-ffec7536d734@suse.com> In-Reply-To: <3475fab2-3f5c-b761-2aa8-ffec7536d734@suse.com> From: "H.J. Lu" Date: Thu, 10 Nov 2022 09:22:35 -0800 Message-ID: Subject: Re: [PATCH] i386: Check invalid (%dx) usage To: Jan Beulich Cc: binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3017.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Nov 9, 2022 at 11:21 PM Jan Beulich wrote: > > On 09.11.2022 21:24, H.J. Lu wrote: > > On Tue, Nov 8, 2022 at 11:21 PM Jan Beulich wrote: > >> > >> On 08.11.2022 22:06, H.J. Lu wrote: > >>> On Mon, Nov 7, 2022 at 11:34 PM Jan Beulich wrote: > >>>> On 07.11.2022 20:58, H.J. Lu wrote: > >>>>> On Mon, Nov 7, 2022 at 3:44 AM Jan Beulich wrote: > >>>>>> x86: restrict use of (%dx) > >>>>>> > >>>>>> PR gas/29751 > >>>>>> The AT&T mode special case operand (%dx) is valid to use only with > >>>>>> instructions nominally expecting %dx to specify an I/O port address. > >>>>>> Prefix the respective checking with an opcode check. Keep that as > >>>>>> simple as possible by recognizing that opcodes 0x64 and 0x66 (which > >>>>> > >>>>> Since current_templates doesn't point to the matched instruction, > >>>>> checking current_templates looks like abuse. I don't think error > >>>>> messages should be a concern here. > >>>> > >>>> We use current_templates in similar ways in quite a number of places, > >>>> when match_templates() hasn't run yet. > >>> > >>> Since the first template isn't the selected one, your check allows > >>> the invalid opcodes. > >> > >> I guess I don't understand, but I guess I'll also give up. Which > > > > Your proposed change does > > > > current_templates->start->base_opcode | 0x8a) == 0xee > > > > to allow opcode 0xe4 and (%dx) is allowed for non-I/O opcodes. > > 0xe4 is very much an I/O opcode, merely one not allowing for (%dx). But it also matches other opcodes. > This solely is to ... > > >> template the check is done against doesn't really matter here, as > >> long as it's one with the correct mnemonic. We could of course > >> also re-order templates to have ones allowing for %dx first, but > >> I view any such ordering dependencies as fragile. > >> > > > > That is true. > > ... avoid introducing yet another ordering dependency. > > Jan -- H.J.