[PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()

Steven Rostedt posted 6 patches 9 months, 2 weeks ago
There is a newer version of this series
[PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Steven Rostedt 9 months, 2 weeks ago
From: Josh Poimboeuf <jpoimboe@kernel.org>

Use the CFI macros instead of the raw .cfi_* directives to be consistent
with the rest of the VDSO asm.  It's also easier on the eyes.

No functional changes.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 arch/x86/entry/vdso/vsgx.S | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S
index c0342238c976..8d7b8eb45c50 100644
--- a/arch/x86/entry/vdso/vsgx.S
+++ b/arch/x86/entry/vdso/vsgx.S
@@ -24,13 +24,14 @@
 .section .text, "ax"
 
 SYM_FUNC_START(__vdso_sgx_enter_enclave)
+	SYM_F_ALIGN
 	push	%rbp
-	.cfi_adjust_cfa_offset	8
-	.cfi_rel_offset		%rbp, 0
+	CFI_ADJUST_CFA_OFFSET	8
+	CFI_REL_OFFSET		%rbp, 0
 	mov	%rsp, %rbp
-	.cfi_def_cfa_register	%rbp
+	CFI_DEF_CFA_REGISTER	%rbp
 	push	%rbx
-	.cfi_rel_offset		%rbx, -8
+	CFI_REL_OFFSET		%rbx, -8
 
 	mov	%ecx, %eax
 .Lenter_enclave:
@@ -77,13 +78,11 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave)
 .Lout:
 	pop	%rbx
 	leave
-	.cfi_def_cfa		%rsp, 8
+	CFI_DEF_CFA		%rsp, 8
 	RET
 
-	/* The out-of-line code runs with the pre-leave stack frame. */
-	.cfi_def_cfa		%rbp, 16
-
 .Linvalid_input:
+	CFI_DEF_CFA		%rbp, 16
 	mov	$(-EINVAL), %eax
 	jmp	.Lout
 
-- 
2.47.2
Re: [PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Josh Poimboeuf 9 months, 2 weeks ago
On Thu, Apr 24, 2025 at 10:37:55PM -0400, Steven Rostedt wrote:
> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> Use the CFI macros instead of the raw .cfi_* directives to be consistent
> with the rest of the VDSO asm.  It's also easier on the eyes.
> 
> No functional changes.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  arch/x86/entry/vdso/vsgx.S | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S
> index c0342238c976..8d7b8eb45c50 100644
> --- a/arch/x86/entry/vdso/vsgx.S
> +++ b/arch/x86/entry/vdso/vsgx.S
> @@ -24,13 +24,14 @@
>  .section .text, "ax"
>  
>  SYM_FUNC_START(__vdso_sgx_enter_enclave)
> +	SYM_F_ALIGN

I'm not sure why I had this SYM_F_ALIGN here, but it doesn't belong here
and can be removed.

-- 
Josh
Re: [PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Indu Bhagat 9 months, 2 weeks ago
On 4/24/25 7:37 PM, Steven Rostedt wrote:
> From: Josh Poimboeuf <jpoimboe@kernel.org>
> 
> Use the CFI macros instead of the raw .cfi_* directives to be consistent
> with the rest of the VDSO asm.  It's also easier on the eyes.
> 
> No functional changes.
> 

Although unrelated to the current intent of the patch, a question:

   Why does the stub after .Linvoke_userspace_handler in vsgs.S not have 
CFI directives ?

> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>   arch/x86/entry/vdso/vsgx.S | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S
> index c0342238c976..8d7b8eb45c50 100644
> --- a/arch/x86/entry/vdso/vsgx.S
> +++ b/arch/x86/entry/vdso/vsgx.S
> @@ -24,13 +24,14 @@
>   .section .text, "ax"
>   
>   SYM_FUNC_START(__vdso_sgx_enter_enclave)
> +	SYM_F_ALIGN
>   	push	%rbp
> -	.cfi_adjust_cfa_offset	8
> -	.cfi_rel_offset		%rbp, 0
> +	CFI_ADJUST_CFA_OFFSET	8
> +	CFI_REL_OFFSET		%rbp, 0
>   	mov	%rsp, %rbp
> -	.cfi_def_cfa_register	%rbp
> +	CFI_DEF_CFA_REGISTER	%rbp
>   	push	%rbx
> -	.cfi_rel_offset		%rbx, -8
> +	CFI_REL_OFFSET		%rbx, -8
>   
>   	mov	%ecx, %eax
>   .Lenter_enclave:
> @@ -77,13 +78,11 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave)
>   .Lout:
>   	pop	%rbx
>   	leave
> -	.cfi_def_cfa		%rsp, 8
> +	CFI_DEF_CFA		%rsp, 8
>   	RET
>   
> -	/* The out-of-line code runs with the pre-leave stack frame. */
> -	.cfi_def_cfa		%rbp, 16
> -
>   .Linvalid_input:
> +	CFI_DEF_CFA		%rbp, 16
>   	mov	$(-EINVAL), %eax
>   	jmp	.Lout
>
Re: [PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Josh Poimboeuf 9 months, 2 weeks ago
On Fri, Apr 25, 2025 at 04:22:22PM -0700, Indu Bhagat wrote:
> On 4/24/25 7:37 PM, Steven Rostedt wrote:
> > From: Josh Poimboeuf <jpoimboe@kernel.org>
> > 
> > Use the CFI macros instead of the raw .cfi_* directives to be consistent
> > with the rest of the VDSO asm.  It's also easier on the eyes.
> > 
> > No functional changes.
> > 
> 
> Although unrelated to the current intent of the patch, a question:
> 
>   Why does the stub after .Linvoke_userspace_handler in vsgs.S not have CFI
> directives ?

Yeah, looks like that stack alignment code needs some CFI.

-- 
Josh
Re: [PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Josh Poimboeuf 9 months, 2 weeks ago
On Mon, Apr 28, 2025 at 09:17:01AM -0700, Josh Poimboeuf wrote:
> On Fri, Apr 25, 2025 at 04:22:22PM -0700, Indu Bhagat wrote:
> > On 4/24/25 7:37 PM, Steven Rostedt wrote:
> > > From: Josh Poimboeuf <jpoimboe@kernel.org>
> > > 
> > > Use the CFI macros instead of the raw .cfi_* directives to be consistent
> > > with the rest of the VDSO asm.  It's also easier on the eyes.
> > > 
> > > No functional changes.
> > > 
> > 
> > Although unrelated to the current intent of the patch, a question:
> > 
> >   Why does the stub after .Linvoke_userspace_handler in vsgs.S not have CFI
> > directives ?
> 
> Yeah, looks like that stack alignment code needs some CFI.

Actually, this function uses a frame pointer so I think the stack
pointer alignment shouldn't affect the CFI?

-- 
Josh
Re: [PATCH 5/6] x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
Posted by Indu Bhagat 9 months, 2 weeks ago
On 4/28/25 10:10 AM, Josh Poimboeuf wrote:
> On Mon, Apr 28, 2025 at 09:17:01AM -0700, Josh Poimboeuf wrote:
>> On Fri, Apr 25, 2025 at 04:22:22PM -0700, Indu Bhagat wrote:
>>> On 4/24/25 7:37 PM, Steven Rostedt wrote:
>>>> From: Josh Poimboeuf <jpoimboe@kernel.org>
>>>>
>>>> Use the CFI macros instead of the raw .cfi_* directives to be consistent
>>>> with the rest of the VDSO asm.  It's also easier on the eyes.
>>>>
>>>> No functional changes.
>>>>
>>>
>>> Although unrelated to the current intent of the patch, a question:
>>>
>>>    Why does the stub after .Linvoke_userspace_handler in vsgs.S not have CFI
>>> directives ?
>>
>> Yeah, looks like that stack alignment code needs some CFI.
> 
> Actually, this function uses a frame pointer so I think the stack
> pointer alignment shouldn't affect the CFI?
> 

You are right.  rbx is already handled too with the required CFI in the 
prologue.