Re: [PATCH v2] arm64: vgic-v2: Fix proxying of cpuif access

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

 



On 04/05/18 16:19, James Morse wrote:
> Proxying the cpuif accesses at EL2 makes use of vcpu_data_guest_to_host
> and co, which check the endianness, which call into vcpu_read_sys_reg...
> which isn't mapped at EL2 (it was inlined before, and got moved OoL
> with the VHE optimizations).
> 
> The result is of course a nice panic. Let's add some specialized
> cruft to keep the broken platforms that require this hack alive.
> 
> But, this code used vcpu_data_guest_to_host(), which expected us to
> write the value to host memory, instead we have trapped the guest's
> read or write to an mmio-device, and are about to replay it using the
> host's readl()/writel() which also perform swabbing based on the host
> endianness. This goes wrong when both host and guest are big-endian,
> as readl()/writel() will undo the guest's swabbing, causing the
> big-endian value to be written to device-memory.
> 
> What needs doing?
> A big-endian guest will have pre-swabbed data before storing, undo this.
> If its necessary for the host, writel() will re-swab it.
> 
> For a read a big-endian guest expects to swab the data after the load.
> The hosts's readl() will correct for host endianness, giving us the
> device-memory's value in the register. For a big-endian guest, swab it
> as if we'd only done the load.
> 
> For a little-endian guest, nothing needs doing as readl()/writel() leave
> the correct device-memory value in registers.
> 
> Tested on Juno with that rarest of things: a big-endian 64K host.

<song>
The Thing That Should Not Be
</song>

> Based on a patch from Marc Zyngier.
> 
> Reported-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
> Fixes: bf8feb39642b ("arm64: KVM: vgic-v2: Add GICV access from HYP")
> CC: Marc Zyngier <marc.zyngier@xxxxxxx>
> Signed-off-by: James Morse <james.morse@xxxxxxx>

Awesome, thanks a lot for picking this up and fixing it the right way!

I'll queue it right away.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux