From patchwork Tue Nov 29 01:23:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 2343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp56571wrr; Mon, 28 Nov 2022 17:25:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf55SABaEjz15tpa0qOHYKQtKde7QbC6aY/6hx+dwn2q2W8lFPmjza2Q/IL9/wVevn0hBki+ X-Received: by 2002:a17:906:6a0c:b0:7ad:9f03:aa46 with SMTP id qw12-20020a1709066a0c00b007ad9f03aa46mr30534119ejc.175.1669685143402; Mon, 28 Nov 2022 17:25:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669685143; cv=none; d=google.com; s=arc-20160816; b=hKYbpApPwmCM8PBVp6G8/WWtoP2slvdVSbpH7yXV+eY6arnJZOXT/p8nj7n8pYRqJN gm9tZkkVw7L4IzvHTEVr3SRbX1tL7aWdRFpIQGSYFD8+opPSSlBkG6G6ntH8YsCByF+2 kgjbXj9Il0qYM39hEfiWXZnEh6BWCv2zmUpxOT9IyDMCUBGldfzan1Yhut6MIkeaWzY2 9e+xkglP1lRz+oalYaAWtHOMVZzrLzye3+oqONYKP0/CRMLoImZc7l5HNJdaJAEnF69X L9cYMoLboRROPG99cPi8a7MBTym1N4S0vYeO92D+Crj6M4P4K9kT2fCOkOOsX6+F8Li/ BkMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=RkPUdBBTLI9g8IVNboL7g1P30pw+Ucn6L9gRW53G61A=; b=kOwWW+D5LPL4Raw13fO6X23Xmun8aaRMaxRsQZ653gYGVFYHSiHmjxbyH+o7/xJOgS vilG58uxkJDvEnXlSxJnDDM/HW3+TSwREu7Npjdu4Z+nHZ23nuDf5LdDFRCzVnLY3wmd 7asmmOf5nMpny4JhwF44NrZmCm++OvHo/Q8ssa+RDcL7EwvuWF3z+8Y3+ZX7Y7xS1WM0 M7w1yFHU9gQvTcCzVlteNS6aWpDanRUMWOjKsH7CkvF6xrbMz/IsF4UgcEdIZg0B3XY0 MsvuE3qWRis2b/vtHkqVjwFRU6UNwx9qpwyknlU6Jphkt0D4WXgqrSvMz5e5T9X6D/9G oA1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=bTQAiQsZ; 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=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c17-20020aa7df11000000b00463c5c32c65si9417580edy.457.2022.11.28.17.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 17:25:43 -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=@sourceware.org header.s=default header.b=bTQAiQsZ; 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=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C4583839D96 for ; Tue, 29 Nov 2022 01:24:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C4583839D96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669685051; bh=RkPUdBBTLI9g8IVNboL7g1P30pw+Ucn6L9gRW53G61A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=bTQAiQsZl7+rfZ/hNXTc98J6+zVK6J2IVsVk7Q9vCl4L7fCw+WuOrGD8fnwgQDuLs mBD1/kePT/TIl910CjDBlnKJoZwPm2Qj8PZ4wtdx272rfDTUUGAN2FTz6AyV1SJFz1 ML54BJ1c5ORZdzoKLVGDbX3ZgRxVye7rm2tUzc5U= 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 8DC7B38451B0 for ; Tue, 29 Nov 2022 01:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DC7B38451B0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id DE8D7300089; Tue, 29 Nov 2022 01:24:00 +0000 (UTC) To: Tsukasa OI Cc: binutils@sourceware.org Subject: [REVIEW ONLY 0/3] UNRATIFIED RISC-V: Add 'Zisslpcfi' extension and its TENTATIVE CSRs Date: Tue, 29 Nov 2022 01:23:56 +0000 Message-Id: Mime-Version: 1.0 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Binutils From: Tsukasa OI Reply-To: Tsukasa OI Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750791768933894012?= X-GMAIL-MSGID: =?utf-8?q?1750791768933894012?= *** WAIT FOR SPECIFICATION FREEZE *** This is an implementation for unratified and not frozen RISC-V extension and not intended to be merged for now. The only intent to submit this patchset is to test new instructions for your (possibly virtual) environment and early review for fast adoption after ratification. This patchset adds following unratified extension to GNU Binutils: - 'Zisslpcfi' (Control-Flow Integrity - Shadow Stacks and Landing Pads) version 0.1 (may change on ratification) which adds 11 instructions (all are MOPs [a type of instruction defined in the 'Zimop' extension as rd=0 by default but allowed to change architectural state if certain features are supported and optionally enabled; unlike HINTs, changing the state is allowed]) and 4 CSRs. This extension is a part of Control-Flow Integrity (CFI) and with this, many types of control-flow attacks usually caused by a buffer overflow (including ROP/JOP/COP) can be prevented/mitigated. Since landing pads come with tags, targeting certain address is harder than Intel's Indirect Branch Tracking. This is based on the commit 6400f27c3742 of: and following change not reflected in the documentation yet: - Extension name: 'Zimop', not 'Zimops' This is told by the author of the upcoming 'Zimop' extension, Dr. Andrew Waterman himself. Note that all (4) CSR values are not allocated yet. So, these CSRs are assigned with custom range values and this patchset comes with an instantiation script ("$(srcdir)/instantiate-zisslpcfi.sh") to assign custom values (overwrites all related files and removes itself). Because of dependency to the 'Zimop' extension (which documentation is not available yet [upcoming]), this patchset is NEVER going to be committed as is (even if a maintainer approves). Be careful. Tsukasa OI (3): RISC-V: Add "XUN@S" operand type UNRATIFIED RISC-V: Add 'Zisslpcfi' extension and its TENTATIVE CSRs TEST: Add instantiation script on CSR allocation bfd/elfxx-riscv.c | 8 ++ gas/config/tc-riscv.c | 6 + gas/testsuite/gas/riscv/csr-dw-regnums.d | 2 + gas/testsuite/gas/riscv/csr-dw-regnums.s | 3 + gas/testsuite/gas/riscv/csr-version-1p10.d | 4 + gas/testsuite/gas/riscv/csr-version-1p10.l | 4 + gas/testsuite/gas/riscv/csr-version-1p11.d | 4 + gas/testsuite/gas/riscv/csr-version-1p11.l | 4 + gas/testsuite/gas/riscv/csr-version-1p12.d | 4 + gas/testsuite/gas/riscv/csr-version-1p12.l | 4 + gas/testsuite/gas/riscv/csr-version-1p9p1.d | 4 + gas/testsuite/gas/riscv/csr-version-1p9p1.l | 4 + gas/testsuite/gas/riscv/csr.s | 4 + gas/testsuite/gas/riscv/zisslpcfi-fail.d | 2 + gas/testsuite/gas/riscv/zisslpcfi-fail.l | 19 +++ gas/testsuite/gas/riscv/zisslpcfi-fail.s | 26 ++++ gas/testsuite/gas/riscv/zisslpcfi-noarch.d | 3 + gas/testsuite/gas/riscv/zisslpcfi-noarch.l | 24 ++++ gas/testsuite/gas/riscv/zisslpcfi.d | 31 +++++ gas/testsuite/gas/riscv/zisslpcfi.s | 26 ++++ include/opcode/riscv-opc.h | 41 +++++++ include/opcode/riscv.h | 1 + instantiate-zisslpcfi.sh | 127 ++++++++++++++++++++ opcodes/riscv-dis.c | 9 +- opcodes/riscv-opc.c | 19 +++ 25 files changed, 380 insertions(+), 3 deletions(-) create mode 100644 gas/testsuite/gas/riscv/zisslpcfi-fail.d create mode 100644 gas/testsuite/gas/riscv/zisslpcfi-fail.l create mode 100644 gas/testsuite/gas/riscv/zisslpcfi-fail.s create mode 100644 gas/testsuite/gas/riscv/zisslpcfi-noarch.d create mode 100644 gas/testsuite/gas/riscv/zisslpcfi-noarch.l create mode 100644 gas/testsuite/gas/riscv/zisslpcfi.d create mode 100644 gas/testsuite/gas/riscv/zisslpcfi.s create mode 100755 instantiate-zisslpcfi.sh base-commit: cb44f89ce977b1ab2d4063f2487950bddfb75bc7