From patchwork Fri Jan 6 11:47:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiong Wang X-Patchwork-Id: 711878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tw2qB70khz9t0X for ; Fri, 6 Jan 2017 22:47:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BBSvzqhC"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Fjdq7FjuU8J4Rlkrf MDuSiFDBWeLr53KwIhOQgigEvHeShEvjKHYnquWqokPuSW8GzXFBWeBtQrer1tKD 4uaVQSeHo6av53hC7hbCvT6kRo/oa+1pu1CGnpkc9NgswyuEQfv5fGmFuLjBwO2B +zztBRojXbBo8NbUpcQ5Ia4izw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=xOMDpgg2r9HeqOr0CCqX6KC dLDQ=; b=BBSvzqhCoS/UwwI82qDHeHTwwS9jwERNdMhgbIyqiygRIk4D1bXj9DA VsJLxk4G1T5lAPVT71/FbFs7hHz510YXJ+hsq39zm3XrZfs9lWKsHyaKzuZhTr08 k7wWZNlANvqjpSAxAbsLbo4FQV0gDQd/AaY1Sb4HTkW2Q05HoIkE= Received: (qmail 18286 invoked by alias); 6 Jan 2017 11:47:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 18254 invoked by uid 89); 6 Jan 2017 11:47:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=cal, letter, 2017-01-06 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jan 2017 11:47:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F7491596; Fri, 6 Jan 2017 03:47:15 -0800 (PST) Received: from [10.2.206.198] (e104437-lin.cambridge.arm.com [10.2.206.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B1DD73F220; Fri, 6 Jan 2017 03:47:14 -0800 (PST) Subject: [2/5][AArch64] Generate dwarf information for -msign-return-address To: gcc-patches References: <4cf21d03-0a88-c6fa-df37-59ec4edf1d89@foss.arm.com> <60457276-8566-8bef-6073-4b00dd975759@foss.arm.com> <2718d6de-4571-694b-3eeb-90b7b839a867@foss.arm.com> Cc: James Greenhalgh , "Richard Earnshaw (lists)" From: Jiong Wang Message-ID: <4df3fc1f-bf5c-b5a5-d372-0b41fb377700@foss.arm.com> Date: Fri, 6 Jan 2017 11:47:13 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <2718d6de-4571-694b-3eeb-90b7b839a867@foss.arm.com> X-IsSubscribed: yes On 11/11/16 18:22, Jiong Wang wrote: > This patch generate DWARF description for pointer authentication. DWARF value > expression is used to describe the authentication action. > > Please see the cover letter and AArch64 DWARF specification for the semantics > of AArch64 DWARF operations. > > When authentication key index is A key, we use compact DWARF description which > can largely save DWARF frame size, otherwise we fallback to general operator. > > > > Example > === > > int > cal (int a, int b, int c) > { > return a + dec (b) + c; > } > > Compact DWARF description > (-march=armv8.3-a -msign-return-address) > === > > DW_CFA_advance_loc: 4 to 0000000000000004 > DW_CFA_val_expression: r30 (x30) (DW_OP_AARCH64_paciasp) > DW_CFA_advance_loc: 4 to 0000000000000008 > DW_CFA_val_expression: r30 (x30) (DW_OP_AARCH64_paciasp_deref: -24) > > General DWARF description > === > (-march=armv8.3-a -msign-return-address -mpauth-key=b_key) > > DW_CFA_advance_loc: 4 to 0000000000000004 > DW_CFA_val_expression: r30 (x30) (DW_OP_breg30 (x30): 0; DW_OP_AARCH64_pauth: 18) > DW_CFA_advance_loc: 4 to 0000000000000008 > DW_CFA_val_expression: r30 (x30) (DW_OP_dup; DW_OP_const1s: -24; DW_OP_plus; DW_OP_deref; DW_OP_AARCH64_pauth: 18) > > From Linux kernel testing, -msign-return-address will introduce +24% > .debug_frame size increase when signing all functions and using compact > description, and about +45% .debug_frame size increase if using general > description. > > > gcc/ > 2016-11-11 Jiong Wang > > * config/aarch64/aarch64.h (aarch64_pauth_action_type): New enum. > * config/aarch64/aarch64.c (aarch64_attach_ra_auth_dwarf_note): New function. > (aarch64_attach_ra_auth_dwarf_general): New function. > (aarch64_attach_ra_auth_dwarf_shortcut): New function. > (aarch64_save_callee_saves): Generate dwarf information if LR is signed. > (aarch64_expand_prologue): Likewise. > (aarch64_expand_epilogue): Likewise. This patch is an update on DWARF generation for return address signing. According to new proposal, we simply needs to generate REG_CFA_WINDOW_SAVE annotation. gcc/ 2017-01-06 Jiong Wang * config/aarch64/aarch64.c (aarch64_expand_prologue): Generate dwarf annotation (REG_CFA_WINDOW_SAVE) for return address signing. (aarch64_expand_epilogue): Likewise. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 002895a167ce0deb45a5c1726527651af18bb4df..20ed79e5690f45ec121ef516245c686cc0cc82b5 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -3553,7 +3553,11 @@ aarch64_expand_prologue (void) /* Sign return address for functions. */ if (aarch64_return_address_signing_enabled ()) - emit_insn (gen_pacisp ()); + { + insn = emit_insn (gen_pacisp ()); + add_reg_note (insn, REG_CFA_WINDOW_SAVE, const0_rtx); + RTX_FRAME_RELATED_P (insn) = 1; + } if (flag_stack_usage_info) current_function_static_stack_size = frame_size; @@ -3698,7 +3702,11 @@ aarch64_expand_epilogue (bool for_sibcall) want to use the CFA of the function which calls eh_return. */ if (aarch64_return_address_signing_enabled () && (for_sibcall || !TARGET_ARMV8_3 || crtl->calls_eh_return)) - emit_insn (gen_autisp ()); + { + insn = emit_insn (gen_autisp ()); + add_reg_note (insn, REG_CFA_WINDOW_SAVE, const0_rtx); + RTX_FRAME_RELATED_P (insn) = 1; + } /* Stack adjustment for exception handler. */ if (crtl->calls_eh_return)