From patchwork Mon Jul 29 19:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 50814 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b88e:0:b0:489:2eb3:e4c4 with SMTP id p14csp13285vqn; Mon, 29 Jul 2024 12:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVlp6TIfP41r7txkwdrADBYh9c5U7/4kQdNKIcRk+Tlzfvr6ANZ+qgB0R4ayL30LfWViGxkOaqKkKs2QhD3PkwFAHcUAWdv0/AwYQ== X-Google-Smtp-Source: AGHT+IHGQd6H0ND1ybe9k0t9DjYUsRcSTsEAG8bMAchDEnqbFCDwS74lvC0FR2n/Ij8bcxAtBVDU X-Received: by 2002:a17:907:9409:b0:a79:7dc0:4fed with SMTP id a640c23a62f3a-a7d400bb34emr570786466b.34.1722282251279; Mon, 29 Jul 2024 12:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722282251; cv=none; d=google.com; s=arc-20160816; b=xtvxyzoCC4zFSXqN7QpUnYQXerUZGfHlOH0VNEsn+LH4op5EohgNowH+86jC2eti7u BDZKmej58R54yRbhqnGCjVSWoaj0/h4Q1tdfEN/r0YycsNRm72x+5C5tcRm4ENtZ0ULF cQHP9/b8jUA3jRcXsKwtORR3M/xpqUMHOHvCoRJ16WkC7BfetYSWOo8PMxG2MUDTzJLc U5p8WgaBgZWd3ScoeSPHRn8twSIPuJ2teonyaEdnUEB/GVumSns6s/0jNjTVxNnU9lL7 Q6PnQt9eUMJCwTQOXc+ytK2aEmRZ+bNm4298ckGE0pNps1qkCdCwm5e0msADidTfmEXC Wu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=w/lt2PzPB6yHVZ9YFwN3DMTltiGbHsUjOVStJaTo7Eo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=yE6zD2eF1jKwbQBWBTqy5GEJtfSNSqbicSzPPmh/kKGL/DOSktT2beywNmH91pdMfz f16wQ4/GjtGw1a96nq0PY5W1J0suveyO8UvEoQxhHx7t+gZrBfUq/exXWG4DQxG2hE0Y wmBfD7PVb2Y10a+aRpeeanPZzaQOZionZevJ7u1HEIbWw6l6zOT/XgrrgzEqlTu+Q9G1 r1iW7XskTBXfHBYI4Yj2jhq59QUCQxklCDokqK/xvLaMGO0T9/mUuqTjPgKwRviANDLb Ekz/ktQd6g35WRFLpBYlr4TJ+EaUsMhje0ImDhpNLDJTzlvHIUYsT7Qq4pQnQaxUjR8C bpxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a7acacc37eesi681293166b.955.2024.07.29.12.44.09; Mon, 29 Jul 2024 12:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3FB0A68D6F9; Mon, 29 Jul 2024 22:44:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB2DF68D077 for ; Mon, 29 Jul 2024 22:43:58 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 6B1CAC0140 for ; Mon, 29 Jul 2024 22:43:58 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Jul 2024 22:43:58 +0300 Message-ID: <20240729194358.129575-1-remi@remlab.net> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] checkasm/riscv: preserve T1 whilst calling... X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9cqU3bTjs30v This preserves T1 whilst calling the instrumented function. In a Sci-Fi setting where type-based Control Flow Integrity (CFI) is supported, the calling code (i.e., the `checkasm` test case) will set T1 to the expected value of the landing pad label (LPL) of the instrumented function. The call wrapper will always use LPL zero which is a wild card. We should preserve the value of T1 at least until the indirect call to the instrumented function. Of course this is Sci-Fi, because: 1) there is no hardware (or even QEMU) support yet, 2) all our assembler functions currently use LPL zero anyway. This uses T3 rather than T2 because indirect branches with T2 is reserved for notionally direct calls made with an indirect call instruction (e.g. due to GOT indirection), and are exempted from forward-edge CFI checks. --- tests/checkasm/riscv/checkasm.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/checkasm/riscv/checkasm.S b/tests/checkasm/riscv/checkasm.S index e8bcbb271e..c4b034ae23 100644 --- a/tests/checkasm/riscv/checkasm.S +++ b/tests/checkasm/riscv/checkasm.S @@ -89,8 +89,8 @@ func checkasm_get_wrapper, v /* Clobber the vector configuration */ li t0, 0 /* Vector length: zero */ - li t1, -1 << 31 /* Vector type: illegal */ - vsetvl zero, t0, t1 + li t2, -4 /* Vector type: illegal */ + vsetvl zero, t0, t2 csrwi vxrm, 3 /* Rounding mode: round-to-odd */ csrwi vxsat, 1 /* Saturation: encountered */ @@ -120,7 +120,7 @@ func checkasm_get_wrapper, v /* Clobber the saved and temporary registers */ .irp n, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - .if (\n > 0 && \n < 7) + .if (\n > 1 && \n < 7) mv t\n, t0 .endif fmv.d.x ft\n, t0 @@ -131,9 +131,9 @@ func checkasm_get_wrapper, v /* Call the tested function */ la.tls.ie t0, checked_func add t0, tp, t0 - ld t1, (t0) + ld t3, (t0) sd zero, (t0) - jalr t1 + jalr t3 /* Check special register values */ la.tls.ie t0, saved_regs