1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2024 ARM Ltd.
9 #include <linux/errno.h>
10 #include <linux/jump_label.h>
11 #include <asm/rsi_cmds.h>
13 #define RSI_PDEV_NAME "arm-cca-dev"
15 DECLARE_STATIC_KEY_FALSE(rsi_present);
17 void __init arm64_rsi_init(void);
19 bool __arm64_is_protected_mmio(phys_addr_t base, size_t size);
21 static inline bool is_realm_world(void)
23 return static_branch_unlikely(&rsi_present);
26 static inline int rsi_set_memory_range(phys_addr_t start, phys_addr_t end,
27 enum ripas state, unsigned long flags)
32 while (start != end) {
33 ret = rsi_set_addr_range_state(start, end, state, flags, &top);
34 if (ret || top < start || top > end)
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.
46 static inline int rsi_set_memory_range_protected(phys_addr_t start,
49 return rsi_set_memory_range(start, end, RSI_RIPAS_RAM,
50 RSI_CHANGE_DESTROYED);
54 * Convert the specified range to RAM. Do not convert any pages that may have
55 * been DESTROYED, without our permission.
57 static inline int rsi_set_memory_range_protected_safe(phys_addr_t start,
60 return rsi_set_memory_range(start, end, RSI_RIPAS_RAM,
61 RSI_NO_CHANGE_DESTROYED);
64 static inline int rsi_set_memory_range_shared(phys_addr_t start,
67 return rsi_set_memory_range(start, end, RSI_RIPAS_EMPTY,
68 RSI_CHANGE_DESTROYED);
70 #endif /* __ASM_RSI_H_ */