From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id C7476385840C; Thu, 25 Nov 2021 23:02:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7476385840C Received: by mail-pg1-x52d.google.com with SMTP id h63so6395869pgc.12; Thu, 25 Nov 2021 15:02:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=93O+rTx8T0zlx8hFIegaask8+54bpqAk5QpljYxlzus=; b=hjLDgW1MbHnGEdwHTGkS5Cw9vff0L1Q6jSqKQzJLpHpBod3asIkyV1TZcyPGGADk2j Lbihu8ZSspajsGCmYbXE7iviKKoTPyxV42RAyOpkT32/UHuMGh2lizlBNBONFau7WTop oU1FokfsFLyku217fH7oLHKqfep99hhMT4pSvPHDOBSof5MXyUuHtiF6RLkyH1vHbblN n0rxFz+dnn4QZy1BWsQzFCRy4UopI2IT8I70Pwj6SaNHE6oOgF+OabAJElGKs1hY0TTi S3CKq1wrUSxUGlpFnoBXc2iTncvvgPtxVFMESLu9KOKnwtx7jFUcsT/Z16p6Dj4eLPRl /oCg== X-Gm-Message-State: AOAM531ice52SylrGv3zhMJodweRl05blKRT7c6uqXSgzMWzxtLfSNPf 4vqvAOKCeT1vLxFQnZwIJDn9aMO6omg= X-Google-Smtp-Source: ABdhPJxXxYSVC2S/ORpJ4ppHhd4FLKPC2+GcaUlcCmNKrLmFCapgS9vMZN2VRJkt3NF5AVYjf4i3Zg== X-Received: by 2002:a05:6a00:1a4f:b0:4a3:3c4a:b708 with SMTP id h15-20020a056a001a4f00b004a33c4ab708mr17228742pfv.29.1637881334848; Thu, 25 Nov 2021 15:02:14 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id p128sm4343959pfg.125.2021.11.25.15.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 15:02:14 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 2AC5D11402EF; Fri, 26 Nov 2021 09:32:11 +1030 (ACDT) Date: Fri, 26 Nov 2021 09:32:11 +1030 From: Alan Modra To: Guillermo Martinez , "Jose E. Marchesi" Cc: cgen@sourceware.org, binutils@sourceware.org Subject: Re: [PATCH v2] cgen: Compute correct mask and values when offset in define-ifield is not 0. Message-ID: References: <20210820023254.2575757-1-guillermo.e.martinez@oracle.com> <20210915163212.157394-1-guillermo.e.martinez@oracle.com> <87tuil943b.fsf@gnu.org> <1807213.tdWV9SEqCh@sali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1807213.tdWV9SEqCh@sali> X-Spam-Status: No, score=-3038.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cgen@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cgen mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 23:02:17 -0000 On Wed, Sep 15, 2021 at 06:04:44PM +0000, Guillermo Martinez wrote: > On Wednesday, September 15, 2021 11:49:12 AM CDT Jose E. Marchesi wrote: > > I just installed this version of the patch on your behalf. > > Thanks! > > > > > If an instruction field is defined in a long form, assigning > > > an offset different to 0 the mask and constant values are not > > > computed appropriately: [snip] It's been a while since I refreshed the binutils opcodes files that are cgen generated. On doing so it appears this patch is responsible for build errors when using mainline gcc. First example: /home/alan/src/binutils-gdb/opcodes/bpf-opc.c:57:11: error: conversion from ‘long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709486335’ to ‘4294902015’ [-Werror=overflow] 57 | 64, 64, 0xffffffffffff00ff, { { F (F_IMM32) }, { F (F_OFFSET16) }, { F (F_SRCLE) }, { F (F_OP_CODE) }, { F (F_DSTLE) }, { F (F_OP_SRC) }, { F (F_OP_CLASS) }, { 0 } } | ^~~~~~~~~~~~~~~~~~ I tested an obvious workaround, diff --git a/include/opcode/cgen.h b/include/opcode/cgen.h index 8b7d2a4b547..0e9571d19b0 100644 --- a/include/opcode/cgen.h +++ b/include/opcode/cgen.h @@ -914,7 +914,7 @@ typedef struct Each insn's value is stored with the insn. The first step in recognizing an insn for disassembly is (opcode & mask) == value. */ - CGEN_INSN_INT mask; + uint64_t mask; #define CGEN_IFMT_MASK(ifmt) ((ifmt)->mask) /* Instruction fields. diff --git a/opcodes/cgen-dis.c b/opcodes/cgen-dis.c index 1a5d1ae8459..37ee5a23564 100644 --- a/opcodes/cgen-dis.c +++ b/opcodes/cgen-dis.c @@ -39,7 +39,7 @@ static void add_insn_to_hash_chain (CGEN_INSN_LIST *, static int count_decodable_bits (const CGEN_INSN *insn) { - unsigned mask = CGEN_INSN_BASE_MASK (insn); + uint64_t mask = CGEN_INSN_BASE_MASK (insn); #if GCC_VERSION >= 3004 return __builtin_popcount (mask); #else Quite possibly the above isn't a complete fix, I just threw it together to see what happens. Regressions: +FAIL: eBPF CALL instruction +FAIL: eBPF CALL instruction, big endian +FAIL: CALL with disp32 reloc +FAIL: CALL with disp32 reloc and addend +FAIL: CALL check unsigned underflow gas/testsuite/gas.log for the first one shows: regexp_diff match failure regexp "^ 20: 85 10 00 00 00 00 00 00 call 0$" line " 20: 85 10 00 00 00 00 00 00 *unknown*" regexp_diff match failure regexp "^ 28: 85 10 00 00 ff ff ff ff call -1$" line " 28: 85 10 00 00 ff ff ff ff *unknown*" regexp_diff match failure regexp "^ 30: 85 10 00 00 fe ff ff ff call -2$" line " 30: 85 10 00 00 fe ff ff ff *unknown*" regexp_diff match failure regexp "^ 38: 85 10 00 00 fd ff ff ff call -3$" line " 38: 85 10 00 00 fd ff ff ff *unknown*" FAIL: eBPF CALL instruction At this point I don't intend to look any further into the problem. The opcodes/ refresh can wait. -- Alan Modra Australia Development Lab, IBM