* [PATCH 0/3] xen: move common hvm code to x86
@ 2017-08-21 14:09 Wei Liu
2017-08-21 14:09 ` [PATCH 1/3] xen: move hvm save code under common " Wei Liu
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Wei Liu @ 2017-08-21 14:09 UTC (permalink / raw)
To: Xen-devel; +Cc: Wei Liu
Wei Liu (3):
xen: move hvm save code under common to x86
xen: merge common hvm/irq.h into x86 hvm/irq.h
x86: switch to plain bool in passthrough code
xen/arch/x86/cpu/mcheck/vmce.c | 2 +-
xen/arch/x86/cpu/vpmu_amd.c | 2 +-
xen/arch/x86/hvm/save.c | 308 +++++++++++++++++++++++++++++
xen/common/Makefile | 2 -
xen/common/hvm/Makefile | 1 -
xen/common/hvm/save.c | 330 --------------------------------
xen/drivers/passthrough/io.c | 17 +-
xen/include/asm-x86/hvm/irq.h | 111 ++++++++++-
xen/include/{xen => asm-x86}/hvm/save.h | 0
xen/include/asm-x86/hvm/support.h | 2 +-
xen/include/asm-x86/irq.h | 2 +-
xen/include/xen/hvm/irq.h | 140 --------------
12 files changed, 430 insertions(+), 487 deletions(-)
delete mode 100644 xen/common/hvm/Makefile
delete mode 100644 xen/common/hvm/save.c
rename xen/include/{xen => asm-x86}/hvm/save.h (100%)
delete mode 100644 xen/include/xen/hvm/irq.h
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] xen: move hvm save code under common to x86
2017-08-21 14:09 [PATCH 0/3] xen: move common hvm code to x86 Wei Liu
@ 2017-08-21 14:09 ` Wei Liu
2017-08-22 12:53 ` Jan Beulich
2017-08-21 14:09 ` [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h Wei Liu
2017-08-21 14:09 ` [PATCH 3/3] x86: switch to plain bool in passthrough code Wei Liu
2 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-08-21 14:09 UTC (permalink / raw)
To: Xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
Ian Jackson, Tim Deegan, Jan Beulich
The code is only used by x86 at this point. Merge common/hvm/save.c
into x86 hvm/save.c. Move the headers and fix up inclusions. Remove
the now empty common/hvm directory.
Also fix some issues while moving:
1. removing trailing spaces;
2. fix multi-line comment;
3. make "i" in hvm_save unsigned int;
4. add some blank lines to separate sections of code;
5. change bool_t to bool.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/cpu/mcheck/vmce.c | 2 +-
xen/arch/x86/cpu/vpmu_amd.c | 2 +-
xen/arch/x86/hvm/save.c | 308 +++++++++++++++++++++++++++++
xen/common/Makefile | 2 -
xen/common/hvm/Makefile | 1 -
xen/common/hvm/save.c | 330 --------------------------------
xen/include/{xen => asm-x86}/hvm/save.h | 0
xen/include/asm-x86/hvm/support.h | 2 +-
8 files changed, 311 insertions(+), 336 deletions(-)
delete mode 100644 xen/common/hvm/Makefile
delete mode 100644 xen/common/hvm/save.c
rename xen/include/{xen => asm-x86}/hvm/save.h (100%)
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index 62faae49c6..9c460c7c6c 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -26,7 +26,7 @@
#include <xen/delay.h>
#include <xen/smp.h>
#include <xen/mm.h>
-#include <xen/hvm/save.h>
+#include <asm/hvm/save.h>
#include <asm/processor.h>
#include <public/sysctl.h>
#include <asm/system.h>
diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c
index b3c3697a68..5efc39b4eb 100644
--- a/xen/arch/x86/cpu/vpmu_amd.c
+++ b/xen/arch/x86/cpu/vpmu_amd.c
@@ -22,11 +22,11 @@
*/
#include <xen/xenoprof.h>
-#include <xen/hvm/save.h>
#include <xen/sched.h>
#include <xen/irq.h>
#include <asm/apic.h>
#include <asm/vpmu.h>
+#include <asm/hvm/save.h>
#include <asm/hvm/vlapic.h>
#include <public/pmu.h>
diff --git a/xen/arch/x86/hvm/save.c b/xen/arch/x86/hvm/save.c
index f7d4999073..8984a23a88 100644
--- a/xen/arch/x86/hvm/save.c
+++ b/xen/arch/x86/hvm/save.c
@@ -20,7 +20,11 @@
* this program; If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/guest_access.h>
+#include <xen/version.h>
+
#include <asm/hvm/support.h>
+
#include <public/hvm/save.h>
void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
@@ -78,6 +82,310 @@ int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
return 0;
}
+/* List of handlers for various HVM save and restore types */
+static struct {
+ hvm_save_handler save;
+ hvm_load_handler load;
+ const char *name;
+ size_t size;
+ int kind;
+} hvm_sr_handlers[HVM_SAVE_CODE_MAX + 1] = { {NULL, NULL, "<?>"}, };
+
+/* Init-time function to add entries to that list */
+void __init hvm_register_savevm(uint16_t typecode,
+ const char *name,
+ hvm_save_handler save_state,
+ hvm_load_handler load_state,
+ size_t size, int kind)
+{
+ ASSERT(typecode <= HVM_SAVE_CODE_MAX);
+ ASSERT(hvm_sr_handlers[typecode].save == NULL);
+ ASSERT(hvm_sr_handlers[typecode].load == NULL);
+ hvm_sr_handlers[typecode].save = save_state;
+ hvm_sr_handlers[typecode].load = load_state;
+ hvm_sr_handlers[typecode].name = name;
+ hvm_sr_handlers[typecode].size = size;
+ hvm_sr_handlers[typecode].kind = kind;
+}
+
+size_t hvm_save_size(struct domain *d)
+{
+ struct vcpu *v;
+ size_t sz;
+ int i;
+
+ /* Basic overhead for header and footer */
+ sz = (2 * sizeof (struct hvm_save_descriptor)) + HVM_SAVE_LENGTH(HEADER);
+
+ /* Plus space for each thing we will be saving */
+ for ( i = 0; i <= HVM_SAVE_CODE_MAX; i++ )
+ if ( hvm_sr_handlers[i].kind == HVMSR_PER_VCPU )
+ for_each_vcpu(d, v)
+ sz += hvm_sr_handlers[i].size;
+ else
+ sz += hvm_sr_handlers[i].size;
+
+ return sz;
+}
+
+/*
+ * Extract a single instance of a save record, by marshalling all records of
+ * that type and copying out the one we need.
+ */
+int hvm_save_one(struct domain *d, unsigned int typecode, unsigned int instance,
+ XEN_GUEST_HANDLE_64(uint8) handle, uint64_t *bufsz)
+{
+ int rv;
+ hvm_domain_context_t ctxt = { };
+ const struct hvm_save_descriptor *desc;
+
+ if ( d->is_dying ||
+ typecode > HVM_SAVE_CODE_MAX ||
+ hvm_sr_handlers[typecode].size < sizeof(*desc) ||
+ !hvm_sr_handlers[typecode].save )
+ return -EINVAL;
+
+ ctxt.size = hvm_sr_handlers[typecode].size;
+ if ( hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU )
+ ctxt.size *= d->max_vcpus;
+ ctxt.data = xmalloc_bytes(ctxt.size);
+ if ( !ctxt.data )
+ return -ENOMEM;
+
+ if ( (rv = hvm_sr_handlers[typecode].save(d, &ctxt)) != 0 )
+ printk(XENLOG_G_ERR "HVM%d save: failed to save type %"PRIu16" (%d)\n",
+ d->domain_id, typecode, rv);
+ else if ( rv = -ENOENT, ctxt.cur >= sizeof(*desc) )
+ {
+ uint32_t off;
+
+ for ( off = 0; off <= (ctxt.cur - sizeof(*desc)); off += desc->length )
+ {
+ desc = (void *)(ctxt.data + off);
+ /* Move past header */
+ off += sizeof(*desc);
+ if ( ctxt.cur < desc->length ||
+ off > ctxt.cur - desc->length )
+ break;
+ if ( instance == desc->instance )
+ {
+ rv = 0;
+ if ( guest_handle_is_null(handle) )
+ *bufsz = desc->length;
+ else if ( *bufsz < desc->length )
+ rv = -ENOBUFS;
+ else if ( copy_to_guest(handle, ctxt.data + off, desc->length) )
+ rv = -EFAULT;
+ else
+ *bufsz = desc->length;
+ break;
+ }
+ }
+ }
+
+ xfree(ctxt.data);
+ return rv;
+}
+
+int hvm_save(struct domain *d, hvm_domain_context_t *h)
+{
+ char *c;
+ struct hvm_save_header hdr;
+ struct hvm_save_end end;
+ hvm_save_handler handler;
+ unsigned int i;
+
+ if ( d->is_dying )
+ return -EINVAL;
+
+ hdr.magic = HVM_FILE_MAGIC;
+ hdr.version = HVM_FILE_VERSION;
+
+ /* Save xen changeset */
+ c = strrchr(xen_changeset(), ':');
+ if ( c )
+ hdr.changeset = simple_strtoll(c, NULL, 16);
+ else
+ hdr.changeset = -1ULL; /* Unknown */
+
+ arch_hvm_save(d, &hdr);
+
+ if ( hvm_save_entry(HEADER, 0, h, &hdr) != 0 )
+ {
+ printk(XENLOG_G_ERR "HVM%d save: failed to write header\n",
+ d->domain_id);
+ return -EFAULT;
+ }
+
+ /* Save all available kinds of state */
+ for ( i = 0; i <= HVM_SAVE_CODE_MAX; i++ )
+ {
+ handler = hvm_sr_handlers[i].save;
+ if ( handler != NULL )
+ {
+ printk(XENLOG_G_INFO "HVM%d save: %s\n",
+ d->domain_id, hvm_sr_handlers[i].name);
+ if ( handler(d, h) != 0 )
+ {
+ printk(XENLOG_G_ERR
+ "HVM%d save: failed to save type %"PRIu16"\n",
+ d->domain_id, i);
+ return -EFAULT;
+ }
+ }
+ }
+
+ /* Save an end-of-file marker */
+ if ( hvm_save_entry(END, 0, h, &end) != 0 )
+ {
+ /* Run out of data */
+ printk(XENLOG_G_ERR "HVM%d save: no room for end marker\n",
+ d->domain_id);
+ return -EFAULT;
+ }
+
+ /* Save macros should not have let us overrun */
+ ASSERT(h->cur <= h->size);
+ return 0;
+}
+
+int hvm_load(struct domain *d, hvm_domain_context_t *h)
+{
+ struct hvm_save_header hdr;
+ struct hvm_save_descriptor *desc;
+ hvm_load_handler handler;
+ struct vcpu *v;
+
+ if ( d->is_dying )
+ return -EINVAL;
+
+ /* Read the save header, which must be first */
+ if ( hvm_load_entry(HEADER, h, &hdr) != 0 )
+ return -1;
+
+ if ( arch_hvm_load(d, &hdr) )
+ return -1;
+
+ /* Down all the vcpus: we only re-enable the ones that had state saved. */
+ for_each_vcpu(d, v)
+ if ( test_and_set_bit(_VPF_down, &v->pause_flags) )
+ vcpu_sleep_nosync(v);
+
+ for ( ; ; )
+ {
+ if ( h->size - h->cur < sizeof(struct hvm_save_descriptor) )
+ {
+ /* Run out of data */
+ printk(XENLOG_G_ERR
+ "HVM%d restore: save did not end with a null entry\n",
+ d->domain_id);
+ return -1;
+ }
+
+ /* Read the typecode of the next entry and check for the end-marker */
+ desc = (struct hvm_save_descriptor *)(&h->data[h->cur]);
+ if ( desc->typecode == 0 )
+ return 0;
+
+ /* Find the handler for this entry */
+ if ( (desc->typecode > HVM_SAVE_CODE_MAX) ||
+ ((handler = hvm_sr_handlers[desc->typecode].load) == NULL) )
+ {
+ printk(XENLOG_G_ERR "HVM%d restore: unknown entry typecode %u\n",
+ d->domain_id, desc->typecode);
+ return -1;
+ }
+
+ /* Load the entry */
+ printk(XENLOG_G_INFO "HVM%d restore: %s %"PRIu16"\n", d->domain_id,
+ hvm_sr_handlers[desc->typecode].name, desc->instance);
+ if ( handler(d, h) != 0 )
+ {
+ printk(XENLOG_G_ERR "HVM%d restore: failed to load entry %u/%u\n",
+ d->domain_id, desc->typecode, desc->instance);
+ return -1;
+ }
+ }
+
+ /* Not reached */
+}
+
+int _hvm_init_entry(struct hvm_domain_context *h, uint16_t tc, uint16_t inst,
+ uint32_t len)
+{
+ struct hvm_save_descriptor *d
+ = (struct hvm_save_descriptor *)&h->data[h->cur];
+
+ if ( h->size - h->cur < len + sizeof (*d) )
+ {
+ printk(XENLOG_G_WARNING "HVM save: no room for"
+ " %"PRIu32" + %zu bytes for typecode %"PRIu16"\n",
+ len, sizeof(*d), tc);
+ return -1;
+ }
+
+ d->typecode = tc;
+ d->instance = inst;
+ d->length = len;
+ h->cur += sizeof(*d);
+
+ return 0;
+}
+
+void _hvm_write_entry(struct hvm_domain_context *h, void *src,
+ uint32_t src_len)
+{
+ memcpy(&h->data[h->cur], src, src_len);
+ h->cur += src_len;
+}
+
+int _hvm_check_entry(struct hvm_domain_context *h, uint16_t type, uint32_t len,
+ bool strict_length)
+{
+ struct hvm_save_descriptor *d
+ = (struct hvm_save_descriptor *)&h->data[h->cur];
+
+ if ( sizeof(*d) > h->size - h->cur)
+ {
+ printk(XENLOG_G_WARNING
+ "HVM restore: not enough data left to read %zu bytes "
+ "for type %u header\n", sizeof(*d), type);
+ return -1;
+ }
+
+ if ( (type != d->typecode) ||
+ (strict_length ? (len != d->length) : (len < d->length)) ||
+ (d->length > (h->size - h->cur - sizeof(*d))) )
+ {
+ printk(XENLOG_G_WARNING
+ "HVM restore mismatch: expected %s type %u length %u, "
+ "saw type %u length %u. %zu bytes remaining\n",
+ strict_length ? "strict" : "zeroextended", type, len,
+ d->typecode, d->length, h->size - h->cur - sizeof(*d));
+ return -1;
+ }
+
+ h->cur += sizeof(*d);
+
+ return 0;
+}
+
+void _hvm_read_entry(struct hvm_domain_context *h, void *dest,
+ uint32_t dest_len)
+{
+ struct hvm_save_descriptor *d
+ = (struct hvm_save_descriptor *)&h->data[h->cur - sizeof(*d)];
+
+ BUG_ON(d->length > dest_len);
+
+ memcpy(dest, &h->data[h->cur], d->length);
+
+ if ( d->length < dest_len )
+ memset((char *)dest + d->length, 0, dest_len - d->length);
+
+ h->cur += d->length;
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/common/Makefile b/xen/common/Makefile
index 26c5a64337..39e2614546 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -74,8 +74,6 @@ tmem-y := tmem.o tmem_xen.o tmem_control.o
tmem-$(CONFIG_COMPAT) += compat/tmem_xen.o
obj-$(CONFIG_TMEM) += $(tmem-y)
-subdir-$(CONFIG_X86) += hvm
-
subdir-$(CONFIG_GCOV) += gcov
subdir-y += libelf
diff --git a/xen/common/hvm/Makefile b/xen/common/hvm/Makefile
deleted file mode 100644
index a464a57d52..0000000000
--- a/xen/common/hvm/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-y += save.o
diff --git a/xen/common/hvm/save.c b/xen/common/hvm/save.c
deleted file mode 100644
index 1a7135ee31..0000000000
--- a/xen/common/hvm/save.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * hvm/save.c: Save and restore HVM guest's emulated hardware state.
- *
- * Copyright (c) 2004, Intel Corporation.
- * Copyright (c) 2007, XenSource Inc.
- * Copyright (c) 2007, Isaku Yamahata <yamahata at valinux co jp>
- * VA Linux Systems Japan K.K.
- * split arch generic part
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <xen/lib.h>
-#include <xen/version.h>
-#include <public/version.h>
-#include <xen/sched.h>
-#include <xen/guest_access.h>
-
-#include <asm/hvm/support.h>
-
-/* List of handlers for various HVM save and restore types */
-static struct {
- hvm_save_handler save;
- hvm_load_handler load;
- const char *name;
- size_t size;
- int kind;
-} hvm_sr_handlers [HVM_SAVE_CODE_MAX + 1] = {{NULL, NULL, "<?>"},};
-
-/* Init-time function to add entries to that list */
-void __init hvm_register_savevm(uint16_t typecode,
- const char *name,
- hvm_save_handler save_state,
- hvm_load_handler load_state,
- size_t size, int kind)
-{
- ASSERT(typecode <= HVM_SAVE_CODE_MAX);
- ASSERT(hvm_sr_handlers[typecode].save == NULL);
- ASSERT(hvm_sr_handlers[typecode].load == NULL);
- hvm_sr_handlers[typecode].save = save_state;
- hvm_sr_handlers[typecode].load = load_state;
- hvm_sr_handlers[typecode].name = name;
- hvm_sr_handlers[typecode].size = size;
- hvm_sr_handlers[typecode].kind = kind;
-}
-
-size_t hvm_save_size(struct domain *d)
-{
- struct vcpu *v;
- size_t sz;
- int i;
-
- /* Basic overhead for header and footer */
- sz = (2 * sizeof (struct hvm_save_descriptor)) + HVM_SAVE_LENGTH(HEADER);
-
- /* Plus space for each thing we will be saving */
- for ( i = 0; i <= HVM_SAVE_CODE_MAX; i++ )
- if ( hvm_sr_handlers[i].kind == HVMSR_PER_VCPU )
- for_each_vcpu(d, v)
- sz += hvm_sr_handlers[i].size;
- else
- sz += hvm_sr_handlers[i].size;
-
- return sz;
-}
-
-/* Extract a single instance of a save record, by marshalling all
- * records of that type and copying out the one we need. */
-int hvm_save_one(struct domain *d, unsigned int typecode, unsigned int instance,
- XEN_GUEST_HANDLE_64(uint8) handle, uint64_t *bufsz)
-{
- int rv;
- hvm_domain_context_t ctxt = { };
- const struct hvm_save_descriptor *desc;
-
- if ( d->is_dying ||
- typecode > HVM_SAVE_CODE_MAX ||
- hvm_sr_handlers[typecode].size < sizeof(*desc) ||
- !hvm_sr_handlers[typecode].save )
- return -EINVAL;
-
- ctxt.size = hvm_sr_handlers[typecode].size;
- if ( hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU )
- ctxt.size *= d->max_vcpus;
- ctxt.data = xmalloc_bytes(ctxt.size);
- if ( !ctxt.data )
- return -ENOMEM;
-
- if ( (rv = hvm_sr_handlers[typecode].save(d, &ctxt)) != 0 )
- printk(XENLOG_G_ERR "HVM%d save: failed to save type %"PRIu16" (%d)\n",
- d->domain_id, typecode, rv);
- else if ( rv = -ENOENT, ctxt.cur >= sizeof(*desc) )
- {
- uint32_t off;
-
- for ( off = 0; off <= (ctxt.cur - sizeof(*desc)); off += desc->length )
- {
- desc = (void *)(ctxt.data + off);
- /* Move past header */
- off += sizeof(*desc);
- if ( ctxt.cur < desc->length ||
- off > ctxt.cur - desc->length )
- break;
- if ( instance == desc->instance )
- {
- rv = 0;
- if ( guest_handle_is_null(handle) )
- *bufsz = desc->length;
- else if ( *bufsz < desc->length )
- rv = -ENOBUFS;
- else if ( copy_to_guest(handle, ctxt.data + off, desc->length) )
- rv = -EFAULT;
- else
- *bufsz = desc->length;
- break;
- }
- }
- }
-
- xfree(ctxt.data);
- return rv;
-}
-
-int hvm_save(struct domain *d, hvm_domain_context_t *h)
-{
- char *c;
- struct hvm_save_header hdr;
- struct hvm_save_end end;
- hvm_save_handler handler;
- uint16_t i;
-
- if ( d->is_dying )
- return -EINVAL;
-
- hdr.magic = HVM_FILE_MAGIC;
- hdr.version = HVM_FILE_VERSION;
-
- /* Save xen changeset */
- c = strrchr(xen_changeset(), ':');
- if ( c )
- hdr.changeset = simple_strtoll(c, NULL, 16);
- else
- hdr.changeset = -1ULL; /* Unknown */
-
- arch_hvm_save(d, &hdr);
-
- if ( hvm_save_entry(HEADER, 0, h, &hdr) != 0 )
- {
- printk(XENLOG_G_ERR "HVM%d save: failed to write header\n",
- d->domain_id);
- return -EFAULT;
- }
-
- /* Save all available kinds of state */
- for ( i = 0; i <= HVM_SAVE_CODE_MAX; i++ )
- {
- handler = hvm_sr_handlers[i].save;
- if ( handler != NULL )
- {
- printk(XENLOG_G_INFO "HVM%d save: %s\n",
- d->domain_id, hvm_sr_handlers[i].name);
- if ( handler(d, h) != 0 )
- {
- printk(XENLOG_G_ERR
- "HVM%d save: failed to save type %"PRIu16"\n",
- d->domain_id, i);
- return -EFAULT;
- }
- }
- }
-
- /* Save an end-of-file marker */
- if ( hvm_save_entry(END, 0, h, &end) != 0 )
- {
- /* Run out of data */
- printk(XENLOG_G_ERR "HVM%d save: no room for end marker\n",
- d->domain_id);
- return -EFAULT;
- }
-
- /* Save macros should not have let us overrun */
- ASSERT(h->cur <= h->size);
- return 0;
-}
-
-int hvm_load(struct domain *d, hvm_domain_context_t *h)
-{
- struct hvm_save_header hdr;
- struct hvm_save_descriptor *desc;
- hvm_load_handler handler;
- struct vcpu *v;
-
- if ( d->is_dying )
- return -EINVAL;
-
- /* Read the save header, which must be first */
- if ( hvm_load_entry(HEADER, h, &hdr) != 0 )
- return -1;
-
- if ( arch_hvm_load(d, &hdr) )
- return -1;
-
- /* Down all the vcpus: we only re-enable the ones that had state saved. */
- for_each_vcpu(d, v)
- if ( test_and_set_bit(_VPF_down, &v->pause_flags) )
- vcpu_sleep_nosync(v);
-
- for ( ; ; )
- {
- if ( h->size - h->cur < sizeof(struct hvm_save_descriptor) )
- {
- /* Run out of data */
- printk(XENLOG_G_ERR
- "HVM%d restore: save did not end with a null entry\n",
- d->domain_id);
- return -1;
- }
-
- /* Read the typecode of the next entry and check for the end-marker */
- desc = (struct hvm_save_descriptor *)(&h->data[h->cur]);
- if ( desc->typecode == 0 )
- return 0;
-
- /* Find the handler for this entry */
- if ( (desc->typecode > HVM_SAVE_CODE_MAX) ||
- ((handler = hvm_sr_handlers[desc->typecode].load) == NULL) )
- {
- printk(XENLOG_G_ERR "HVM%d restore: unknown entry typecode %u\n",
- d->domain_id, desc->typecode);
- return -1;
- }
-
- /* Load the entry */
- printk(XENLOG_G_INFO "HVM%d restore: %s %"PRIu16"\n", d->domain_id,
- hvm_sr_handlers[desc->typecode].name, desc->instance);
- if ( handler(d, h) != 0 )
- {
- printk(XENLOG_G_ERR "HVM%d restore: failed to load entry %u/%u\n",
- d->domain_id, desc->typecode, desc->instance);
- return -1;
- }
- }
-
- /* Not reached */
-}
-
-int _hvm_init_entry(struct hvm_domain_context *h,
- uint16_t tc, uint16_t inst, uint32_t len)
-{
- struct hvm_save_descriptor *d
- = (struct hvm_save_descriptor *)&h->data[h->cur];
- if ( h->size - h->cur < len + sizeof (*d) )
- {
- printk(XENLOG_G_WARNING "HVM save: no room for"
- " %"PRIu32" + %zu bytes for typecode %"PRIu16"\n",
- len, sizeof(*d), tc);
- return -1;
- }
- d->typecode = tc;
- d->instance = inst;
- d->length = len;
- h->cur += sizeof(*d);
- return 0;
-}
-
-void _hvm_write_entry(struct hvm_domain_context *h,
- void *src, uint32_t src_len)
-{
- memcpy(&h->data[h->cur], src, src_len);
- h->cur += src_len;
-}
-
-int _hvm_check_entry(struct hvm_domain_context *h,
- uint16_t type, uint32_t len, bool_t strict_length)
-{
- struct hvm_save_descriptor *d
- = (struct hvm_save_descriptor *)&h->data[h->cur];
- if ( sizeof(*d) > h->size - h->cur)
- {
- printk(XENLOG_G_WARNING
- "HVM restore: not enough data left to read %zu bytes "
- "for type %u header\n", sizeof(*d), type);
- return -1;
- }
- if ( (type != d->typecode) ||
- (strict_length ? (len != d->length) : (len < d->length)) ||
- (d->length > (h->size - h->cur - sizeof(*d))) )
- {
- printk(XENLOG_G_WARNING
- "HVM restore mismatch: expected %s type %u length %u, "
- "saw type %u length %u. %zu bytes remaining\n",
- strict_length ? "strict" : "zeroextended", type, len,
- d->typecode, d->length, h->size - h->cur - sizeof(*d));
- return -1;
- }
- h->cur += sizeof(*d);
- return 0;
-}
-
-void _hvm_read_entry(struct hvm_domain_context *h,
- void *dest, uint32_t dest_len)
-{
- struct hvm_save_descriptor *d
- = (struct hvm_save_descriptor *)&h->data[h->cur - sizeof(*d)];
- BUG_ON(d->length > dest_len);
- memcpy(dest, &h->data[h->cur], d->length);
- if ( d->length < dest_len )
- memset((char *)dest + d->length, 0, dest_len - d->length);
- h->cur += d->length;
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/xen/hvm/save.h b/xen/include/asm-x86/hvm/save.h
similarity index 100%
rename from xen/include/xen/hvm/save.h
rename to xen/include/asm-x86/hvm/save.h
diff --git a/xen/include/asm-x86/hvm/support.h b/xen/include/asm-x86/hvm/support.h
index 8a1252b29e..b18dbb6d43 100644
--- a/xen/include/asm-x86/hvm/support.h
+++ b/xen/include/asm-x86/hvm/support.h
@@ -22,7 +22,7 @@
#include <xen/types.h>
#include <xen/sched.h>
-#include <xen/hvm/save.h>
+#include <asm/hvm/save.h>
#include <asm/processor.h>
#ifndef NDEBUG
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h
2017-08-21 14:09 [PATCH 0/3] xen: move common hvm code to x86 Wei Liu
2017-08-21 14:09 ` [PATCH 1/3] xen: move hvm save code under common " Wei Liu
@ 2017-08-21 14:09 ` Wei Liu
2017-08-21 14:14 ` Wei Liu
2017-08-21 14:09 ` [PATCH 3/3] x86: switch to plain bool in passthrough code Wei Liu
2 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-08-21 14:09 UTC (permalink / raw)
To: Xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
Ian Jackson, Tim Deegan, Jan Beulich
That header file is only used by x86. Merge is into the x86 header.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
xen/drivers/passthrough/io.c | 1 -
xen/include/asm-x86/hvm/irq.h | 111 ++++++++++++++++++++++++++++++++-
xen/include/asm-x86/irq.h | 2 +-
xen/include/xen/hvm/irq.h | 140 ------------------------------------------
4 files changed, 111 insertions(+), 143 deletions(-)
delete mode 100644 xen/include/xen/hvm/irq.h
diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c
index ffeaf70be6..e30fd568f3 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -23,7 +23,6 @@
#include <xen/irq.h>
#include <asm/hvm/irq.h>
#include <asm/hvm/support.h>
-#include <xen/hvm/irq.h>
#include <asm/io_apic.h>
static DEFINE_PER_CPU(struct list_head, dpci_list);
diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h
index 7d45293aed..84cb8f8765 100644
--- a/xen/include/asm-x86/hvm/irq.h
+++ b/xen/include/asm-x86/hvm/irq.h
@@ -21,7 +21,8 @@
#ifndef __ASM_X86_HVM_IRQ_H__
#define __ASM_X86_HVM_IRQ_H__
-#include <xen/hvm/irq.h>
+#include <xen/timer.h>
+
#include <asm/hvm/hvm.h>
#include <asm/hvm/vpic.h>
#include <asm/hvm/vioapic.h>
@@ -106,4 +107,112 @@ struct hvm_intack hvm_vcpu_has_pending_irq(struct vcpu *v);
struct hvm_intack hvm_vcpu_ack_pending_irq(struct vcpu *v,
struct hvm_intack intack);
+struct dev_intx_gsi_link {
+ struct list_head list;
+ uint8_t bus;
+ uint8_t device;
+ uint8_t intx;
+};
+
+#define _HVM_IRQ_DPCI_MACH_PCI_SHIFT 0
+#define _HVM_IRQ_DPCI_MACH_MSI_SHIFT 1
+#define _HVM_IRQ_DPCI_MAPPED_SHIFT 2
+#define _HVM_IRQ_DPCI_EOI_LATCH_SHIFT 3
+#define _HVM_IRQ_DPCI_GUEST_PCI_SHIFT 4
+#define _HVM_IRQ_DPCI_GUEST_MSI_SHIFT 5
+#define _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT 6
+#define _HVM_IRQ_DPCI_TRANSLATE_SHIFT 15
+#define HVM_IRQ_DPCI_MACH_PCI (1 << _HVM_IRQ_DPCI_MACH_PCI_SHIFT)
+#define HVM_IRQ_DPCI_MACH_MSI (1 << _HVM_IRQ_DPCI_MACH_MSI_SHIFT)
+#define HVM_IRQ_DPCI_MAPPED (1 << _HVM_IRQ_DPCI_MAPPED_SHIFT)
+#define HVM_IRQ_DPCI_EOI_LATCH (1 << _HVM_IRQ_DPCI_EOI_LATCH_SHIFT)
+#define HVM_IRQ_DPCI_GUEST_PCI (1 << _HVM_IRQ_DPCI_GUEST_PCI_SHIFT)
+#define HVM_IRQ_DPCI_GUEST_MSI (1 << _HVM_IRQ_DPCI_GUEST_MSI_SHIFT)
+#define HVM_IRQ_DPCI_IDENTITY_GSI (1 << _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT)
+#define HVM_IRQ_DPCI_TRANSLATE (1 << _HVM_IRQ_DPCI_TRANSLATE_SHIFT)
+
+#define VMSI_DEST_ID_MASK 0xff
+#define VMSI_RH_MASK 0x100
+#define VMSI_DM_MASK 0x200
+#define VMSI_DELIV_MASK 0x7000
+#define VMSI_TRIG_MODE 0x8000
+
+#define GFLAGS_SHIFT_RH 8
+#define GFLAGS_SHIFT_DELIV_MODE 12
+#define GFLAGS_SHIFT_TRG_MODE 15
+
+struct hvm_gmsi_info {
+ uint32_t gvec;
+ uint32_t gflags;
+ int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
+ bool posted; /* directly deliver to guest via VT-d PI? */
+};
+
+struct hvm_girq_dpci_mapping {
+ struct list_head list;
+ uint8_t bus;
+ uint8_t device;
+ uint8_t intx;
+ uint8_t machine_gsi;
+};
+
+#define NR_ISAIRQS 16
+#define NR_LINK 4
+#if defined(CONFIG_X86)
+# define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)
+#endif
+
+/* Protected by domain's event_lock */
+struct hvm_irq_dpci {
+ /* Guest IRQ to guest device/intx mapping. */
+ struct list_head girq[NR_HVM_DOMU_IRQS];
+ /* Record of mapped ISA IRQs */
+ DECLARE_BITMAP(isairq_map, NR_ISAIRQS);
+ /* Record of mapped Links */
+ uint8_t link_cnt[NR_LINK];
+};
+
+/* Machine IRQ to guest device/intx mapping. */
+struct hvm_pirq_dpci {
+ uint32_t flags;
+ unsigned int state;
+ bool_t masked;
+ uint16_t pending;
+ struct list_head digl_list;
+ struct domain *dom;
+ struct hvm_gmsi_info gmsi;
+ struct timer timer;
+ struct list_head softirq_list;
+};
+
+void pt_pirq_init(struct domain *, struct hvm_pirq_dpci *);
+bool_t pt_pirq_cleanup_check(struct hvm_pirq_dpci *);
+int pt_pirq_iterate(struct domain *d,
+ int (*cb)(struct domain *,
+ struct hvm_pirq_dpci *, void *arg),
+ void *arg);
+
+bool_t pt_pirq_softirq_active(struct hvm_pirq_dpci *);
+/* Modify state of a PCI INTx wire. */
+void hvm_pci_intx_assert(struct domain *d, unsigned int device,
+ unsigned int intx);
+void hvm_pci_intx_deassert(struct domain *d, unsigned int device,
+ unsigned int intx);
+
+/* Modify state of an ISA device's IRQ wire. */
+void hvm_isa_irq_assert(struct domain *d, unsigned int isa_irq);
+void hvm_isa_irq_deassert(struct domain *d, unsigned int isa_irq);
+
+/* Modify state of GSIs. */
+void hvm_gsi_assert(struct domain *d, unsigned int gsi);
+void hvm_gsi_deassert(struct domain *d, unsigned int gsi);
+
+int hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq);
+
+int hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data);
+
+void hvm_maybe_deassert_evtchn_irq(void);
+void hvm_assert_evtchn_irq(struct vcpu *v);
+void hvm_set_callback_via(struct domain *d, uint64_t via);
+
#endif /* __ASM_X86_HVM_IRQ_H__ */
diff --git a/xen/include/asm-x86/irq.h b/xen/include/asm-x86/irq.h
index 38edc053f8..d9dad393b1 100644
--- a/xen/include/asm-x86/irq.h
+++ b/xen/include/asm-x86/irq.h
@@ -7,7 +7,7 @@
#include <asm/numa.h>
#include <xen/cpumask.h>
#include <xen/smp.h>
-#include <xen/hvm/irq.h>
+#include <asm/hvm/irq.h>
#include <irq_vectors.h>
#include <asm/percpu.h>
diff --git a/xen/include/xen/hvm/irq.h b/xen/include/xen/hvm/irq.h
deleted file mode 100644
index 0d2c72c109..0000000000
--- a/xen/include/xen/hvm/irq.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/******************************************************************************
- * irq.h
- *
- * Interrupt distribution and delivery logic.
- *
- * Copyright (c) 2006, K A Fraser, XenSource Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __XEN_HVM_IRQ_H__
-#define __XEN_HVM_IRQ_H__
-
-#include <xen/types.h>
-#include <xen/spinlock.h>
-#include <xen/tasklet.h>
-#include <xen/timer.h>
-#include <public/hvm/save.h>
-
-struct dev_intx_gsi_link {
- struct list_head list;
- uint8_t bus;
- uint8_t device;
- uint8_t intx;
-};
-
-#define _HVM_IRQ_DPCI_MACH_PCI_SHIFT 0
-#define _HVM_IRQ_DPCI_MACH_MSI_SHIFT 1
-#define _HVM_IRQ_DPCI_MAPPED_SHIFT 2
-#define _HVM_IRQ_DPCI_EOI_LATCH_SHIFT 3
-#define _HVM_IRQ_DPCI_GUEST_PCI_SHIFT 4
-#define _HVM_IRQ_DPCI_GUEST_MSI_SHIFT 5
-#define _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT 6
-#define _HVM_IRQ_DPCI_TRANSLATE_SHIFT 15
-#define HVM_IRQ_DPCI_MACH_PCI (1 << _HVM_IRQ_DPCI_MACH_PCI_SHIFT)
-#define HVM_IRQ_DPCI_MACH_MSI (1 << _HVM_IRQ_DPCI_MACH_MSI_SHIFT)
-#define HVM_IRQ_DPCI_MAPPED (1 << _HVM_IRQ_DPCI_MAPPED_SHIFT)
-#define HVM_IRQ_DPCI_EOI_LATCH (1 << _HVM_IRQ_DPCI_EOI_LATCH_SHIFT)
-#define HVM_IRQ_DPCI_GUEST_PCI (1 << _HVM_IRQ_DPCI_GUEST_PCI_SHIFT)
-#define HVM_IRQ_DPCI_GUEST_MSI (1 << _HVM_IRQ_DPCI_GUEST_MSI_SHIFT)
-#define HVM_IRQ_DPCI_IDENTITY_GSI (1 << _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT)
-#define HVM_IRQ_DPCI_TRANSLATE (1 << _HVM_IRQ_DPCI_TRANSLATE_SHIFT)
-
-#define VMSI_DEST_ID_MASK 0xff
-#define VMSI_RH_MASK 0x100
-#define VMSI_DM_MASK 0x200
-#define VMSI_DELIV_MASK 0x7000
-#define VMSI_TRIG_MODE 0x8000
-
-#define GFLAGS_SHIFT_RH 8
-#define GFLAGS_SHIFT_DELIV_MODE 12
-#define GFLAGS_SHIFT_TRG_MODE 15
-
-struct hvm_gmsi_info {
- uint32_t gvec;
- uint32_t gflags;
- int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
- bool posted; /* directly deliver to guest via VT-d PI? */
-};
-
-struct hvm_girq_dpci_mapping {
- struct list_head list;
- uint8_t bus;
- uint8_t device;
- uint8_t intx;
- uint8_t machine_gsi;
-};
-
-#define NR_ISAIRQS 16
-#define NR_LINK 4
-#if defined(CONFIG_X86)
-# define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)
-#endif
-
-/* Protected by domain's event_lock */
-struct hvm_irq_dpci {
- /* Guest IRQ to guest device/intx mapping. */
- struct list_head girq[NR_HVM_DOMU_IRQS];
- /* Record of mapped ISA IRQs */
- DECLARE_BITMAP(isairq_map, NR_ISAIRQS);
- /* Record of mapped Links */
- uint8_t link_cnt[NR_LINK];
-};
-
-/* Machine IRQ to guest device/intx mapping. */
-struct hvm_pirq_dpci {
- uint32_t flags;
- unsigned int state;
- bool_t masked;
- uint16_t pending;
- struct list_head digl_list;
- struct domain *dom;
- struct hvm_gmsi_info gmsi;
- struct timer timer;
- struct list_head softirq_list;
-};
-
-void pt_pirq_init(struct domain *, struct hvm_pirq_dpci *);
-bool_t pt_pirq_cleanup_check(struct hvm_pirq_dpci *);
-int pt_pirq_iterate(struct domain *d,
- int (*cb)(struct domain *,
- struct hvm_pirq_dpci *, void *arg),
- void *arg);
-
-bool_t pt_pirq_softirq_active(struct hvm_pirq_dpci *);
-/* Modify state of a PCI INTx wire. */
-void hvm_pci_intx_assert(
- struct domain *d, unsigned int device, unsigned int intx);
-void hvm_pci_intx_deassert(
- struct domain *d, unsigned int device, unsigned int intx);
-
-/* Modify state of an ISA device's IRQ wire. */
-void hvm_isa_irq_assert(
- struct domain *d, unsigned int isa_irq);
-void hvm_isa_irq_deassert(
- struct domain *d, unsigned int isa_irq);
-
-/* Modify state of GSIs. */
-void hvm_gsi_assert(struct domain *d, unsigned int gsi);
-void hvm_gsi_deassert(struct domain *d, unsigned int gsi);
-
-int hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq);
-
-int hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data);
-
-void hvm_maybe_deassert_evtchn_irq(void);
-void hvm_assert_evtchn_irq(struct vcpu *v);
-void hvm_set_callback_via(struct domain *d, uint64_t via);
-
-#endif /* __XEN_HVM_IRQ_H__ */
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] x86: switch to plain bool in passthrough code
2017-08-21 14:09 [PATCH 0/3] xen: move common hvm code to x86 Wei Liu
2017-08-21 14:09 ` [PATCH 1/3] xen: move hvm save code under common " Wei Liu
2017-08-21 14:09 ` [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h Wei Liu
@ 2017-08-21 14:09 ` Wei Liu
2017-08-22 12:55 ` Jan Beulich
2 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-08-21 14:09 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/drivers/passthrough/io.c | 16 ++++++++--------
xen/include/asm-x86/hvm/irq.h | 6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c
index e30fd568f3..19a21bf85a 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -81,17 +81,17 @@ static void raise_softirq_for(struct hvm_pirq_dpci *pirq_dpci)
* If it is false, it is the callers responsibility to make sure
* that the softirq (with the event_lock dropped) has ran.
*/
-bool_t pt_pirq_softirq_active(struct hvm_pirq_dpci *pirq_dpci)
+bool pt_pirq_softirq_active(struct hvm_pirq_dpci *pirq_dpci)
{
if ( pirq_dpci->state & ((1 << STATE_RUN) | (1 << STATE_SCHED)) )
- return 1;
+ return true;
/*
* If in the future we would call 'raise_softirq_for' right away
* after 'pt_pirq_softirq_active' we MUST reset the list (otherwise it
* might have stale data).
*/
- return 0;
+ return false;
}
/*
@@ -136,7 +136,7 @@ static void pt_pirq_softirq_reset(struct hvm_pirq_dpci *pirq_dpci)
pirq_dpci->masked = 0;
}
-bool_t pt_irq_need_timer(uint32_t flags)
+bool pt_irq_need_timer(uint32_t flags)
{
return !(flags & (HVM_IRQ_DPCI_GUEST_MSI | HVM_IRQ_DPCI_TRANSLATE));
}
@@ -232,7 +232,7 @@ void free_hvm_irq_dpci(struct hvm_irq_dpci *dpci)
*/
static struct vcpu *vector_hashing_dest(const struct domain *d,
uint32_t dest_id,
- bool_t dest_mode,
+ bool dest_mode,
uint8_t gvec)
{
@@ -739,14 +739,14 @@ void pt_pirq_init(struct domain *d, struct hvm_pirq_dpci *dpci)
dpci->gmsi.dest_vcpu_id = -1;
}
-bool_t pt_pirq_cleanup_check(struct hvm_pirq_dpci *dpci)
+bool pt_pirq_cleanup_check(struct hvm_pirq_dpci *dpci)
{
if ( !dpci->flags && !pt_pirq_softirq_active(dpci) )
{
dpci->dom = NULL;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
int pt_pirq_iterate(struct domain *d,
diff --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h
index 84cb8f8765..2a9305b158 100644
--- a/xen/include/asm-x86/hvm/irq.h
+++ b/xen/include/asm-x86/hvm/irq.h
@@ -176,7 +176,7 @@ struct hvm_irq_dpci {
struct hvm_pirq_dpci {
uint32_t flags;
unsigned int state;
- bool_t masked;
+ bool masked;
uint16_t pending;
struct list_head digl_list;
struct domain *dom;
@@ -186,13 +186,13 @@ struct hvm_pirq_dpci {
};
void pt_pirq_init(struct domain *, struct hvm_pirq_dpci *);
-bool_t pt_pirq_cleanup_check(struct hvm_pirq_dpci *);
+bool pt_pirq_cleanup_check(struct hvm_pirq_dpci *);
int pt_pirq_iterate(struct domain *d,
int (*cb)(struct domain *,
struct hvm_pirq_dpci *, void *arg),
void *arg);
-bool_t pt_pirq_softirq_active(struct hvm_pirq_dpci *);
+bool pt_pirq_softirq_active(struct hvm_pirq_dpci *);
/* Modify state of a PCI INTx wire. */
void hvm_pci_intx_assert(struct domain *d, unsigned int device,
unsigned int intx);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h
2017-08-21 14:09 ` [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h Wei Liu
@ 2017-08-21 14:14 ` Wei Liu
2017-08-22 12:55 ` Jan Beulich
0 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2017-08-21 14:14 UTC (permalink / raw)
To: Xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
Ian Jackson, Tim Deegan, Jan Beulich
On Mon, Aug 21, 2017 at 03:09:12PM +0100, Wei Liu wrote:
> That header file is only used by x86. Merge is into the x86 header.
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
[...]
> +#define HVM_IRQ_DPCI_MACH_PCI (1 << _HVM_IRQ_DPCI_MACH_PCI_SHIFT)
> +#define HVM_IRQ_DPCI_MACH_MSI (1 << _HVM_IRQ_DPCI_MACH_MSI_SHIFT)
> +#define HVM_IRQ_DPCI_MAPPED (1 << _HVM_IRQ_DPCI_MAPPED_SHIFT)
> +#define HVM_IRQ_DPCI_EOI_LATCH (1 << _HVM_IRQ_DPCI_EOI_LATCH_SHIFT)
> +#define HVM_IRQ_DPCI_GUEST_PCI (1 << _HVM_IRQ_DPCI_GUEST_PCI_SHIFT)
> +#define HVM_IRQ_DPCI_GUEST_MSI (1 << _HVM_IRQ_DPCI_GUEST_MSI_SHIFT)
> +#define HVM_IRQ_DPCI_IDENTITY_GSI (1 << _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT)
> +#define HVM_IRQ_DPCI_TRANSLATE (1 << _HVM_IRQ_DPCI_TRANSLATE_SHIFT)
Hmm... I think I'd better change these to 1u
> +
> +#define VMSI_DEST_ID_MASK 0xff
> +#define VMSI_RH_MASK 0x100
> +#define VMSI_DM_MASK 0x200
> +#define VMSI_DELIV_MASK 0x7000
> +#define VMSI_TRIG_MODE 0x8000
> +
> +#define GFLAGS_SHIFT_RH 8
> +#define GFLAGS_SHIFT_DELIV_MODE 12
> +#define GFLAGS_SHIFT_TRG_MODE 15
> +
> +struct hvm_gmsi_info {
> + uint32_t gvec;
> + uint32_t gflags;
> + int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
> + bool posted; /* directly deliver to guest via VT-d PI? */
> +};
> +
> +struct hvm_girq_dpci_mapping {
> + struct list_head list;
> + uint8_t bus;
> + uint8_t device;
> + uint8_t intx;
> + uint8_t machine_gsi;
> +};
> +
> +#define NR_ISAIRQS 16
> +#define NR_LINK 4
> +#if defined(CONFIG_X86)
> +# define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)
> +#endif
And this if defined is not needed any more after moving.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] xen: move hvm save code under common to x86
2017-08-21 14:09 ` [PATCH 1/3] xen: move hvm save code under common " Wei Liu
@ 2017-08-22 12:53 ` Jan Beulich
0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2017-08-22 12:53 UTC (permalink / raw)
To: Wei Liu
Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
Tim Deegan, Xen-devel
>>> On 21.08.17 at 16:09, <wei.liu2@citrix.com> wrote:
> The code is only used by x86 at this point. Merge common/hvm/save.c
> into x86 hvm/save.c. Move the headers and fix up inclusions. Remove
> the now empty common/hvm directory.
>
> Also fix some issues while moving:
> 1. removing trailing spaces;
> 2. fix multi-line comment;
> 3. make "i" in hvm_save unsigned int;
> 4. add some blank lines to separate sections of code;
> 5. change bool_t to bool.
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h
2017-08-21 14:14 ` Wei Liu
@ 2017-08-22 12:55 ` Jan Beulich
0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2017-08-22 12:55 UTC (permalink / raw)
To: Wei Liu
Cc: Stefano Stabellini, George Dunlap, Andrew Cooper, Ian Jackson,
Tim Deegan, Xen-devel
>>> On 21.08.17 at 16:14, <wei.liu2@citrix.com> wrote:
> On Mon, Aug 21, 2017 at 03:09:12PM +0100, Wei Liu wrote:
>> That header file is only used by x86. Merge is into the x86 header.
>>
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> [...]
>> +#define HVM_IRQ_DPCI_MACH_PCI (1 << _HVM_IRQ_DPCI_MACH_PCI_SHIFT)
>> +#define HVM_IRQ_DPCI_MACH_MSI (1 << _HVM_IRQ_DPCI_MACH_MSI_SHIFT)
>> +#define HVM_IRQ_DPCI_MAPPED (1 << _HVM_IRQ_DPCI_MAPPED_SHIFT)
>> +#define HVM_IRQ_DPCI_EOI_LATCH (1 << _HVM_IRQ_DPCI_EOI_LATCH_SHIFT)
>> +#define HVM_IRQ_DPCI_GUEST_PCI (1 << _HVM_IRQ_DPCI_GUEST_PCI_SHIFT)
>> +#define HVM_IRQ_DPCI_GUEST_MSI (1 << _HVM_IRQ_DPCI_GUEST_MSI_SHIFT)
>> +#define HVM_IRQ_DPCI_IDENTITY_GSI (1 << _HVM_IRQ_DPCI_IDENTITY_GSI_SHIFT)
>> +#define HVM_IRQ_DPCI_TRANSLATE (1 << _HVM_IRQ_DPCI_TRANSLATE_SHIFT)
>
> Hmm... I think I'd better change these to 1u
>
>> +
>> +#define VMSI_DEST_ID_MASK 0xff
>> +#define VMSI_RH_MASK 0x100
>> +#define VMSI_DM_MASK 0x200
>> +#define VMSI_DELIV_MASK 0x7000
>> +#define VMSI_TRIG_MODE 0x8000
>> +
>> +#define GFLAGS_SHIFT_RH 8
>> +#define GFLAGS_SHIFT_DELIV_MODE 12
>> +#define GFLAGS_SHIFT_TRG_MODE 15
>> +
>> +struct hvm_gmsi_info {
>> + uint32_t gvec;
>> + uint32_t gflags;
>> + int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
>> + bool posted; /* directly deliver to guest via VT-d PI? */
>> +};
>> +
>> +struct hvm_girq_dpci_mapping {
>> + struct list_head list;
>> + uint8_t bus;
>> + uint8_t device;
>> + uint8_t intx;
>> + uint8_t machine_gsi;
>> +};
>> +
>> +#define NR_ISAIRQS 16
>> +#define NR_LINK 4
>> +#if defined(CONFIG_X86)
>> +# define NR_HVM_DOMU_IRQS ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)
>> +#endif
>
> And this if defined is not needed any more after moving.
Wit these adjustments
Acked-by: Jan Beulich <jbeulich@suse.com>
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] x86: switch to plain bool in passthrough code
2017-08-21 14:09 ` [PATCH 3/3] x86: switch to plain bool in passthrough code Wei Liu
@ 2017-08-22 12:55 ` Jan Beulich
0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2017-08-22 12:55 UTC (permalink / raw)
To: Wei Liu; +Cc: AndrewCooper, Xen-devel
>>> On 21.08.17 at 16:09, <wei.liu2@citrix.com> wrote:
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-08-22 12:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 14:09 [PATCH 0/3] xen: move common hvm code to x86 Wei Liu
2017-08-21 14:09 ` [PATCH 1/3] xen: move hvm save code under common " Wei Liu
2017-08-22 12:53 ` Jan Beulich
2017-08-21 14:09 ` [PATCH 2/3] xen: merge common hvm/irq.h into x86 hvm/irq.h Wei Liu
2017-08-21 14:14 ` Wei Liu
2017-08-22 12:55 ` Jan Beulich
2017-08-21 14:09 ` [PATCH 3/3] x86: switch to plain bool in passthrough code Wei Liu
2017-08-22 12:55 ` Jan Beulich
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.