KVM: arm64: Make kern_hyp_va() robust against NULL pointers

Applying kern_hyp_va() to a NULL pointer doesn't really do what
you'd expect. If EL2 randomization is enabled, you'd end-up
with some extra bits, making sure that the resulting pointer
isn't zero.

Bad things follow.

Given that kern_hyp_va() is only supposed to apply to kernel
pointers, add a check for bit 55, which will tell us cheaply
whether the value is likely to be a kernel pointer or not.
If this bit is 0, zero the pointer as something went wrong.

This requires a bit of reworking of the patching function.

Signed-off-by: Marc Zyngier <maz@kernel.org>
2 files changed