Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp548468ybh; Thu, 12 Mar 2020 06:53:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuz8Ag3hMfxJ5FpGUJ55Po6V3a1C/ygcyjFpa/R++x+hYd9cOrzTY+dL24PP+Oils95Bnia X-Received: by 2002:a9d:b8f:: with SMTP id 15mr6386884oth.256.1584021198393; Thu, 12 Mar 2020 06:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584021198; cv=none; d=google.com; s=arc-20160816; b=HwhuYj5BDTXWBGR+Qo2PICeNOpSQOW+gIg7KxnLKRhRMJJbylWPXZng+HiOaywUKul lQqR0xbrWXiJoVxh8Ynv54kmbuDwSk7Qw6+cTFIq2SYGRJUHA17z9YKsUxCHoqdGo/oW xtPZoaEMf9PHa/mNg718BXxsOEC55Bp8/KxoA+rYfdNR87akBEa8G5DDyLfruWtgB83R 1LU/cx9R+jvMjImHjbLN9McmEDSAWzsBNcSozg08i7ES5oCLTUZ6r/OGCiXlSRf9nPi7 dAXvvr7a65bt7wSQ7pO+QFPkow5Jya8yYwaPzKBm0OKCMe7X/rZctza+MGp23pQjxMxi +nmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=V7Duu4tbcIT7Gqqhjc4VX+XUii17MaHeZ72gDmdRkTE=; b=mhEaLV8wclA5h+cgFL/mlAl02LonmF5H3xA3R7X0qsWCX5iL2m2dAVIUL/Ur7fnvGd xDLS/xgk5Ck9Zx3BQGOJZLX1VmV4QdEgMijIrMvgPEtNN8fBsJCfi+b0EGvpfWtS6tWZ gtzSHaqMFY2tXJAAJiwpSQceV8gWJeSMoXPAaOZmnBtVJDrbxKyYPsPc8CQQJx0leaZn mIA9bcMZ4FKgeVHqcQKRu4ZbasCCYEwm5IUYtj0jT3yTBhhjzaiyUVSq7y6yeWIa0ztN nGG9BDmG3HOIwBXv2yzKsDYq8LUfrBR0t+FZSeSBZMpE9wHbtiXKgM+IZnZRSAVNAnqR qCGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="vxvv/eNG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si2132439oib.127.2020.03.12.06.53.05; Thu, 12 Mar 2020 06:53:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="vxvv/eNG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727618AbgCLNwQ (ORCPT + 99 others); Thu, 12 Mar 2020 09:52:16 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46840 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727461AbgCLNvl (ORCPT ); Thu, 12 Mar 2020 09:51:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=V7Duu4tbcIT7Gqqhjc4VX+XUii17MaHeZ72gDmdRkTE=; b=vxvv/eNGqAMlrl8no5cVpLOTaa mZrBClebDALcyG8VHOMlcA0Ecuatoy/bNWmdzY5qJ2RyKkP8zshaAdZ46Iopg//S9NE7U7huVMKCd K+JUpMRR5/SdqoSK3pSt0FMWNckmBLspClqMUOEFZ/57G7js5qz3Bc809Fdkx0u6cxmu+oL2ERZff oof/9wGyHFuG34q2OuWCzBnuAAY/P9PyUVlK5cqMEm4mF9S02xEYkgeNrviIkcfoDnA6dWSiU3mZc UuMy4/bafcCDsO/DBoYzlvJ+dN873Z5tGum/znxZoPm5wlFyYJqmFbRkDXSv+GUgtxUgXrCFkpK83 nm+zbdwg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCOFM-0003AQ-Nh; Thu, 12 Mar 2020 13:51:37 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 27A49303C41; Thu, 12 Mar 2020 14:51:34 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 14A382B740AE6; Thu, 12 Mar 2020 14:51:34 +0100 (CET) Message-Id: <20200312135041.641079164@infradead.org> User-Agent: quilt/0.65 Date: Thu, 12 Mar 2020 14:41:11 +0100 From: Peter Zijlstra To: tglx@linutronix.de, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org Subject: [RFC][PATCH 04/16] objtool: Annotate identity_mapped() References: <20200312134107.700205216@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Normally identity_mapped is not visible to objtool, due to: arch/x86/kernel/Makefile:OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y However, when we want to run objtool on vmlinux.o there is no hiding it. Without the annotation we'll get complaints about the: call 1f 1: popq %rB construct from the add_call_destinations() pass. Because identity_mapped() is a SYM_CODE_START_LOCAL_NOALIGN() it is STT_NOTYPE and we need sym_for_each_insn() to iterate the actual instructions. Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/kernel/relocate_kernel_64.S | 2 ++ include/linux/frame.h | 16 ++++++++++++++++ tools/objtool/check.c | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -210,6 +211,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma pushq %rax ret SYM_CODE_END(identity_mapped) +STACK_FRAME_NON_STANDARD(identity_mapped) SYM_CODE_START_LOCAL_NOALIGN(virtual_mapped) movq RSP(%r8), %rsp --- a/include/linux/frame.h +++ b/include/linux/frame.h @@ -3,6 +3,9 @@ #define _LINUX_FRAME_H #ifdef CONFIG_STACK_VALIDATION + +#ifndef __ASSEMBLY__ + /* * This macro marks the given function's stack frame as "non-standard", which * tells objtool to ignore the function when doing stack metadata validation. @@ -15,6 +18,19 @@ static void __used __section(.discard.func_stack_frame_non_standard) \ *__func_stack_frame_non_standard_##func = func +#else /* __ASSEMBLY__ */ + +#define STACK_FRAME_NON_STANDARD(func) \ + .pushsection .discard.func_stack_frame_non_standard, "aw"; \ + .align 8; \ + .type __func_stack_frame_non_standard_##func, @object; \ + .size __func_stack_frame_non_standard_##func, 8; \ +__func_stack_frame_non_standard_##func: \ + .quad func; \ + .popsection + +#endif /* __ASSEMBLY */ + #else /* !CONFIG_STACK_VALIDATION */ #define STACK_FRAME_NON_STANDARD(func) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -416,7 +416,7 @@ static void add_ignores(struct objtool_f case STT_SECTION: func = find_symbol_by_offset(rela->sym->sec, rela->addend); - if (!func || func->type != STT_FUNC) + if (!func || (func->type != STT_FUNC && func->type != STT_NOTYPE)) continue; break; @@ -425,7 +425,7 @@ static void add_ignores(struct objtool_f continue; } - func_for_each_insn(file, func, insn) + sym_for_each_insn(file, func, insn) insn->ignore = true; } }