3715b23
From bbcc1a69f787881f16156f3c789052942a564103 Mon Sep 17 00:00:00 2001
3715b23
From: "H.J. Lu" <hjl.tools@gmail.com>
3715b23
Date: Thu, 20 Jan 2022 05:35:49 -0800
3715b23
Subject: [PATCH] isa-l/CET: Add CET marker to x86-64 crc32 assembly codes
3715b23
3715b23
Add .note.gnu.property section to x86-64 crc32 assembly codes to mark
3715b23
for IBT and SHSTK compatibility.
3715b23
---
3715b23
 crc/crc32_gzip_refl_by16_10.asm | 9 +++++++++
3715b23
 crc/crc32_gzip_refl_by8.asm     | 9 +++++++++
3715b23
 crc/crc32_gzip_refl_by8_02.asm  | 9 +++++++++
3715b23
 crc/crc32_ieee_01.asm           | 8 ++++++++
3715b23
 crc/crc32_ieee_02.asm           | 9 +++++++++
3715b23
 crc/crc32_ieee_by16_10.asm      | 9 +++++++++
3715b23
 crc/crc32_ieee_by4.asm          | 9 +++++++++
3715b23
 crc/crc32_iscsi_00.asm          | 8 ++++++++
3715b23
 crc/crc32_iscsi_01.asm          | 8 ++++++++
3715b23
 9 files changed, 78 insertions(+)
3715b23
3715b23
diff --git a/src/isa-l/crc/crc32_gzip_refl_by16_10.asm b/src/isa-l/crc/crc32_gzip_refl_by16_10.asm
3715b23
index 40236f6..b16874d 100644
3715b23
--- a/src/isa-l/crc/crc32_gzip_refl_by16_10.asm
3715b23
+++ b/src/isa-l/crc/crc32_gzip_refl_by16_10.asm
3715b23
@@ -566,3 +566,12 @@ global no_ %+ FUNCTION_NAME
3715b23
 no_ %+ FUNCTION_NAME %+ :
3715b23
 %endif
3715b23
 %endif ; (AS_FEATURE_LEVEL) >= 10
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_gzip_refl_by8.asm b/src/isa-l/crc/crc32_gzip_refl_by8.asm
3715b23
index 62f7e7d..97b0c4a 100644
3715b23
--- a/src/isa-l/crc/crc32_gzip_refl_by8.asm
3715b23
+++ b/src/isa-l/crc/crc32_gzip_refl_by8.asm
3715b23
@@ -622,3 +622,12 @@ dq 0x0706050403020100, 0x000e0d0c0b0a0908
3715b23
 
3715b23
 ;;;       func        core, ver, snum
3715b23
 slversion crc32_gzip_refl_by8, 01,   00,  002c
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_gzip_refl_by8_02.asm b/src/isa-l/crc/crc32_gzip_refl_by8_02.asm
3715b23
index 80d849e..1d5a75f 100644
3715b23
--- a/src/isa-l/crc/crc32_gzip_refl_by8_02.asm
3715b23
+++ b/src/isa-l/crc/crc32_gzip_refl_by8_02.asm
3715b23
@@ -553,3 +553,12 @@ pshufb_shf_table:
3715b23
 ;       dq 0x060504030201008f, 0x0e0d0c0b0a090807 ; shl 1  (16-15) / shr15
3715b23
 dq 0x8786858483828100, 0x8f8e8d8c8b8a8988
3715b23
 dq 0x0706050403020100, 0x000e0d0c0b0a0908
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_ieee_01.asm b/src/isa-l/crc/crc32_ieee_01.asm
3715b23
index 32495ed..cfc443b 100644
3715b23
--- a/src/isa-l/crc/crc32_ieee_01.asm
3715b23
+++ b/src/isa-l/crc/crc32_ieee_01.asm
3715b23
@@ -653,3 +653,11 @@ dq 0x0706050403020100, 0x000e0d0c0b0a0908
3715b23
 ;;;       func        core, ver, snum
3715b23
 slversion crc32_ieee_01, 01,   06,  0011
3715b23
 
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_ieee_02.asm b/src/isa-l/crc/crc32_ieee_02.asm
3715b23
index 8a472b0..dd7096a 100644
3715b23
--- a/src/isa-l/crc/crc32_ieee_02.asm
3715b23
+++ b/src/isa-l/crc/crc32_ieee_02.asm
3715b23
@@ -649,3 +649,12 @@ pshufb_shf_table:
3715b23
 ;	dq 0x060504030201008f, 0x0e0d0c0b0a090807 ; shl 1  (16-15) / shr15
3715b23
 dq 0x8786858483828100, 0x8f8e8d8c8b8a8988
3715b23
 dq 0x0706050403020100, 0x000e0d0c0b0a0908
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_ieee_by16_10.asm b/src/isa-l/crc/crc32_ieee_by16_10.asm
3715b23
index 200fd93..2afd597 100644
3715b23
--- a/src/isa-l/crc/crc32_ieee_by16_10.asm
3715b23
+++ b/src/isa-l/crc/crc32_ieee_by16_10.asm
3715b23
@@ -582,3 +582,12 @@ global no_ %+ FUNCTION_NAME
3715b23
 no_ %+ FUNCTION_NAME %+ :
3715b23
 %endif
3715b23
 %endif ; (AS_FEATURE_LEVEL) >= 10
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_ieee_by4.asm b/src/isa-l/crc/crc32_ieee_by4.asm
3715b23
index 39bed5a..847d0bd 100644
3715b23
--- a/src/isa-l/crc/crc32_ieee_by4.asm
3715b23
+++ b/src/isa-l/crc/crc32_ieee_by4.asm
3715b23
@@ -563,3 +563,12 @@ SHUF_MASK	dq 0x08090A0B0C0D0E0F, 0x0001020304050607
3715b23
 
3715b23
 ;;;       func             core, ver, snum
3715b23
 slversion crc32_ieee_by4, 05,   02,  0017
3715b23
+
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_iscsi_00.asm b/src/isa-l/crc/crc32_iscsi_00.asm
3715b23
index 4f81e3a..3d6b2d1 100644
3715b23
--- a/src/isa-l/crc/crc32_iscsi_00.asm
3715b23
+++ b/src/isa-l/crc/crc32_iscsi_00.asm
3715b23
@@ -669,3 +669,11 @@ DD 0x54851c7f,0x89e3d7c4,0xeba4fdf8,0x36c23643
3715b23
 ;;;       func            core, ver, snum
3715b23
 slversion crc32_iscsi_00, 00,   04,  0014
3715b23
 
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
diff --git a/src/isa-l/crc/crc32_iscsi_01.asm b/src/isa-l/crc/crc32_iscsi_01.asm
3715b23
index 2a81517..c048413 100644
3715b23
--- a/src/isa-l/crc/crc32_iscsi_01.asm
3715b23
+++ b/src/isa-l/crc/crc32_iscsi_01.asm
3715b23
@@ -588,3 +588,11 @@ K_table:
3715b23
 ;;;       func            core, ver, snum
3715b23
 slversion crc32_iscsi_01, 01,   04,  0015
3715b23
 
3715b23
+%ifidn __OUTPUT_FORMAT__, elf64
3715b23
+; inform linker that this doesn't require executable stack
3715b23
+section .note.GNU-stack noalloc noexec nowrite progbits
3715b23
+; inform linker that this is compatible with IBT and SHSTK
3715b23
+section .note.gnu.property  note  alloc noexec align=8
3715b23
+DD 0x00000004,0x00000010,0x00000005,0x00554e47
3715b23
+DD 0xc0000002,0x00000004,0x00000003,0x00000000
3715b23
+%endif
3715b23
-- 
3715b23
2.34.1
3715b23