From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 3/6] hvmloader: add helper functions to get/set HVM params
Date: Tue, 3 Jun 2014 15:43:42 -0400 [thread overview]
Message-ID: <20140603194342.GA19662@phenom.dumpdata.com> (raw)
In-Reply-To: <1401801340-6196-4-git-send-email-david.vrabel@citrix.com>
On Tue, Jun 03, 2014 at 02:15:37PM +0100, David Vrabel wrote:
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> tools/firmware/hvmloader/Makefile | 1 +
> tools/firmware/hvmloader/hvm_param.c | 36 ++++++++++++++++++++++++++++++++++
> tools/firmware/hvmloader/hvmloader.c | 14 ++-----------
> tools/firmware/hvmloader/util.h | 9 +++++++++
> tools/firmware/hvmloader/xenbus.c | 14 +++++--------
> 5 files changed, 53 insertions(+), 21 deletions(-)
> create mode 100644 tools/firmware/hvmloader/hvm_param.c
>
> diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
> index 00ee952..46a79c5 100644
> --- a/tools/firmware/hvmloader/Makefile
> +++ b/tools/firmware/hvmloader/Makefile
> @@ -31,6 +31,7 @@ CFLAGS += $(CFLAGS_xeninclude)
> OBJS = hvmloader.o mp_tables.o util.o smbios.o
> OBJS += smp.o cacheattr.o xenbus.o
> OBJS += e820.o pci.o pir.o ctype.o
> +OBJS += hvm_param.o
> ifeq ($(debug),y)
> OBJS += tests.o
> endif
> diff --git a/tools/firmware/hvmloader/hvm_param.c b/tools/firmware/hvmloader/hvm_param.c
> new file mode 100644
> index 0000000..f7d8720
> --- /dev/null
> +++ b/tools/firmware/hvmloader/hvm_param.c
> @@ -0,0 +1,36 @@
> +/*
> + * hvm_param.c: get/set HVM params.
> + *
> + * Copyright (C) 2014 Citrix Systems R&D Ltd.
> + */
> +#include "util.h"
> +#include "config.h"
> +#include "hypercall.h"
> +
> +#include <xen/hvm/params.h>
> +
> +int hvm_param_get(uint32_t index, uint64_t *value)
> +{
> + struct xen_hvm_param p;
> + int ret;
> +
> + p.domid = DOMID_SELF;
> + p.index = index;
> +
> + ret = hypercall_hvm_op(HVMOP_get_param, &p);
> + if (ret == 0)
> + *value = p.value;
> +
> + return ret;
> +}
> +
> +int hvm_param_set(uint32_t index, uint64_t value)
> +{
> + struct xen_hvm_param p;
> +
> + p.domid = DOMID_SELF;
> + p.index = index;
> + p.value = value;
> +
> + return hypercall_hvm_op(HVMOP_set_param, &p);
> +}
> diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
> index 1cc8cf2..7b0da38 100644
> --- a/tools/firmware/hvmloader/hvmloader.c
> +++ b/tools/firmware/hvmloader/hvmloader.c
> @@ -176,14 +176,10 @@ static void cmos_write_memory_size(void)
> static void init_vm86_tss(void)
> {
> void *tss;
> - struct xen_hvm_param p;
>
> tss = mem_alloc(128, 128);
> memset(tss, 0, 128);
> - p.domid = DOMID_SELF;
> - p.index = HVM_PARAM_VM86_TSS;
> - p.value = virt_to_phys(tss);
> - hypercall_hvm_op(HVMOP_set_param, &p);
> + hvm_param_set(HVM_PARAM_VM86_TSS, virt_to_phys(tss));
> printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
> }
>
> @@ -314,12 +310,6 @@ int main(void)
>
> if ( acpi_enabled )
> {
> - struct xen_hvm_param p = {
> - .domid = DOMID_SELF,
> - .index = HVM_PARAM_ACPI_IOPORTS_LOCATION,
> - .value = 1,
> - };
> -
> if ( bios->acpi_build_tables )
> {
> printf("Loading ACPI ...\n");
> @@ -328,7 +318,7 @@ int main(void)
>
> acpi_enable_sci();
>
> - hypercall_hvm_op(HVMOP_set_param, &p);
> + hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1);
> }
>
> init_vm86_tss();
> diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h
> index 9ccb905..e4b6be4 100644
> --- a/tools/firmware/hvmloader/util.h
> +++ b/tools/firmware/hvmloader/util.h
> @@ -210,6 +210,15 @@ const char *xenstore_read(const char *path, const char *default_resp);
> */
> int xenstore_write(const char *path, const char *value);
>
> +
> +/* Get a HVM param.
> + */
> +int hvm_param_get(uint32_t index, uint64_t *value);
> +
> +/* Set a HVM param.
> + */
> +int hvm_param_set(uint32_t index, uint64_t value);
> +
> /* Setup PCI bus */
> void pci_setup(void);
>
> diff --git a/tools/firmware/hvmloader/xenbus.c b/tools/firmware/hvmloader/xenbus.c
> index fe72e97..64c2176 100644
> --- a/tools/firmware/hvmloader/xenbus.c
> +++ b/tools/firmware/hvmloader/xenbus.c
> @@ -41,21 +41,17 @@ static char payload[XENSTORE_PAYLOAD_MAX + 1]; /* Unmarshalling area */
> * Call once, before any other xenbus actions. */
> void xenbus_setup(void)
> {
> - xen_hvm_param_t param;
> + uint64_t val;
>
> /* Ask Xen where the xenbus shared page is. */
> - param.domid = DOMID_SELF;
> - param.index = HVM_PARAM_STORE_PFN;
> - if ( hypercall_hvm_op(HVMOP_get_param, ¶m) )
> + if ( hvm_param_get(HVM_PARAM_STORE_PFN, &val) )
> BUG();
> - rings = (void *) (unsigned long) (param.value << PAGE_SHIFT);
> + rings = (void *) (unsigned long) (val << PAGE_SHIFT);
>
> /* Ask Xen where the xenbus event channel is. */
> - param.domid = DOMID_SELF;
> - param.index = HVM_PARAM_STORE_EVTCHN;
> - if ( hypercall_hvm_op(HVMOP_get_param, ¶m) )
> + if ( hvm_param_get(HVM_PARAM_STORE_EVTCHN, &val) )
> BUG();
> - event = param.value;
> + event = val;
>
> printf("Xenbus rings @0x%lx, event channel %lu\n",
> (unsigned long) rings, (unsigned long) event);
> --
> 1.7.10.4
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-06-03 19:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 13:15 [PATCHv3 0/6] tools: rework VM Generation ID David Vrabel
2014-06-03 13:15 ` [PATCH 1/6] docs: update docs for the ~/platform/generation-id key David Vrabel
2014-06-10 10:25 ` Ian Campbell
2014-06-03 13:15 ` [PATCH 2/6] hvm: add HVM_PARAM_VM_GENERATION_ID_ADDR David Vrabel
2014-06-03 13:19 ` Andrew Cooper
2014-06-10 10:27 ` Ian Campbell
2014-06-10 10:40 ` Jan Beulich
2014-06-10 10:44 ` Andrew Cooper
2014-06-10 10:49 ` Jan Beulich
2014-06-03 13:15 ` [PATCH 3/6] hvmloader: add helper functions to get/set HVM params David Vrabel
2014-06-03 19:43 ` Konrad Rzeszutek Wilk [this message]
2014-06-10 10:39 ` Ian Campbell
2014-06-03 13:15 ` [PATCH 4/6] libxc, libxl, hvmloader: strip out outdated VM generation ID implementation David Vrabel
2014-06-10 10:42 ` Ian Campbell
2014-06-03 13:15 ` [PATCH 5/6] libxl: allow a generation ID to be specified at domain creation David Vrabel
2014-06-03 13:28 ` Andrew Cooper
2014-06-03 14:14 ` David Vrabel
2014-06-10 11:01 ` Ian Campbell
2014-06-10 12:35 ` David Vrabel
2014-06-10 13:37 ` Ian Campbell
2014-06-10 13:41 ` David Vrabel
2014-06-10 14:18 ` Ian Campbell
2014-06-10 17:59 ` David Vrabel
2014-06-11 8:22 ` Ian Campbell
2014-06-11 10:53 ` David Vrabel
2014-06-11 11:01 ` Ian Campbell
2014-06-11 11:47 ` David Vrabel
2014-06-11 11:53 ` Ian Campbell
2014-06-03 13:15 ` [PATCH 6/6] xl: generate a new random VM generation ID if requested David Vrabel
2014-06-10 11:02 ` Ian Campbell
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=20140603194342.GA19662@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xenproject.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).