All of lore.kernel.org
 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,
	virtualization@lists.linux-foundation.org,
	Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Deep Shah <sdeep@vmware.com>,
	"VMware, Inc." <pv-drivers@vmware.com>
Subject: Re: [PATCH v5 11/12] x86/paravirt: switch functions with custom code to ALTERNATIVE
Date: Tue, 9 Mar 2021 07:21:35 +0100	[thread overview]
Message-ID: <09410a65-a5dc-db76-d867-f6b0b968323f@suse.com> (raw)
In-Reply-To: <20210308183058.GC12548@zn.tnic>


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

On 08.03.21 19:30, Borislav Petkov wrote:
> On Mon, Mar 08, 2021 at 01:28:43PM +0100, Juergen Gross wrote:
>> diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
>> index 36cd71fa097f..04b3067f31b5 100644
>> --- a/arch/x86/include/asm/paravirt.h
>> +++ b/arch/x86/include/asm/paravirt.h
>> @@ -137,7 +137,8 @@ static inline void write_cr0(unsigned long x)
>>   
>>   static inline unsigned long read_cr2(void)
>>   {
>> -	return PVOP_CALLEE0(unsigned long, mmu.read_cr2);
>> +	return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,
>> +				"mov %%cr2, %%rax;", ~X86_FEATURE_XENPV);
> 
> Just some cursory poking first - indepth review later.
> 
> Do I see this correctly that the negated feature can be expressed with, to use
> this example here:
> 
> 	ALTERNATIVE_TERNARY(mmu.read_cr2, X86_FEATURE_XENPV, "", "mov %%cr2, %%rax;");
> 
> ?

No.

This would leave the Xen-pv case with a nop, while we need it to call
mmu.read_cr2().

In the Xen-pv case there must be _no_ alternative patching in order to
have the paravirt patching do its patching (indirect->direct call).

This is exactly the reason why I need to "not feature".

The only other solution I can think of would be a "split static_call"
handling using ALTERNATIVE_TERNARY():

ALTERNATIVE_TERNARY(initial_static_call(mmu.read_cr2),
                     X86_FEATURE_XENPV,
                     final_static_call(mmu.read_cr2),
                     "mov %%cr2, %%rax;");

with initial_static_call() doing an indirect call, while
final_static_call() would do a direct call.

Not sure we really want that.


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 --]

WARNING: multiple messages have this Message-ID (diff)
From: "Jürgen Groß via Virtualization" <virtualization@lists.linux-foundation.org>
To: Borislav Petkov <bp@alien8.de>
Cc: "VMware, Inc." <pv-drivers@vmware.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Ingo Molnar <mingo@redhat.com>, Andy Lutomirski <luto@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v5 11/12] x86/paravirt: switch functions with custom code to ALTERNATIVE
Date: Tue, 9 Mar 2021 07:21:35 +0100	[thread overview]
Message-ID: <09410a65-a5dc-db76-d867-f6b0b968323f@suse.com> (raw)
In-Reply-To: <20210308183058.GC12548@zn.tnic>


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1646 bytes --]

On 08.03.21 19:30, Borislav Petkov wrote:
> On Mon, Mar 08, 2021 at 01:28:43PM +0100, Juergen Gross wrote:
>> diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
>> index 36cd71fa097f..04b3067f31b5 100644
>> --- a/arch/x86/include/asm/paravirt.h
>> +++ b/arch/x86/include/asm/paravirt.h
>> @@ -137,7 +137,8 @@ static inline void write_cr0(unsigned long x)
>>   
>>   static inline unsigned long read_cr2(void)
>>   {
>> -	return PVOP_CALLEE0(unsigned long, mmu.read_cr2);
>> +	return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,
>> +				"mov %%cr2, %%rax;", ~X86_FEATURE_XENPV);
> 
> Just some cursory poking first - indepth review later.
> 
> Do I see this correctly that the negated feature can be expressed with, to use
> this example here:
> 
> 	ALTERNATIVE_TERNARY(mmu.read_cr2, X86_FEATURE_XENPV, "", "mov %%cr2, %%rax;");
> 
> ?

No.

This would leave the Xen-pv case with a nop, while we need it to call
mmu.read_cr2().

In the Xen-pv case there must be _no_ alternative patching in order to
have the paravirt patching do its patching (indirect->direct call).

This is exactly the reason why I need to "not feature".

The only other solution I can think of would be a "split static_call"
handling using ALTERNATIVE_TERNARY():

ALTERNATIVE_TERNARY(initial_static_call(mmu.read_cr2),
                     X86_FEATURE_XENPV,
                     final_static_call(mmu.read_cr2),
                     "mov %%cr2, %%rax;");

with initial_static_call() doing an indirect call, while
final_static_call() would do a direct call.

Not sure we really want that.


Juergen

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

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

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2021-03-09  6:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 12:28 [PATCH v5 00/12] x86: major paravirt cleanup Juergen Gross
2021-03-08 12:28 ` Juergen Gross
2021-03-08 12:28 ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 01/12] staticcall: move struct static_call_key definition to static_call_types.h Juergen Gross
2021-03-08 16:27   ` Peter Zijlstra
2021-03-08 12:28 ` [PATCH v5 02/12] x86/paravirt: switch time pvops functions to use static_call() Juergen Gross
2021-03-08 12:28   ` Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 17:00   ` Boris Ostrovsky
2021-03-08 17:00     ` Boris Ostrovsky
2021-03-08 17:00     ` Boris Ostrovsky
2021-03-09  6:14     ` Jürgen Groß
2021-03-09  6:14       ` Jürgen Groß
2021-03-09  6:14       ` Jürgen Groß via Virtualization
2021-03-08 12:28 ` [PATCH v5 03/12] x86/alternative: drop feature parameter from ALTINSTR_REPLACEMENT() Juergen Gross
2021-03-08 12:28 ` [PATCH v5 04/12] x86/alternative: support not-feature Juergen Gross
2021-03-08 12:28 ` [PATCH v5 05/12] x86/alternative: support ALTERNATIVE_TERNARY Juergen Gross
2021-03-08 12:28 ` [PATCH v5 06/12] x86: add new features for paravirt patching Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 07/12] x86/paravirt: remove no longer needed 32-bit pvops cruft Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 08/12] x86/paravirt: simplify paravirt macros Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 09/12] x86/paravirt: switch iret pvops to ALTERNATIVE Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 10/12] x86/paravirt: add new macros PVOP_ALT* supporting pvops in ALTERNATIVEs Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 12:28 ` [PATCH v5 11/12] x86/paravirt: switch functions with custom code to ALTERNATIVE Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 18:30   ` Borislav Petkov
2021-03-08 18:30     ` Borislav Petkov
2021-03-09  6:21     ` Jürgen Groß [this message]
2021-03-09  6:21       ` Jürgen Groß via Virtualization
2021-03-08 12:28 ` [PATCH v5 12/12] x86/paravirt: have only one paravirt patch function Juergen Gross
2021-03-08 12:28   ` Juergen Gross via Virtualization
2021-03-08 16:31 ` [PATCH v5 00/12] x86: major paravirt cleanup Peter Zijlstra
2021-03-08 16:31   ` Peter Zijlstra
2021-03-08 16:31   ` Peter Zijlstra

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=09410a65-a5dc-db76-d867-f6b0b968323f@suse.com \
    --to=jgross@suse.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pv-drivers@vmware.com \
    --cc=sdeep@vmware.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.