KVM: arm64: More PMU/debug ID register fixes
Marc Zyngier
maintainercover KVM: arm64: More PMU/debug ID register fixes
This is a respin of a series I posted in the 5.7 time frame, and completely forgot about it until I noticed again that a few things where not what I remembered... Given how long it has been, I'm pretending this is v1 again.
Anyway, this covers a few gaps in our ID register handling for PMU and Debug, plus the upgrade of the PMU support to 8.4 when possible.
I don't plan to take this into 5.11, but this is a likely candidate for 5.12.
Marc Zyngier (6):
KVM: arm64: Fix missing RES1 in emulation of DBGBIDR
KVM: arm64: Fix AArch32 PMUv3 capping
KVM: arm64: Add handling of AArch32 PCMEID{2,3} PMUv3 registers
KVM: arm64: Refactor filtering of ID registers
KVM: arm64: Limit the debug architecture to ARMv8.0
KVM: arm64: Upgrade PMU support to ARMv8.4
arch/arm64/kvm/sys_regs.c | 75 +++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 30 deletions(-)
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 1/6 KVM: arm64: Fix missing RES1 in emulation of DBGBIDR
The AArch32 CP14 DBGDIDR has bit 15 set to RES1, which our current emulation doesn't set. Just add the missing bit.
--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +1 -1
@@ -1711,7 +1711,7 @@ static bool trap_dbgidr(struct kvm_vcpu *vcpu, p->regval = ((((dfr >>ID_AA64DFR0_WRPS_SHIFT ) &0xf ) <<28 ) | (((dfr >>ID_AA64DFR0_BRPS_SHIFT ) &0xf ) <<24 ) | (((dfr >>ID_AA64DFR0_CTX_CMPS_SHIFT ) &0xf ) <<20 ) - | (6 <<16 ) | (el3 <<14 ) | (el3 <<12 )); + | (6 <<16 ) | (1 <<15 ) | (el3 <<14 ) | (el3 <<12 ));return true; } }
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 2/6 KVM: arm64: Fix AArch32 PMUv3 capping
In reply to Marc ZyngierWe shouldn't expose *any* PMU capability when no PMU has been configured for this VM.
--- arch/arm64/kvm/sys_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/sys_regs.c +2 -2
@@ -1048,8 +1048,8 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, }else if (id ==SYS_ID_DFR0_EL1 ) {/* Limit guests to PMUv3 for ARMv8.1 */ val =cpuid_feature_cap_perfmon_field (val, -ID_DFR0_PERFMON_SHIFT , -ID_DFR0_PERFMON_8_1 ); +ID_DFR0_PERFMON_SHIFT , +kvm_vcpu_has_pmu (vcpu) ?ID_DFR0_PERFMON_8_1 :0 ); }return val;
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 3/6 KVM: arm64: Add handling of AArch32 PCMEID{2,3} PMUv3 registers
In reply to Marc ZyngierDespite advertising support for AArch32 PMUv3p1, we fail to handle the PMCEID{2,3} registers, which conveniently alias with with the top bits of PMCEID{0,1}_EL1.
Implement these registers with the usual AA32(HI/LO) aliasing mechanism.
--- arch/arm64/kvm/sys_regs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/arm64/kvm/sys_regs.c +9 -3
@@ -685,14 +685,18 @@ static bool access_pmselr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,static bool access_pmceid (struct kvm_vcpu *vcpu,struct sys_reg_params *p,const struct sys_reg_desc *r) { -u64 pmceid; +u64 pmceid, mask, shift;BUG_ON (p->is_write);if (pmu_access_el0_disabled (vcpu))return false; +get_access_mask (r, &mask, &shift); + pmceid =kvm_pmu_get_pmceid (vcpu, (p->Op2 &1 )); + pmceid &= mask; + pmceid >>= shift; p->regval = pmceid;
@@ -1895,8 +1899,8 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 9), CRm(12), Op2( 3), access_pmovs }, { Op1( 0), CRn( 9), CRm(12), Op2( 4), access_pmswinc }, { Op1( 0), CRn( 9), CRm(12), Op2( 5), access_pmselr }, - { Op1( 0), CRn( 9), CRm(12), Op2( 6), access_pmceid }, - { Op1( 0), CRn( 9), CRm(12), Op2( 7), access_pmceid }, + { AA32(LO), Op1( 0), CRn( 9), CRm(12), Op2( 6), access_pmceid }, + { AA32(LO), Op1( 0), CRn( 9), CRm(12), Op2( 7), access_pmceid }, { Op1( 0), CRn( 9), CRm(13), Op2( 0), access_pmu_evcntr }, { Op1( 0), CRn( 9), CRm(13), Op2( 1), access_pmu_evtyper }, { Op1( 0), CRn( 9), CRm(13), Op2( 2), access_pmu_evcntr },
@@ -1904,6 +1908,8 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 9), CRm(14), Op2( 1), access_pminten }, { Op1( 0), CRn( 9), CRm(14), Op2( 2), access_pminten }, { Op1( 0), CRn( 9), CRm(14), Op2( 3), access_pmovs }, + { AA32(HI), Op1( 0), CRn( 9), CRm(14), Op2( 4), access_pmceid }, + { AA32(HI), Op1( 0), CRn( 9), CRm(14), Op2( 5), access_pmceid },/* PRRR/MAIR0 */ { AA32(LO), Op1( 0), CRn(10), CRm( 2), Op2( 0), access_vm_reg, NULL, MAIR_EL1 },
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 4/6 KVM: arm64: Refactor filtering of ID registers
In reply to Marc ZyngierOur current ID register filtering is starting to be a mess of if() statements, and isn't going to get any saner.
Let's turn it into a switch(), which has a chance of being more readable, and introduce a FEATURE() macro that allows easy generation of feature masks.
No functionnal change intended.
--- arch/arm64/kvm/sys_regs.c | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-)
arch/arm64/kvm/sys_regs.c +28 -23
@@ -9,6 +9,7 @@* Christoffer Dall <[email protected]> */ +#include <linux/bitfield.h> #include <linux/bsearch.h> #include <linux/kvm_host.h> #include <linux/mm.h>
@@ -1016,6 +1017,8 @@ static bool access_arch_timer(struct kvm_vcpu *vcpu,return true; } +#define FEATURE (x) (GENMASK_ULL(x##_SHIFT + 3, x##_SHIFT)) +/* Read a sanitised cpufeature ID register by sys_reg_desc */ static u64 read_id_reg (const struct kvm_vcpu *vcpu,struct sys_reg_desc const *r,bool raz)
@@ -1024,36 +1027,38 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, (u32)r->CRn, (u32)r->CRm, (u32)r->Op2);u64 val = raz ?0 :read_sanitised_ftr_reg (id); -if (id ==SYS_ID_AA64PFR0_EL1 ) { +switch (id) { +case SYS_ID_AA64PFR0_EL1 :if (!vcpu_has_sve (vcpu)) - val &= ~(0xfUL <<ID_AA64PFR0_SVE_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_AMU_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_CSV2_SHIFT ); - val |= ((u64 )vcpu->kvm->arch.pfr0_csv2 <<ID_AA64PFR0_CSV2_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_CSV3_SHIFT ); - val |= ((u64 )vcpu->kvm->arch.pfr0_csv3 <<ID_AA64PFR0_CSV3_SHIFT ); - }else if (id ==SYS_ID_AA64PFR1_EL1 ) { - val &= ~(0xfUL <<ID_AA64PFR1_MTE_SHIFT ); - }else if (id ==SYS_ID_AA64ISAR1_EL1 && !vcpu_has_ptrauth (vcpu)) { - val &= ~((0xfUL <<ID_AA64ISAR1_APA_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_API_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_GPA_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_GPI_SHIFT )); - }else if (id ==SYS_ID_AA64DFR0_EL1 ) { -u64 cap =0 ; - + val &= ~FEATURE (ID_AA64PFR0_SVE ); + val &= ~FEATURE (ID_AA64PFR0_AMU ); + val &= ~FEATURE (ID_AA64PFR0_CSV2 ); + val |=FIELD_PREP (FEATURE (ID_AA64PFR0_CSV2 ), (u64 )vcpu->kvm->arch.pfr0_csv2); + val &= ~FEATURE (ID_AA64PFR0_CSV3 ); + val |=FIELD_PREP (FEATURE (ID_AA64PFR0_CSV3 ), (u64 )vcpu->kvm->arch.pfr0_csv3); +break ; +case SYS_ID_AA64PFR1_EL1 : + val &= ~FEATURE (ID_AA64PFR1_MTE ); +break ; +case SYS_ID_AA64ISAR1_EL1 : +if (!vcpu_has_ptrauth (vcpu)) + val &= ~(FEATURE (ID_AA64ISAR1_APA ) | +FEATURE (ID_AA64ISAR1_API ) | +FEATURE (ID_AA64ISAR1_GPA ) | +FEATURE (ID_AA64ISAR1_GPI )); +break ; +case SYS_ID_AA64DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */ -if (kvm_vcpu_has_pmu (vcpu)) - cap =ID_AA64DFR0_PMUVER_8_1 ; - val =cpuid_feature_cap_perfmon_field (val, -ID_AA64DFR0_PMUVER_SHIFT , - cap); - }else if (id ==SYS_ID_DFR0_EL1 ) { +ID_AA64DFR0_PMUVER_SHIFT , +kvm_vcpu_has_pmu (vcpu) ?ID_AA64DFR0_PMUVER_8_1 :0 ); +break ; +case SYS_ID_DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */ val =cpuid_feature_cap_perfmon_field (val,ID_DFR0_PERFMON_SHIFT ,kvm_vcpu_has_pmu (vcpu) ?ID_DFR0_PERFMON_8_1 :0 ); +break ; }return val;
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 5/6 KVM: arm64: Limit the debug architecture to ARMv8.0
In reply to Marc ZyngierLet's not pretend we support anything but ARMv8.0 as far as the debug architecture is concerned.
--- arch/arm64/kvm/sys_regs.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kvm/sys_regs.c +3 -0
@@ -1048,6 +1048,9 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, FEATURE(ID_AA64ISAR1_GPI));break ;case SYS_ID_AA64DFR0_EL1 : +/* Limit debug to ARMv8.0 */ + val &= ~FEATURE (ID_AA64DFR0_DEBUGVER ); + val |=FIELD_PREP (FEATURE (ID_AA64DFR0_DEBUGVER ),6 );/* Limit guests to PMUv3 for ARMv8.1 */ val = cpuid_feature_cap_perfmon_field(val, ID_AA64DFR0_PMUVER_SHIFT,
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerPATCH 6/6 KVM: arm64: Upgrade PMU support to ARMv8.4
In reply to Marc ZyngierUpgrading the PMU code from ARMv8.1 to ARMv8.4 turns out to be pretty easy. All that is required is support for PMMIR_EL1, which is read-only, and for which returning 0 is a valid option.
Let's just do that and adjust what we return to the guest.
--- arch/arm64/kvm/sys_regs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/kvm/sys_regs.c +3 -2
@@ -1051,10 +1051,10 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,/* Limit debug to ARMv8.0 */ val &= ~FEATURE (ID_AA64DFR0_DEBUGVER ); val |=FIELD_PREP (FEATURE (ID_AA64DFR0_DEBUGVER ),6 ); -/* Limit guests to PMUv3 for ARMv8.1 */ +/* Limit guests to PMUv3 for ARMv8.4 */ val =cpuid_feature_cap_perfmon_field (val,ID_AA64DFR0_PMUVER_SHIFT , -kvm_vcpu_has_pmu (vcpu) ?ID_AA64DFR0_PMUVER_8_1 :0 ); +kvm_vcpu_has_pmu (vcpu) ?ID_AA64DFR0_PMUVER_8_4 :0 );break ;case SYS_ID_DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */
@@ -1496,6 +1496,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_PMINTENSET_EL1), access_pminten, reset_unknown, PMINTENSET_EL1 }, { SYS_DESC(SYS_PMINTENCLR_EL1), access_pminten, reset_unknown, PMINTENSET_EL1 }, + { SYS_DESC(SYS_PMMIR_EL1), trap_raz_wi }, { SYS_DESC(SYS_MAIR_EL1), access_vm_reg, reset_unknown, MAIR_EL1 }, { SYS_DESC(SYS_AMAIR_EL1), access_vm_reg, reset_amair_el1, AMAIR_EL1 },
Signature · 6 lines
2.29.2 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 3/6] KVM: arm64: Add handling of AArch32 PCMEID{2,3} PMUv3 registers
In reply to Marc ZyngierHi Marc,
Quoted 2 lines · Marc Zyngier
Despite advertising support for AArch32 PMUv3p1, we fail to handle the PMCEID{2,3} registers, which conveniently alias with with the top
s/with with/with
Quoted 6 lines
bits of PMCEID{0,1}_EL1.
Implement these registers with the usual AA32(HI/LO) aliasing mechanism.
Signed-off-by Marc Zyngier <[email protected]>
Thanks
Eric
Quoted 41 lines
--- arch/arm64/kvm/sys_regs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)arch/arm64/kvm/sys_regs.c +7
-3@@ -685,14 +685,18 @@ static bool access_pmselr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,static bool access_pmceid (struct kvm_vcpu *vcpu,struct sys_reg_params *p,const struct sys_reg_desc *r) { -u64 pmceid; +u64 pmceid, mask, shift;BUG_ON (p->is_write);if (pmu_access_el0_disabled (vcpu))return false; +get_access_mask (r, &mask, &shift); + pmceid =kvm_pmu_get_pmceid (vcpu, (p->Op2 &1 )); + pmceid &= mask; + pmceid >>= shift; p->regval = pmceid;@@ -1895,8 +1899,8 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 9), CRm(12), Op2( 3), access_pmovs }, { Op1( 0), CRn( 9), CRm(12), Op2( 4), access_pmswinc }, { Op1( 0), CRn( 9), CRm(12), Op2( 5), access_pmselr }, - { Op1( 0), CRn( 9), CRm(12), Op2( 6), access_pmceid }, - { Op1( 0), CRn( 9), CRm(12), Op2( 7), access_pmceid }, + { AA32(LO), Op1( 0), CRn( 9), CRm(12), Op2( 6), access_pmceid }, + { AA32(LO), Op1( 0), CRn( 9), CRm(12), Op2( 7), access_pmceid }, { Op1( 0), CRn( 9), CRm(13), Op2( 0), access_pmu_evcntr }, { Op1( 0), CRn( 9), CRm(13), Op2( 1), access_pmu_evtyper }, { Op1( 0), CRn( 9), CRm(13), Op2( 2), access_pmu_evcntr },
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc cp15_regs[] = { · line 1915
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +2
-0@@ -1904,6 +1908,8 @@ static const struct sys_reg_desc cp15_regs[] = { { Op1( 0), CRn( 9), CRm(14), Op2( 1), access_pminten }, { Op1( 0), CRn( 9), CRm(14), Op2( 2), access_pminten }, { Op1( 0), CRn( 9), CRm(14), Op2( 3), access_pmovs }, + { AA32(HI), Op1( 0), CRn( 9), CRm(14), Op2( 4), access_pmceid }, + { AA32(HI), Op1( 0), CRn( 9), CRm(14), Op2( 5), access_pmceid },/* PRRR/MAIR0 */ { AA32(LO), Op1( 0), CRn(10), CRm( 2), Op2( 0), access_vm_reg, NULL, MAIR_EL1 },
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/6] KVM: arm64: Fix missing RES1 in emulation of DBGBIDR
In reply to Marc ZyngierHi Marc,
Quoted 17 lines · Marc Zyngier
The AArch32 CP14 DBGDIDR has bit 15 set to RES1, which our current emulation doesn't set. Just add the missing bit.
Reported-by Peter Maydell <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kvm/sys_regs.c +0
-0
arch/arm64/kvm/sys_regs.c static bool trap_dbgidr(struct kvm_vcpu *vcpu, · line 1717
Quoted 8 lines
arch/arm64/kvm/sys_regs.c +1
-1@@ -1711,7 +1711,7 @@ static bool trap_dbgidr(struct kvm_vcpu *vcpu, p->regval = ((((dfr >>ID_AA64DFR0_WRPS_SHIFT ) &0xf ) <<28 ) | (((dfr >>ID_AA64DFR0_BRPS_SHIFT ) &0xf ) <<24 ) | (((dfr >>ID_AA64DFR0_CTX_CMPS_SHIFT ) &0xf ) <<20 ) - | (6 <<16 ) | (el3 <<14 ) | (el3 <<12 )); + | (6 <<16 ) | (1 <<15 ) | (el3 <<14 ) | (el3 <<12 ));return true; } }
Thanks
Eric
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 2/6] KVM: arm64: Fix AArch32 PMUv3 capping
In reply to Marc ZyngierHi Marc,
Quoted 13 lines · Marc Zyngier
We shouldn't expose *any* PMU capability when no PMU has been configured for this VM.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kvm/sys_regs.c +0
-0
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1052
Quoted 7 lines
arch/arm64/kvm/sys_regs.c +2
-2@@ -1048,8 +1048,8 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, }else if (id ==SYS_ID_DFR0_EL1 ) {/* Limit guests to PMUv3 for ARMv8.1 */ val =cpuid_feature_cap_perfmon_field (val, -ID_DFR0_PERFMON_SHIFT , -ID_DFR0_PERFMON_8_1 ); +ID_DFR0_PERFMON_SHIFT , +kvm_vcpu_has_pmu (vcpu) ?ID_DFR0_PERFMON_8_1 :0 );
nit: Maybe you could use the same layout for SYS_ID_AA64DFR0_EL1 andremove cap there.
Eric
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1055
Quoted 4 lines
arch/arm64/kvm/sys_regs.c +0
-0}return val;
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 4/6] KVM: arm64: Refactor filtering of ID registers
In reply to Marc ZyngierHi Marc,
Quoted 76 lines · Marc Zyngier
Our current ID register filtering is starting to be a mess of
if()statements, and isn't going to get any saner.Let's turn it into a
switch(), which has a chance of being more readable, and introduce aFEATURE()macro that allows easy generation of feature masks.No functionnal change intended.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-)arch/arm64/kvm/sys_regs.c +20
-17@@ -9,6 +9,7 @@* Christoffer Dall <[email protected]> */ +#include <linux/bitfield.h> #include <linux/bsearch.h> #include <linux/kvm_host.h> #include <linux/mm.h> @@ -1016,6 +1017,8 @@ static bool access_arch_timer(struct kvm_vcpu *vcpu,return true; } +#define FEATURE (x) (GENMASK_ULL(x##_SHIFT + 3, x##_SHIFT)) +/* Read a sanitised cpufeature ID register by sys_reg_desc */ static u64 read_id_reg (const struct kvm_vcpu *vcpu,struct sys_reg_desc const *r,bool raz)@@ -1024,36 +1027,38 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, (u32)r->CRn, (u32)r->CRm, (u32)r->Op2);u64 val = raz ?0 :read_sanitised_ftr_reg (id); -if (id ==SYS_ID_AA64PFR0_EL1 ) { +switch (id) { +case SYS_ID_AA64PFR0_EL1 :if (!vcpu_has_sve (vcpu)) - val &= ~(0xfUL <<ID_AA64PFR0_SVE_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_AMU_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_CSV2_SHIFT ); - val |= ((u64 )vcpu->kvm->arch.pfr0_csv2 <<ID_AA64PFR0_CSV2_SHIFT ); - val &= ~(0xfUL <<ID_AA64PFR0_CSV3_SHIFT ); - val |= ((u64 )vcpu->kvm->arch.pfr0_csv3 <<ID_AA64PFR0_CSV3_SHIFT ); - }else if (id ==SYS_ID_AA64PFR1_EL1 ) { - val &= ~(0xfUL <<ID_AA64PFR1_MTE_SHIFT ); - }else if (id ==SYS_ID_AA64ISAR1_EL1 && !vcpu_has_ptrauth (vcpu)) { - val &= ~((0xfUL <<ID_AA64ISAR1_APA_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_API_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_GPA_SHIFT ) | - (0xfUL <<ID_AA64ISAR1_GPI_SHIFT )); - }else if (id ==SYS_ID_AA64DFR0_EL1 ) { -u64 cap =0 ; - + val &= ~FEATURE (ID_AA64PFR0_SVE ); + val &= ~FEATURE (ID_AA64PFR0_AMU ); + val &= ~FEATURE (ID_AA64PFR0_CSV2 ); + val |=FIELD_PREP (FEATURE (ID_AA64PFR0_CSV2 ), (u64 )vcpu->kvm->arch.pfr0_csv2); + val &= ~FEATURE (ID_AA64PFR0_CSV3 ); + val |=FIELD_PREP (FEATURE (ID_AA64PFR0_CSV3 ), (u64 )vcpu->kvm->arch.pfr0_csv3); +break ; +case SYS_ID_AA64PFR1_EL1 : + val &= ~FEATURE (ID_AA64PFR1_MTE ); +break ; +case SYS_ID_AA64ISAR1_EL1 : +if (!vcpu_has_ptrauth (vcpu)) + val &= ~(FEATURE(ID_AA64ISAR1_APA) | + FEATURE(ID_AA64ISAR1_API) | + FEATURE(ID_AA64ISAR1_GPA) |
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1051
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +3
-5+ FEATURE(ID_AA64ISAR1_GPI)); +break ; +case SYS_ID_AA64DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */ -if (kvm_vcpu_has_pmu (vcpu)) - cap =ID_AA64DFR0_PMUVER_8_1 ; - val = cpuid_feature_cap_perfmon_field(val, -ID_AA64DFR0_PMUVER_SHIFT , - cap);
so you did the change evoked in my previous comment here.
Quoted 4 lines
arch/arm64/kvm/sys_regs.c +2
-1- }else if (id ==SYS_ID_DFR0_EL1 ) { +ID_AA64DFR0_PMUVER_SHIFT , + kvm_vcpu_has_pmu(vcpu) ? ID_AA64DFR0_PMUVER_8_1 : 0);
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1064
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +3
-0+break ; +case SYS_ID_DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */ val =cpuid_feature_cap_perfmon_field (val,ID_DFR0_PERFMON_SHIFT ,kvm_vcpu_has_pmu (vcpu) ?ID_DFR0_PERFMON_8_1 :0 ); +break ; }return val;
Looks indeed more readable
Eric
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 6/6] KVM: arm64: Upgrade PMU support to ARMv8.4
In reply to Marc ZyngierHi Marc,
Quoted 18 lines · Marc Zyngier
Upgrading the PMU code from ARMv8.1 to ARMv8.4 turns out to be pretty easy. All that is required is support for
PMMIR_EL1, which is read-only, and for which returning 0 is a valid option.Let's just do that and adjust what we return to the guest.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm64/kvm/sys_regs.c +0
-0@@ -1051,10 +1051,10 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,/* Limit debug to ARMv8.0 */ val &= ~FEATURE (ID_AA64DFR0_DEBUGVER );
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1060
Quoted 10 lines
arch/arm64/kvm/sys_regs.c +2
-2val |=FIELD_PREP (FEATURE (ID_AA64DFR0_DEBUGVER ),6 ); -/* Limit guests to PMUv3 for ARMv8.1 */ +/* Limit guests to PMUv3 for ARMv8.4 */ val =cpuid_feature_cap_perfmon_field (val,ID_AA64DFR0_PMUVER_SHIFT , -kvm_vcpu_has_pmu (vcpu) ?ID_AA64DFR0_PMUVER_8_1 :0 ); +kvm_vcpu_has_pmu (vcpu) ?ID_AA64DFR0_PMUVER_8_4 :0 );break ;case SYS_ID_DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */
what about the debug version in aarch32 state. Is it on purpose that you leave it as 8_1?
Thanks
Eric
arch/arm64/kvm/sys_regs.c static const struct sys_reg_desc sys_reg_descs[] = { · line 1502
Quoted 9 lines
arch/arm64/kvm/sys_regs.c +1
-0@@ -1496,6 +1496,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_PMINTENSET_EL1), access_pminten, reset_unknown, PMINTENSET_EL1 }, { SYS_DESC(SYS_PMINTENCLR_EL1), access_pminten, reset_unknown, PMINTENSET_EL1 }, + { SYS_DESC(SYS_PMMIR_EL1), trap_raz_wi }, { SYS_DESC(SYS_MAIR_EL1), access_vm_reg, reset_unknown, MAIR_EL1 }, { SYS_DESC(SYS_AMAIR_EL1), access_vm_reg, reset_amair_el1, AMAIR_EL1 },
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 5/6] KVM: arm64: Limit the debug architecture to ARMv8.0
In reply to Marc ZyngierHi Marc,
Quoted 4 lines · Marc Zyngier
Let's not pretend we support anything but ARMv8.0 as far as the debug architecture is concerned.
Signed-off-by Marc Zyngier <[email protected]>
Eric
Quoted 10 lines
--- arch/arm64/kvm/sys_regs.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm64/kvm/sys_regs.c +0
-0
arch/arm64/kvm/sys_regs.c static u64 read_id_reg(const struct kvm_vcpu *vcpu, · line 1056
Quoted 9 lines
arch/arm64/kvm/sys_regs.c +3
-0@@ -1048,6 +1048,9 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, FEATURE(ID_AA64ISAR1_GPI));break ;case SYS_ID_AA64DFR0_EL1 : +/* Limit debug to ARMv8.0 */ + val &= ~FEATURE (ID_AA64DFR0_DEBUGVER ); + val |=FIELD_PREP (FEATURE (ID_AA64DFR0_DEBUGVER ),6 );/* Limit guests to PMUv3 for ARMv8.1 */ val = cpuid_feature_cap_perfmon_field(val, ID_AA64DFR0_PMUVER_SHIFT,
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH 6/6] KVM: arm64: Upgrade PMU support to ARMv8.4
In reply to Auger EricHi Eric,
Quoted 26 lines · Auger Eric
Hi Marc,
Quoted 23 lines · Marc Zyngier
Upgrading the PMU code from ARMv8.1 to ARMv8.4 turns out to be pretty easy. All that is required is support for
PMMIR_EL1, which is read-only, and for which returning 0 is a valid option.Let's just do that and adjust what we return to the guest.
Signed-off-by Marc Zyngier <[email protected]>--- arch/arm64/kvm/sys_regs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm64/kvm/sys_regs.c +1
-1@@ -1051,10 +1051,10 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,/* Limit debug to ARMv8.0 */ val &= ~FEATURE (ID_AA64DFR0_DEBUGVER ); val |=FIELD_PREP (FEATURE (ID_AA64DFR0_DEBUGVER ),6 ); -/* Limit guests to PMUv3 for ARMv8.1 */ +/* Limit guests to PMUv3 for ARMv8.4 */ val = cpuid_feature_cap_perfmon_field(val,
Quoted 8 lines
Quoted 6 lines
arch/arm64/kvm/sys_regs.c +1
-1ID_AA64DFR0_PMUVER_SHIFT , - kvm_vcpu_has_pmu(vcpu) ? ID_AA64DFR0_PMUVER_8_1 : 0); + kvm_vcpu_has_pmu(vcpu) ? ID_AA64DFR0_PMUVER_8_4 : 0);break ;case SYS_ID_DFR0_EL1 :/* Limit guests to PMUv3 for ARMv8.1 */
what about the debug version in aarch32 state. Is it on purpose that you leave it as 8_1?
That's a good point. There is also the fact that we keep reporting STALL_SLOT as a valid event even in PMCEID0_EL1 despite PMMIR_EL1.SLOTS always reporting 0.
I'll fix that and resend something next week.
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 6/6] KVM: arm64: Upgrade PMU support to ARMv8.4
Hi Marc,
Quoted 40 lines · Marc Zyngier
Hi Eric,
Quoted 28 lines · Auger Eric
Hi Marc,
Quoted 25 lines · Marc Zyngier
Upgrading the PMU code from ARMv8.1 to ARMv8.4 turns out to be pretty easy. All that is required is support for
PMMIR_EL1, which is read-only, and for which returning 0 is a valid option.Let's just do that and adjust what we return to the guest.
Signed-off-by Marc Zyngier <[email protected]>---
arch/arm64/kvm/sys_regs.c | 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)arch/arm64/kvm/sys_regs.c +1
-2@@ -1051,10 +1051,10 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, /* Limit debug to ARMv8.0 */ val &= ~FEATURE(ID_AA64DFR0_DEBUGVER); val |= FIELD_PREP(FEATURE(ID_AA64DFR0_DEBUGVER), 6); - /* Limit guests to PMUv3 for ARMv8.1 */ + /* Limit guests to PMUv3 for ARMv8.4 */ val = cpuid_feature_cap_perfmon_field(val, ID_AA64DFR0_PMUVER_SHIFT, - kvm_vcpu_has_pmu(vcpu) ?Quoted 8 lines
Quoted 6 lines
arch/arm64/kvm/sys_regs.c +1
-0ID_AA64DFR0_PMUVER_8_1 : 0); + kvm_vcpu_has_pmu(vcpu) ? ID_AA64DFR0_PMUVER_8_4 : 0);break;
caseSYS_ID_DFR0_EL1:
/* Limit guests to PMUv3 for ARMv8.1 */what about the debug version in aarch32 state. Is it on purpose that you leave it as 8_1?
Quoted 3 lines
That's a good point. There is also the fact that we keep reporting
STALL_SLOTas a valid event even inPMCEID0_EL1despite PMMIR_EL1.SLOTS always reporting 0.
Hum OK. I did not notice that ;-)
Thanks
Eric
Quoted 6 lines
I'll fix that and resend something next week.
Thanks,
M.
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm