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 DECLARE_STATIC_KEY_FALSE(rsi_present);
15 void __init arm64_rsi_init(void);
17 bool __arm64_is_protected_mmio(phys_addr_t base, size_t size);
19 static inline bool is_realm_world(void)
21 return static_branch_unlikely(&rsi_present);
24 static inline int rsi_set_memory_range(phys_addr_t start, phys_addr_t end,
25 enum ripas state, unsigned long flags)
30 while (start != end) {
31 ret = rsi_set_addr_range_state(start, end, state, flags, &top);
32 if (ret || top < start || top > end)
41 * Convert the specified range to RAM. Do not use this if you rely on the
42 * contents of a page that may already be in RAM state.
44 static inline int rsi_set_memory_range_protected(phys_addr_t start,
47 return rsi_set_memory_range(start, end, RSI_RIPAS_RAM,
48 RSI_CHANGE_DESTROYED);
52 * Convert the specified range to RAM. Do not convert any pages that may have
53 * been DESTROYED, without our permission.
55 static inline int rsi_set_memory_range_protected_safe(phys_addr_t start,
58 return rsi_set_memory_range(start, end, RSI_RIPAS_RAM,
59 RSI_NO_CHANGE_DESTROYED);
62 static inline int rsi_set_memory_range_shared(phys_addr_t start,
65 return rsi_set_memory_range(start, end, RSI_RIPAS_EMPTY,
66 RSI_CHANGE_DESTROYED);
68 #endif /* __ASM_RSI_H_ */