[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [v2 05/16] xen/arm: guest_copy: Extend the prototype to pass the vCPU
On Tue, 12 Dec 2017, Julien Grall wrote: > Currently, guest_copy assumes the copy will only be done for the current > vCPU. copy_guest is meant to be vCPU agnostic, so extend the prototype > to pass the vCPU. > > At the same time, encapsulate the vCPU in an union to allow extension > for copying from a guest domain (ipa case) in the future. > > Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> > --- > Changes in v2: > - Encapsulate the vCPU in an union. > - Rework the commit message > --- > xen/arch/arm/guestcopy.c | 25 +++++++++++++++++++------ > 1 file changed, 19 insertions(+), 6 deletions(-) > > diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c > index ff7d15380f..7e92e27beb 100644 > --- a/xen/arch/arm/guestcopy.c > +++ b/xen/arch/arm/guestcopy.c > @@ -9,8 +9,18 @@ > #define COPY_from_guest (0U << 1) > #define COPY_to_guest (1U << 1) > > +typedef union > +{ > + struct > + { > + struct vcpu *v; > + } gva; > +} copy_info_t; > + > +#define GVA_INFO(vcpu) ((copy_info_t) { .gva = { vcpu } }) > + > static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, > - unsigned int flags) > + copy_info_t info, unsigned int flags) > { > /* XXX needs to handle faults */ > unsigned offset = addr & ~PAGE_MASK; > @@ -23,7 +33,7 @@ static unsigned long copy_guest(void *buf, uint64_t addr, > unsigned int len, > unsigned size = min(len, (unsigned)PAGE_SIZE - offset); > struct page_info *page; > > - page = get_page_from_gva(current, addr, > + page = get_page_from_gva(info.gva.v, addr, > (flags & COPY_to_guest) ? GV2M_WRITE : > GV2M_READ); > if ( page == NULL ) > return len; > @@ -64,24 +74,27 @@ static unsigned long copy_guest(void *buf, uint64_t addr, > unsigned int len, > > unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) > { > - return copy_guest((void *)from, (vaddr_t)to, len, COPY_to_guest); > + return copy_guest((void *)from, (vaddr_t)to, len, > + GVA_INFO(current), COPY_to_guest); > } > > unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, > unsigned len) > { > - return copy_guest((void *)from, (vaddr_t)to, len, > + return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current), > COPY_to_guest | COPY_flush_dcache); > } > > unsigned long raw_clear_guest(void *to, unsigned len) > { > - return copy_guest(NULL, (vaddr_t)to, len, COPY_to_guest); > + return copy_guest(NULL, (vaddr_t)to, len, GVA_INFO(current), > + COPY_to_guest); > } > > unsigned long raw_copy_from_guest(void *to, const void __user *from, > unsigned len) > { > - return copy_guest(to, (vaddr_t)from, len, COPY_from_guest); > + return copy_guest(to, (vaddr_t)from, len, GVA_INFO(current), > + COPY_from_guest); > } > > /* > -- > 2.11.0 > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |