Re: [PATCH v4 06/36] KVM: arm64: nv: Handle CNTHCTL_EL2 specially

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

 



On Wed, 16 Oct 2024 14:19:14 +0100,
Alexandru Elisei <alexandru.elisei@xxxxxxx> wrote:
> 
> > > > @@ -207,6 +222,19 @@ void vcpu_write_sys_reg(struct kvm_vcpu *vcpu, u64 val, int reg)
> > > >  		 */
> > > >  		__vcpu_sys_reg(vcpu, reg) = val;
> > > >  
> > > > +		switch (reg) {
> > > > +		case CNTHCTL_EL2:
> > > > +			/*
> > > > +			 * If E2H=0, CNHTCTL_EL2 is a pure shadow register.
> > > > +			 * Otherwise, some of the bits are backed by
> > > > +			 * CNTKCTL_EL1, while the rest is kept in memory.
> > > > +			 * Yes, this is fun stuff.
> > > > +			 */
> > > > +			if (vcpu_el2_e2h_is_set(vcpu))
> > > > +				write_sysreg_el1(val, SYS_CNTKCTL);
> > > 
> > > Sorry, but I just can't seem to get my head around why the RES0 bits aren't
> > > cleared. Is KVM relying on the guest to implement Should-Be-Zero-or-Preserved,
> > > as per the RES0 definition?
> > 
> > KVM isn't relying on anything. And it isn't about the RES0 bits not
> > being cleared. It is about the HW not providing storage for some of
> > the CNTHCTL_EL2 bits when the guest is using CNTKCTL_EL1 as a proxy
> > for its own view of CNTHCTL_EL2.
> > 
> > Namely, bits outside of CNTKCTL_VALID_BITS are not guaranteed to be
> > stored until (IIRC) FEAT_NV2p1, which retrospectively fixes the
> > architecture by mandating that the relevant bits have dedicated
> > storage.
> 
> The definition for RES0 says:
> 
> 'A bit that is RES0 in a context is reserved for possible future use in that
> context. To preserve forward compatibility, software:
>  * Must not rely on the bit reading as 0.
>  * Must use an SBZP policy to write to the bit.'
> 
> where Should-Be-Zero-of-Preserved (SBZP):
> 
> 'When writing this field, software must either write all 0s to this field or, if
> the register is being restored from a previously read state, write the
> previously read value to this field. If this is not done, then the result is
> unpredictable.'

And? I can quote the ARM ARM too, but that's not going to lead us
anywhere if you don't explain why what you quote is related to the
problem at hand (hint, I don't think it is).

> And what about the rest of the RES0 bits from CNTKCTL_EL1, those that are RES0
> in both registers?

What about them *what*?

It would definitely help if you didn't write in riddles and actually
spell out what you mean. If you think this code is wrong, please
explain why you think it is wrong, and maybe we'll be able to make
some progress.


Thanks,

	M.

-- 
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