Re: [PATCH v8 09/69] KVM: arm64: nv: Reset VMPIDR_EL2 and VPIDR_EL2 to sane values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 31 Jan 2023 20:17:50 +0000,
Oliver Upton <oliver.upton@xxxxxxxxx> wrote:
> 
> On Tue, Jan 31, 2023 at 09:24:04AM +0000, Marc Zyngier wrote:
> > From: Christoffer Dall <christoffer.dall@xxxxxxx>
> > 
> > The VMPIDR_EL2 and VPIDR_EL2 are architecturally UNKNOWN at reset, but
> > let's be nice to a guest hypervisor behaving foolishly and reset these
> > to something reasonable anyway.
> 
> Must we be so kind? :)
> 
> In all seriousness, I've found the hexspeak value of reset_unknown() to
> be a rather useful debugging aid. And I can promise you that I'll use NV
> to debug my own crap changes!
> 
> Any particular reason against just using reset_unknown()?

Because debugging NV itself is hell when all you have is a model!

As we were trying to debug the early code base, we really wanted to
make it easy to run tiny guests without much setup, and work out of
the box. That's how this sort of changes came about.

In any case, something like this the hack below works as well (I just
booted an L1 and a couple of L2s with it, and nothing caught fire).

	M.

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 924afc40ab8b..c1016a35a996 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -924,16 +924,6 @@ static void reset_mpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 	vcpu_write_sys_reg(vcpu, compute_reset_mpidr(vcpu), MPIDR_EL1);
 }
 
-static void reset_vmpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
-{
-	vcpu_write_sys_reg(vcpu, compute_reset_mpidr(vcpu), VMPIDR_EL2);
-}
-
-static void reset_vpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
-{
-	vcpu_write_sys_reg(vcpu, read_cpuid_id(), VPIDR_EL2);
-}
-
 static unsigned int pmu_visibility(const struct kvm_vcpu *vcpu,
 				   const struct sys_reg_desc *r)
 {
@@ -2678,8 +2668,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {
 	{ PMU_SYS_REG(SYS_PMCCFILTR_EL0), .access = access_pmu_evtyper,
 	  .reset = reset_val, .reg = PMCCFILTR_EL0, .val = 0 },
 
-	EL2_REG(VPIDR_EL2, access_rw, reset_vpidr, 0),
-	EL2_REG(VMPIDR_EL2, access_rw, reset_vmpidr, 0),
+	EL2_REG(VPIDR_EL2, access_rw, reset_unknown, 0),
+	EL2_REG(VMPIDR_EL2, access_rw, reset_unknown, 0),
 	EL2_REG(SCTLR_EL2, access_rw, reset_val, SCTLR_EL2_RES1),
 	EL2_REG(ACTLR_EL2, access_rw, reset_val, 0),
 	EL2_REG(HCR_EL2, access_rw, reset_val, 0),

-- 
Without deviation from the norm, progress is not possible.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux