]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/traps: Consolidate user fixups in the #GP handler
authorSohil Mehta <sohil.mehta@intel.com>
Mon, 9 Mar 2026 18:10:26 +0000 (11:10 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Thu, 19 Mar 2026 22:11:13 +0000 (15:11 -0700)
Move the UMIP exception fixup under the common "if (user_mode(regs))"
condition where the rest of user mode fixups reside. Also, move the UMIP
feature check into its fixup function to keep the calling code
consistent and clean.

No functional change intended.

Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Link: https://patch.msgid.link/20260309181029.398498-3-sohil.mehta@intel.com
arch/x86/kernel/traps.c
arch/x86/kernel/umip.c

index 4dbff8ef9b1cda4ef92da90dfa7dee85953345c9..614a281bd419c311fd929b3770a5c8487e0cc3d6 100644 (file)
@@ -921,11 +921,6 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
 
        cond_local_irq_enable(regs);
 
-       if (static_cpu_has(X86_FEATURE_UMIP)) {
-               if (user_mode(regs) && fixup_umip_exception(regs))
-                       goto exit;
-       }
-
        if (v8086_mode(regs)) {
                local_irq_enable();
                handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
@@ -940,6 +935,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
                if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0))
                        goto exit;
 
+               if (fixup_umip_exception(regs))
+                       goto exit;
+
                gp_user_force_sig_segv(regs, X86_TRAP_GP, error_code, desc);
                goto exit;
        }
index d432f3824f0c2940e6488a40107f0f337499eab8..3ce99cbcf1874b4d0cead1daddc431a026eecccb 100644 (file)
@@ -354,6 +354,9 @@ bool fixup_umip_exception(struct pt_regs *regs)
        void __user *uaddr;
        struct insn insn;
 
+       if (!cpu_feature_enabled(X86_FEATURE_UMIP))
+               return false;
+
        if (!regs)
                return false;