Message ID | cover.1665050099.git.research_trasio@irq.a4lg.com |
---|---|
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp226364wrs; Thu, 6 Oct 2022 02:56:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5j/5Yb81a+U852n1IE2sx6HHeM3aHqiAEinFPlZi75Miq2eabM6mavc54LvWkQLgZl3fU6 X-Received: by 2002:a17:906:730e:b0:783:87a1:b5db with SMTP id di14-20020a170906730e00b0078387a1b5dbmr3303388ejc.383.1665050206604; Thu, 06 Oct 2022 02:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665050206; cv=none; d=google.com; s=arc-20160816; b=X9hAp3XwBsifnNpiQNjaNFqudYrL20fXQ5CMcEzn0mehQwSMsGZXnUTQUJ9KRIP/Oh DjUhoiLcknQ4yTajlDG7MrDAf2b3wrjYYWgWaP+jJhbwKrmsS4BpX99KnE6D+uf01JpP ydmrTbrG5//9+qglnT5ZOtEPrBhHQZkPY2btLS9Deyl2FRPtCYaYfuUBnjB9YqoeappV 7THe4Fii3GbgqfJgSI9a51XsxU58Y3csxwycPYgoymNxEIE6CwnRKtEQVqkegAz8UO7z OMH4VVbGLNJSRsBTo+5H42v5SwAQI4KpJJplUN/Eu/J0p2+d35OrtIpnUJreXAMP2VEg MjSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=D1meqIUwskGX5/bikj+V9GxhLDuctEhPfJAaQfzKVaE=; b=CKHK6xhtYd6vLS5KcHW1f7L1iczgQOjzXJkPS6+wiAQ44WHDSQqmKVSMOYKq5rXqQf vYPSHMGLf7DJBMMh0xMhIk6rKhNJveNzRjD+h+EF6kV/zz2TgdrUFPbfxqgIxak+cEEj yYiuSxQZD54SwYsU5fck3xGd2YkYhSvYtxGs377K1otOL8WJZcGfwgzHacUjooF3HtZh Aj6h/ujZUc0WzFU8Wv/+aoKYZ6R6by919Mrny8FY8Ka5dg2/XqIAKPYHyH4u3HDpqrxq EbXJlnaJIK8iMBsCw9+vtrwbfXxtFJ3nkQoHe+WjE6xl03kD05e/iSlEmzWQDTLOvUn+ iMbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=U8s18JsV; 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=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id oz33-20020a1709077da100b00782c6ab6f34si16603600ejc.428.2022.10.06.02.56.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 02:56:46 -0700 (PDT) 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=@sourceware.org header.s=default header.b=U8s18JsV; 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=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5990384B0CB for <ouuuleilei@gmail.com>; Thu, 6 Oct 2022 09:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5990384B0CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665050205; bh=D1meqIUwskGX5/bikj+V9GxhLDuctEhPfJAaQfzKVaE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=U8s18JsV9MwsWwIV8Mx+T7bChbBs+YBG7CCB3F3sysjWeuuiFjtETxtSKy1LOTVAS FIinQjTjZuWAxQjUCupXjb1WDcYIXB+L6Qj9AJLnCU0aXyT1TcwH0szLxxHR1zzdfG ck5WxYCs+z+JJlYORMyz3TsW27i2JgBeifDsenDY= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 5D3EA384D1BE for <binutils@sourceware.org>; Thu, 6 Oct 2022 09:56:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D3EA384D1BE Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 9ADD8300089; Thu, 6 Oct 2022 09:56:34 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Nelson Chu <nelson@rivosinc.com>, Kito Cheng <kito.cheng@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com> Subject: [PATCH v3 0/2] RISC-V: Improve "bits undefined" diagnostics Date: Thu, 6 Oct 2022 09:56:29 +0000 Message-Id: <cover.1665050099.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1665031170.git.research_trasio@irq.a4lg.com> References: <cover.1665031170.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Binutils <binutils@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: binutils@sourceware.org Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745911799964221706?= X-GMAIL-MSGID: =?utf-8?q?1745931685318405163?= |
Series |
RISC-V: Improve "bits undefined" diagnostics
|
|
Message
Tsukasa OI
Oct. 6, 2022, 9:56 a.m. UTC
Hello, This small patch intends to improve one of the internal diagnostic messages when an invalid RISC-V instruction is defined in riscv-opc.c. Tracker on GitHub: <https://github.com/a4lg/binutils-gdb/wiki/riscv_gas_diag_unused_bits> It was a very low-priority patch but since commit bb996692bd9 "RISC-V/gas: allow generating up to 176-bit instructions with .insn" can break validate_riscv_insn function (by negative shift width), it'a good chance to improve this function entirely. [Changes: v2 -> v3] - PATCH 1/2: Revised the function description to reflect the specification. - PATCH 2/2: Started using "%#llx" instead of "0x%llx". In this occurrence, it will not change the behavior. Both changes are based on the feedback from Jan Beulich. This is mostly a quote from the cover letter of PATCH v1 but the words "PATCH 1/2" are replaced with "PATCH 2/2" to reflect PATCH v2 and v3. > First -- just to experiment -- we change mask value of "fcvt.d.s" > instruction from MASK_FCVT_D_S|MASK_RM to MASK_FCVT_D_S while not touching > operands "D,S" and we run compiled assembler, we get following message: > > Assembler messages: > Error: internal: bad RISC-V opcode (bits 0xffffffff00007000 undefined): fcvt.d.s D,S > Fatal error: internal: broken assembler. No assembly attempted > > Bits 0x7000 corresponds to rm (rounding mode) bits we just removed and no > corresponding operands are found (making definition of fcvt.d.s instruction > invalid). > > Then, what about 0xffffffff00000000 (upper 32-bits)? > Yes, they are non-instruction bits. Because of ~ (bitwise complement) > operator while computing undefined bits, it also displays non-instruction > bits. > > > This patchset (PATCH 2/2) changes how undefined/invalid bits are computed. > > before: > ~(used & required) > after: > (used ^ required) > > After PATCH 2/2, following error message is generated. > > Assembler messages: > Error: internal: bad RISC-V opcode (bits 0x7000 undefined or invalid): fcvt.d.s D,S > Fatal error: internal: broken assembler. No assembly attempted > > > Note that we are testing for "undefined or invalid" bits here, not just > undefined bits. In fact, if we corrupt a variant of c.addi instruction with > ADDITIONAL "j" operand (which is an immediate for I-type instruction, upper > 12-bits of **32-bit** instruction encoding), we get following message: > > Assembler messages: > Error: internal: bad RISC-V opcode (bits 0xfff00000 undefined or invalid): addi d,CU,Cj,j > Fatal error: internal: broken assembler. No assembly attempted > > Okay, extra "j" operand generates "extra" bits (that should not have been > defined considering its 16-bit encoding) and words "undefined or invalid" > are working here. We are correctly capturing invalid extra bits. Before > this patch, invalid bits are hidden by 0xffffffffffff0000 (48 non- > instruction bits). Thanks, Tsukasa Tsukasa OI (2): RISC-V: Fallback for instructions longer than 64b RISC-V: Improve "bits undefined" diagnostics gas/config/tc-riscv.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) base-commit: 80e0c6dc91f52fad32c3ff3cf20da889d77013ac