Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2590015rdb; Mon, 4 Dec 2023 01:40:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHATkfDYK4MRWK4Af+VosQuScUABBAx0Ql2oAw3aEw6MQ5z6iOD7q081TsXMaVyYX2BMpXC X-Received: by 2002:a05:6a21:a5aa:b0:18c:35a5:e3b6 with SMTP id gd42-20020a056a21a5aa00b0018c35a5e3b6mr22570174pzc.31.1701682810916; Mon, 04 Dec 2023 01:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701682810; cv=none; d=google.com; s=arc-20160816; b=s9M8K3PUCRF9e+8iuTjuNqoBI36+3FfHcDiUypk/EFE85sdTbGeJg7nHRkY7rLRltK c0GtQwarkfKcO2syIYl3bOy48vuyuvoFxXeP+ptFnyHJnOj98qj8CgtQvClNpC9+kxAP zNneWpdruSFGSossikyhU1K35ymvQuXElVDb2Ohx6FGWdpqP1h6OgJ8WPvF3stieJIbi aLGGVcYP8UeZH5+K9h6SwQjHwJgk153lboZEOsLNF2+kfpH9k+/+/rG+d2NVE7egvBsk GO0p5BcUH0fBF2BY6nMI1Zn/zNpJfgCegWyZ2euLNKBkD/y1HNFx/buMeLVlfkoZy7IH mcXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=g0iuyQNisDJC7BhdoXr7Rs7MdGYNzIIaLt95P6Iehys=; fh=abAVVA/4Ak+d0eJGu6DCh50I2ZCtyA1W4ewSFh8uvFU=; b=ZFOpFfXO3ssGFMfnFbSMCyjBMr0A/yvnQcm8XQan+dnq1BYUAWhmIy5StHqYvlKldW uG5vkHQFSoioIxH7SOLjSnIzgD5J3Rennwi+PmBlBhheZtGJLg8wYS2Tr2prsC4F3DrQ 8zlIM2WFPOWbHqqD+cKsRMYKumMPZ0Klg3ccdECowFbp9yDcdHGonnhLqaeWUDzLFhcY egqgqko0b71NTsm08l/o9WRFu3r1Q7tl/pSzNzSteiNhlap9/noPeQ4VS2jxKUIP1HQm 5sAta/lFbQue65IYgOytNvtanulgXBNW1kxkGx/BYrbl+BH+C+okEmYc9xLeEF5su5I0 1rnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Rgb1sTCn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g12-20020a056a000b8c00b006ce578f0719si861244pfj.281.2023.12.04.01.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:40:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Rgb1sTCn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 86AE8807DECD; Mon, 4 Dec 2023 01:40:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234824AbjLDJjt (ORCPT + 99 others); Mon, 4 Dec 2023 04:39:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjLDJjr (ORCPT ); Mon, 4 Dec 2023 04:39:47 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B86D2; Mon, 4 Dec 2023 01:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=g0iuyQNisDJC7BhdoXr7Rs7MdGYNzIIaLt95P6Iehys=; b=Rgb1sTCnRXLp1JXvxpNMSDS/1Z mIlwpaJ5yxcl7ADLIOhucqUrAEp0vm0h502BryZed9fq+raHpUTD06iVrwRkDVKZUj40MSRckEJgU 7MIqcb0uwH63f0WuPRUSVFkK4NNHQCKRp1GMY3nqKMgEPxuP3NWjf1ma/XmwpA1Rxe4sApMJIlTF7 pG7TeZv7icS38Q7qGYlXNqrJ04SJZZoqdiuc5rqRgl8BYUagwDU7t9cCcqgfDIG22izfvK+0sMBqq rd51IgIfKKvvRyhd56KWi+xXipG1WtvGZ/KLyVCjEjXzWjz8TgFv1AFtqWboNrrI1RkPb+DVuUEhY GEDJLQlA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rA5QZ-004KSf-0G; Mon, 04 Dec 2023 09:39:47 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 9C995300665; Mon, 4 Dec 2023 10:39:45 +0100 (CET) Message-Id: <20231204093731.812275775@infradead.org> User-Agent: quilt/0.65 Date: Mon, 04 Dec 2023 10:37:07 +0100 From: Peter Zijlstra To: Sean Christopherson , Paolo Bonzini , Josh Poimboeuf , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH 05/11] objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE References: <20231204093702.989848513@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 01:40:07 -0800 (PST) Signed-off-by: Peter Zijlstra (Intel) --- include/linux/objtool.h | 9 +++------ include/linux/objtool_types.h | 1 + tools/include/linux/objtool_types.h | 1 + tools/objtool/check.c | 28 +++++----------------------- 4 files changed, 10 insertions(+), 29 deletions(-) --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -128,15 +128,12 @@ * NOTE: The macro must be used at the beginning of a global symbol, otherwise * it will be ignored. */ -.macro VALIDATE_UNRET_BEGIN #if defined(CONFIG_NOINSTR_VALIDATION) && \ (defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_SRSO)) -.Lhere_\@: - .pushsection .discard.validate_unret - .long .Lhere_\@ - . - .popsection +#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN +#else +#define VALIDATE_UNRET_BEGIN #endif -.endm .macro REACHABLE .Lhere_\@: --- a/include/linux/objtool_types.h +++ b/include/linux/objtool_types.h @@ -61,5 +61,6 @@ struct unwind_hint { #define ANNOTYPE_RETPOLINE_SAFE 2 #define ANNOTYPE_INSTR_BEGIN 3 #define ANNOTYPE_INSTR_END 4 +#define ANNOTYPE_UNRET_BEGIN 5 #endif /* _LINUX_OBJTOOL_TYPES_H */ --- a/tools/include/linux/objtool_types.h +++ b/tools/include/linux/objtool_types.h @@ -61,5 +61,6 @@ struct unwind_hint { #define ANNOTYPE_RETPOLINE_SAFE 2 #define ANNOTYPE_INSTR_BEGIN 3 #define ANNOTYPE_INSTR_END 4 +#define ANNOTYPE_UNRET_BEGIN 5 #endif /* _LINUX_OBJTOOL_TYPES_H */ --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2385,33 +2385,15 @@ static int __annotate_instr(int type, st return 0; } -static int read_validate_unret_hints(struct objtool_file *file) +static int __annotate_unret(int type, struct instruction *insn) { - struct section *rsec; - struct instruction *insn; - struct reloc *reloc; - - rsec = find_section_by_name(file->elf, ".rela.discard.validate_unret"); - if (!rsec) + if (type != ANNOTYPE_UNRET_BEGIN) return 0; - for_each_reloc(rsec, reloc) { - if (reloc->sym->type != STT_SECTION) { - WARN("unexpected relocation symbol type in %s", rsec->name); - return -1; - } - - insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); - if (!insn) { - WARN("bad .discard.instr_end entry"); - return -1; - } - insn->unret = 1; - } - + insn->unret = 1; return 0; -} +} static int read_intra_function_calls(struct objtool_file *file) { @@ -2629,7 +2611,7 @@ static int decode_sections(struct objtoo if (ret) return ret; - ret = read_validate_unret_hints(file); + ret = read_annotate(file, __annotate_unret); if (ret) return ret;