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

Re: [PATCH] xen/x86: allow Dom0 PVH to call XENMEM_exchange



Hello Stefano,

Le 25/04/2025 à 22:21, Stefano Stabellini a écrit :
> From: Xenia Ragiadakou <Xenia.Ragiadakou@xxxxxxx>
>
> Dom0 PVH might need XENMEM_exchange when passing contiguous memory
> addresses to firmware or co-processors not behind an IOMMU.
>
> XENMEM_exchange was blocked for HVM/PVH DomUs, and accidentally it
> impacted Dom0 PVH as well.
>
> Permit Dom0 PVH to call XENMEM_exchange while leaving it blocked for
> HVM/PVH DomUs.
>

In addition to Jan's remarks, I think it wants some additional
clarifications on the hypercall interface. public/memory.h indicates
"only PV guests can use this operation", so the interface is actually
unspecified about HVM guests (e.g what are MFN/GMFN in this case ?).

> Signed-off-by: Xenia Ragiadakou <Xenia.Ragiadakou@xxxxxxx>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
>
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index 1cf2365167..e995944333 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -4401,7 +4401,7 @@ int steal_page(
>       const struct domain *owner;
>       int rc;
>
> -    if ( paging_mode_external(d) )
> +    if ( paging_mode_external(d) && !is_hardware_domain(d) )
>           return -EOPNOTSUPP;
>
>       /* Grab a reference to make sure the page doesn't change under our feet 
> */
> diff --git a/xen/common/memory.c b/xen/common/memory.c
> index 8ca4e1a842..796eec081b 100644
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -794,7 +794,7 @@ static long 
> memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)
>               rc = guest_physmap_add_page(d, _gfn(gpfn), mfn,
>                                           exch.out.extent_order) ?: rc;
>
> -            if ( !paging_mode_translate(d) &&
> +            if ( (!paging_mode_translate(d) || is_hardware_domain(d)) &&
>                    __copy_mfn_to_guest_offset(exch.out.extent_start,
>                                               (i << out_chunk_order) + j,
>                                               mfn) )
>

Teddy


 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.