Loading arch/x86/include/asm/asm.h +5 −3 Original line number Diff line number Diff line Loading @@ -7,9 +7,11 @@ # define __ASM_FORM_RAW(x) x # define __ASM_FORM_COMMA(x) x, #else # define __ASM_FORM(x) " " #x " " # define __ASM_FORM_RAW(x) #x # define __ASM_FORM_COMMA(x) " " #x "," #include <linux/stringify.h> # define __ASM_FORM(x) " " __stringify(x) " " # define __ASM_FORM_RAW(x) __stringify(x) # define __ASM_FORM_COMMA(x) " " __stringify(x) "," #endif #ifndef __x86_64__ Loading arch/x86/include/asm/emulate_prefix.h 0 → 100644 +14 −0 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_EMULATE_PREFIX_H #define _ASM_X86_EMULATE_PREFIX_H /* * Virt escape sequences to trigger instruction emulation; * ideally these would decode to 'whole' instruction and not destroy * the instruction stream; sadly this is not true for the 'kvm' one :/ */ #define __XEN_EMULATE_PREFIX 0x0f,0x0b,0x78,0x65,0x6e /* ud2 ; .ascii "xen" */ #define __KVM_EMULATE_PREFIX 0x0f,0x0b,0x6b,0x76,0x6d /* ud2 ; .ascii "kvm" */ #endif arch/x86/include/asm/insn.h +6 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ struct insn { struct insn_field immediate2; /* for 64bit imm or seg16 */ }; int emulate_prefix_size; insn_attr_t attr; unsigned char opnd_bytes; unsigned char addr_bytes; Loading Loading @@ -128,6 +129,11 @@ static inline int insn_is_evex(struct insn *insn) return (insn->vex_prefix.nbytes == 4); } static inline int insn_has_emulate_prefix(struct insn *insn) { return !!insn->emulate_prefix_size; } /* Ensure this instruction is decoded completely */ static inline int insn_complete(struct insn *insn) { Loading arch/x86/include/asm/xen/interface.h +4 −7 Original line number Diff line number Diff line Loading @@ -379,12 +379,9 @@ struct xen_pmu_arch { * Prefix forces emulation of some non-trapping instructions. * Currently only CPUID. */ #ifdef __ASSEMBLY__ #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; #define XEN_CPUID XEN_EMULATE_PREFIX cpuid #else #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" #endif #include <asm/emulate_prefix.h> #define XEN_EMULATE_PREFIX __ASM_FORM(.byte __XEN_EMULATE_PREFIX ;) #define XEN_CPUID XEN_EMULATE_PREFIX __ASM_FORM(cpuid) #endif /* _ASM_X86_XEN_INTERFACE_H */ arch/x86/kernel/kprobes/core.c +4 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,10 @@ int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn) kernel_insn_init(insn, dest, MAX_INSN_SIZE); insn_get_length(insn); /* We can not probe force emulate prefixed instruction */ if (insn_has_emulate_prefix(insn)) return 0; /* Another subsystem puts a breakpoint, failed to recover */ if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; Loading Loading
arch/x86/include/asm/asm.h +5 −3 Original line number Diff line number Diff line Loading @@ -7,9 +7,11 @@ # define __ASM_FORM_RAW(x) x # define __ASM_FORM_COMMA(x) x, #else # define __ASM_FORM(x) " " #x " " # define __ASM_FORM_RAW(x) #x # define __ASM_FORM_COMMA(x) " " #x "," #include <linux/stringify.h> # define __ASM_FORM(x) " " __stringify(x) " " # define __ASM_FORM_RAW(x) __stringify(x) # define __ASM_FORM_COMMA(x) " " __stringify(x) "," #endif #ifndef __x86_64__ Loading
arch/x86/include/asm/emulate_prefix.h 0 → 100644 +14 −0 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_EMULATE_PREFIX_H #define _ASM_X86_EMULATE_PREFIX_H /* * Virt escape sequences to trigger instruction emulation; * ideally these would decode to 'whole' instruction and not destroy * the instruction stream; sadly this is not true for the 'kvm' one :/ */ #define __XEN_EMULATE_PREFIX 0x0f,0x0b,0x78,0x65,0x6e /* ud2 ; .ascii "xen" */ #define __KVM_EMULATE_PREFIX 0x0f,0x0b,0x6b,0x76,0x6d /* ud2 ; .ascii "kvm" */ #endif
arch/x86/include/asm/insn.h +6 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ struct insn { struct insn_field immediate2; /* for 64bit imm or seg16 */ }; int emulate_prefix_size; insn_attr_t attr; unsigned char opnd_bytes; unsigned char addr_bytes; Loading Loading @@ -128,6 +129,11 @@ static inline int insn_is_evex(struct insn *insn) return (insn->vex_prefix.nbytes == 4); } static inline int insn_has_emulate_prefix(struct insn *insn) { return !!insn->emulate_prefix_size; } /* Ensure this instruction is decoded completely */ static inline int insn_complete(struct insn *insn) { Loading
arch/x86/include/asm/xen/interface.h +4 −7 Original line number Diff line number Diff line Loading @@ -379,12 +379,9 @@ struct xen_pmu_arch { * Prefix forces emulation of some non-trapping instructions. * Currently only CPUID. */ #ifdef __ASSEMBLY__ #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; #define XEN_CPUID XEN_EMULATE_PREFIX cpuid #else #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" #endif #include <asm/emulate_prefix.h> #define XEN_EMULATE_PREFIX __ASM_FORM(.byte __XEN_EMULATE_PREFIX ;) #define XEN_CPUID XEN_EMULATE_PREFIX __ASM_FORM(cpuid) #endif /* _ASM_X86_XEN_INTERFACE_H */
arch/x86/kernel/kprobes/core.c +4 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,10 @@ int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn) kernel_insn_init(insn, dest, MAX_INSN_SIZE); insn_get_length(insn); /* We can not probe force emulate prefixed instruction */ if (insn_has_emulate_prefix(insn)) return 0; /* Another subsystem puts a breakpoint, failed to recover */ if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; Loading