Only intercept accesses to IO port 0xcf8 if there's at least one IOREQ server, otherwise it makes no sense since the only code that uses the value stored by hvm_access_cf8 is the IOREQ server.
Signed-off-by: Roger Pau Monné <roger....@citrix.com> --- Cc: Jan Beulich <jbeul...@suse.com> Cc: Andrew Cooper <andrew.coop...@citrix.com> --- xen/arch/x86/hvm/hvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 28c6cd9..24c3d46 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1141,6 +1141,13 @@ static int hvm_create_ioreq_server(struct domain *d, domid_t domid, if ( rc ) goto fail3; + /* + * We cannot fail after this point, or we risk registering the handler + * multiple times (there's no unregister function yet). + */ + if ( list_empty(&d->arch.hvm_domain.ioreq_server.list) ) + register_portio_handler(d, 0xcf8, 4, hvm_access_cf8); + list_add(&s->list_entry, &d->arch.hvm_domain.ioreq_server.list); @@ -1625,7 +1632,6 @@ int hvm_domain_initialise(struct domain *d) pit_init(d, cpu_khz); register_portio_handler(d, 0xe9, 1, hvm_print_line); - register_portio_handler(d, 0xcf8, 4, hvm_access_cf8); rc = hvm_funcs.domain_initialise(d); if ( rc != 0 ) -- 1.9.5 (Apple Git-50.3) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel