Merge branch 'x86-paravirt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / arch / x86 / kernel / kprobes / opt.c
index e77a895a9ecc3a1a161b08c567f95627a988b5be..9d4aedece363cc28c696be0dbfa1af8deaba9fa3 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  *  Kernel Probes Jump Optimization (Optprobes)
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
  * Copyright (C) IBM Corporation, 2002, 2004
  * Copyright (C) Hitachi Ltd., 2012
  */
@@ -115,14 +102,15 @@ asm (
                        "optprobe_template_call:\n"
                        ASM_NOP5
                        /* Move flags to rsp */
-                       "       movq 144(%rsp), %rdx\n"
-                       "       movq %rdx, 152(%rsp)\n"
+                       "       movq 18*8(%rsp), %rdx\n"
+                       "       movq %rdx, 19*8(%rsp)\n"
                        RESTORE_REGS_STRING
                        /* Skip flags entry */
                        "       addq $8, %rsp\n"
                        "       popfq\n"
 #else /* CONFIG_X86_32 */
-                       "       pushf\n"
+                       "       pushl %esp\n"
+                       "       pushfl\n"
                        SAVE_REGS_STRING
                        "       movl %esp, %edx\n"
                        ".global optprobe_template_val\n"
@@ -131,9 +119,13 @@ asm (
                        ".global optprobe_template_call\n"
                        "optprobe_template_call:\n"
                        ASM_NOP5
+                       /* Move flags into esp */
+                       "       movl 14*4(%esp), %edx\n"
+                       "       movl %edx, 15*4(%esp)\n"
                        RESTORE_REGS_STRING
-                       "       addl $4, %esp\n"        /* skip cs */
-                       "       popf\n"
+                       /* Skip flags entry */
+                       "       addl $4, %esp\n"
+                       "       popfl\n"
 #endif
                        ".global optprobe_template_end\n"
                        "optprobe_template_end:\n"
@@ -165,10 +157,9 @@ optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
        } else {
                struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
                /* Save skipped registers */
-#ifdef CONFIG_X86_64
                regs->cs = __KERNEL_CS;
-#else
-               regs->cs = __KERNEL_CS | get_kernel_rpl();
+#ifdef CONFIG_X86_32
+               regs->cs |= get_kernel_rpl();
                regs->gs = 0;
 #endif
                regs->ip = (unsigned long)op->kp.addr + INT3_SIZE;