]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
arm64: entry: Allow handling of undefined instructions from EL1
authorWill Deacon <will.deacon@arm.com>
Tue, 7 Aug 2018 12:43:06 +0000 (13:43 +0100)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:58:15 +0000 (19:58 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836802
[ Upstream commit 0bf0f444b2c49241b2b39aa3cf210d7c95ef6c34 ]

Rather than panic() when taking an undefined instruction exception from
EL1, allow a hook to be registered in case we want to emulate the
instruction, like we will for the SSBS PSTATE manipulation instructions.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/kernel/entry.S
arch/arm64/kernel/traps.c

index b225b7897956ec2ebe0b87d5017b0c8541cfcbf4..fb937e4c49531cc1a78d25001d458214e8df2179 100644 (file)
@@ -595,7 +595,7 @@ el1_undef:
        inherit_daif    pstate=x23, tmp=x2
        mov     x0, sp
        bl      do_undefinstr
-       ASM_BUG()
+       kernel_exit 1
 el1_dbg:
        /*
         * Debug exception handling
index e904f4ed49ff302363ee89df0dbb1d3520262dda..d973ceafca433d7ee5858c21c13bd54a0338c3b3 100644 (file)
@@ -276,10 +276,12 @@ static int call_undef_hook(struct pt_regs *regs)
        int (*fn)(struct pt_regs *regs, u32 instr) = NULL;
        void __user *pc = (void __user *)instruction_pointer(regs);
 
-       if (!user_mode(regs))
-               return 1;
-
-       if (compat_thumb_mode(regs)) {
+       if (!user_mode(regs)) {
+               __le32 instr_le;
+               if (probe_kernel_address((__force __le32 *)pc, instr_le))
+                       goto exit;
+               instr = le32_to_cpu(instr_le);
+       } else if (compat_thumb_mode(regs)) {
                /* 16-bit Thumb instruction */
                __le16 instr_le;
                if (get_user(instr_le, (__le16 __user *)pc))
@@ -373,6 +375,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
                return;
 
        force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
+       BUG_ON(!user_mode(regs));
 }
 
 int cpu_enable_cache_maint_trap(void *__unused)