KVM: arm64: Enable S1PIE for hVHE
When FEAT_S1PIE (stage 1 permission indirection) is supported we
currently enable and use it in the hypervisor when running in VHE mode
but not when running in nVHE or hVHE mode. While systems with
FEAT_S1PIE would normally use VHE users can configure them for nVHE or
hVHE. Enable FEAT_S1PIE with hVHE only, hVHE is used for protected VMs
but there is no real use case for nVHE mode on hardware with this
feature.
AP[1] is one of the bits used to encode the indirected permissions.
Since for hVHE this is always 0 we only configure the subset of
indirected permissions that the system is expected to use.
With permission indirection read and write permissions must be encoded
in the bits used by S1PIE, set DBM for writable mappings. Only do this
when using S1PIE, the hypervisor does not otherwise use DBM so no
existing hypervisor code sets that bit. Since the meaning is assigned
via S1PIE this does not actually enable DBM, the mappings we configure
just grant write permission.
In order to enable S1PIE we also need to configure TCR2_EL2 which is
currently only done in __finalise_el2 which is VHE only, do so when the
register is present. When running in nVHE we leave TCR2_EL2.PIE
disabled. This ensures we have an explicit configuration for TCR2_EL2
when it is present in the system.
For simplicity we unconditionally initialise PIR_EL2 and PIRE0_EL2 if
FEAT_S1PIE is present, this will have no effect in nVHE mode since we
set TCR2_EL2.PIE to 0.
This should have no practical impact other than causing any unexpected
encodings to map to no permissions instead of their default meanings.
It will mean that the configuration is closer to that in VHE mode, and
will be required for future work enabling features like D128 and GCS
which are only available via indirection.
Signed-off-by: Mark Brown <broonie@kernel.org>
7 files changed