
From: Yiwei Zhuang <zhuangyiwei@huawei.com> cca inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IBWQ24 -------------------------------- maillist: Aneesh pointed out that this call to is_realm_world() is now too early since the decision to delay the RSI detection. The upshot is that a realm guest which doesn't have page granularity forced for other reasons will fail to share pages with the host. At the moment I can think of a couple of options: (1) Make rodata_full a requirement for realm guests. CONFIG_RODATA_FULL_DEFAULT_ENABLED is already "default y" so this isn't a big ask. (2) Revisit the idea of detecting when running as a realm guest early. This has the advantage of also "fixing" earlycon (no need to manually specify the shared-alias of an unprotected UART). I'm currently leaning towards (1) because it's the default anyway. But if we're going to need to fix earlycon (or indeed find other similar issues) then (2) would obviously make sense. CCA context is follow: CCA guest must run at page granularity. Thus, we need to make sure NO_BLOCK_MAPPINGS and NO_CONT_MAPPINGS flags are set during paging_init. However, at that time, is_realm_world has not been initialized yet. Therefore, rodata=full is forced currently while booting a realm guest[1]. Link: https://patchwork.kernel.org/project/kvm/patch/20241017131434.40935-10-steve... Signed-off-by: Yiwei Zhuang <zhuangyiwei@huawei.com> Signed-off-by: Cai Xinchen <caixinchen1@huawei.com> --- arch/arm64/kernel/rsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c index 58860483eadd..be868cb5a4b4 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -6,6 +6,7 @@ #include <linux/jump_label.h> #include <linux/memblock.h> #include <linux/psci.h> +#include <linux/set_memory.h> #include <linux/swiotlb.h> #include <linux/cc_platform.h> @@ -143,6 +144,10 @@ void __init arm64_rsi_init(void) return; if (!rsi_version_matches()) return; + if (!can_set_direct_map()) { + pr_err("RME: Cannot set the kernel direct map, consider CONFIG_RODATA_FULL_DEFAULT_ENABLED=y or rodata=full\n"); + return; + } if (WARN_ON(rsi_get_realm_config(&config))) return; prot_ns_shared = BIT(config.ipa_bits - 1); -- 2.18.0.huawei.25