public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: "Xu, Pengfei" <pengfei.xu@intel.com>,
	"Yang, Weijiang" <weijiang.yang@intel.com>,
	"Su, Heng" <heng.su@intel.com>,
	linux-kernel@vger.kernel.org,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	pbonzini@redhat.com, x86@kernel.org
Subject: Re: [PATCH] x86/kvm, objtool: Avoid fastop ENDBR from being sealed
Date: Thu, 18 Aug 2022 09:28:28 +0200	[thread overview]
Message-ID: <Yv3qHNGBM2aU2NuA@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20220818011045.v4baekgxajylqxvh@treble>

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)

  reply	other threads:[~2022-08-18  7:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <PH0PR11MB4839B4D2FB8B8D8D52A62C7F9A629@PH0PR11MB4839.namprd11.prod.outlook.com>
2022-08-17 10:56 ` [PATCH] x86/kvm, objtool: Avoid fastop ENDBR from being sealed Peter Zijlstra
2022-08-17 16:26   ` [tip: core/urgent] " tip-bot2 for Peter Zijlstra
2022-08-18  1:10   ` [PATCH] " Josh Poimboeuf
2022-08-18  7:28     ` Peter Zijlstra [this message]
2022-08-18  7:38       ` Pengfei Xu
2022-08-18 11:06         ` Peter Zijlstra
2022-08-18 15:17           ` Josh Poimboeuf
2022-08-18  5:04   ` Pengfei Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yv3qHNGBM2aU2NuA@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=heng.su@intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pengfei.xu@intel.com \
    --cc=weijiang.yang@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox