Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/rseq.h
- This file was added.
/*- | |||||
* Copyright (c) 2021 The FreeBSD Foundation | |||||
* | |||||
* This software were developed by Konstantin Belousov <kib@FreeBSD.org> | |||||
* under sponsorship from the FreeBSD Foundation. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
*/ | |||||
#ifndef __SYS_RSEQ_H__ | |||||
#define __SYS_RSEQ_H__ | |||||
#include <sys/cdefs.h> | |||||
#include <sys/types.h> | |||||
#include <sys/endian.h> | |||||
enum rseq_cpu_id_state { | |||||
RSEQ_CPU_ID_UNINITIALIZED = -1, | |||||
RSEQ_CPU_ID_REGISTRATION_FAILED = -2, | |||||
}; | |||||
enum rseq_flags { | |||||
RSEQ_FLAG_UNREGISTER = 1, | |||||
}; | |||||
enum rseq_cs_flags { | |||||
RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT = 0x00000001, | |||||
RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL = 0x00000002, | |||||
RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE = 0x00000004, | |||||
}; | |||||
struct rseq_cs { | |||||
uint32_t version; | |||||
uint32_t flags; | |||||
uint64_t start_ip; | |||||
uint64_t post_commit_offset; | |||||
uint64_t abort_ip; | |||||
}; | |||||
struct rseq { | |||||
uint32_t cpu_id_start; | |||||
uint32_t cpu_id; | |||||
union { | |||||
uint64_t ptr64; | |||||
#ifdef __LP64__ | |||||
uint64_t ptr; | |||||
#else | |||||
struct { | |||||
#if _BYTE_ORDER == _BIG_ENDIAN | |||||
uint32_t pad; | |||||
uint32_t ptr32; | |||||
#else /* BYTE_ORDER */ | |||||
uint32_t ptr32; | |||||
uint32_t pad; | |||||
#endif /* BYTE_ORDER */ | |||||
} ptr; | |||||
#endif /* LP64 */ | |||||
} rseq_cs; | |||||
uint32_t flags; | |||||
}; | |||||
#ifdef _KERNEL | |||||
#define TD_RSEQ_ACTIVE 0x00000001 | |||||
void rseq_ast(struct thread *td); | |||||
void rseq_before_sig(struct thread *td); | |||||
void rseq_on_sig(struct thread *td); | |||||
#else /* _KERNEL */ | |||||
__BEGIN_DECLS | |||||
extern __thread volatile struct rseq __rseq_abi __weak_symbol; | |||||
int rseq(volatile struct rseq *rseq, uint32_t rseqlen, int flags, uint32_t sig); | |||||
__END_DECLS | |||||
#endif /* _KERNEL */ | |||||
#endif /* __SYS_RSEQ_H__ */ |