mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Borislav Petkov <bp@alien8.de>
Cc: xen-devel@lists.xenproject.org, x86@kernel.org,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v6 04/12] x86/alternative: support not-feature
Date: Wed, 10 Mar 2021 08:52:40 +0100	[thread overview]
Message-ID: <1b95376a-56e1-ab3e-aa85-73a9d38aaaf7@suse.com> (raw)
In-Reply-To: <20210310060705.GB23521@zn.tnic>


[-- Attachment #1.1.1: Type: text/plain, Size: 2634 bytes --]

On 10.03.21 07:07, Borislav Petkov wrote:
> On Tue, Mar 09, 2021 at 02:48:05PM +0100, Juergen Gross wrote:
>> Add support for alternative patching for the case a feature is not
>> present on the current cpu.
>>
>> For users of ALTERNATIVE() and friends an inverted feature is specified
>> by applying the ALT_NOT() macro to it, e.g.:
>>
>> ALTERNATIVE(old, new, ALT_NOT(feature))
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> V5:
>> - split off from next patch
>> - reworked to use flag byte (Boris Petkov)
>> V6:
>> - rework again to not use flag byte (Boris Petkov)
>> ---
>>   arch/x86/include/asm/alternative-asm.h |  3 +++
>>   arch/x86/include/asm/alternative.h     |  3 +++
>>   arch/x86/kernel/alternative.c          | 19 ++++++++++++++-----
>>   3 files changed, 20 insertions(+), 5 deletions(-)
> 
> LGTM, minor touchups I'd do ontop:
> 
> ---
> 
> diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
> index 89889618ae01..fd205cdcfbad 100644
> --- a/arch/x86/include/asm/alternative.h
> +++ b/arch/x86/include/asm/alternative.h
> @@ -55,18 +55,18 @@
>   	".long 999b - .\n\t"					\
>   	".popsection\n\t"
>   
> +#define ALTINSTR_FLAG_INV	(1 << 15)
> +#define ALT_NOT(feat)		((feat) | ALTINSTR_FLAG_INV)
> +
>   struct alt_instr {
>   	s32 instr_offset;	/* original instruction */
>   	s32 repl_offset;	/* offset to replacement instruction */
>   	u16 cpuid;		/* cpuid bit set for replacement */
> -#define ALTINSTR_FLAG_INV (1 << 15)
>   	u8  instrlen;		/* length of original instruction */
>   	u8  replacementlen;	/* length of new instruction */
>   	u8  padlen;		/* length of build-time padding */
>   } __packed;
>   
> -#define ALT_NOT(feat)	((feat) | ALTINSTR_FLAG_INV)
> -

Did you look at patch 13? :-)

>   /*
>    * Debug flag that can be tested to see whether alternative
>    * instructions were patched in already:
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index d8e669a1546f..133b549dc091 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -397,9 +397,10 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
>   		BUG_ON(feature >= (NCAPINTS + NBUGINTS) * 32);
>   
>   		/*
> -		 * Drop out if either:
> -		 * - feature not available, but required, or
> -		 * - feature available, but NOT required
> +		 * Patch if either:
> +		 * - feature is present
> +		 * - feature not present but ALTINSTR_FLAG_INV is set to mean,
> +		 *   patch if feature is *NOT* present.

Okay.


Juergen

[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2021-03-10  7:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 13:48 [PATCH v6 00/12] x86: major paravirt cleanup Juergen Gross
2021-03-09 13:48 ` [PATCH v6 01/12] static_call: move struct static_call_key definition to static_call_types.h Juergen Gross
2021-03-09 13:48 ` [PATCH v6 02/12] x86/paravirt: switch time pvops functions to use static_call() Juergen Gross
2021-03-09 18:57   ` Borislav Petkov
2021-03-10  7:51     ` Jürgen Groß
2021-03-10 14:13       ` Borislav Petkov
2021-03-09 13:48 ` [PATCH v6 03/12] x86/alternative: drop feature parameter from ALTINSTR_REPLACEMENT() Juergen Gross
2021-03-09 19:17   ` [tip: x86/alternatives] x86/alternative: Drop unused " tip-bot2 for Juergen Gross
2021-03-09 13:48 ` [PATCH v6 04/12] x86/alternative: support not-feature Juergen Gross
2021-03-10  6:07   ` Borislav Petkov
2021-03-10  7:52     ` Jürgen Groß [this message]
2021-03-10 14:15       ` Borislav Petkov
2021-03-10 14:41         ` Jürgen Groß
2021-03-09 13:48 ` [PATCH v6 05/12] x86/alternative: support ALTERNATIVE_TERNARY Juergen Gross
2021-03-10 14:27   ` Borislav Petkov
2021-03-10 14:42     ` Jürgen Groß
2021-03-09 13:48 ` [PATCH v6 06/12] x86: add new features for paravirt patching Juergen Gross
2021-03-09 13:48 ` [PATCH v6 07/12] x86/paravirt: remove no longer needed 32-bit pvops cruft Juergen Gross
2021-03-09 13:48 ` [PATCH v6 08/12] x86/paravirt: simplify paravirt macros Juergen Gross
2021-03-09 13:48 ` [PATCH v6 09/12] x86/paravirt: switch iret pvops to ALTERNATIVE Juergen Gross
2021-03-09 13:48 ` [PATCH v6 10/12] x86/paravirt: add new macros PVOP_ALT* supporting pvops in ALTERNATIVEs Juergen Gross
2021-03-09 13:48 ` [PATCH v6 11/12] x86/paravirt: switch functions with custom code to ALTERNATIVE Juergen Gross
2021-03-09 13:48 ` [PATCH v6 12/12] x86/paravirt: have only one paravirt patch function Juergen Gross
2021-03-09 16:06 ` [PATCH v6 13/12] x86/alternative: merge include files Juergen Gross
2021-03-09 16:06   ` [PATCH v6 14/12] x86/alternative: don't open code ALTERNATIVE_TERNARY() in _static_cpu_has() Juergen Gross
2021-03-11 12:50 ` [PATCH v6 00/12] x86: major paravirt cleanup Borislav Petkov
2021-03-11 12:51   ` Borislav Petkov
2021-03-11 13:09     ` Jürgen Groß

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=1b95376a-56e1-ab3e-aa85-73a9d38aaaf7@suse.com \
    --to=jgross@suse.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.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

all inboxes | Powered by JetHome®