Skip to content

Commit e0bb80c

Browse files
kristina-martsenkooupton
authored andcommitted
KVM: arm64: Expose MOPS instructions to guests
Expose the Armv8.8 FEAT_MOPS feature to guests in the ID register and allow the MOPS instructions to be run in a guest. Only expose MOPS if the whole system supports it. Note, it is expected that guests do not use these instructions on MMIO, similarly to other instructions where ESR_EL2.ISV==0 such as LDP/STP. Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230922112508.1774352-3-kristina.martsenko@arm.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 2de451a commit e0bb80c

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
#define HCR_HOST_NVHE_PROTECTED_FLAGS (HCR_HOST_NVHE_FLAGS | HCR_TSC)
103103
#define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
104104

105-
#define HCRX_GUEST_FLAGS (HCRX_EL2_SMPME | HCRX_EL2_TCR2En)
105+
#define HCRX_GUEST_FLAGS \
106+
(HCRX_EL2_SMPME | HCRX_EL2_TCR2En | \
107+
(cpus_have_final_cap(ARM64_HAS_MOPS) ? (HCRX_EL2_MSCEn | HCRX_EL2_MCE2) : 0))
106108
#define HCRX_HOST_FLAGS (HCRX_EL2_MSCEn | HCRX_EL2_TCR2En)
107109

108110
/* TCR_EL2 Registers bits */

arch/arm64/kvm/hyp/include/nvhe/fixed_config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@
197197

198198
#define PVM_ID_AA64ISAR2_ALLOW (\
199199
ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_GPA3) | \
200-
ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3) \
200+
ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3) | \
201+
ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_MOPS) \
201202
)
202203

203204
u64 pvm_read_id_reg(const struct kvm_vcpu *vcpu, u32 id);

arch/arm64/kvm/sys_regs.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu,
13441344
ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_GPA3));
13451345
if (!cpus_have_final_cap(ARM64_HAS_WFXT))
13461346
val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_WFxT);
1347-
val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_MOPS);
13481347
break;
13491348
case SYS_ID_AA64MMFR2_EL1:
13501349
val &= ~ID_AA64MMFR2_EL1_CCIDX_MASK;
@@ -2095,7 +2094,6 @@ static const struct sys_reg_desc sys_reg_descs[] = {
20952094
ID_AA64ISAR1_EL1_API |
20962095
ID_AA64ISAR1_EL1_APA)),
20972096
ID_WRITABLE(ID_AA64ISAR2_EL1, ~(ID_AA64ISAR2_EL1_RES0 |
2098-
ID_AA64ISAR2_EL1_MOPS |
20992097
ID_AA64ISAR2_EL1_APA3 |
21002098
ID_AA64ISAR2_EL1_GPA3)),
21012099
ID_UNALLOCATED(6,3),

0 commit comments

Comments
 (0)