Warning: This file is not a C or C++ file. It does not have highlighting.
1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
---|---|
2 | /* |
3 | * Copyright (C) 2024 ARM Ltd. |
4 | */ |
5 | |
6 | #ifndef __ASM_RSI_H_ |
7 | #define __ASM_RSI_H_ |
8 | |
9 | #include <linux/errno.h> |
10 | #include <linux/jump_label.h> |
11 | #include <asm/rsi_cmds.h> |
12 | |
13 | #define RSI_PDEV_NAME "arm-cca-dev" |
14 | |
15 | DECLARE_STATIC_KEY_FALSE(rsi_present); |
16 | |
17 | void __init arm64_rsi_init(void); |
18 | |
19 | bool __arm64_is_protected_mmio(phys_addr_t base, size_t size); |
20 | |
21 | static inline bool is_realm_world(void) |
22 | { |
23 | return static_branch_unlikely(&rsi_present); |
24 | } |
25 | |
26 | static inline int rsi_set_memory_range(phys_addr_t start, phys_addr_t end, |
27 | enum ripas state, unsigned long flags) |
28 | { |
29 | unsigned long ret; |
30 | phys_addr_t top; |
31 | |
32 | while (start != end) { |
33 | ret = rsi_set_addr_range_state(start, end, state, flags, &top); |
34 | if (ret || top < start || top > end) |
35 | return -EINVAL; |
36 | start = top; |
37 | } |
38 | |
39 | return 0; |
40 | } |
41 | |
42 | /* |
43 | * Convert the specified range to RAM. Do not use this if you rely on the |
44 | * contents of a page that may already be in RAM state. |
45 | */ |
46 | static inline int rsi_set_memory_range_protected(phys_addr_t start, |
47 | phys_addr_t end) |
48 | { |
49 | return rsi_set_memory_range(start, end, RSI_RIPAS_RAM, |
50 | RSI_CHANGE_DESTROYED); |
51 | } |
52 | |
53 | /* |
54 | * Convert the specified range to RAM. Do not convert any pages that may have |
55 | * been DESTROYED, without our permission. |
56 | */ |
57 | static inline int rsi_set_memory_range_protected_safe(phys_addr_t start, |
58 | phys_addr_t end) |
59 | { |
60 | return rsi_set_memory_range(start, end, RSI_RIPAS_RAM, |
61 | RSI_NO_CHANGE_DESTROYED); |
62 | } |
63 | |
64 | static inline int rsi_set_memory_range_shared(phys_addr_t start, |
65 | phys_addr_t end) |
66 | { |
67 | return rsi_set_memory_range(start, end, RSI_RIPAS_EMPTY, |
68 | RSI_CHANGE_DESTROYED); |
69 | } |
70 | #endif /* __ASM_RSI_H_ */ |
71 |
Warning: This file is not a C or C++ file. It does not have highlighting.