Blame SOURCES/0001-x86-add-endbr32-and-endbr64-instructions.patch

6694ab
From eac51dc1b6eb89e00ed2294e39949ad056287d1e Mon Sep 17 00:00:00 2001
6694ab
From: Wim Taymans <wtaymans@redhat.com>
6694ab
Date: Fri, 19 Jul 2019 16:18:04 +0200
6694ab
Subject: [PATCH] x86: add endbr32 and endbr64 instructions
6694ab
6694ab
Issue endbr instructions at the start of generated functions to
6694ab
make IBT (indirect branch tracking) work.
6694ab
6694ab
Resolves #17
6694ab
---
6694ab
 orc/orcx86.c     | 4 ++++
6694ab
 orc/orcx86insn.c | 2 ++
6694ab
 orc/orcx86insn.h | 2 ++
6694ab
 3 files changed, 8 insertions(+)
6694ab
6694ab
diff --git a/orc/orcx86.c b/orc/orcx86.c
6694ab
index 02e6b34..d4cc086 100644
6694ab
--- a/orc/orcx86.c
6694ab
+++ b/orc/orcx86.c
6694ab
@@ -452,6 +452,9 @@ orc_x86_emit_prologue (OrcCompiler *compiler)
6694ab
   orc_compiler_append_code(compiler,"%s:\n", compiler->program->name);
6694ab
   if (compiler->is_64bit) {
6694ab
     int i;
6694ab
+
6694ab
+    orc_x86_emit_cpuinsn_none (compiler, ORC_X86_endbr64);
6694ab
+
6694ab
     for(i=0;i<16;i++){
6694ab
       if (compiler->used_regs[ORC_GP_REG_BASE+i] &&
6694ab
           compiler->save_regs[ORC_GP_REG_BASE+i]) {
6694ab
@@ -459,6 +462,7 @@ orc_x86_emit_prologue (OrcCompiler *compiler)
6694ab
       }
6694ab
     }
6694ab
   } else {
6694ab
+    orc_x86_emit_cpuinsn_none (compiler, ORC_X86_endbr32);
6694ab
     orc_x86_emit_push (compiler, 4, X86_EBP);
6694ab
     if (compiler->use_frame_pointer) {
6694ab
       orc_x86_emit_mov_reg_reg (compiler, 4, X86_ESP, X86_EBP);
6694ab
diff --git a/orc/orcx86insn.c b/orc/orcx86insn.c
6694ab
index 9d93197..a9bdd9f 100644
6694ab
--- a/orc/orcx86insn.c
6694ab
+++ b/orc/orcx86insn.c
6694ab
@@ -254,6 +254,8 @@ static const OrcSysOpcode orc_x86_opcodes[] = {
6694ab
   { "pshufw", ORC_X86_INSN_TYPE_IMM8_MMXM_MMX, 0, 0x00, 0x0f70 },
6694ab
   { "movq", ORC_X86_INSN_TYPE_MMXM_MMX, 0, 0x00, 0x0f6f },
6694ab
   { "movq", ORC_X86_INSN_TYPE_MMXM_MMX_REV, 0, 0x00, 0x0f7f },
6694ab
+  { "endbr32", ORC_X86_INSN_TYPE_NONE, 0, 0xf3, 0x0f1efb },
6694ab
+  { "endbr64", ORC_X86_INSN_TYPE_NONE, 0, 0xf3, 0x0f1efa },
6694ab
 };
6694ab
 
6694ab
 static void
6694ab
diff --git a/orc/orcx86insn.h b/orc/orcx86insn.h
6694ab
index d109c95..864e5d6 100644
6694ab
--- a/orc/orcx86insn.h
6694ab
+++ b/orc/orcx86insn.h
6694ab
@@ -277,6 +277,8 @@ typedef enum {
6694ab
   ORC_X86_pshufw,
6694ab
   ORC_X86_movq_mmx_load,
6694ab
   ORC_X86_movq_mmx_store,
6694ab
+  ORC_X86_endbr32,
6694ab
+  ORC_X86_endbr64,
6694ab
 } OrcX86Opcode;
6694ab
 
6694ab
 enum {
6694ab
-- 
6694ab
2.21.0
6694ab