@@ -467,6 +467,17 @@ static struct feature_config_ctrl ftr_ctrl_tracefilt = {
.cfg_val = MDCR_EL2_TTRF,
};
+/* For ID_AA64MMFR1_EL1 */
+static struct feature_config_ctrl ftr_ctrl_lor = {
+ .ftr_reg = SYS_ID_AA64MMFR1_EL1,
+ .ftr_shift = ID_AA64MMFR1_LOR_SHIFT,
+ .ftr_min = 1,
+ .ftr_signed = FTR_UNSIGNED,
+ .cfg_reg = VCPU_HCR_EL2,
+ .cfg_mask = HCR_TLOR,
+ .cfg_val = HCR_TLOR,
+};
+
struct id_reg_info {
u32 sys_reg; /* Register ID */
u64 sys_val; /* Sanitized system value */
@@ -968,6 +979,14 @@ static struct id_reg_info id_aa64dfr0_el1_info = {
},
};
+static struct id_reg_info id_aa64mmfr1_el1_info = {
+ .sys_reg = SYS_ID_AA64MMFR1_EL1,
+ .trap_features = &(const struct feature_config_ctrl *[]) {
+ &ftr_ctrl_lor,
+ NULL,
+ },
+};
+
static struct id_reg_info id_dfr0_el1_info = {
.sys_reg = SYS_ID_DFR0_EL1,
.init = init_id_dfr0_el1_info,
@@ -1010,6 +1029,7 @@ static struct id_reg_info *id_reg_info_table[KVM_ARM_ID_REG_MAX_NUM] = {
[IDREG_IDX(SYS_ID_AA64ISAR0_EL1)] = &id_aa64isar0_el1_info,
[IDREG_IDX(SYS_ID_AA64ISAR1_EL1)] = &id_aa64isar1_el1_info,
[IDREG_IDX(SYS_ID_AA64MMFR0_EL1)] = &id_aa64mmfr0_el1_info,
+ [IDREG_IDX(SYS_ID_AA64MMFR1_EL1)] = &id_aa64mmfr1_el1_info,
};
static int validate_id_reg(struct kvm_vcpu *vcpu,
@@ -1104,10 +1124,9 @@ static bool trap_loregion(struct kvm_vcpu *vcpu,
struct sys_reg_params *p,
const struct sys_reg_desc *r)
{
- u64 val = __vcpu_sys_reg(vcpu, IDREG_SYS_IDX(SYS_ID_AA64MMFR1_EL1));
u32 sr = reg_to_encoding(r);
- if (!(val & (0xfUL << ID_AA64MMFR1_LOR_SHIFT))) {
+ if (!vcpu_feature_is_available(vcpu, &ftr_ctrl_lor)) {
kvm_inject_undefined(vcpu);
return false;
}
Add feature_config_ctrl for LORegions, which is indicated in ID_AA64MMFR1_EL1, to program configuration register to trap guest's using the feature when it is not exposed to the guest. Change trap_loregion() to use vcpu_feature_is_available() to simplify checking of the feature's availability. Signed-off-by: Reiji Watanabe <reijiw@google.com> --- arch/arm64/kvm/sys_regs.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)