Message ID | 20220425140311.95231-1-german.gomez@arm.com |
---|---|
Headers |
Return-Path: <elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D18A93858C74 for <patchwork@sourceware.org>; Mon, 25 Apr 2022 14:03:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D18A93858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650895411; bh=NSjFpbEDyt8s5VQSwMQZf6ecNTHb/0y0qagGJ7Iz3dY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=F4bvgzt9OEoVzJiCPbKMnbT/i2AffzZwJ8sGV7ERDFD402N8F/LnT5H8n5tEYCIw+ FZk0JB0oj1mnXQKc2bUgrcdKQ9LcKmBTd3nLCblNlOnoFBhOHDaa32jPPqal41T170 /YQbFCcG41D32s77zQ2k6Np8KN1PwLjpeYSya2SQ= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 9FB573858D28 for <elfutils-devel@sourceware.org>; Mon, 25 Apr 2022 14:03:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9FB573858D28 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34B261FB; Mon, 25 Apr 2022 07:03:22 -0700 (PDT) Received: from ip-10-252-15-96.eu-west-1.compute.internal (unknown [10.252.15.96]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 90E2D3F774; Mon, 25 Apr 2022 07:03:21 -0700 (PDT) To: elfutils-devel@sourceware.org Subject: [PATCH 0/4] Add AARCH64 pointer authentication support Date: Mon, 25 Apr 2022 14:03:07 +0000 Message-Id: <20220425140311.95231-1-german.gomez@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> From: German Gomez via Elfutils-devel <elfutils-devel@sourceware.org> Reply-To: German Gomez <german.gomez@arm.com> Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" <elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Add AARCH64 pointer authentication support
|
|
Message
German Gomez
April 25, 2022, 2:03 p.m. UTC
Hi, I've included a set of patches in order to demangle return addresses in aarch64 platforms with pointer authentication. Besides adding the implementation of the negate_ra_state opcode, there is a new function in the libdwfl.h header to feed the PAC masks to the library. Let me know if there are any concerns with the current version. Thanks, German German Gomez (4): aarch64: Create definitions for AARCH64_RA_SIGN_STATE register libdw,aarch64: Implement DW_CFA_AARCH64_negate_ra_state CFI instruction libdwfl,aarch64: Demangle return addresses using a PAC mask libdwfl,eu-stack,aarch64: Add API for setting AARCH64 PAC mask. backends/aarch64_init.c | 6 +++--- backends/aarch64_initreg.c | 2 ++ backends/aarch64_regs.c | 5 ++++- libdw/cfi.c | 14 +++++++++++++- libdw/dwarf.h | 5 +++++ libdw/libdw.map | 5 +++++ libdwfl/dwfl_frame.c | 3 +++ libdwfl/dwfl_frame_regs.c | 10 ++++++++++ libdwfl/frame_unwind.c | 14 +++++++++++++- libdwfl/libdwfl.h | 6 ++++++ libdwfl/libdwflP.h | 7 +++++++ libdwfl/linux-pid-attach.c | 34 ++++++++++++++++++++++++++++++++-- tests/run-addrcfi.sh | 1 + tests/run-allregs.sh | 1 + 14 files changed, 105 insertions(+), 8 deletions(-)
Comments
Hi German, On Mon, Apr 25, 2022 at 02:03:07PM +0000, German Gomez via Elfutils-devel wrote: > I've included a set of patches in order to demangle return addresses in > aarch64 platforms with pointer authentication. > > Besides adding the implementation of the negate_ra_state opcode, there > is a new function in the libdwfl.h header to feed the PAC masks to the > library. > > Let me know if there are any concerns with the current version. Thanks a lot for this. Last time I looked at this didn't have any means to test this, so I skipped implementing it. How did you test? Do distributions now enable PAC by default and is there hardware (qemu?) support? I haven't been able to look at the actual patches yet. And I am on vacation this week. But I'll review next week after I am back. A quick scan shows we need a aarch64 special public function, which would be slightly ugly imho. I had hoped it could be a variant of the func_addr_mask. But maybe this is too different to make more generic. Cheers, Mark
Hi Mark, thanks for looking, and sorry for the delay On 28/04/2022 20:56, Mark Wielaard wrote: > Hi German, > > On Mon, Apr 25, 2022 at 02:03:07PM +0000, German Gomez via Elfutils-devel wrote: >> I've included a set of patches in order to demangle return addresses in >> aarch64 platforms with pointer authentication. >> >> Besides adding the implementation of the negate_ra_state opcode, there >> is a new function in the libdwfl.h header to feed the PAC masks to the >> library. >> >> Let me know if there are any concerns with the current version. > Thanks a lot for this. Last time I looked at this didn't have any > means to test this, so I skipped implementing it. How did you test? Do > distributions now enable PAC by default and is there hardware (qemu?) > support? So far I've been testing on Graviton3 cores (running linux), which seem to implement the PAC extension, and it came enabled by default. https://www.kernel.org/doc/html/latest/arm64/pointer-authentication.html > I haven't been able to look at the actual patches yet. And I am on > vacation this week. But I'll review next week after I am back. Thanks a lot for looking. > > A quick scan shows we need a aarch64 special public function, which > would be slightly ugly imho. I had hoped it could be a variant of the > func_addr_mask. But maybe this is too different to make more generic. I did consider func_addr_mask initially, but when I wrote the patch it wasn't exposed as a perf-thread value. Currently PAC masks are constant but might be different from thread to thread in the future. So I placed it in the Thread struct. I agree the arch-specific naming is not pretty. I think I can certainly rework it into a more generic feature. But I think I would need to make sure that the masks can be supplied to the Thread struct before the unwind. Thanks, German > Cheers, > > Mark >
On 19/05/2022 14:30, German Gomez via Elfutils-devel wrote: > Hi Mark, thanks for looking, and sorry for the delay > > On 28/04/2022 20:56, Mark Wielaard wrote: >> Hi German, >> >> On Mon, Apr 25, 2022 at 02:03:07PM +0000, German Gomez via Elfutils-devel wrote: >>> [...] >> Thanks a lot for this. Last time I looked at this didn't have any >> means to test this, so I skipped implementing it. How did you test? Do >> distributions now enable PAC by default and is there hardware (qemu?) >> support? > So far I've been testing on Graviton3 cores (running linux), which seem > to implement the PAC extension, and it came enabled by default. > Regarding qemu support, I haven't used it myself so I can't really speak for it, but according to the docs FEAT_PAuth is supported. https://www.qemu.org/docs/master/system/arm/emulation.html