[v3,2/5] x86/entry: Rename ignore_sysret

Message ID 20230616125730.1164989-3-nik.borisov@suse.com
State New
Headers
Series Make IA32_EMULATION boot time overridable |

Commit Message

Nikolay Borisov June 16, 2023, 12:57 p.m. UTC
  Give ignore_sysret() a more descriptive name as it's actually used to make
32bit syscalls return ENOSYS, rather than doing anything specific with
regards to sysret.

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
---
 arch/x86/entry/entry_64.S        | 4 ++--
 arch/x86/include/asm/processor.h | 2 +-
 arch/x86/kernel/cpu/common.c     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Thomas Gleixner June 18, 2023, 8:51 p.m. UTC | #1
On Fri, Jun 16 2023 at 15:57, Nikolay Borisov wrote:

> Give ignore_sysret() a more descriptive name as it's actually used to make
> 32bit syscalls return ENOSYS, rather than doing anything specific with

That's not really correct. This is not about 32bit syscalls in general.

It's specifically about the SYSCALL entry point on 32bit, right?

The reason why this is required is because 32bit SYSCALL cannot be
disabled in hardware.

Thanks,

        tglx
  
Nikolay Borisov June 19, 2023, 1:30 p.m. UTC | #2
On 18.06.23 г. 23:51 ч., Thomas Gleixner wrote:
> On Fri, Jun 16 2023 at 15:57, Nikolay Borisov wrote:
> 
>> Give ignore_sysret() a more descriptive name as it's actually used to make
>> 32bit syscalls return ENOSYS, rather than doing anything specific with
> 
> That's not really correct. This is not about 32bit syscalls in general.
> 
> It's specifically about the SYSCALL entry point on 32bit, right?
> 
> The reason why this is required is because 32bit SYSCALL cannot be
> disabled in hardware.

How about:

"SYSCALL instruction cannot really be disabled in compatibility mode. 
The best that can be done is to configure the CSTAR msr with a minimal 
handler that returns directly some error value.

ignore_sysret is this minimal handler in the Linux kernel. Rename it by 
giving it a more descriptive name."

> 
> Thanks,
> 
>          tglx
> 
>
  

Patch

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index f31e286c2977..ccce0ccd8589 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1519,12 +1519,12 @@  SYM_CODE_END(asm_exc_nmi)
  * This handles SYSCALL from 32-bit code.  There is no way to program
  * MSRs to fully disable 32-bit SYSCALL.
  */
-SYM_CODE_START(ignore_sysret)
+SYM_CODE_START(entry_SYSCALL32_ignore)
 	UNWIND_HINT_END_OF_STACK
 	ENDBR
 	mov	$-ENOSYS, %eax
 	sysretl
-SYM_CODE_END(ignore_sysret)
+SYM_CODE_END(entry_SYSCALL32_ignore)
 #endif
 
 .pushsection .text, "ax"
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index a1e4fa58b357..61c10b4e3e35 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -399,7 +399,7 @@  static inline unsigned long cpu_kernelmode_gs_base(int cpu)
 	return (unsigned long)per_cpu(fixed_percpu_data.gs_base, cpu);
 }
 
-extern asmlinkage void ignore_sysret(void);
+extern asmlinkage void entry_SYSCALL32_ignore(void);
 
 /* Save actual FS/GS selectors and bases to current->thread */
 void current_save_fsgs(void);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 80710a68ef7d..b20774181e1a 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -2066,7 +2066,7 @@  void syscall_init(void)
 		    (unsigned long)(cpu_entry_stack(smp_processor_id()) + 1));
 	wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat);
 #else
-	wrmsrl_cstar((unsigned long)ignore_sysret);
+	wrmsrl_cstar((unsigned long)entry_SYSCALL32_ignore);
 	wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)GDT_ENTRY_INVALID_SEG);
 	wrmsrl_safe(MSR_IA32_SYSENTER_ESP, 0ULL);
 	wrmsrl_safe(MSR_IA32_SYSENTER_EIP, 0ULL);