lkml.org 
[lkml]   [2021]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/11] x86/fault: Rename no_context() to kernelmode_fixup_or_oops()
On Sun, Jan 31, 2021 at 09:24:40AM -0800, Andy Lutomirski wrote:
> The name no_context() has never been very clear. It's only called for
> faults from kernel mode, so rename it and change the no-longer-useful
> user_mode(regs) check to a WARN_ON_ONCE.
>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
> arch/x86/mm/fault.c | 28 ++++++++++------------------
> 1 file changed, 10 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 177b612c7f33..04cc98ec2423 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -693,17 +693,10 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
> }
>
> static noinline void
> -no_context(struct pt_regs *regs, unsigned long error_code,
> - unsigned long address, int signal, int si_code)
> +kernelmode_fixup_or_oops(struct pt_regs *regs, unsigned long error_code,
> + unsigned long address, int signal, int si_code)

Ew, I don't like functions with "or" in the name - they're probably not
doing one thing only as they should.

Why not simply "handle_kernel_fault" ?

Also, all the callsites now do:

if (!user_mode(regs)) {
kernelmode_fixup_or_oops
...

I guess you can push the "user_mode" check inside that function for less
hairy code at the callsites.

> {
> - if (user_mode(regs)) {
> - /*
> - * This is an implicit supervisor-mode access from user
> - * mode. Bypass all the kernel-mode recovery code and just
> - * OOPS.
> - */
> - goto oops;
> - }
> + WARN_ON_ONCE(user_mode(regs));

I guess...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

\
 
 \ /
  Last update: 2021-02-03 20:42    [W:0.169 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site