From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 8096C3858D1E for ; Wed, 9 Nov 2022 20:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8096C3858D1E 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-x635.google.com with SMTP id kt23so49975580ejc.7 for ; Wed, 09 Nov 2022 12:25:29 -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=/fEyDORVhz7101y6ZUOSVYzO85oUlfn75fzf0P4ryB0=; b=gfraM3uAJ6Yjt2oVCR6t1TMdDZ/kNWIzzPMjGes3lvhucAVjkb5A8wh3mg6DeK8309 p5cwqHwtU9SfS+Ff0ak0ztKhe8Er7lZ1dZAP2MKtPILpzpehQ6vpkmgULnbchgOybkGJ vxGfuyFSg6rc3Alec5Vb3unmt2E3W+kd2X3VKIw2cTUbdoqrRnjY+PyjSktQY6dR+FVz yMV3okdHznJbFQ8ouInUdJDmeKvET0gnsBV+W5iCb8cfGKBnLE1Mqm2FExr+OikpHsg8 R2ssM2amY0GJ7hRln+iX7jR1UcWTPyl45nPCQPWr4F8zxGcge7lZWU7ssqM7hW8cEWCk vL1g== 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=/fEyDORVhz7101y6ZUOSVYzO85oUlfn75fzf0P4ryB0=; b=rAlXhLn/wfXHjJm4aIRFjNaSm2753A1wCVR4MymkpiCImFXYQH9Aow/piYOCHiN1wa ucNY7C/cNReH7OqLPPyu4y1SXMyUi+r40DSfcay69BMS2K89d/dxg2dkMyS2DcBm610F 8FHf0gmLl7n0sJq3oMDiZiA38DSGHtS2kQAYBbtnQW2QFOYqti5T6Z7sssD+rRW8zpi3 SL1zzL799ZBKCjAw/WMm/covKsMoc9Ctagy/tTAS/Stm2d7aBn8J4B6+aBQj9CPPAbTd lhmSTFGD+C+mS1iHn7SVTjD+UmRsLoaqf55G3xC+mWstLDJ3NXwwURjrv2DzrPhYo+pa EOQg== X-Gm-Message-State: ACrzQf3/lxdtfivB8jl2JN9BA/3ZujvmqToXP2QjNCyoT10rmnMi5l4l /mkp31hCkxBFqQAkaofOmtDEwpCONjXtfce/wV5dbT/7tpY= X-Google-Smtp-Source: AMsMyM66hWp12mOILVNqKJ53fTeXR0WmXk7RmA1Y209veku5v9SsLpjLWVbOkWDkyclflJi3mqu338nAEFenqOqrTf4= X-Received: by 2002:a17:907:1dc8:b0:7ad:b792:2fec with SMTP id og8-20020a1709071dc800b007adb7922fecmr53582797ejc.732.1668025528203; Wed, 09 Nov 2022 12:25:28 -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> In-Reply-To: <5e2a1d31-546f-23bd-bd2d-2de39af81ce8@suse.com> From: "H.J. Lu" Date: Wed, 9 Nov 2022 12:24:50 -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.7 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 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. > 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. I posted the v2 patch to add inw tests. -- H.J.