All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
@ 2021-09-30 12:40 Jan Beulich via Virtualization
  2021-10-05  7:43 ` Juergen Gross via Virtualization
  2022-01-24 19:26 ` [tip: x86/paravirt] x86/paravirt: Use " tip-bot2 for Jan Beulich
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Beulich via Virtualization @ 2021-09-30 12:40 UTC (permalink / raw)
  To: Juergen Gross, Deep Shah, VMware, Inc.; +Cc: Linux Virtualization

While using a plain (constant) address works, its use needlessly invokes
a SIB addressing mode, making every call site one byte larger than
necessary. Instead of using an "i" constraint with address-of operator
and a 'c' operand modifier, simply use an ordinary "m" constraint, which
the 64-bit compiler will translate to %rip-relative addressing. This way
we also tell the compiler the truth about operand usage - the memory
location gets actually read, after all.

32-bit code generation is unaffected by the change.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -278,7 +278,7 @@ extern void (*paravirt_iret)(void);
 
 #define paravirt_type(op)				\
 	[paravirt_typenum] "i" (PARAVIRT_PATCH(op)),	\
-	[paravirt_opptr] "i" (&(pv_ops.op))
+	[paravirt_opptr] "m" (pv_ops.op)
 #define paravirt_clobber(clobber)		\
 	[paravirt_clobber] "i" (clobber)
 
@@ -315,7 +315,7 @@ int paravirt_disable_iospace(void);
  */
 #define PARAVIRT_CALL					\
 	ANNOTATE_RETPOLINE_SAFE				\
-	"call *%c[paravirt_opptr];"
+	"call *%[paravirt_opptr];"
 
 /*
  * These macros are intended to wrap calls through one of the paravirt

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
  2021-09-30 12:40 [PATCH] x86/paravirt: use %rip-relative addressing in hook calls Jan Beulich via Virtualization
@ 2021-10-05  7:43 ` Juergen Gross via Virtualization
  2021-11-23  9:29   ` Jan Beulich via Virtualization
  2022-01-24 19:26 ` [tip: x86/paravirt] x86/paravirt: Use " tip-bot2 for Jan Beulich
  1 sibling, 1 reply; 7+ messages in thread
From: Juergen Gross via Virtualization @ 2021-10-05  7:43 UTC (permalink / raw)
  To: Jan Beulich, Deep Shah, VMware, Inc.; +Cc: Linux Virtualization


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

On 30.09.21 14:40, Jan Beulich via Virtualization wrote:
> While using a plain (constant) address works, its use needlessly invokes
> a SIB addressing mode, making every call site one byte larger than
> necessary. Instead of using an "i" constraint with address-of operator
> and a 'c' operand modifier, simply use an ordinary "m" constraint, which
> the 64-bit compiler will translate to %rip-relative addressing. This way
> we also tell the compiler the truth about operand usage - the memory
> location gets actually read, after all.
> 
> 32-bit code generation is unaffected by the change.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
  2021-10-05  7:43 ` Juergen Gross via Virtualization
@ 2021-11-23  9:29   ` Jan Beulich via Virtualization
  2021-11-23  9:52     ` Juergen Gross via Virtualization
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich via Virtualization @ 2021-11-23  9:29 UTC (permalink / raw)
  To: Juergen Gross; +Cc: VMware, Inc., Linux Virtualization

On 05.10.2021 09:43, Juergen Gross wrote:
> On 30.09.21 14:40, Jan Beulich via Virtualization wrote:
>> While using a plain (constant) address works, its use needlessly invokes
>> a SIB addressing mode, making every call site one byte larger than
>> necessary. Instead of using an "i" constraint with address-of operator
>> and a 'c' operand modifier, simply use an ordinary "m" constraint, which
>> the 64-bit compiler will translate to %rip-relative addressing. This way
>> we also tell the compiler the truth about operand usage - the memory
>> location gets actually read, after all.
>>
>> 32-bit code generation is unaffected by the change.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Juergen Gross <jgross@suse.com>

Thanks. I notice this wasn't part of your 5.16-rc1 pull request, nor
did it make it into Linus'es tree via any other route. May I ask what
the plans here are?

Jan

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
  2021-11-23  9:29   ` Jan Beulich via Virtualization
@ 2021-11-23  9:52     ` Juergen Gross via Virtualization
  2022-01-10 13:26       ` Juergen Gross via Virtualization
  0 siblings, 1 reply; 7+ messages in thread
From: Juergen Gross via Virtualization @ 2021-11-23  9:52 UTC (permalink / raw)
  To: Jan Beulich, Thomas Gleixner; +Cc: VMware, Inc., Linux Virtualization


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

On 23.11.21 10:29, Jan Beulich wrote:
> On 05.10.2021 09:43, Juergen Gross wrote:
>> On 30.09.21 14:40, Jan Beulich via Virtualization wrote:
>>> While using a plain (constant) address works, its use needlessly invokes
>>> a SIB addressing mode, making every call site one byte larger than
>>> necessary. Instead of using an "i" constraint with address-of operator
>>> and a 'c' operand modifier, simply use an ordinary "m" constraint, which
>>> the 64-bit compiler will translate to %rip-relative addressing. This way
>>> we also tell the compiler the truth about operand usage - the memory
>>> location gets actually read, after all.
>>>
>>> 32-bit code generation is unaffected by the change.
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> Reviewed-by: Juergen Gross <jgross@suse.com>
> 
> Thanks. I notice this wasn't part of your 5.16-rc1 pull request, nor
> did it make it into Linus'es tree via any other route. May I ask what
> the plans here are?

I CC-ed you on the related mail I sent to the x86 maintainers:

"Re: Which tree for paravirt related patches?" on Nov 4th, and Thomas
Gleixner promised to look at your patch. Adding him to this response
again in order to remind him.


Juergen

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
  2021-11-23  9:52     ` Juergen Gross via Virtualization
@ 2022-01-10 13:26       ` Juergen Gross via Virtualization
  2022-01-10 19:31         ` Borislav Petkov
  0 siblings, 1 reply; 7+ messages in thread
From: Juergen Gross via Virtualization @ 2022-01-10 13:26 UTC (permalink / raw)
  To: Jan Beulich, Thomas Gleixner; +Cc: VMware, Inc., X86 ML, Linux Virtualization


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

On 23.11.21 10:52, Juergen Gross via Virtualization wrote:
> On 23.11.21 10:29, Jan Beulich wrote:
>> On 05.10.2021 09:43, Juergen Gross wrote:
>>> On 30.09.21 14:40, Jan Beulich via Virtualization wrote:
>>>> While using a plain (constant) address works, its use needlessly 
>>>> invokes
>>>> a SIB addressing mode, making every call site one byte larger than
>>>> necessary. Instead of using an "i" constraint with address-of operator
>>>> and a 'c' operand modifier, simply use an ordinary "m" constraint, 
>>>> which
>>>> the 64-bit compiler will translate to %rip-relative addressing. This 
>>>> way
>>>> we also tell the compiler the truth about operand usage - the memory
>>>> location gets actually read, after all.
>>>>
>>>> 32-bit code generation is unaffected by the change.
>>>>
>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> Reviewed-by: Juergen Gross <jgross@suse.com>
>>
>> Thanks. I notice this wasn't part of your 5.16-rc1 pull request, nor
>> did it make it into Linus'es tree via any other route. May I ask what
>> the plans here are?
> 
> I CC-ed you on the related mail I sent to the x86 maintainers:
> 
> "Re: Which tree for paravirt related patches?" on Nov 4th, and Thomas
> Gleixner promised to look at your patch. Adding him to this response
> again in order to remind him.

Thomas, another ping. Didn't you want to take this patch more than a
month ago? Cc-ing the other x86 maintainers, too.


Juergen

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/paravirt: use %rip-relative addressing in hook calls
  2022-01-10 13:26       ` Juergen Gross via Virtualization
@ 2022-01-10 19:31         ` Borislav Petkov
  0 siblings, 0 replies; 7+ messages in thread
From: Borislav Petkov @ 2022-01-10 19:31 UTC (permalink / raw)
  To: Juergen Gross
  Cc: VMware, Inc., Thomas Gleixner, X86 ML, Jan Beulich, Linux Virtualization

On Mon, Jan 10, 2022 at 02:26:18PM +0100, Juergen Gross wrote:
> Thomas, another ping. Didn't you want to take this patch more than a
> month ago? Cc-ing the other x86 maintainers, too.

I'll have a look after the merge window is over.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip: x86/paravirt] x86/paravirt: Use %rip-relative addressing in hook calls
  2021-09-30 12:40 [PATCH] x86/paravirt: use %rip-relative addressing in hook calls Jan Beulich via Virtualization
  2021-10-05  7:43 ` Juergen Gross via Virtualization
@ 2022-01-24 19:26 ` tip-bot2 for Jan Beulich
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot2 for Jan Beulich @ 2022-01-24 19:26 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Jan Beulich, Borislav Petkov, Juergen Gross, x86, linux-kernel

The following commit has been merged into the x86/paravirt branch of tip:

Commit-ID:     2e1f8e55f9e054b4a49ffc06c7e33b5d4725f05e
Gitweb:        https://git.kernel.org/tip/2e1f8e55f9e054b4a49ffc06c7e33b5d4725f05e
Author:        Jan Beulich <jbeulich@suse.com>
AuthorDate:    Thu, 30 Sep 2021 14:40:38 +02:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Mon, 24 Jan 2022 20:21:19 +01:00

x86/paravirt: Use %rip-relative addressing in hook calls

While using a plain (constant) address works, its use needlessly invokes
a SIB addressing mode, making every call site one byte larger than
necessary:

  ff 14 25 98 89 42 82    call   *0xffffffff82428998

Instead of using an "i" constraint with address-of operator and a 'c'
operand modifier, simply use an ordinary "m" constraint, which the
64-bit compiler will translate to %rip-relative addressing:

  ff 15 62 fb d2 00       call   *0xd2fb62(%rip)	# ffffffff82428998 <pv_ops+0x18>

This way the compiler is also told the truth about operand usage - the
memory location gets actually read, after all.

32-bit code generation is unaffected by the change.

  [ bp: Remove "we", add examples. ]

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/b8192e8a-13ef-6ac6-6364-8ba58992cd1d@suse.com
---
 arch/x86/include/asm/paravirt_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index a69012e..e159146 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -279,7 +279,7 @@ extern void (*paravirt_iret)(void);
 
 #define paravirt_type(op)				\
 	[paravirt_typenum] "i" (PARAVIRT_PATCH(op)),	\
-	[paravirt_opptr] "i" (&(pv_ops.op))
+	[paravirt_opptr] "m" (pv_ops.op)
 #define paravirt_clobber(clobber)		\
 	[paravirt_clobber] "i" (clobber)
 
@@ -316,7 +316,7 @@ int paravirt_disable_iospace(void);
  */
 #define PARAVIRT_CALL					\
 	ANNOTATE_RETPOLINE_SAFE				\
-	"call *%c[paravirt_opptr];"
+	"call *%[paravirt_opptr];"
 
 /*
  * These macros are intended to wrap calls through one of the paravirt

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-24 20:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 12:40 [PATCH] x86/paravirt: use %rip-relative addressing in hook calls Jan Beulich via Virtualization
2021-10-05  7:43 ` Juergen Gross via Virtualization
2021-11-23  9:29   ` Jan Beulich via Virtualization
2021-11-23  9:52     ` Juergen Gross via Virtualization
2022-01-10 13:26       ` Juergen Gross via Virtualization
2022-01-10 19:31         ` Borislav Petkov
2022-01-24 19:26 ` [tip: x86/paravirt] x86/paravirt: Use " tip-bot2 for Jan Beulich

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.