From patchwork Fri Dec 15 13:32:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 179290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9275533dys; Fri, 15 Dec 2023 05:32:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqYzZB3/6zk1U4cnezFc3t2n10RofgNjhP1gfjidO/PKEP8hxTX/t4BavzoSkD5KrqfIeI X-Received: by 2002:a1f:6e85:0:b0:4b2:c554:d2be with SMTP id j127-20020a1f6e85000000b004b2c554d2bemr7544057vkc.32.1702647134408; Fri, 15 Dec 2023 05:32:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702647134; cv=pass; d=google.com; s=arc-20160816; b=ynNLFMEjqImFf5Vws0IIu/biG3xH6U5XKIg7MUVgrBK4uB4jQbzYa8HTT14RPW4gIp 7yrXhO8bqxsCwv14OINsT4JWpj/dbB4kDLcgW3ReCwqsyxp3sU/5F76DSnVTaDYjfDCY 5y99hg8qJcZeMwODQc2AfkOQmU4RviuXYMZScCSQxMJT6zLjq0LfNv/sHeR+/6R8EL3h LmuYenTPTG3KzXkDdTasd+5LoXp9m99REijFgWy9YOI96AKTlxkvhNio5sal4P7el+At kq/jLFMA2wvx3EZrFOCwBHXmQHgo0Bf7cbc7olxIuMAokjJYSL+gjDZgQRzhok3s56LH goLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:autocrypt:references:cc:to:from:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=MWeaEqK61c8mSPhwmFjMdGP3GCCRp0ujoc1pcqtTDmc=; fh=2DbSPqOhyO7CNtGa024QKgSiHKlKGVt2h+1rlgWLnZI=; b=giOU2TBalQ7LrxpPrj4AotzHDydk0u9BmLnsJuVjNoH5+rLcmg1QFmYBplz1uXyn0x /fiH4J3es/y/uvc+acSm/3ToxLKB+NzhSdASHT9vxfTD5SnxzAgA6f4/p+V/sjEFLGLM TuGNG3t4xoF9TfOl+NfOU3crkaM/95JkfHE2FA70ON1a/9VgkngEm7wDQ82mSr77qjZ7 ECWz1/hKHt7gqaGEjgL7+QRU4H2iA7T7ePVD3SijPRDwq2VtUbBtgJ1IiRHWJ0+xrxc9 ISVm/KrtpdrDLclf+np4VccOI97e+OXX5XxBHI8e0/AJ3AmQOhojW+Eo3wR3yuFXFmRP 9wQQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=A3a159o0; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b64-20020a1fe443000000b004b4d428afaasi2372817vkh.173.2023.12.15.05.32.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 05:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=A3a159o0; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A6B2386D615 for ; Fri, 15 Dec 2023 13:32:14 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 44AEB38618CD for ; Fri, 15 Dec 2023 13:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 44AEB38618CD 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 44AEB38618CD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::233 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702647130; cv=none; b=dLOybveIScuyuPGBYbWE83QjNwwY+yc32eqPV+sHeC1X9z1cG//1PsyHIkuXO0myr1KYK+mYBhb27jtOKON/oTyAOCUB4hOzmfPhUVtUurDyMhuhJJhrFNexBTFmP27YKQtGlFcqP/6MIw9zSZUkQ47M0bDa7I1WpCsIv/pW/iU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702647130; c=relaxed/simple; bh=Qw5W8hBnEXA6T/hzwmR0UEzdDf/EGui6Z46Lkq2RJig=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=nU+xm9qmqYDmoX6lWwVc3ZA6XmFYtbEmh+tBjVdBl+MmBSUGtFZcn2tkMP8zAq5DhupY1oPWtJGAKvkqRP1VNDgWWdl40xuWFA+CZ6X/KUXXa0R4t4ZRTLl5949wMWk43pw5wZDyExKZSEAlXC0nysARhl5OLYJnU5jjZrmcLWM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ca0715f0faso8262101fa.0 for ; Fri, 15 Dec 2023 05:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702647126; x=1703251926; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=MWeaEqK61c8mSPhwmFjMdGP3GCCRp0ujoc1pcqtTDmc=; b=A3a159o0m56+KHvJ/V9dFCFre/KfSoJYgr/3r0EPWqgDZ+kBZQOncabw+GosVUMcyG suL/ktUSNIc7uiX77av6PfYH+4HWq/EUpRrK1AVuDnMGk0Ac8bvCYE0wJpOADs8jgZ3P og676kZez2zC/+avnR2GcCeTNgH1fxiknUDtvTaFFQ5einNuSIfurXv+mNDuuWJk3rhI PtUTNwXF+wg5SNsqtWdQ7erFQEb706yOPZ1dybh2acV/IpeDAUem8ds0ZMrTG3eMX3cU rXtWFqElBpNkYe5LqXP5wZhYTar6Dw8b7j1X/8cb1GfPBeN5UHnI0ih30HE0/UGCs7IQ WI4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702647126; x=1703251926; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MWeaEqK61c8mSPhwmFjMdGP3GCCRp0ujoc1pcqtTDmc=; b=Cwq9icUqSLZnb10RrHWgJhrFZPFw4hHrumhwZQCRejCeB8xO1Yi4oNZkpf3g7tPNUP rxJ00utfD2LILvvFbSF9C0EjZFbmdapv52VvzQq9FGXj0y3HcZUMvgRYy65c+7aqhyJg 6JfEx0eJAmUyOPZj1zIWsaSoXPhP9WZNohKcudJ0LbZuD3xOyE605OgRQ+O7ylX45G52 4CfahJev7cmN/CrB4EL6bRASt5r88sMKREmhYQUJyu+b0BstjvO7CPiiLZb4kZtoP6JF z+MFc24VglwKnN4q6aYeiXQ37LGxzSNyWNk6JuHWi53MQ4uaDHVRV43zafPImVHzWRca Gn9A== X-Gm-Message-State: AOJu0Yxvesrf63zSZqj9+6eD0p8jMvhu74H9hk7GmE9kxxv8LgAyml3O eNHpBjnf+f21k6ByUzzAAcLTBDMB9BduKhjiFMuU X-Received: by 2002:a2e:9113:0:b0:2cc:4d7a:6b7 with SMTP id m19-20020a2e9113000000b002cc4d7a06b7mr380948ljg.71.1702647125705; Fri, 15 Dec 2023 05:32:05 -0800 (PST) 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 bq5-20020a056638468500b00468ebaadd2dsm3954559jab.152.2023.12.15.05.32.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Dec 2023 05:32:05 -0800 (PST) Message-ID: Date: Fri, 15 Dec 2023 14:32:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] x86: properly respect rex/{rex} Content-Language: en-US From: Jan Beulich To: Binutils Cc: "H.J. Lu" , Lili Cui References: <663a2bcd-188c-42d9-9147-9f5d1e627429@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4Hxo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r wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <663a2bcd-188c-42d9-9147-9f5d1e627429@suse.com> X-Spam-Status: No, score=-3026.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785354921718093918 X-GMAIL-MSGID: 1785354921718093918 This addresses two issues: For one, a user specified "rex" did not cause the diagnostic to trigger when there was no other need for a REX prefix; instead, another than the specified insn+operands was encoded. And then (which is what this started from) .insn didn't respect {rex} (and was otherwise similarly flawed as ordinary insns). The latter requires splitting out code from md_assemble(), for it to become re-usable. Besides the addition to address the first issue, that code then also needs generalizing to account for immediate operands, as with .insn we can't make assumptions anymore on all respective templates having at most two operands (we still can build upon there being at most two non-immediate operands, though). While moving the code also simplify the first if(), by folding redundant checks. In the new testcase also test a few more things which afaics weren't tested till now. --- It's not at all obvious to me why the existing "rex" testcase is excluded for so many targets. It can't really be the use of / as prefix separator, as that could easily be covered by passing --divide to gas. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4123,6 +4123,74 @@ build_evex_prefix (void) i.vex.bytes[3] |= i.mask.reg->reg_num; } +static void establish_rex (void) +{ + /* Note that legacy encodings have at most 2 non-immediate operands. */ + unsigned int first = i.imm_operands; + unsigned int last = i.operands > first ? i.operands - first - 1 : first; + + /* Respect a user-specified REX prefix. */ + i.rex |= i.prefix[REX_PREFIX] & REX_OPCODE; + + /* For 8 bit registers we need an empty rex prefix. Also if the + instruction already has a prefix, we need to convert old + registers to new ones. */ + + if ((i.types[first].bitfield.class == Reg && i.types[first].bitfield.byte + && ((i.op[first].regs->reg_flags & RegRex64) != 0 || i.rex != 0)) + || (i.types[last].bitfield.class == Reg && i.types[last].bitfield.byte + && ((i.op[last].regs->reg_flags & RegRex64) != 0 || i.rex != 0))) + { + unsigned int x; + + i.rex |= REX_OPCODE; + for (x = first; x <= last; x++) + { + /* Look for 8 bit operand that uses old registers. */ + if (i.types[x].bitfield.class == Reg && i.types[x].bitfield.byte + && (i.op[x].regs->reg_flags & RegRex64) == 0) + { + gas_assert (!(i.op[x].regs->reg_flags & RegRex)); + /* In case it is "hi" register, give up. */ + if (i.op[x].regs->reg_num > 3) + as_bad (_("can't encode register '%s%s' in an " + "instruction requiring REX prefix"), + register_prefix, i.op[x].regs->reg_name); + + /* Otherwise it is equivalent to the extended register. + Since the encoding doesn't change this is merely + cosmetic cleanup for debug output. */ + i.op[x].regs += 8; + } + } + } + + if (i.rex == 0 && i.rex_encoding) + { + /* Check if we can add a REX_OPCODE byte. Look for 8 bit operand + that uses legacy register. If it is "hi" register, don't add + the REX_OPCODE byte. */ + unsigned int x; + + for (x = first; x <= last; x++) + if (i.types[x].bitfield.class == Reg + && i.types[x].bitfield.byte + && (i.op[x].regs->reg_flags & RegRex64) == 0 + && i.op[x].regs->reg_num > 3) + { + gas_assert (!(i.op[x].regs->reg_flags & RegRex)); + i.rex_encoding = false; + break; + } + + if (i.rex_encoding) + i.rex = REX_OPCODE; + } + + if (i.rex != 0) + add_prefix (REX_OPCODE | i.rex); +} + static void process_immext (void) { @@ -5620,66 +5688,7 @@ md_assemble (char *line) i.op[0].disps->X_op = O_symbol; } - /* For 8 bit registers we need an empty rex prefix. Also if the - instruction already has a prefix, we need to convert old - registers to new ones. */ - - if ((i.types[0].bitfield.class == Reg && i.types[0].bitfield.byte - && (i.op[0].regs->reg_flags & RegRex64) != 0) - || (i.types[1].bitfield.class == Reg && i.types[1].bitfield.byte - && (i.op[1].regs->reg_flags & RegRex64) != 0) - || (((i.types[0].bitfield.class == Reg && i.types[0].bitfield.byte) - || (i.types[1].bitfield.class == Reg && i.types[1].bitfield.byte)) - && i.rex != 0)) - { - int x; - - i.rex |= REX_OPCODE; - for (x = 0; x < 2; x++) - { - /* Look for 8 bit operand that uses old registers. */ - if (i.types[x].bitfield.class == Reg && i.types[x].bitfield.byte - && (i.op[x].regs->reg_flags & RegRex64) == 0) - { - gas_assert (!(i.op[x].regs->reg_flags & RegRex)); - /* In case it is "hi" register, give up. */ - if (i.op[x].regs->reg_num > 3) - as_bad (_("can't encode register '%s%s' in an " - "instruction requiring REX prefix."), - register_prefix, i.op[x].regs->reg_name); - - /* Otherwise it is equivalent to the extended register. - Since the encoding doesn't change this is merely - cosmetic cleanup for debug output. */ - - i.op[x].regs = i.op[x].regs + 8; - } - } - } - - if (i.rex == 0 && i.rex_encoding) - { - /* Check if we can add a REX_OPCODE byte. Look for 8 bit operand - that uses legacy register. If it is "hi" register, don't add - the REX_OPCODE byte. */ - int x; - for (x = 0; x < 2; x++) - if (i.types[x].bitfield.class == Reg - && i.types[x].bitfield.byte - && (i.op[x].regs->reg_flags & RegRex64) == 0 - && i.op[x].regs->reg_num > 3) - { - gas_assert (!(i.op[x].regs->reg_flags & RegRex)); - i.rex_encoding = false; - break; - } - - if (i.rex_encoding) - i.rex = REX_OPCODE; - } - - if (i.rex != 0) - add_prefix (REX_OPCODE | i.rex); + establish_rex (); insert_lfence_before (last_insn); @@ -11697,8 +11706,8 @@ s_insn (int dummy ATTRIBUTE_UNUSED) build_evex_prefix (); i.rex &= REX_OPCODE; } - else if (i.rex != 0) - add_prefix (REX_OPCODE | i.rex); + else + establish_rex (); last_insn = &seg_info(now_seg)->tc_segment_info_data.last_insn; output_insn (last_insn); --- /dev/null +++ b/gas/testsuite/gas/i386/rex-bad.l @@ -0,0 +1,10 @@ +.*: Assembler messages: +.*:4: Error: same .* +.*:5: Error: same .* +.*:6: Error: same .* +.*:7: Error: same .* +.*:9: Error: .* REX .* +.*:10: Error: .* REX .* +.*:12: Error: .* REX .* +.*:13: Error: .* REX .* +#pass --- /dev/null +++ b/gas/testsuite/gas/i386/rex-bad.s @@ -0,0 +1,13 @@ + .text + +_start: + rex.w add (%rax,%rax), %rax + rex.r add (%rax,%rax), %r8 + rex.b add (%r8,%rax), %eax + rex.x add (%rax,%r8), %eax + + rex mov %al, %ch + rex mov %ah, %cl + + .insn rex 0x88, %al, %ch + .insn rex 0x88, %ah, %cl --- a/gas/testsuite/gas/i386/x86-64-pseudos.d +++ b/gas/testsuite/gas/i386/x86-64-pseudos.d @@ -470,4 +470,5 @@ Disassembly of section .text: +[a-f0-9]+: 41 8a 45 00 mov 0x0\(%r13\),%al +[a-f0-9]+: 67 41 8a 45 00 mov 0x0\(%r13d\),%al +[a-f0-9]+: 67 41 8a 85 00 00 00 00 mov 0x0\(%r13d\),%al + +[a-f0-9]+: 40 8a c1 rex mov %cl,%al #pass --- a/gas/testsuite/gas/i386/x86-64-pseudos.s +++ b/gas/testsuite/gas/i386/x86-64-pseudos.s @@ -438,3 +438,5 @@ _start: mov al, BYTE PTR [r13] {disp8} mov al, BYTE PTR [r13d] {disp32} mov al, BYTE PTR [r13d] + + .insn {rex} 0x8a, al, cl --- a/gas/testsuite/gas/i386/x86-64.exp +++ b/gas/testsuite/gas/i386/x86-64.exp @@ -596,6 +596,7 @@ if { ![istarget "*-*-aix*"] && ![istarget "*-*-solaris*"] && ![istarget "*-*-sysv*"] } then { run_dump_test "rex" + run_list_test "rex-bad" } # ELF specific tests From patchwork Fri Dec 15 13:32:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 179291 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9275781dys; Fri, 15 Dec 2023 05:32:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLw+3o6cRs+vO9+HJcHZwVFllgU4ehgfF8Yc49f4oNnvFOWBG3U246yQJcSKL2xro+W5cH X-Received: by 2002:a05:6808:1307:b0:3b8:3442:8d99 with SMTP id y7-20020a056808130700b003b834428d99mr14720324oiv.20.1702647156328; Fri, 15 Dec 2023 05:32:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702647156; cv=pass; d=google.com; s=arc-20160816; b=KaMr+1M+NhD0Np5mYa9TMNTI7If30sw1/WztVVlbCbCRJFqZ+eFELeW9dfEz276ISc uL9XJQYhu2dHDGJ1S/IKozODuvfcamG1ju1h346nI/Q2iaDgXwmpyXHVM8hT1v7sJuKi b7fD49CIJwBv1/VqquHvfUh6i2HBKepb+bB1E1uQy3GUscDqxP/AX7lelmHLnq3oSV60 wk20r+C0+9276d2CHBf1UBXhVCuK//31Mb1Cm9BeIst/vdOli7WihB+9LAUUyfTCX3oI NytBNxCVMkF9+mdjITG5DmNa2vdTrpiV7z9aXv87iXeLbNhm67Mjr409b8OFz0y4u+c9 RCiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:autocrypt:references:cc:to:from:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=5hvlNWEB6P67gnJAVlcqcfb4GXQgoDUBUyieTHjDP+U=; fh=2DbSPqOhyO7CNtGa024QKgSiHKlKGVt2h+1rlgWLnZI=; b=P7ucGPOZOOMP3qy9O79MEnIgO8579ffMEIElf14CO2LOA/M23V9xR2A9/168az7+xa IVSST3mSCKOE0OOZ/XOx5wamw3RAs9+HrcXK7AtreJNL5R2c7QBF6c7bBcFCTIE2BoRd CZOlCT3gKZGCHfeyfmZNEWJT6/3ULU6numma6BRBcAoAJC4GpGmYwK5n6iocSxdSD3le lkJafrBfHwOe1k3HM0a/UxYcc7Pl6h4AxPNAXry2VJ5Slcm6HMRhnMRoEeL/ODp5Ccfu qp3IFw8doQxR+EmhdIR0Ug6tckPyaG14r1fcZ6iCCCmqM5ec/F3vGx8AB+1Tbyb4GVvN y+yA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=gDbEnTeD; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o13-20020a67f48d000000b0046633537b45si2081414vsn.322.2023.12.15.05.32.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 05:32:36 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=gDbEnTeD; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 821EE387543B for ; Fri, 15 Dec 2023 13:32:35 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 2FC2238708C2 for ; Fri, 15 Dec 2023 13:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FC2238708C2 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 2FC2238708C2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702647151; cv=none; b=OPvfAqzV1UHgB86+jn8SzW/2X2kqKyCc8xQHK8m05dy78O+Q6xb7T63ZN8zu4ffhaXetcHMH4AGh8l8aB78HwFPbUGYVj+8ETv2mBXZ0Zr6HPyBLCXsHQM/kIrQJVbePyYHNQY+SYfgm3hHYeCyhMAmQVCZ3uY83+E41YWZwsCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702647151; c=relaxed/simple; bh=jRzTCN8q65T4pShHX9yypsIOOrVdd/WUu4mZ6KExIUo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=PMnbw2WRQ6/Xn9gbhNbDVncNPHhySn3mdC1tlTn2IzLMVie7IbByQeead3+hLSqrnq18xZpIWHPmEP+dejCy/GLugVtNz/pqRJ5yPoNfzxYQ5aLDssk+I+qlm3z5R9Mtlm7565tbNiK35mYyOzCCXRnSQ2vLduJVp6Xa6iGmID8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a1f8a1e9637so112689866b.1 for ; Fri, 15 Dec 2023 05:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702647148; x=1703251948; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=5hvlNWEB6P67gnJAVlcqcfb4GXQgoDUBUyieTHjDP+U=; b=gDbEnTeDzkoLixpvTb4rl4efYlfk7IBVME0omLcy0PVmvFddZAd7A/O1Yk3hveQklC gQN2zdkKLVCwq/1MNjkDlPnvzIr41pKMsLRKWkP5/Ns3Y8yHWGgR4aohVSW9V9xmvH0J wPrZh9af71qgP5ZySXZkxUtrSwcRkui0VH6ftPKKwtpNq+7EQEUc2I4w4MghFqzJAgl7 OWwX1YbCUWgZ4KeOcWRfQnj/ZdQz9ep4PFjxgJx6Ive8CJBzTS5pqtwBZKgm5R4JorTa r7SnUS+Uq2NjljNNp9Hdn31WO2f483axe2JjXsWM+7bNGa5PG6ev0GwJQkefkpPVoVVr ZLPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702647148; x=1703251948; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5hvlNWEB6P67gnJAVlcqcfb4GXQgoDUBUyieTHjDP+U=; b=Z2wBMQF6Wo1rjIVPdUesdWnkVuwc4SZ2KgfkPcFm0Zr3+/UD+P+pusrPNOWQqA6ze7 4V5k1wfIckr8lhX2fHzy5DPzJ+oScVnR2A6IDKREXTOU5tqHxbau6dl3jRehXK+xYQBP iDxm1kwajOaeDsn7FN2YSctyr5f9T8/5Dlq0DMlcdLm3r8F76spc9qbTy5UJFmp8QmKz 34+MCvJcCU0BFXQ7HMHo98UcsXtX7v/yJ2PpaBo788HES5x5RTXMfuPqe3qgVsdqeTIe 7O64yotjzPgM9n7Y9T4EyjBqiU+1xp21IbsG9pWSntVAJR7Z4bsTIkoCKvo2OjLSF7yf Lr3w== X-Gm-Message-State: AOJu0YzB0xNTobTrJtzp1O51AyjLKaQwpKv3h4T0owR+Sj4mbsio6+gI 6Cx/dlcBLktwM3Tn1KAs6jHVpysk4oAncPo3BcfG X-Received: by 2002:a17:907:aa6:b0:a1e:5a8a:674a with SMTP id bz6-20020a1709070aa600b00a1e5a8a674amr14789965ejc.19.1702647147840; Fri, 15 Dec 2023 05:32:27 -0800 (PST) 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 bq5-20020a056638468500b00468ebaadd2dsm3954559jab.152.2023.12.15.05.32.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Dec 2023 05:32:27 -0800 (PST) Message-ID: <870d2722-85a5-4ab8-9680-4b1c4e8f98af@suse.com> Date: Fri, 15 Dec 2023 14:32:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] x86-64: refuse "high" 8-bit regs with .insn and VEX/XOP/EVEX encodings Content-Language: en-US From: Jan Beulich To: Binutils Cc: "H.J. Lu" , Lili Cui References: <663a2bcd-188c-42d9-9147-9f5d1e627429@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6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a2bcd-188c-42d9-9147-9f5d1e627429@suse.com> X-Spam-Status: No, score=-3026.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785354944536001952 X-GMAIL-MSGID: 1785354944536001952 Much like REX, those encodings - if permitting 8-bit regs at all, i.e. only starting with APX - permit use of "new" 8-bit registers only. %ah, %ch, %dh, and %bh cannot be encoded and hence should be rejected. Permit their use outside of 64-bit code though, as "new" registers simply don't exist there. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11484,6 +11484,16 @@ s_insn (int dummy ATTRIBUTE_UNUSED) for (j = i.imm_operands; j < i.operands; ++j) { + /* Look for 8-bit operands that use old registers. */ + if (i.vec_encoding != vex_encoding_default + && flag_code == CODE_64BIT + && i.types[j].bitfield.class == Reg + && i.types[j].bitfield.byte + && !(i.op[j].regs->reg_flags & RegRex64) + && i.op[j].regs->reg_num > 3) + as_bad (_("can't encode register '%s%s' with VEX/XOP/EVEX"), + register_prefix, i.op[j].regs->reg_name); + i.types[j].bitfield.instance = InstanceNone; if (operand_type_check (i.types[j], disp))