Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/compat/linux/linux_rseq.c
39507 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause
3
*
4
* Copyright (c) 2022 Dmitry Chagin <[email protected]>
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
* SUCH DAMAGE.
26
*/
27
28
#include <sys/param.h>
29
#include <sys/systm.h>
30
31
#ifdef COMPAT_LINUX32
32
#include <machine/../linux32/linux.h>
33
#include <machine/../linux32/linux32_proto.h>
34
#else
35
#include <machine/../linux/linux.h>
36
#include <machine/../linux/linux_proto.h>
37
#endif
38
39
40
enum linux_rseq_cpu_id_state {
41
LINUX_RSEQ_CPU_ID_UNINITIALIZED = -1,
42
LINUX_RSEQ_CPU_ID_REGISTRATION_FAILED = -2,
43
};
44
45
enum linux_rseq_flags {
46
LINUX_RSEQ_FLAG_UNREGISTER = (1 << 0),
47
};
48
49
enum linux_rseq_cs_flags_bit {
50
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = 0,
51
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = 1,
52
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = 2,
53
};
54
55
enum linux_rseq_cs_flags {
56
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT =
57
(1U << LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT),
58
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL =
59
(1U << LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT),
60
LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE =
61
(1U << LINUX_RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT),
62
};
63
64
struct linux_rseq_cs {
65
uint32_t version;
66
uint32_t flags;
67
uint64_t start_ip;
68
uint64_t post_commit_offset;
69
uint64_t abort_ip;
70
} __attribute__((aligned(4 * sizeof(uint64_t))));
71
72
struct linux_rseq {
73
uint32_t cpu_id_start;
74
uint32_t cpu_id;
75
uint64_t rseq_cs;
76
uint32_t flags;
77
} __attribute__((aligned(4 * sizeof(uint64_t))));
78
79
int
80
linux_rseq(struct thread *td, struct linux_rseq_args *args)
81
{
82
83
return (ENOSYS);
84
}
85
86