From patchwork Tue Oct 8 10:25:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 98531 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42EA93850204 for ; Tue, 8 Oct 2024 10:26:13 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 976FC3861039 for ; Tue, 8 Oct 2024 10:25:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 976FC3861039 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 976FC3861039 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728383144; cv=none; b=uZ2UAoqbCgMri3SvX0YgRBirUhKXimzN9S/YLIHIeuarJTzY7DP+AaZVlbxMeKLs8+UhNFnRkFl9960kE9U3Dv9T2p25W6VIQqxQ9w1Jc7WIR5+gKTWFghYJfvLqun0qk5g7uv1BAU7MLCNRgfdF0RWNcJQG9o+MXQ8EJ2dePtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728383144; c=relaxed/simple; bh=bEXDM1AimbUTJECk99x2hAKjrBHY55PdQJNp3QcYksE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=qgk00JR5mbyeku5qpgTxeWkwsPilC4IWkOcSUPWgEhkrV80lDPcT8jh4RzOTtsraea4nzKuLhV92bW2DQlO+pRyb2jlbOn4mKvJFCmXF5Jgn1xY1EGXI9VIgxD5bibz04yonxGY4zFQEjz8d/V17ek3w81taUvB/mSZbUOLXLNU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5389e24a4d1so6629614e87.3 for ; Tue, 08 Oct 2024 03:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728383140; x=1728987940; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=rUIZQ4zcTIzLW/L5JmkFl8sbgvMzkaqrk0YRtrvQZLI=; b=FDxIen82aRhmstrLkLLbdFnQgviE6yEI9zRSU35A+gJVbVJXWTUYqECp11l+f5qrBg t+JCQSFssTUnuE3is5EGVlpB8Ul0oggsy4/Z+Alp9l/bmZSZOa9yOkkNIbPV4CLWH8WK wUrs3cMSLo7+YhHTMjEkAZoFPvv+98b7GYh4EcX/v02sJOq5Kbi+RuKOJ2o7U8ripcXx oW1G6nSddlXnuCWupKTYXrxtY+7Iop7Eg0FNGI2SYX+pUWM2M1gk46kf0YOh7cHNQCoH 5S/XP0CvZVTDEiS+jUkbPCvgNOwxLwUAH9E6A2/Mz7J3oheEbEoO3zLUj+PCy3Mu7oJL xPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728383140; x=1728987940; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rUIZQ4zcTIzLW/L5JmkFl8sbgvMzkaqrk0YRtrvQZLI=; b=tumbrVbsLPJdG8camF+u3Im7HJF5l11F4H53jX+8hQUr5wbfvcwhfUt5iA4EEsOXzn Nwd63lwn7N5iP5Jz+pqvbFf7EPNE7TzN+YrdOKHsiqlc2BBhPgeFQw1WWJ0y05wDBrfz 2Oxi/R8fjo8YgL39pf54d7qV9QLzMJsNzHP9Td4VVSMM0d9SvzjwfL8JL2z5ZripKExV U9eMgVJeVkAXZSBIsZ6QYpmLsj98+r6cs5fxKDAQP17OXDrsHdBc93KVq1MEVRuy+uOV OaEzH8yUQmOeUtkB5g1sIKjgSzVT2Z+EWPowwtxvR/A41uZrLAKnKF4lczKG5NlVGWaO dZHA== X-Gm-Message-State: AOJu0Yy4M8laZ+5fouv0QLZUvD1qVDtMA1sqH5IfbkFvEX2QXbDiF6ri uKtCfBe3krZmouBHRuw3Zy+jgu4an0O3IYlkozySHIuPl2R10wYU8Jn86CN4DY0yNfipS6r8evM = X-Google-Smtp-Source: AGHT+IEv9atkvtzWdM9eHRzhKi+o9M5NxxXFaeQub6JepRx7xpQYHuzVuf3QcflTBhQP/aJZlWNOvQ== X-Received: by 2002:a05:6512:3189:b0:539:9360:b288 with SMTP id 2adb3069b0e04-539ab873e2fmr7360096e87.34.1728383139867; Tue, 08 Oct 2024 03:25:39 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e627c9fsm490102466b.83.2024.10.08.03.25.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Oct 2024 03:25:39 -0700 (PDT) Message-ID: <218ffe6d-102e-472d-98f5-9b7b99fe6a49@suse.com> Date: Tue, 8 Oct 2024 12:25:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] x86/APX: squash REX prefix when REX2 is being emitted From: Jan Beulich To: Binutils Cc: Lili Cui , "H.J. Lu" References: <4e9c7d7b-02b5-4fd1-81f3-25eeba400b56@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcH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BJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <4e9c7d7b-02b5-4fd1-81f3-25eeba400b56@suse.com> X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org We should not (silently) emit a REX prefix ahead of a REX2-encoded insn; such encodings are illegal. Best we can do is fold the REX bits into the REX2 prefix, and then zap the REX one from i.prefix[]. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4526,7 +4526,8 @@ build_rex2_prefix (void) i.vex.bytes[0] = 0xd5; /* For the W R X B bits, the variables of rex prefix will be reused. */ i.vex.bytes[1] = ((i.tm.opcode_space << 7) - | (i.rex2 << 4) | i.rex); + | (i.rex2 << 4) + | ((i.rex | i.prefix[REX_PREFIX]) & 0xf)); } /* Build the EVEX prefix (4-byte) for evex insn @@ -4675,6 +4676,7 @@ static void establish_rex (void) build_rex2_prefix (); /* The individual REX.RXBW bits got consumed. */ i.rex &= REX_OPCODE; + i.prefix[REX_PREFIX] = 0; } else if (i.rex != 0) add_prefix (REX_OPCODE | i.rex); --- a/gas/testsuite/gas/i386/x86-64-apx-rex2.d +++ b/gas/testsuite/gas/i386/x86-64-apx-rex2.d @@ -80,4 +80,8 @@ Disassembly of section .text: [ ]*[a-f0-9]+:[ ]*d5 76 8d 7c 20 01 lea 0x1\(%r16,%r28,1\),%r31d [ ]*[a-f0-9]+:[ ]*d5 12 8d 84 04 81 00 00 00 lea 0x81\(%r20,%r8,1\),%eax [ ]*[a-f0-9]+:[ ]*d5 57 8d bc 04 81 00 00 00 lea 0x81\(%r28,%r8,1\),%r31d +[ ]*[a-f0-9]+:[ ]*d5 14 f7 14 24 \{rex2 0x14\} notl \(%r20\) +[ ]*[a-f0-9]+:[ ]*d5 12 f7 14 24 notl \(%r20,%r12,1\) +[ ]*[a-f0-9]+:[ ]*d5 11 f7 14 24 notl \(%r28\) +[ ]*[a-f0-9]+:[ ]*d5 18 f7 14 24 notq \(%r20\) #pass --- a/gas/testsuite/gas/i386/x86-64-apx-rex2.s +++ b/gas/testsuite/gas/i386/x86-64-apx-rex2.s @@ -83,3 +83,9 @@ _start: leal 1(%r16, %r28), %r31d leal 129(%r20, %r8), %eax leal 129(%r28, %r8), %r31d + +## explicit REX prefix + rex.r notl (%r20) + rex.x notl (%r20) + rex.b notl (%r20) + rex.w not (%r20)