[RFC PATCH 09/45] KVM: arm64: pkvm: Add pkvm_create_hyp_device_mapping()

Jean-Philippe Brucker jean-philippe at linaro.org
Wed Feb 8 10:02:09 PST 2023


On Tue, Feb 07, 2023 at 12:22:13PM +0000, Mostafa Saleh wrote:
> > +/* Map the MMIO region into the hypervisor and remove it from host */
> > +int pkvm_create_hyp_device_mapping(u64 base, u64 size, void __iomem *haddr)
> > +{
> > +	int ret;
> > +
> > +	ret = __pkvm_create_private_mapping(base, size, PAGE_HYP_DEVICE, haddr);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/* lock not needed during setup */
> > +	ret = host_stage2_set_owner_locked(base, size, PKVM_ID_HYP);
> > +	if (ret)
> > +		return ret;
> > +
> 
> Do we need to unmap in case of errors from host_stage2_set_owner_locked?

I don't think so because this function is meant for hyp setup only, so any
error causes a complete teardown of both hyp and host page tables

I wondered about adding a BUG_ON() here if the function is not used during
setup, but maybe improving the comment would be good enough.

Thanks,
Jean




More information about the linux-arm-kernel mailing list