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

Re: [PATCH v2 5/8] x86/gdbsx: convert "user" to "guest" accesses


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 22 Feb 2021 17:08:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WLnkZsJwwsI8HcmRulCLgyxmuujzINu+NYJ+HPQolY4=; b=ncoIMq9+OWRCe/CyvcBX+XdClROT1eeVY7OzhUnMAkmzpvIELHEVshj8CX2GsbUy+8XcwVGb/KeEJaaS6g8jliybMRKc8kN+PfAnesYQd9eQFOkDmcQo6bmBoVfoRHiO1SPgoMbfNNqOqhO2NNFEZwvWH8hP/okaQoEHzf6vKHOlLOfJNDgXHR1Qv0InHVtvbDrVhgAnWUKdMqq/VDHdWiGexnHC6Fggr/SXyUYILVljcYmBekG/x2NzjP+WEuyjAQljRyBb8QDjO4di0EB89iG2Ky7Fcu8OAVUWI+JYNn0A22CZcO0nkGnKYqNRzpnC0bAhnrtuCVOBBemL6JWT9Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYOUSujoU/eB2aVFpGcUhiBDB19CeBtJUH0O35gMDAlbwDX/0fXf8N0J3zMwBNlE6fcaAATSbvUc8b0oH5kGVsX4tOm2UbSR+E4JamV0IH3//IqaZh6Pc/Jb/DGy36MDSWc+Qnnl3XcgB7rSFfrUe5C5SkHonyBsUPY6Ws61D3nBRRZ5vy5dxo7fTZbMfFGf35Trw+3aTi5gorH9luqs5Yzxdf5p9Q/4lFl78NqbdGisoRXnUMkkGlerAfwCj6MXshrgTdqAAh6M1yZFm4d+Poqj44/O6iuuwfCt95GeOGzXHenny5NZjBsLyFocGFjT2hwbmUoUZo3yF7SeL/sFCw==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Mon, 22 Feb 2021 16:08:28 +0000
  • Ironport-sdr: 4H+WQCI7vCLXTiDhBv2gLDZdacPuGNvJAYMZIjxCXaMPzf7iAoQOb/larwec8UmgwSZH84gMpP 634JMeuEO4cQ/IsXkU0YRTnK2UcxzKuCJoa1cvmoxkXHS1zKpHwmi0xWyVX8uPglJ/9QoiNFZg BXXJhzhxqSet3k1MUe8VVQCpBY0rk0DtAvF9GBTiOd3y3oQGET9jTYzW4ROorlDXl7CugHLGx2 OJexsIXc9u0vzkEtWrAWYpd5DzA48FAK2PgHKDiVh/OLJRxUwtwBhdI5rwKf8mwtuOtJ8JDLzQ 140=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Feb 22, 2021 at 04:55:03PM +0100, Jan Beulich wrote:
> On 22.02.2021 16:31, Roger Pau Monné wrote:
> > On Wed, Feb 17, 2021 at 09:21:36AM +0100, Jan Beulich wrote:
> >> Using copy_{from,to}_user(), this code was assuming to be called only by
> >> PV guests. Use copy_{from,to}_guest() instead, transforming the incoming
> >> structure field into a guest handle (the field should really have been
> >> one in the first place). Also do not transform the debuggee address into
> >> a pointer.
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> > 
> > Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Thanks.
> 
> > One minor comment below that can be taken care of when committing I
> > think.
> > 
> >> ---
> >> v2: Re-base (bug fix side effect was taken care of already).
> >>
> >> --- a/xen/arch/x86/debug.c
> >> +++ b/xen/arch/x86/debug.c
> >> @@ -108,12 +108,11 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct doma
> >>  }
> >>  
> >>  /* Returns: number of bytes remaining to be copied */
> >> -static unsigned int dbg_rw_guest_mem(struct domain *dp, void * __user 
> >> gaddr,
> >> -                                     void * __user buf, unsigned int len,
> >> -                                     bool toaddr, uint64_t pgd3)
> >> +static unsigned int dbg_rw_guest_mem(struct domain *dp, unsigned long 
> >> addr,
> >> +                                     XEN_GUEST_HANDLE_PARAM(void) buf,
> >> +                                     unsigned int len, bool toaddr,
> >> +                                     uint64_t pgd3)
> >>  {
> >> -    unsigned long addr = (unsigned long)gaddr;
> >> -
> >>      while ( len > 0 )
> >>      {
> >>          char *va;
> >> @@ -134,20 +133,18 @@ static unsigned int dbg_rw_guest_mem(str
> >>  
> >>          if ( toaddr )
> >>          {
> >> -            copy_from_user(va, buf, pagecnt);    /* va = buf */
> >> +            copy_from_guest(va, buf, pagecnt);
> >>              paging_mark_dirty(dp, mfn);
> >>          }
> >>          else
> >> -        {
> >> -            copy_to_user(buf, va, pagecnt);    /* buf = va */
> >> -        }
> >> +            copy_to_guest(buf, va, pagecnt);
> >>  
> >>          unmap_domain_page(va);
> >>          if ( !gfn_eq(gfn, INVALID_GFN) )
> >>              put_gfn(dp, gfn_x(gfn));
> >>  
> >>          addr += pagecnt;
> >> -        buf += pagecnt;
> >> +        guest_handle_add_offset(buf, pagecnt);
> >>          len -= pagecnt;
> >>      }
> >>  
> >> @@ -161,7 +158,7 @@ static unsigned int dbg_rw_guest_mem(str
> >>   * pgd3: value of init_mm.pgd[3] in guest. see above.
> >>   * Returns: number of bytes remaining to be copied.
> >>   */
> >> -unsigned int dbg_rw_mem(void * __user addr, void * __user buf,
> >> +unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) 
> >> buf,
> >>                          unsigned int len, domid_t domid, bool toaddr,
> >>                          uint64_t pgd3)
> > 
> > You change the prototype below to make pgd3 unsigned long, so you
> > should change the type here also? (and likely in dbg_rw_guest_mem?)
> 
> I'd rather undo the change to the prototype, or else further
> changes would be needed for consistency. I'll take it that
> you're fine either way, and hence your ack stands.

Yes, that's also fine as long as it's consistent.

Roger.



 


Rackspace

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