Re: [PATCH v7 02/24] KVM: arm64: Donate MMIO to the hypervisor
Mostafa Saleh <[email protected]> Wed, 5 Aug 2026 15:26:06 +0000
| Newsgroups | dev.linux.lists.iommu,dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 05, 2026 at 02:57:02PM +0000, Sebastian Ene wrote: > > > > + KVM_HOST_INVALID_PTE_TYPE_DONATION, > > > > + FIELD_PREP(KVM_HOST_DONATION_PTE_OWNER_MASK, PKVM_ID_HYP)); > > > > +unlock: > > > > + host_unlock_component(); > > > > + return ret; > > > > +} > > > > + > > > > +int __pkvm_hyp_donate_host_mmio(phys_addr_t addr, size_t size) > > > > > > This function seems to only update the host stage-2 annotation but it > > > doesn't destroy the hyp mapping. > > > > Yes, as mentioned above there is no way to destroy it, and this was > > not desgined for frequent use. Typicaly, __pkvm_host_donate_hyp_mmio() > > is called at boot per area/device. And __pkvm_hyp_donate_host_mmio() > > is only used for failures. > > > > Yes, I saw that you only allow the call during the init pKVM calls, however it seems a bit fragile. Why is it fragile? Nothing is wrong with leaking private mapping it's not real memory and it's massive, and given that this shouldn't happen and will cause KVM to fail on the system, it is not that bad. (as mentioned all other callers do the same) > > > > > > > I was looking to make use of this patch in an upcoming posting for the > > > v2 ITS hardening but in my case I don't need the private VA range > > > creation. > > > > I believe if you need to map MMIO, private range is the right way to > > do it as the linear map was mainly designed around system memory. > > Is there a reason behind not having MMIO as part of the linear > map in the hypervisor ? I would like to avoid holding the hva around and > just do a simple addition to resolve the hyp_va. When the linear is created it only considers the system memory layout https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/kvm/va_layout.c#n82 Which means that on some systems an MMIO address can be larger than the linear map. There is another comment about tha also in: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/kvm/hyp/nvhe/mm.c#n420 Thanks, Mostafa > > > > > Thanks, > > Mostafa > > > > Thanks, > Sebastian