|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 03/11] xen/riscv: implement copy_to_guest_phys()
On 23.03.2026 17:29, Oleksii Kurochko wrote:
> Introduce copy_to_guest_phys() for RISC-V, based on the Arm implementation.
>
> Add a generic copy_guest() helper for copying to and from guest physical
> (and potentially virtual addresses in the future), and implement
> translate_get_page() to translate a guest physical address into a struct
> page_info via the domain p2m.
>
> Compared to the Arm code:
> - Drop COPY_flush_dcache(), as no such use cases exist on RISC-V.
> - Do not implement the linear mapping case, which is currently unused.
> - Use PAGE_OFFSET() to initialize the local offset variable in copy_guest().
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
preferably with ...
> +static unsigned int copy_guest(void *buf, uint64_t addr, unsigned int len,
> + copy_info_t info, unsigned int flags)
> +{
> + unsigned int offset = PAGE_OFFSET(addr);
> +
> + BUILD_BUG_ON((sizeof(addr)) < sizeof(vaddr_t));
> + BUILD_BUG_ON((sizeof(addr)) < sizeof(paddr_t));
> +
> + while ( len )
> + {
> + void *p;
> + unsigned int size = min(len, (unsigned int)PAGE_SIZE - offset);
> + struct page_info *page;
> +
> + page = translate_get_page(info, addr, flags & COPY_gva,
> + flags & COPY_to_guest);
> + if ( page == NULL )
... this consistent ("!page") with ....
> + return len;
> +
> + p = __map_domain_page(page);
> + p += offset;
> + if ( flags & COPY_to_guest )
> + {
> + /*
> + * buf will be NULL when the caller request to zero the
> + * guest memory.
> + */
> + if ( buf )
... this.
> + memcpy(p, buf, size);
> + else
> + memset(p, 0, size);
> + }
> + else
> + memcpy(buf, p, size);
> +
> + unmap_domain_page(p - offset);
It doesn't look like the subtracting of "offset" would be needed here. Any
pointer into the correct page will do.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |