For this specific case there may be another resolution but could
you please, please look at marking the missing pages PG_reserved
and not hacking phys_to_virt.
At this point anything short of explicitly introducing an intermediate
step say virt_to_logical() logical_to_virt() will be extremely
confusing and lead to very hard to spot bugs. Silently changing
the semantics of functions is bad.
We also use the additional level of indirection to implement suspend/
resume and relocation of virtual machines between physical machines --
you won't get the same sparse allocation of memory on the target machine.
Also, this will make it much easier to support hot plug memory at the
hypervisor level since it will be able to substitute memory with very
little support from the OS running in the virtual machine.