Message ID | 20241004144307.66199-4-steven.price@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: Support for running as a guest in Arm CCA | expand |
On 10/5/24 12:42 AM, Steven Price wrote: > The top bit of the configured IPA size is used as an attribute to > control whether the address is protected or shared. Query the > configuration from the RMM to assertain which bit this is. > > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> > Reviewed-by: Gavin Shan <gshan@redhat.com> > Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > Signed-off-by: Steven Price <steven.price@arm.com> > --- > Changes since v4: > * Make PROT_NS_SHARED check is_realm_world() to reduce impact on > non-CCA systems. > Changes since v2: > * Drop unneeded extra brackets from PROT_NS_SHARED. > * Drop the explicit alignment from 'config' as struct realm_config now > specifies the alignment. > --- > arch/arm64/include/asm/pgtable-prot.h | 4 ++++ > arch/arm64/include/asm/rsi.h | 2 +- > arch/arm64/kernel/rsi.c | 8 ++++++++ > 3 files changed, 13 insertions(+), 1 deletion(-) > [...] > diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h > index e4c01796c618..acba065eb00e 100644 > --- a/arch/arm64/include/asm/rsi.h > +++ b/arch/arm64/include/asm/rsi.h > @@ -27,7 +27,7 @@ static inline int rsi_set_memory_range(phys_addr_t start, phys_addr_t end, > > while (start != end) { > ret = rsi_set_addr_range_state(start, end, state, flags, &top); > - if (WARN_ON(ret || top < start || top > end)) > + if (ret || top < start || top > end) > return -EINVAL; > start = top; > } I think the changes belong to PATCH[02/11] :) Thanks, Gavin
On 10/5/24 12:42 AM, Steven Price wrote: > The top bit of the configured IPA size is used as an attribute to > control whether the address is protected or shared. Query the > configuration from the RMM to assertain which bit this is. > > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> > Reviewed-by: Gavin Shan <gshan@redhat.com> > Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > Signed-off-by: Steven Price <steven.price@arm.com> > --- > Changes since v4: > * Make PROT_NS_SHARED check is_realm_world() to reduce impact on > non-CCA systems. > Changes since v2: > * Drop unneeded extra brackets from PROT_NS_SHARED. > * Drop the explicit alignment from 'config' as struct realm_config now > specifies the alignment. > --- > arch/arm64/include/asm/pgtable-prot.h | 4 ++++ > arch/arm64/include/asm/rsi.h | 2 +- > arch/arm64/kernel/rsi.c | 8 ++++++++ > 3 files changed, 13 insertions(+), 1 deletion(-) > [...] > diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c > index 9bf757b4b00c..a6495a64d9bb 100644 > --- a/arch/arm64/kernel/rsi.c > +++ b/arch/arm64/kernel/rsi.c > @@ -8,6 +8,11 @@ > #include <linux/psci.h> > #include <asm/rsi.h> > > +struct realm_config config; > + Nit: I think this variable is file-scoped since it has a generic name. In this case, 'static' is needed to match with the scope. > +unsigned long prot_ns_shared; > +EXPORT_SYMBOL(prot_ns_shared); > + > DEFINE_STATIC_KEY_FALSE_RO(rsi_present); > EXPORT_SYMBOL(rsi_present); > > @@ -67,6 +72,9 @@ void __init arm64_rsi_init(void) > return; > if (!rsi_version_matches()) > return; > + if (WARN_ON(rsi_get_realm_config(&config))) > + return; > + prot_ns_shared = BIT(config.ipa_bits - 1); > > arm64_rsi_setup_memory(); > Thanks, Gavin
On 15/10/2024 04:55, Gavin Shan wrote: > On 10/5/24 12:42 AM, Steven Price wrote: >> The top bit of the configured IPA size is used as an attribute to >> control whether the address is protected or shared. Query the >> configuration from the RMM to assertain which bit this is. >> >> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> >> Reviewed-by: Gavin Shan <gshan@redhat.com> >> Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> Signed-off-by: Steven Price <steven.price@arm.com> >> --- >> Changes since v4: >> * Make PROT_NS_SHARED check is_realm_world() to reduce impact on >> non-CCA systems. >> Changes since v2: >> * Drop unneeded extra brackets from PROT_NS_SHARED. >> * Drop the explicit alignment from 'config' as struct realm_config now >> specifies the alignment. >> --- >> arch/arm64/include/asm/pgtable-prot.h | 4 ++++ >> arch/arm64/include/asm/rsi.h | 2 +- >> arch/arm64/kernel/rsi.c | 8 ++++++++ >> 3 files changed, 13 insertions(+), 1 deletion(-) >> > > [...] > >> diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c >> index 9bf757b4b00c..a6495a64d9bb 100644 >> --- a/arch/arm64/kernel/rsi.c >> +++ b/arch/arm64/kernel/rsi.c >> @@ -8,6 +8,11 @@ >> #include <linux/psci.h> >> #include <asm/rsi.h> >> +struct realm_config config; >> + > > Nit: I think this variable is file-scoped since it has a generic name. > In this case, 'static' is needed to match with the scope. Good spot - it should definitely be static. Thanks, Steve >> +unsigned long prot_ns_shared; >> +EXPORT_SYMBOL(prot_ns_shared); >> + >> DEFINE_STATIC_KEY_FALSE_RO(rsi_present); >> EXPORT_SYMBOL(rsi_present); >> @@ -67,6 +72,9 @@ void __init arm64_rsi_init(void) >> return; >> if (!rsi_version_matches()) >> return; >> + if (WARN_ON(rsi_get_realm_config(&config))) >> + return; >> + prot_ns_shared = BIT(config.ipa_bits - 1); >> arm64_rsi_setup_memory(); >> > > Thanks, > Gavin >
diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index 2a11d0c10760..820a3b06f08c 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -68,8 +68,12 @@ #include <asm/cpufeature.h> #include <asm/pgtable-types.h> +#include <asm/rsi.h> extern bool arm64_use_ng_mappings; +extern unsigned long prot_ns_shared; + +#define PROT_NS_SHARED (is_realm_world() ? prot_ns_shared : 0) #define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0) #define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0) diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h index e4c01796c618..acba065eb00e 100644 --- a/arch/arm64/include/asm/rsi.h +++ b/arch/arm64/include/asm/rsi.h @@ -27,7 +27,7 @@ static inline int rsi_set_memory_range(phys_addr_t start, phys_addr_t end, while (start != end) { ret = rsi_set_addr_range_state(start, end, state, flags, &top); - if (WARN_ON(ret || top < start || top > end)) + if (ret || top < start || top > end) return -EINVAL; start = top; } diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c index 9bf757b4b00c..a6495a64d9bb 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -8,6 +8,11 @@ #include <linux/psci.h> #include <asm/rsi.h> +struct realm_config config; + +unsigned long prot_ns_shared; +EXPORT_SYMBOL(prot_ns_shared); + DEFINE_STATIC_KEY_FALSE_RO(rsi_present); EXPORT_SYMBOL(rsi_present); @@ -67,6 +72,9 @@ void __init arm64_rsi_init(void) return; if (!rsi_version_matches()) return; + if (WARN_ON(rsi_get_realm_config(&config))) + return; + prot_ns_shared = BIT(config.ipa_bits - 1); arm64_rsi_setup_memory();