Skip to content

Commit 53ee0b7

Browse files
committed
x86: Enable Intel CET
When Intel CET is enabled, we need to include <cet.h> in assembly codes to mark Intel CET support and place _CET_ENDBR at the function entry.
1 parent dc6b04c commit 53ee0b7

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

common.h

+9
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,15 @@ please https://github.com/xianyi/OpenBLAS/issues/246
416416
#include "common_alpha.h"
417417
#endif
418418

419+
#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(__CET__) && defined(__has_include)
420+
#if __has_include(<cet.h>)
421+
#include <cet.h>
422+
#endif
423+
#endif
424+
#ifndef _CET_ENDBR
425+
#define _CET_ENDBR
426+
#endif
427+
419428
#ifdef ARCH_X86
420429
#include "common_x86.h"
421430
#endif

common_x86.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
340340
.align 16; \
341341
.globl REALNAME ;\
342342
.type REALNAME, @function; \
343-
REALNAME:
343+
REALNAME: \
344+
_CET_ENDBR
344345

345346
#ifdef PROFILE
346347
#define PROFCODE call mcount

common_x86_64.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
451451
.align 512; \
452452
.globl REALNAME ;\
453453
.type REALNAME, @function; \
454-
REALNAME:
454+
REALNAME: \
455+
_CET_ENDBR
455456

456457
#ifdef PROFILE
457458
#define PROFCODE call *mcount@GOTPCREL(%rip)

0 commit comments

Comments
 (0)