Path: blob/main/contrib/llvm-project/libunwind/src/cet_unwind.h
35148 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//7//===----------------------------------------------------------------------===//89#ifndef LIBUNWIND_CET_UNWIND_H10#define LIBUNWIND_CET_UNWIND_H1112#include "libunwind.h"1314// Currently, CET is implemented on Linux x86 platforms.15#if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__)16#define _LIBUNWIND_USE_CET 117#endif1819#if defined(_LIBUNWIND_USE_CET)20#include <cet.h>21#include <immintrin.h>2223#define _LIBUNWIND_POP_CET_SSP(x) \24do { \25unsigned long ssp = _get_ssp(); \26if (ssp != 0) { \27unsigned int tmp = (x); \28while (tmp > 255) { \29_inc_ssp(255); \30tmp -= 255; \31} \32_inc_ssp(tmp); \33} \34} while (0)35#endif3637// On AArch64 we use _LIBUNWIND_USE_GCS to indicate that GCS is supported. We38// need to guard any use of GCS instructions with __chkfeat though, as GCS may39// not be enabled.40#if defined(_LIBUNWIND_TARGET_AARCH64) && defined(__ARM_FEATURE_GCS_DEFAULT)41#include <arm_acle.h>4243// We can only use GCS if arm_acle.h defines the GCS intrinsics.44#ifdef _CHKFEAT_GCS45#define _LIBUNWIND_USE_GCS 146#endif4748#define _LIBUNWIND_POP_CET_SSP(x) \49do { \50if (__chkfeat(_CHKFEAT_GCS)) { \51unsigned tmp = (x); \52while (tmp--) \53__gcspopm(); \54} \55} while (0)5657#endif5859extern void *__libunwind_cet_get_registers(unw_cursor_t *);60extern void *__libunwind_cet_get_jump_target(void);6162#endif636465