Message ID | 20190617154105.32323-4-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Fix build of Xen support + cleanup | expand |
> -----Original Message----- > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > Sent: 17 June 2019 16:41 > To: qemu-devel@nongnu.org > Cc: xen-devel@lists.xenproject.org; Anthony Perard <anthony.perard@citrix.com>; Stefano Stabellini > <sstabellini@kernel.org>; Paul Durrant <Paul.Durrant@citrix.com> > Subject: [PATCH 3/4] xen: Import Xen public headers used by xen-hvm.c > > Following "xen: Fix build with public headers", import other Xen > public headers that are describing interfaces. > > The headers are cleaned up a bit while importing them. The header > guard symbols are changed to match QEMU's coding style, some other > part of the files that QEMU doesn't use are removed. > > xen-mapcache.c doesn't needs params.h, so remove the include. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > --- > hw/i386/xen/xen-hvm.c | 6 +- > hw/i386/xen/xen-mapcache.c | 2 - > include/hw/xen/interface/hvm/e820.h | 28 +++++++ > include/hw/xen/interface/hvm/ioreq.h | 101 ++++++++++++++++++++++++++ > include/hw/xen/interface/hvm/params.h | 33 +++++++++ > 5 files changed, 165 insertions(+), 5 deletions(-) > create mode 100644 include/hw/xen/interface/hvm/e820.h > create mode 100644 include/hw/xen/interface/hvm/ioreq.h > create mode 100644 include/hw/xen/interface/hvm/params.h > > diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c > index 2939122e7c..725f9c2278 100644 > --- a/hw/i386/xen/xen-hvm.c > +++ b/hw/i386/xen/xen-hvm.c > @@ -26,9 +26,9 @@ > #include "trace.h" > #include "exec/address-spaces.h" > > -#include <xen/hvm/ioreq.h> > -#include <xen/hvm/params.h> > -#include <xen/hvm/e820.h> > +#include "hw/xen/interface/hvm/ioreq.h" > +#include "hw/xen/interface/hvm/params.h" AFAICT the only place (apart from legacy code in xen_common.h) that params.h is necessary is in xen_suspend_notifier(). I wonder whether that would be better moved into xen_common.h too (since it's just a wrapper round xc_set_hvm_param() and then the inclusion of params.h can be moved there as well. Paul
On Mon, Jun 17, 2019 at 05:15:51PM +0100, Paul Durrant wrote: > > -----Original Message----- > > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > > Sent: 17 June 2019 16:41 > > To: qemu-devel@nongnu.org > > Cc: xen-devel@lists.xenproject.org; Anthony Perard <anthony.perard@citrix.com>; Stefano Stabellini > > <sstabellini@kernel.org>; Paul Durrant <Paul.Durrant@citrix.com> > > Subject: [PATCH 3/4] xen: Import Xen public headers used by xen-hvm.c > > > > Following "xen: Fix build with public headers", import other Xen > > public headers that are describing interfaces. > > > > The headers are cleaned up a bit while importing them. The header > > guard symbols are changed to match QEMU's coding style, some other > > part of the files that QEMU doesn't use are removed. > > > > xen-mapcache.c doesn't needs params.h, so remove the include. > > > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > > --- > > hw/i386/xen/xen-hvm.c | 6 +- > > hw/i386/xen/xen-mapcache.c | 2 - > > include/hw/xen/interface/hvm/e820.h | 28 +++++++ > > include/hw/xen/interface/hvm/ioreq.h | 101 ++++++++++++++++++++++++++ > > include/hw/xen/interface/hvm/params.h | 33 +++++++++ > > 5 files changed, 165 insertions(+), 5 deletions(-) > > create mode 100644 include/hw/xen/interface/hvm/e820.h > > create mode 100644 include/hw/xen/interface/hvm/ioreq.h > > create mode 100644 include/hw/xen/interface/hvm/params.h > > > > diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c > > index 2939122e7c..725f9c2278 100644 > > --- a/hw/i386/xen/xen-hvm.c > > +++ b/hw/i386/xen/xen-hvm.c > > @@ -26,9 +26,9 @@ > > #include "trace.h" > > #include "exec/address-spaces.h" > > > > -#include <xen/hvm/ioreq.h> > > -#include <xen/hvm/params.h> > > -#include <xen/hvm/e820.h> > > +#include "hw/xen/interface/hvm/ioreq.h" > > +#include "hw/xen/interface/hvm/params.h" > > AFAICT the only place (apart from legacy code in xen_common.h) that > params.h is necessary is in xen_suspend_notifier(). I wonder whether > that would be better moved into xen_common.h too (since it's just a > wrapper round xc_set_hvm_param() and then the inclusion of params.h > can be moved there as well. :(, I didn't realised that xen_common.h needed params.h too. That patch series might not build on older version of Xen. I'll move the inclusion of params.h to xen_common.h, and fix params.h to have all the needed #defines. About xen_suspend_notifier(), it's actually more than a wrapper, it's also a function. A pointer to the function is given to a notifier. So I don't think using "inline" will work, and I don't think it makes sense to have a function without "inline" in xen_common.h. So I think xen_{suspend,wakeup}_notifier are fine where there are, do you agree? Thanks,
> -----Original Message----- > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > Sent: 17 June 2019 17:46 > To: Paul Durrant <Paul.Durrant@citrix.com> > Cc: qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org> > Subject: Re: [PATCH 3/4] xen: Import Xen public headers used by xen-hvm.c > > On Mon, Jun 17, 2019 at 05:15:51PM +0100, Paul Durrant wrote: > > > -----Original Message----- > > > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > > > Sent: 17 June 2019 16:41 > > > To: qemu-devel@nongnu.org > > > Cc: xen-devel@lists.xenproject.org; Anthony Perard <anthony.perard@citrix.com>; Stefano Stabellini > > > <sstabellini@kernel.org>; Paul Durrant <Paul.Durrant@citrix.com> > > > Subject: [PATCH 3/4] xen: Import Xen public headers used by xen-hvm.c > > > > > > Following "xen: Fix build with public headers", import other Xen > > > public headers that are describing interfaces. > > > > > > The headers are cleaned up a bit while importing them. The header > > > guard symbols are changed to match QEMU's coding style, some other > > > part of the files that QEMU doesn't use are removed. > > > > > > xen-mapcache.c doesn't needs params.h, so remove the include. > > > > > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > > > --- > > > hw/i386/xen/xen-hvm.c | 6 +- > > > hw/i386/xen/xen-mapcache.c | 2 - > > > include/hw/xen/interface/hvm/e820.h | 28 +++++++ > > > include/hw/xen/interface/hvm/ioreq.h | 101 ++++++++++++++++++++++++++ > > > include/hw/xen/interface/hvm/params.h | 33 +++++++++ > > > 5 files changed, 165 insertions(+), 5 deletions(-) > > > create mode 100644 include/hw/xen/interface/hvm/e820.h > > > create mode 100644 include/hw/xen/interface/hvm/ioreq.h > > > create mode 100644 include/hw/xen/interface/hvm/params.h > > > > > > diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c > > > index 2939122e7c..725f9c2278 100644 > > > --- a/hw/i386/xen/xen-hvm.c > > > +++ b/hw/i386/xen/xen-hvm.c > > > @@ -26,9 +26,9 @@ > > > #include "trace.h" > > > #include "exec/address-spaces.h" > > > > > > -#include <xen/hvm/ioreq.h> > > > -#include <xen/hvm/params.h> > > > -#include <xen/hvm/e820.h> > > > +#include "hw/xen/interface/hvm/ioreq.h" > > > +#include "hw/xen/interface/hvm/params.h" > > > > AFAICT the only place (apart from legacy code in xen_common.h) that > > params.h is necessary is in xen_suspend_notifier(). I wonder whether > > that would be better moved into xen_common.h too (since it's just a > > wrapper round xc_set_hvm_param() and then the inclusion of params.h > > can be moved there as well. > > :(, I didn't realised that xen_common.h needed params.h too. That patch > series might not build on older version of Xen. I'll move the inclusion > of params.h to xen_common.h, and fix params.h to have all the needed > #defines. > > About xen_suspend_notifier(), it's actually more than a wrapper, it's > also a function. A pointer to the function is given to a notifier. > So I don't think using "inline" will work, and I don't think it makes > sense to have a function without "inline" in xen_common.h. So I think > xen_{suspend,wakeup}_notifier are fine where there are, do you agree? Oh, I hadn't realized they were callbacks. In that case, leave the functions where they are. We really ought to have a stable API rather than a params interface... Not something you can address here though. Cheers, Paul > > Thanks, > > -- > Anthony PERARD
On Mon, Jun 17, 2019 at 05:45:44PM +0100, Anthony PERARD wrote: > On Mon, Jun 17, 2019 at 05:15:51PM +0100, Paul Durrant wrote: > > AFAICT the only place (apart from legacy code in xen_common.h) that > > params.h is necessary is in xen_suspend_notifier(). I wonder whether > > that would be better moved into xen_common.h too (since it's just a > > wrapper round xc_set_hvm_param() and then the inclusion of params.h > > can be moved there as well. > > :(, I didn't realised that xen_common.h needed params.h too. That patch > series might not build on older version of Xen. I'll move the inclusion > of params.h to xen_common.h, and fix params.h to have all the needed > #defines. Actually, it works fine without including hvm/params.h in xen_common.h because xen_common.h includes xenctrl.h which includes hvm/params.h. So I think instead I'll remove all includes of params.h, because HVM_PARAM_* are parameters for xc_hvm_param_{get,set}, which is in a library and not an interface with a guest. Including xenctrl.h should be enough.
> -----Original Message----- > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > Sent: 17 June 2019 18:19 > To: Paul Durrant <Paul.Durrant@citrix.com> > Cc: xen-devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>; qemu-devel@nongnu.org > Subject: Re: [Xen-devel] [PATCH 3/4] xen: Import Xen public headers used by xen-hvm.c > > On Mon, Jun 17, 2019 at 05:45:44PM +0100, Anthony PERARD wrote: > > On Mon, Jun 17, 2019 at 05:15:51PM +0100, Paul Durrant wrote: > > > AFAICT the only place (apart from legacy code in xen_common.h) that > > > params.h is necessary is in xen_suspend_notifier(). I wonder whether > > > that would be better moved into xen_common.h too (since it's just a > > > wrapper round xc_set_hvm_param() and then the inclusion of params.h > > > can be moved there as well. > > > > :(, I didn't realised that xen_common.h needed params.h too. That patch > > series might not build on older version of Xen. I'll move the inclusion > > of params.h to xen_common.h, and fix params.h to have all the needed > > #defines. > > Actually, it works fine without including hvm/params.h in xen_common.h > because xen_common.h includes xenctrl.h which includes hvm/params.h. > > So I think instead I'll remove all includes of params.h, because > HVM_PARAM_* are parameters for xc_hvm_param_{get,set}, which is in a > library and not an interface with a guest. Including xenctrl.h should be > enough. The guest/tools separation is messy. ioreq.h is also an interface with Xen and not with a guest, so really I think it should be treated the same way as params.h. e820.h is referring to guest memory layout, which IMO shouldn't really be hardcoded at all. Paul > > -- > Anthony PERARD
On Tue, Jun 18, 2019 at 08:55:53AM +0100, Paul Durrant wrote: > > -----Original Message----- > > From: Anthony PERARD [mailto:anthony.perard@citrix.com] > > > > On Mon, Jun 17, 2019 at 05:45:44PM +0100, Anthony PERARD wrote: > > > On Mon, Jun 17, 2019 at 05:15:51PM +0100, Paul Durrant wrote: > > > > AFAICT the only place (apart from legacy code in xen_common.h) that > > > > params.h is necessary is in xen_suspend_notifier(). I wonder whether > > > > that would be better moved into xen_common.h too (since it's just a > > > > wrapper round xc_set_hvm_param() and then the inclusion of params.h > > > > can be moved there as well. > > > > > > :(, I didn't realised that xen_common.h needed params.h too. That patch > > > series might not build on older version of Xen. I'll move the inclusion > > > of params.h to xen_common.h, and fix params.h to have all the needed > > > #defines. > > > > Actually, it works fine without including hvm/params.h in xen_common.h > > because xen_common.h includes xenctrl.h which includes hvm/params.h. > > > > So I think instead I'll remove all includes of params.h, because > > HVM_PARAM_* are parameters for xc_hvm_param_{get,set}, which is in a > > library and not an interface with a guest. Including xenctrl.h should be > > enough. > > The guest/tools separation is messy. ioreq.h is also an interface with > Xen and not with a guest, so really I think it should be treated the > same way as params.h. Yes, I'll drop this patch, and replace it with a patch that just removes includes of params.h. > e820.h is referring to guest memory layout, > which IMO shouldn't really be hardcoded at all. I'll leave e820.h include alone.
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 2939122e7c..725f9c2278 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -26,9 +26,9 @@ #include "trace.h" #include "exec/address-spaces.h" -#include <xen/hvm/ioreq.h> -#include <xen/hvm/params.h> -#include <xen/hvm/e820.h> +#include "hw/xen/interface/hvm/ioreq.h" +#include "hw/xen/interface/hvm/params.h" +#include "hw/xen/interface/hvm/e820.h" //#define DEBUG_XEN_HVM diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c index 254759f776..dc73c86c61 100644 --- a/hw/i386/xen/xen-mapcache.c +++ b/hw/i386/xen/xen-mapcache.c @@ -17,8 +17,6 @@ #include "hw/xen/xen-legacy-backend.h" #include "qemu/bitmap.h" -#include <xen/hvm/params.h> - #include "sysemu/xen-mapcache.h" #include "trace.h" diff --git a/include/hw/xen/interface/hvm/e820.h b/include/hw/xen/interface/hvm/e820.h new file mode 100644 index 0000000000..9cb141e3c4 --- /dev/null +++ b/include/hw/xen/interface/hvm/e820.h @@ -0,0 +1,28 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2006, Keir Fraser + */ + +#ifndef XEN_PUBLIC_HVM_E820_H +#define XEN_PUBLIC_HVM_E820_H + +#define HVM_BELOW_4G_RAM_END 0xF0000000 + +#endif /* XEN_PUBLIC_HVM_E820_H */ diff --git a/include/hw/xen/interface/hvm/ioreq.h b/include/hw/xen/interface/hvm/ioreq.h new file mode 100644 index 0000000000..453f320c28 --- /dev/null +++ b/include/hw/xen/interface/hvm/ioreq.h @@ -0,0 +1,101 @@ +/* + * ioreq.h: I/O request definitions for device models + * Copyright (c) 2004, Intel Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef XEN_PUBLIC_HVM_IOREQ_H +#define XEN_PUBLIC_HVM_IOREQ_H + +#define IOREQ_READ 1 +#define IOREQ_WRITE 0 + +#define STATE_IOREQ_NONE 0 +#define STATE_IOREQ_READY 1 +#define STATE_IOREQ_INPROCESS 2 +#define STATE_IORESP_READY 3 + +#define IOREQ_TYPE_PIO 0 /* pio */ +#define IOREQ_TYPE_COPY 1 /* mmio ops */ +#define IOREQ_TYPE_PCI_CONFIG 2 +#define IOREQ_TYPE_TIMEOFFSET 7 +#define IOREQ_TYPE_INVALIDATE 8 /* mapcache */ + +/* + * VMExit dispatcher should cooperate with instruction decoder to + * prepare this structure and notify service OS and DM by sending + * virq. + * + * For I/O type IOREQ_TYPE_PCI_CONFIG, the physical address is formatted + * as follows: + * + * 63....48|47..40|39..35|34..32|31........0 + * SEGMENT |BUS |DEV |FN |OFFSET + */ +struct ioreq { + uint64_t addr; /* physical address */ + uint64_t data; /* data (or paddr of data) */ + uint32_t count; /* for rep prefixes */ + uint32_t size; /* size in bytes */ + uint32_t vp_eport; /* evtchn for notifications to/from device model */ + uint16_t _pad0; + uint8_t state:4; + uint8_t data_is_ptr:1; /* if 1, data above is the guest paddr + * of the real data to use. */ + uint8_t dir:1; /* 1=read, 0=write */ + uint8_t df:1; + uint8_t _pad1:1; + uint8_t type; /* I/O type */ +}; +typedef struct ioreq ioreq_t; + +struct shared_iopage { + struct ioreq vcpu_ioreq[1]; +}; +typedef struct shared_iopage shared_iopage_t; + +struct buf_ioreq { + uint8_t type; /* I/O type */ + uint8_t pad:1; + uint8_t dir:1; /* 1=read, 0=write */ + uint8_t size:2; /* 0=>1, 1=>2, 2=>4, 3=>8. If 8, use two buf_ioreqs */ + uint32_t addr:20;/* physical address */ + uint32_t data; /* data */ +}; +typedef struct buf_ioreq buf_ioreq_t; + +#define IOREQ_BUFFER_SLOT_NUM 511 /* 8 bytes each, plus 2 4-byte indexes */ +struct buffered_iopage { +#ifdef __XEN__ + union bufioreq_pointers { + struct { +#endif + uint32_t read_pointer; + uint32_t write_pointer; +#ifdef __XEN__ + }; + uint64_t full; + } ptrs; +#endif + buf_ioreq_t buf_ioreq[IOREQ_BUFFER_SLOT_NUM]; +}; /* NB. Size of this structure must be no greater than one page. */ +typedef struct buffered_iopage buffered_iopage_t; + +#endif /* XEN_PUBLIC_HVM_IOREQ_H */ diff --git a/include/hw/xen/interface/hvm/params.h b/include/hw/xen/interface/hvm/params.h new file mode 100644 index 0000000000..a4b6ff3853 --- /dev/null +++ b/include/hw/xen/interface/hvm/params.h @@ -0,0 +1,33 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2007, Keir Fraser + */ + +#ifndef XEN_PUBLIC_HVM_PARAMS_H +#define XEN_PUBLIC_HVM_PARAMS_H + +/* + * Parameter space for HVMOP_{set,get}_param. + */ + +/* ACPI S state: currently support S0 and S3 on x86. */ +#define HVM_PARAM_ACPI_S_STATE 14 + +#endif /* XEN_PUBLIC_HVM_PARAMS_H */
Following "xen: Fix build with public headers", import other Xen public headers that are describing interfaces. The headers are cleaned up a bit while importing them. The header guard symbols are changed to match QEMU's coding style, some other part of the files that QEMU doesn't use are removed. xen-mapcache.c doesn't needs params.h, so remove the include. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- hw/i386/xen/xen-hvm.c | 6 +- hw/i386/xen/xen-mapcache.c | 2 - include/hw/xen/interface/hvm/e820.h | 28 +++++++ include/hw/xen/interface/hvm/ioreq.h | 101 ++++++++++++++++++++++++++ include/hw/xen/interface/hvm/params.h | 33 +++++++++ 5 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 include/hw/xen/interface/hvm/e820.h create mode 100644 include/hw/xen/interface/hvm/ioreq.h create mode 100644 include/hw/xen/interface/hvm/params.h