Zephyr API Documentation
4.2.0-rc3
A Scalable Open Source RTOS
4.2.0-rc3
Toggle main menu visibility
Main Page
Related Pages
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Enumerator
Files
File List
Globals
All
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
$
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
x
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Macros
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Zephyr API Documentation
Introduction
Deprecated List
Topics
Data Structures
Files
File List
doc
kernel
lib
modules
subsys
zephyr
acpi
app_memory
arch
audio
bluetooth
canbus
console
crypto
data
debug
devicetree
dfu
display
drivers
dsp
dt-bindings
fs
input
internal
ipc
kernel
linker
llext
logging
lorawan
math
mem_mgmt
mgmt
misc
modbus
modem
multi_heap
net
platform
pm
pmci
portability
posix
psa
random
retention
rtio
sd
sensing
settings
shell
sip_svc
stats
storage
sys
internal
__assert.h
atomic.h
atomic_arch.h
atomic_builtin.h
atomic_c.h
atomic_types.h
barrier.h
barrier_builtin.h
base64.h
bitarray.h
byteorder.h
cbprintf.h
cbprintf_cxx.h
cbprintf_enums.h
cbprintf_internal.h
check.h
clock.h
crc.h
device_mmio.h
dlist.h
errno_private.h
fdtable.h
hash_function.h
hash_map.h
hash_map_api.h
hash_map_cxx.h
hash_map_oa_lp.h
hash_map_sc.h
heap_listener.h
iterable_sections.h
kobject.h
libc-hooks.h
linear_range.h
list_gen.h
math_extras.h
math_extras_impl.h
mem_blocks.h
mem_manage.h
mem_stats.h
min_heap.h
mpsc_lockfree.h
mpsc_packet.h
mpsc_pbuf.h
multi_heap.h
mutex.h
notify.h
onoff.h
p4wq.h
poweroff.h
printk-hooks.h
printk.h
rb.h
reboot.h
ring_buffer.h
sem.h
sflist.h
slist.h
speculation.h
spsc_lockfree.h
spsc_pbuf.h
sys_heap.h
sys_io.h
time_units.h
timeutil.h
util.h
util_internal.h
util_internal_is_eq.h
util_internal_util_dec.h
util_internal_util_inc.h
util_internal_util_x2.h
util_listify.h
util_loops.h
util_macro.h
uuid.h
winstream.h
task_wdt
timing
toolchain
tracing
usb
usb_c
xen
zbus
zvfs
bindesc.h
cache.h
device.h
devicetree.h
fatal.h
fatal_types.h
init.h
irq.h
irq_multilevel.h
irq_nextlevel.h
irq_offload.h
kernel.h
kernel_includes.h
kernel_structs.h
kernel_version.h
net_buf.h
service.h
shared_irq.h
smf.h
spinlock.h
sw_isr_table.h
sys_clock.h
syscall.h
toolchain.h
types.h
Globals
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
speculation.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Intel Corporation.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
#ifndef ZEPHYR_MISC_SPECULATION_H
8
#define ZEPHYR_MISC_SPECULATION_H
9
10
#include <
zephyr/types.h
>
11
33
static
inline
uint32_t
k_array_index_sanitize
(
uint32_t
index,
uint32_t
array_size)
34
{
35
#ifdef CONFIG_BOUNDS_CHECK_BYPASS_MITIGATION
36
int32_t
signed_index = index, signed_array_size = array_size;
37
38
/* Take the difference between index and max.
39
* A proper value will result in a negative result. We also AND in
40
* the complement of index, so that we automatically reject any large
41
* indexes which would wrap around the difference calculation.
42
*
43
* Sign-extend just the sign bit to produce a mask of all 1s (accept)
44
* or all 0s (truncate).
45
*/
46
uint32_t
mask = ((signed_index - signed_array_size) & ~signed_index) >> 31;
47
48
return
index & mask;
49
#else
50
ARG_UNUSED(array_size);
51
52
return
index;
53
#endif
/* CONFIG_BOUNDS_CHECK_BYPASS_MITIGATION */
54
}
33
static
inline
uint32_t
k_array_index_sanitize
(
uint32_t
index,
uint32_t
array_size) {
…
}
55
#endif
/* ZEPHYR_MISC_SPECULATION_H */
types.h
k_array_index_sanitize
static uint32_t k_array_index_sanitize(uint32_t index, uint32_t array_size)
Sanitize an array index against bounds check bypass attacks aka the Spectre V1 vulnerability.
Definition
speculation.h:33
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:90
int32_t
__INT32_TYPE__ int32_t
Definition
stdint.h:74
zephyr
sys
speculation.h
Generated on
for Zephyr API Documentation by
1.14.0