From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@arm.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH for-4.10 v2 3/5] tools/dombuilder: Switch to using gfn terminology for console and xenstore rings
Date: Thu, 12 Oct 2017 20:19:07 +0100 [thread overview]
Message-ID: <1507835949-9429-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1507835949-9429-1-git-send-email-andrew.cooper3@citrix.com>
The sole use of xc_dom_translated() and xc_dom_p2m() outside of the domain
builder is for libxl_dom() to translate the console and xenstore pfns back
into useful values. PV guest pfns are only interesting to the domain builder,
and gfns are the address space used by all other hypercalls.
Renaming the fields in xc_dom_image is deliberate, as it will cause
out-of-tree users of the dombuilder to notice the different semantics.
Correct the terminology throughout xc_dom_gnttab{_hvm,}_seed(), which are all
using gfns despite the existing variable names.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Julien Grall <julien.grall@arm.com>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Julien Grall <julien.grall@arm.com>
v2:
* More style fixes
---
tools/libxc/include/xc_dom.h | 10 +++++++--
tools/libxc/xc_dom_arm.c | 12 +++++------
tools/libxc/xc_dom_boot.c | 45 ++++++++++++++++++---------------------
tools/libxc/xc_dom_compat_linux.c | 4 ++--
tools/libxc/xc_dom_x86.c | 45 ++++++++++++++++++++-------------------
tools/libxl/libxl_dom.c | 11 +++-------
6 files changed, 63 insertions(+), 64 deletions(-)
diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index cdcdd07..5907559 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -94,8 +94,6 @@ struct xc_dom_image {
struct xc_dom_seg devicetree_seg;
struct xc_dom_seg start_info_seg; /* HVMlite only */
xen_pfn_t start_info_pfn;
- xen_pfn_t console_pfn;
- xen_pfn_t xenstore_pfn;
xen_pfn_t shared_info_pfn;
xen_pfn_t bootstack_pfn;
xen_pfn_t pfn_alloc_end;
@@ -103,6 +101,14 @@ struct xc_dom_image {
xen_vaddr_t bsd_symtab_start;
/*
+ * Details for the toolstack-prepared rings.
+ *
+ * *_gfn fields are allocated by the domain builder.
+ */
+ xen_pfn_t console_gfn;
+ xen_pfn_t xenstore_gfn;
+
+ /*
* initrd parameters as specified in start_info page
* Depending on capabilities of the booted kernel this may be a virtual
* address or a pfn. Type is neutral and large enough to hold a virtual
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index fce151d..2fe75cd 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -84,19 +84,19 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
if ( rc < 0 )
return rc;
- dom->console_pfn = base + CONSOLE_PFN_OFFSET;
- dom->xenstore_pfn = base + XENSTORE_PFN_OFFSET;
+ dom->console_gfn = base + CONSOLE_PFN_OFFSET;
+ dom->xenstore_gfn = base + XENSTORE_PFN_OFFSET;
dom->vuart_gfn = base + VUART_PFN_OFFSET;
- xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn);
- xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn);
+ xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
+ xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
xc_clear_domain_page(dom->xch, dom->guest_domid, base + MEMACCESS_PFN_OFFSET);
xc_clear_domain_page(dom->xch, dom->guest_domid, dom->vuart_gfn);
xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN,
- dom->console_pfn);
+ dom->console_gfn);
xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN,
- dom->xenstore_pfn);
+ dom->xenstore_gfn);
xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_MONITOR_RING_PFN,
base + MEMACCESS_PFN_OFFSET);
/* allocated by toolstack */
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index 2e5681d..bbf98b6 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -257,24 +257,23 @@ static xen_pfn_t xc_dom_gnttab_setup(xc_interface *xch, uint32_t domid)
}
int xc_dom_gnttab_seed(xc_interface *xch, uint32_t domid,
- xen_pfn_t console_gmfn,
- xen_pfn_t xenstore_gmfn,
+ xen_pfn_t console_gfn,
+ xen_pfn_t xenstore_gfn,
uint32_t console_domid,
uint32_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 +283,17 @@ int xc_dom_gnttab_seed(xc_interface *xch, uint32_t domid,
return -1;
}
- if ( domid != console_domid && console_gmfn != -1)
+ if ( domid != console_domid && console_gfn != -1 )
{
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 +307,19 @@ int xc_dom_gnttab_seed(xc_interface *xch, uint32_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, uint32_t domid,
- xen_pfn_t console_gpfn,
- xen_pfn_t xenstore_gpfn,
+ xen_pfn_t console_gfn,
+ xen_pfn_t xenstore_gfn,
uint32_t console_domid,
uint32_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 +329,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_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 +338,10 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t domid,
__FUNCTION__, errno);
return -1;
}
- xatp.gpfn = scratch_gpfn;
- xrfp.gpfn = scratch_gpfn;
+ xatp.gpfn = xrfp.gpfn = scratch_gfn;
- 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 +355,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_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 +383,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);
}
}
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 bff68a0..c74fb96 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);
+ xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
+ xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN, dom->xenstore_gfn);
+
xc_hvm_param_set(xch, domid, HVM_PARAM_BUFIOREQ_PFN,
special_pfn(SPECIALPAGE_BUFIOREQ));
xc_hvm_param_set(xch, domid, HVM_PARAM_IOREQ_PFN,
special_pfn(SPECIALPAGE_IOREQ));
- xc_hvm_param_set(xch, domid, HVM_PARAM_CONSOLE_PFN,
- special_pfn(SPECIALPAGE_CONSOLE));
+
+ dom->console_gfn = special_pfn(SPECIALPAGE_CONSOLE);
+ xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
+ xc_hvm_param_set(xch, domid, HVM_PARAM_CONSOLE_PFN, dom->console_gfn);
+
xc_hvm_param_set(xch, domid, HVM_PARAM_PAGING_RING_PFN,
special_pfn(SPECIALPAGE_PAGING));
xc_hvm_param_set(xch, domid, HVM_PARAM_MONITOR_RING_PFN,
@@ -699,12 +706,6 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
xc_hvm_param_set(xch, domid, HVM_PARAM_IDENT_PT,
special_pfn(SPECIALPAGE_IDENT_PT) << PAGE_SHIFT);
- dom->console_pfn = special_pfn(SPECIALPAGE_CONSOLE);
- xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn);
-
- dom->xenstore_pfn = special_pfn(SPECIALPAGE_XENSTORE);
- xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn);
-
dom->parms.virt_hypercall = -1;
rc = 0;
@@ -744,9 +745,9 @@ static int start_info_x86_32(struct xc_dom_image *dom)
start_info->mfn_list = dom->p2m_seg.vstart;
start_info->flags = dom->flags;
- start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
+ start_info->store_mfn = dom->xenstore_gfn;
start_info->store_evtchn = dom->xenstore_evtchn;
- start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn);
+ start_info->console.domU.mfn = dom->console_gfn;
start_info->console.domU.evtchn = dom->console_evtchn;
if ( dom->ramdisk_blob )
@@ -795,9 +796,9 @@ static int start_info_x86_64(struct xc_dom_image *dom)
}
start_info->flags = dom->flags;
- start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
+ start_info->store_mfn = dom->xenstore_gfn;
start_info->store_evtchn = dom->xenstore_evtchn;
- start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn);
+ start_info->console.domU.mfn = dom->console_gfn;
start_info->console.domU.evtchn = dom->console_evtchn;
if ( dom->ramdisk_blob )
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;
- } else {
- state->console_mfn = xc_dom_p2m(dom, dom->console_pfn);
- state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
- }
+ state->console_mfn = dom->console_gfn;
+ state->store_mfn = dom->xenstore_gfn;
+ state->vuart_gfn = dom->vuart_gfn;
ret = 0;
out:
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-12 19:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 19:19 [PATCH for-4.10 v2 0/5] tools/dombuilder: Fixes and improvements to grant handling Andrew Cooper
2017-10-12 19:19 ` [PATCH for-4.10 v2 1/5] tools/dombuilder: Drop more PVH v1 leftovers Andrew Cooper
2017-10-12 19:19 ` [PATCH for-4.10 v2 2/5] tools/dombuilder: Remove clear_page() from xc_dom_boot.c Andrew Cooper
2017-10-12 19:19 ` Andrew Cooper [this message]
2017-11-02 16:42 ` [PATCH for-4.10 v2 3/5] tools/dombuilder: Switch to using gfn terminology for console and xenstore rings Wei Liu
2017-10-12 19:19 ` [PATCH for-4.10 v2 4/5] tools/dombuilder: Fix asymmetry when setting up " Andrew Cooper
2017-10-12 19:19 ` [PATCH for-4.10 v2 5/5] tools/dombuilder: Prevent failures of xc_dom_gnttab_init() Andrew Cooper
2017-10-24 16:06 ` [PATCH for-4.10 v2 0/5] tools/dombuilder: Fixes and improvements to grant handling Julien Grall
2017-10-25 7:08 ` Juergen Gross
2017-10-27 13:31 ` Julien Grall
2017-11-02 13:44 ` Julien Grall
2017-11-02 13:45 ` 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=1507835949-9429-4-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=julien.grall@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).