All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH for-4.10 3/5] tools/dombuilder: Switch to using gfn terminology for console and xenstore rings
Date: Fri, 6 Oct 2017 10:57:22 +0100	[thread overview]
Message-ID: <20171006095722.c2mg4k56hdm6o3fm@MacBook-Pro-de-Roger.local> (raw)
In-Reply-To: <1507227824-11744-4-git-send-email-andrew.cooper3@citrix.com>

On Thu, Oct 05, 2017 at 06:23:41PM +0000, Andrew Cooper wrote:
> diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
> index ce3c22e..a84a95e 100644
> --- a/tools/libxc/xc_dom_boot.c
> +++ b/tools/libxc/xc_dom_boot.c
> @@ -257,24 +257,24 @@ static xen_pfn_t xc_dom_gnttab_setup(xc_interface *xch, domid_t domid)
>  }
>  
>  int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid,
> -                       xen_pfn_t console_gmfn,
> -                       xen_pfn_t xenstore_gmfn,
> +                       xen_pfn_t console_gfn,
> +                       xen_pfn_t xenstore_gfn,
>                         domid_t console_domid,
>                         domid_t xenstore_domid)
>  {
>  
> -    xen_pfn_t gnttab_gmfn;
> +    xen_pfn_t gnttab_gfn;
>      grant_entry_v1_t *gnttab;
>  
> -    gnttab_gmfn = xc_dom_gnttab_setup(xch, domid);
> -    if ( gnttab_gmfn == -1 )
> +    gnttab_gfn = xc_dom_gnttab_setup(xch, domid);
> +    if ( gnttab_gfn == -1 )
>          return -1;
>  
>      gnttab = xc_map_foreign_range(xch,
>                                    domid,
>                                    PAGE_SIZE,
>                                    PROT_READ|PROT_WRITE,
> -                                  gnttab_gmfn);
> +                                  gnttab_gfn);
>      if ( gnttab == NULL )
>      {
>          xc_dom_panic(xch, XC_INTERNAL_ERROR,
> @@ -284,17 +284,17 @@ int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid,
>          return -1;
>      }
>  
> -    if ( domid != console_domid  && console_gmfn != -1)
> +    if ( domid != console_domid  && console_gfn != -1 )
                                  ^ extra space
>      {
>          gnttab[GNTTAB_RESERVED_CONSOLE].flags = GTF_permit_access;
>          gnttab[GNTTAB_RESERVED_CONSOLE].domid = console_domid;
> -        gnttab[GNTTAB_RESERVED_CONSOLE].frame = console_gmfn;
> +        gnttab[GNTTAB_RESERVED_CONSOLE].frame = console_gfn;
>      }
> -    if ( domid != xenstore_domid && xenstore_gmfn != -1)
> +    if ( domid != xenstore_domid && xenstore_gfn != -1 )
>      {
>          gnttab[GNTTAB_RESERVED_XENSTORE].flags = GTF_permit_access;
>          gnttab[GNTTAB_RESERVED_XENSTORE].domid = xenstore_domid;
> -        gnttab[GNTTAB_RESERVED_XENSTORE].frame = xenstore_gmfn;
> +        gnttab[GNTTAB_RESERVED_XENSTORE].frame = xenstore_gfn;
>      }
>  
>      if ( munmap(gnttab, PAGE_SIZE) == -1 )
> @@ -308,19 +308,19 @@ int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid,
>  
>      /* Guest shouldn't really touch its grant table until it has
>       * enabled its caches. But lets be nice. */
> -    xc_domain_cacheflush(xch, domid, gnttab_gmfn, 1);
> +    xc_domain_cacheflush(xch, domid, gnttab_gfn, 1);
>  
>      return 0;
>  }
>  
>  int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
> -                           xen_pfn_t console_gpfn,
> -                           xen_pfn_t xenstore_gpfn,
> +                           xen_pfn_t console_gfn,
> +                           xen_pfn_t xenstore_gfn,
>                             domid_t console_domid,
>                             domid_t xenstore_domid)
>  {
>      int rc;
> -    xen_pfn_t scratch_gpfn;
> +    xen_pfn_t scratch_gfn;
>      struct xen_add_to_physmap xatp = {
>          .domid = domid,
>          .space = XENMAPSPACE_grant_table,
> @@ -330,7 +330,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
>          .domid = domid,
>      };
>  
> -    rc = xc_core_arch_get_scratch_gpfn(xch, domid, &scratch_gpfn);
> +    rc = xc_core_arch_get_scratch_gpfn(xch, domid, &scratch_gfn);
>      if ( rc < 0 )
>      {
>          xc_dom_panic(xch, XC_INTERNAL_ERROR,
> @@ -339,11 +339,11 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
>                       __FUNCTION__, errno);
>          return -1;
>      }
> -    xatp.gpfn = scratch_gpfn;
> -    xrfp.gpfn = scratch_gpfn;
> +    xatp.gpfn = scratch_gfn;
> +    xrfp.gpfn = scratch_gfn;

xatp.gpfn = xrfp.gpfn = scratch_gfn;

Maybe, not important IMHO.

>  
> -    xc_dom_printf(xch, "%s: called, pfn=0x%"PRI_xen_pfn, __FUNCTION__,
> -                  scratch_gpfn);
> +    xc_dom_printf(xch, "%s: called, scratch gfn=0x%"PRI_xen_pfn, __FUNCTION__,
> +                  scratch_gfn);
>  
>  
>      rc = do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
> @@ -357,7 +357,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
>      }
>  
>      rc = xc_dom_gnttab_seed(xch, domid,
> -                            console_gpfn, xenstore_gpfn,
> +                            console_gfn, xenstore_gfn,
>                              console_domid, xenstore_domid);
>      if (rc != 0)
>      {
> @@ -385,12 +385,11 @@ int xc_dom_gnttab_init(struct xc_dom_image *dom)
>  {
>      if ( xc_dom_translated(dom) ) {
>          return xc_dom_gnttab_hvm_seed(dom->xch, dom->guest_domid,
> -                                      dom->console_pfn, dom->xenstore_pfn,
> +                                      dom->console_gfn, dom->xenstore_gfn,
>                                        dom->console_domid, dom->xenstore_domid);
>      } else {
>          return xc_dom_gnttab_seed(dom->xch, dom->guest_domid,
> -                                  xc_dom_p2m(dom, dom->console_pfn),
> -                                  xc_dom_p2m(dom, dom->xenstore_pfn),
> +                                  dom->console_gfn, dom->xenstore_gfn,
>                                    dom->console_domid, dom->xenstore_domid);

return xc_dom_translated(dom) ? xc_dom_gnttab_hvm_seed : xc_dom_gnttab_seed
                                (dom->xch, dom->guest_domid, dom->console_gfn,
                                 dom->xenstore_gfn, dom->console_domid,
                                 dom->xenstore_domid);

Not sure about the best indentation here. Or that could even be hidden
inside of xc_dom_gnttab_seed, so that xc_dom_gnttab_hvm_seed can be
removed.

>      }
>  }
> diff --git a/tools/libxc/xc_dom_compat_linux.c b/tools/libxc/xc_dom_compat_linux.c
> index c922c61..6d27ec2 100644
> --- a/tools/libxc/xc_dom_compat_linux.c
> +++ b/tools/libxc/xc_dom_compat_linux.c
> @@ -78,8 +78,8 @@ int xc_linux_build(xc_interface *xch, uint32_t domid,
>      if ( (rc = xc_dom_gnttab_init(dom)) != 0)
>          goto out;
>  
> -    *console_mfn = xc_dom_p2m(dom, dom->console_pfn);
> -    *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
> +    *console_mfn = dom->console_gfn;
> +    *store_mfn = dom->xenstore_gfn;
>  
>   out:
>      xc_dom_release(dom);
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index 0c80b59..aa0ced1 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -536,21 +536,23 @@ static int alloc_p2m_list_x86_64(struct xc_dom_image *dom)
>  
>  static int alloc_magic_pages_pv(struct xc_dom_image *dom)
>  {
> +    xen_pfn_t pfn;
> +
>      dom->start_info_pfn = xc_dom_alloc_page(dom, "start info");
>      if ( dom->start_info_pfn == INVALID_PFN )
>          return -1;
>  
> -    dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore");
> -    if ( dom->xenstore_pfn == INVALID_PFN )
> +    pfn = xc_dom_alloc_page(dom, "xenstore");
> +    if ( pfn == INVALID_PFN )
>          return -1;
> -    xc_clear_domain_page(dom->xch, dom->guest_domid,
> -                         xc_dom_p2m(dom, dom->xenstore_pfn));
> +    dom->xenstore_gfn = xc_dom_p2m(dom, pfn);
> +    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
>  
> -    dom->console_pfn = xc_dom_alloc_page(dom, "console");
> -    if ( dom->console_pfn == INVALID_PFN )
> +    pfn = xc_dom_alloc_page(dom, "console");
> +    if ( pfn == INVALID_PFN )
>          return -1;
> -    xc_clear_domain_page(dom->xch, dom->guest_domid,
> -                         xc_dom_p2m(dom, dom->console_pfn));
> +    dom->console_gfn = xc_dom_p2m(dom, pfn);
> +    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
>  
>      dom->alloc_bootstack = 1;
>  
> @@ -612,14 +614,19 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
>                                 X86_HVM_NR_SPECIAL_PAGES) )
>              goto error_out;
>  
> -    xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN,
> -                     special_pfn(SPECIALPAGE_XENSTORE));
> +    dom->xenstore_gfn = special_pfn(SPECIALPAGE_XENSTORE);

A pre-patch to s/special_pfn/special_gfn/ would be nice :) for
coherency.

> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index ef834e6..0389a06 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -851,14 +851,9 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
>      if (ret != 0)
>          goto out;
>  
> -    if (xc_dom_translated(dom)) {
> -        state->console_mfn = dom->console_pfn;
> -        state->store_mfn = dom->xenstore_pfn;
> -        state->vuart_gfn = dom->vuart_gfn;

This chunk should go with patch 1, it's a PVHv1 leftover also.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-10-06  9:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05 18:23 [PATCH for-4.10 0/5] tools/dombuilder: Fixes and improvements to grant handling Andrew Cooper
2017-10-05 18:23 ` [PATCH for-4.10 1/5] tools/dombuilder: Drop more PVH v1 leftovers Andrew Cooper
2017-10-06  9:26   ` Roger Pau Monné
2017-10-06  9:33     ` Wei Liu
2017-10-06  9:40       ` Roger Pau Monné
2017-10-06 10:06         ` Wei Liu
2017-10-06  9:33   ` Wei Liu
2017-10-05 18:23 ` [PATCH for-4.10 2/5] tools/dombuilder: Remove clear_page() from xc_dom_boot.c Andrew Cooper
2017-10-06  9:35   ` Roger Pau Monné
2017-10-06  9:51     ` Andrew Cooper
2017-10-06 17:28   ` Wei Liu
2017-10-05 18:23 ` [PATCH for-4.10 3/5] tools/dombuilder: Switch to using gfn terminology for console and xenstore rings Andrew Cooper
2017-10-06  9:57   ` Roger Pau Monné [this message]
2017-10-06 10:03     ` Andrew Cooper
2017-10-06 10:36       ` Roger Pau Monné
2017-10-06 14:48         ` Julien Grall
2017-10-06 17:35           ` Roger Pau Monné
2017-10-06 17:34   ` Wei Liu
2017-10-05 18:23 ` [PATCH for-4.10 4/5] tools/dombuilder: Fix asymetry when setting up " Andrew Cooper
2017-10-06 17:36   ` Wei Liu
2017-10-05 18:23 ` [PATCH for-4.10 4/5] tools/dombuilder: Fix asymmetry " Andrew Cooper
2017-10-06 10:17   ` Roger Pau Monné
2017-10-06 10:27     ` Andrew Cooper
2017-10-05 18:23 ` [PATCH for-4.10 5/5] tools/dombuilder: Prevent failures of xc_dom_gnttab_init() Andrew Cooper
2017-10-06 10:30   ` Roger Pau Monné
2017-10-06 18:04     ` Andrew Cooper
2017-10-09 15:33       ` Wei Liu
2017-10-06 17:39   ` Wei Liu
2017-10-06 18:22     ` Andrew Cooper
2017-10-09 11:03 ` [PATCH for-4.10 0/5] tools/dombuilder: Fixes and improvements to grant handling Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171006095722.c2mg4k56hdm6o3fm@MacBook-Pro-de-Roger.local \
    --to=roger.pau@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.