Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp134964rwb; Thu, 18 Aug 2022 00:38:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5pbFq2eK5bKKTOpxz09D3thvQTLlxGq3/S2OwPw+pOsBzV2YXGWva7BxUzwxMBN3XYgsBJ X-Received: by 2002:a05:6402:38c:b0:446:80e:fd43 with SMTP id o12-20020a056402038c00b00446080efd43mr1263720edv.404.1660808339140; Thu, 18 Aug 2022 00:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660808339; cv=none; d=google.com; s=arc-20160816; b=YmaUddNfX9QI9BIRsEkhB8Ybkun+nYUi8S5Bs2i9k63PYoznKoCBceeKsrvY5scD0W oakPleKg1YBlX4HSXpGNvjDXR+xHuwDLQ8NqRopnSwU6onPe4gXg89vv3DkeCRJn7tE8 1bk3icMoerzIyn95Opahiuprl3SnzKgdEaX+NCH/ksOkaQeNda2AqyfNWHl1rDsV9FOm D78yYX/gn1FFnJOk8E+cKjhta/hyY5uEVmRsUvUVZ9KbcOHWa4EYYxz4g+xxvKD/nkES Dvv6ZAUzTEjVBIOpBTd0LVikEwaEwRrxRROVHIydCB3Nt48mifxZytddhPD1SmOBuISd oOBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pW1/5rYq0S/VSHO+khmNewkH3TTeLKwfeQrhQZaS0bE=; b=J6ACLtZEFJvQl6+UjYLDxmukjc3LO2CioeNIf2jSm8WVLfQ2Uu4oOr65BDuMwhcFXu cKKOnImc5VGLtWHZR6WvSzekDahkq2YNoreuTGoPbbNOc5biS+LXe5v7REOViSYy61IA AAGSIDWDkjikPpbsecPDG/x8vRlOmjRkB/C5eZ49NB9QJmwTLwRQ/KGBk7/o1auA1n0y DQT1B/+TMLN7Y0I7+xJZbmzG2h59K/XdspsXmFrOlnhZcSf7mK76FPh/StGjuHZOizhM mtSeKuw5sC5QeMVi2HfC33hiad7n8mGk1fq9HQ+wmzAF0OCqZAVUGQ/VCSb5hdzNDndX kaCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=JmPNsclJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v27-20020a1709063bdb00b0073139e03ee7si520498ejf.280.2022.08.18.00.38.33; Thu, 18 Aug 2022 00:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=JmPNsclJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243791AbiHRH2v (ORCPT + 99 others); Thu, 18 Aug 2022 03:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241717AbiHRH2u (ORCPT ); Thu, 18 Aug 2022 03:28:50 -0400 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 2FC9E4E613 for ; Thu, 18 Aug 2022 00:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pW1/5rYq0S/VSHO+khmNewkH3TTeLKwfeQrhQZaS0bE=; b=JmPNsclJgWX0IB/5CwfFlGKdzP PoK1LL9VsZvW5crT4lLZAyHbxBTAJBe8dIXfOF7uoXL1bOh85p3DkdQWf2hgC4AfhkYmToJZP9biK xVbjLMknEjiP9D3RbXVP5IEOVrANxZIWW+rFb/D2sZH3qQIiRo/ceRw9DcQ+1Wdh7A9efjllGNJvj lqTbcvUelfHeKMoStByY8KBcgLIUfOp0+i4oO3R+O1fNXMZzx2voQe5+PAys7HpR16Bn35xisWmNa lnDrLvSwIua3YA6JvboJudfnn9J6cLndBW5vRwmvfm5Etm6HOtmtSQTGNSJv5kxfZkxw1TFRKsask 8Iv5znxw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOZxA-003WFE-HT; Thu, 18 Aug 2022 07:28:33 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id B99A1980083; Thu, 18 Aug 2022 09:28:28 +0200 (CEST) Date: Thu, 18 Aug 2022 09:28:28 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: "Xu, Pengfei" , "Yang, Weijiang" , "Su, Heng" , linux-kernel@vger.kernel.org, Josh Poimboeuf , pbonzini@redhat.com, x86@kernel.org Subject: Re: [PATCH] x86/kvm, objtool: Avoid fastop ENDBR from being sealed Message-ID: References: <20220818011045.v4baekgxajylqxvh@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220818011045.v4baekgxajylqxvh@treble> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2022 at 06:10:45PM -0700, Josh Poimboeuf wrote: > On Wed, Aug 17, 2022 at 12:56:15PM +0200, Peter Zijlstra wrote: > > Add (yet another) annotation to inhibit objtool from sealing a specific > > ENDBR instance. > > Nah, just add a throwaway reference to the function. Then no objtool > change is needed: Nice!, should I 'borrow' this and respin the patch or you want to make a real patch out of it? > diff --git a/arch/x86/include/asm/ibt.h b/arch/x86/include/asm/ibt.h > index 689880eca9ba..3ae795150374 100644 > --- a/arch/x86/include/asm/ibt.h > +++ b/arch/x86/include/asm/ibt.h > @@ -31,6 +31,16 @@ > > #define __noendbr __attribute__((nocf_check)) > > +/* > + * Create a dummy function pointer reference to prevent objtool from marking > + * the function as needing to be "sealed" (i.e. ENDBR converted to NOP by > + * apply_ibt_endbr()). > + */ > +#define IBT_NOSEAL(fname) \ > + ".pushsection .discard.endbr.noseal\n\t" \ > + _ASM_PTR fname "\n\t" \ > + ".popsection\n\t" > + > static inline __attribute_const__ u32 gen_endbr(void) > { > u32 endbr; > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index f8382abe22ff..88623add0db4 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -316,7 +316,8 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); > ".align " __stringify(FASTOP_SIZE) " \n\t" \ > ".type " name ", @function \n\t" \ > name ":\n\t" \ > - ASM_ENDBR > + ASM_ENDBR \ > + IBT_NOSEAL(name) > > #define FOP_FUNC(name) \ > __FOP_FUNC(#name)