Hi Marc, On 16/10/2021 14:50, Marc Zyngier wrote: > On Fri, 15 Oct 2021 17:14:13 +0100, > James Morse <james.morse@xxxxxxx> wrote: >> >> If the CPUs support HPDS2, and there is a DT description of PBHA values >> that only affect performance, enable those bits for both TTBR0 and TTBR1. >> >> Enabling PBHA requires the hierarchical-permissions to be disabled. >> Commit 87143f404f33 ("arm64: mm: use XN table mapping attributes for >> the linear region") used these, but only as an optimisation. >> >> Only the necessary PBHA bits are enabled to reduce the risk of an >> unsafe bit/value being used by accident. >> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c >> index 8694f9dec5e5..548c6f96a878 100644 >> --- a/arch/arm64/kernel/cpufeature.c >> +++ b/arch/arm64/kernel/cpufeature.c >> @@ -1676,6 +1679,71 @@ static bool has_hw_dbm(const struct arm64_cpu_capabilities *cap, >> +static bool plat_can_use_pbha_stage1(const struct arm64_cpu_capabilities *cap, >> + int scope) >> +{ >> + u8 val; >> + struct device_node *cpus; >> + const u8 *perf_only_vals; >> + int num_perf_only_vals, i; >> + >> + if (!has_cpuid_feature(cap, scope)) >> + return false; >> + >> + /* >> + * Calls with scope == SCOPE_LOCAL_CPU need only testing whether this >> + * cpu has the feature. A later 'system' scope call will check for a >> + * firmware description. >> + */ >> + if (scope == SCOPE_LOCAL_CPU) >> + return true; >> + >> + cpus = of_find_node_by_path("/cpus"); >> + if (!cpus) >> + goto done; >> + >> + perf_only_vals = of_get_property(cpus, "arm,pbha-performance-only", >> + &num_perf_only_vals); >> + if (!perf_only_vals) >> + goto done; >> + >> + /* any listed value is usable at stage 1 */ >> + for (i = 0 ; i < num_perf_only_vals; i++) { >> + val = perf_only_vals[i]; >> + if (val > 0xf) >> + continue; >> + >> + pbha_stage1_enable_bits |= val; >> + set_bit(val, &arm64_pbha_perf_only_values); >> + } > Somehow, this would need to be exposed to userspace so that a VMM > could tell a guest what it can use. I'm assuming any user is very soc-specific... but it would help the VMM to know. I guess KVM could return the bitmap as KVM_CAP_PBHA. There is no way to tell the VMM what the bits do, as that is imp-def... Thanks, James _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm