From nobody Mon Feb 9 05:41:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1567527368; cv=none; d=zoho.com; s=zohoarc; b=nnPFmgS1d5FhAkDNFC60au5A0moBtL+gBZtwwCPeF3UPE2Vpca1jYXWr2TQQdXzO2Mka0nevBryzIDDNcbdUmm8qNyx7MFiq7fNOjgcpYZCs+5a+P4sgDep6SixyR8/IdnUEe+IyFKtajlbP8bVSR2x70NKX3HKA4g/vXmbdcQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567527368; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LJ7YUmb/fn2786n36Hm/avSKBwQP2IxkVdXjdEBVnNo=; b=EyutiRjn9bG/9XQPq6MKj6Zqxu0GbZVUg48doVOvxNqHMDH8ZTXTr5aKaEd930zB3BRcXnA7tSi2rTX0GELounMAMbsQMAYN0opcYuCVP6bCoYaY6Rw8+NAgSj4xqpC9trdtLnKaeNzssEdyqzobnQXoA8biPaTxUyuH7ENU9DE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1567527368741428.7608376322662; Tue, 3 Sep 2019 09:16:08 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5BSD-0001s7-2j; Tue, 03 Sep 2019 16:14:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5BSC-0001rv-1E for xen-devel@lists.xenproject.org; Tue, 03 Sep 2019 16:14:48 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f24a4446-ce65-11e9-ab97-12813bfff9fa; Tue, 03 Sep 2019 16:14:47 +0000 (UTC) X-Inumbo-ID: f24a4446-ce65-11e9-ab97-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567527287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qt960/TRo1SbW4x+6PlOt+hn82QaKoUVl+HwvwZNaTs=; b=d4nIYO7Vc5q/55EHEyiGO4tEfthrWe/8CdG7sONFVCEJ5K7e4BYT9QgB ztoXGMmhFfG8TYK6pvC6JwvcrI3DlL0FUi1P2TKI+jTuZBidsoJ4jhuS9 Q2WV5KlY/iikytqPvmoePk4pAEMqfwRWefv4jGI3Z4ZDMZCjmn35I3y5o U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: MQgDxRFDgY2qkXyYx9EhX8pYHExyYJpVkIwzlzEhbT2OiwJnCbpmX9ptFd4rzldySLa++GldwA Z+5j1sBUEOmI3tq/e+PJ++SE8qsV7fx4iM53RAh1ykmMrX2fT++2s4Qhtw3HWezMevHABrYH4x uJcZ4LAMuxyD1guo5OUQlnRQZHu6Z7jDk38gYFFV/3EOSFR/WjPOB8jlB7Bq4y2ERVrxykhzX/ RLrGDPcS+PUwrKJ3t4usQNglgKonLjTe9CYHLGVyjwzvL0br8B+uSMnXbEgq7C/6jnc9kZvQPS uXQ= X-SBRS: 2.7 X-MesageID: 5068893 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,463,1559534400"; d="scan'208";a="5068893" From: Roger Pau Monne To: Date: Tue, 3 Sep 2019 18:14:20 +0200 Message-ID: <20190903161428.7159-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190903161428.7159-1-roger.pau@citrix.com> References: <20190903161428.7159-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 03/11] ioreq: switch selection and forwarding to use ioservid_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Paul Durrant , Jan Beulich , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) hvm_select_ioreq_server and hvm_send_ioreq where both using hvm_ioreq_server directly, switch to use ioservid_t in order to select and forward ioreqs. This is a preparatory change, since future patches will use the ioreq server id in order to differentiate between internal and external ioreq servers. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich Reviewed-by: Paul Durrant --- Changes since v1: - New in this version. --- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/emulate.c | 14 +++++++------- xen/arch/x86/hvm/ioreq.c | 24 ++++++++++++------------ xen/arch/x86/hvm/stdvga.c | 8 ++++---- xen/arch/x86/mm/p2m.c | 20 ++++++++++---------- xen/include/asm-x86/hvm/ioreq.h | 5 ++--- xen/include/asm-x86/p2m.h | 9 ++++----- xen/include/public/hvm/dm_op.h | 1 + 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index d6d0e8be89..c2fca9f729 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -263,7 +263,7 @@ static int set_mem_type(struct domain *d, return -EOPNOTSUPP; =20 /* Do not change to HVMMEM_ioreq_server if no ioreq server mapped.= */ - if ( !p2m_get_ioreq_server(d, &flags) ) + if ( p2m_get_ioreq_server(d, &flags) =3D=3D XEN_INVALID_IOSERVID ) return -EINVAL; } =20 diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index d75d3e6fd6..51d2fcba2d 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -254,7 +254,7 @@ static int hvmemul_do_io( * However, there's no cheap approach to avoid above situations in= xen, * so the device model side needs to check the incoming ioreq even= t. */ - struct hvm_ioreq_server *s =3D NULL; + ioservid_t id =3D XEN_INVALID_IOSERVID; p2m_type_t p2mt =3D p2m_invalid; =20 if ( is_mmio ) @@ -267,9 +267,9 @@ static int hvmemul_do_io( { unsigned int flags; =20 - s =3D p2m_get_ioreq_server(currd, &flags); + id =3D p2m_get_ioreq_server(currd, &flags); =20 - if ( s =3D=3D NULL ) + if ( id =3D=3D XEN_INVALID_IOSERVID ) { rc =3D X86EMUL_RETRY; vio->io_req.state =3D STATE_IOREQ_NONE; @@ -289,18 +289,18 @@ static int hvmemul_do_io( } } =20 - if ( !s ) - s =3D hvm_select_ioreq_server(currd, &p); + if ( id =3D=3D XEN_INVALID_IOSERVID ) + id =3D hvm_select_ioreq_server(currd, &p); =20 /* If there is no suitable backing DM, just ignore accesses */ - if ( !s ) + if ( id =3D=3D XEN_INVALID_IOSERVID ) { rc =3D hvm_process_io_intercept(&null_handler, &p); vio->io_req.state =3D STATE_IOREQ_NONE; } else { - rc =3D hvm_send_ioreq(s, &p, 0); + rc =3D hvm_send_ioreq(id, &p, 0); if ( rc !=3D X86EMUL_RETRY || currd->is_shutting_down ) vio->io_req.state =3D STATE_IOREQ_NONE; else if ( !hvm_ioreq_needs_completion(&vio->io_req) ) diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 69652e1080..95492bc111 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -39,6 +39,7 @@ static void set_ioreq_server(struct domain *d, unsigned i= nt id, { ASSERT(id < MAX_NR_IOREQ_SERVERS); ASSERT(!s || !d->arch.hvm.ioreq_server.server[id]); + BUILD_BUG_ON(MAX_NR_IOREQ_SERVERS >=3D XEN_INVALID_IOSERVID); =20 d->arch.hvm.ioreq_server.server[id] =3D s; } @@ -868,7 +869,7 @@ int hvm_destroy_ioreq_server(struct domain *d, ioservid= _t id) =20 domain_pause(d); =20 - p2m_set_ioreq_server(d, 0, s); + p2m_set_ioreq_server(d, 0, id); =20 hvm_ioreq_server_disable(s); =20 @@ -1131,7 +1132,7 @@ int hvm_map_mem_type_to_ioreq_server(struct domain *d= , ioservid_t id, if ( s->emulator !=3D current->domain ) goto out; =20 - rc =3D p2m_set_ioreq_server(d, flags, s); + rc =3D p2m_set_ioreq_server(d, flags, id); =20 out: spin_unlock_recursive(&d->arch.hvm.ioreq_server.lock); @@ -1255,8 +1256,7 @@ void hvm_destroy_all_ioreq_servers(struct domain *d) spin_unlock_recursive(&d->arch.hvm.ioreq_server.lock); } =20 -struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, - ioreq_t *p) +ioservid_t hvm_select_ioreq_server(struct domain *d, ioreq_t *p) { struct hvm_ioreq_server *s; uint32_t cf8; @@ -1265,7 +1265,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(stru= ct domain *d, unsigned int id; =20 if ( p->type !=3D IOREQ_TYPE_COPY && p->type !=3D IOREQ_TYPE_PIO ) - return NULL; + return XEN_INVALID_IOSERVID; =20 cf8 =3D d->arch.hvm.pci_cf8; =20 @@ -1320,7 +1320,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(stru= ct domain *d, start =3D addr; end =3D start + p->size - 1; if ( rangeset_contains_range(r, start, end) ) - return s; + return id; =20 break; =20 @@ -1329,7 +1329,7 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(stru= ct domain *d, end =3D hvm_mmio_last_byte(p); =20 if ( rangeset_contains_range(r, start, end) ) - return s; + return id; =20 break; =20 @@ -1338,14 +1338,14 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(st= ruct domain *d, { p->type =3D IOREQ_TYPE_PCI_CONFIG; p->addr =3D addr; - return s; + return id; } =20 break; } } =20 - return NULL; + return XEN_INVALID_IOSERVID; } =20 static int hvm_send_buffered_ioreq(struct hvm_ioreq_server *s, ioreq_t *p) @@ -1441,12 +1441,12 @@ static int hvm_send_buffered_ioreq(struct hvm_ioreq= _server *s, ioreq_t *p) return X86EMUL_OKAY; } =20 -int hvm_send_ioreq(struct hvm_ioreq_server *s, ioreq_t *proto_p, - bool buffered) +int hvm_send_ioreq(ioservid_t id, ioreq_t *proto_p, bool buffered) { struct vcpu *curr =3D current; struct domain *d =3D curr->domain; struct hvm_ioreq_vcpu *sv; + struct hvm_ioreq_server *s =3D get_ioreq_server(d, id); =20 ASSERT(s); =20 @@ -1512,7 +1512,7 @@ unsigned int hvm_broadcast_ioreq(ioreq_t *p, bool buf= fered) if ( !s->enabled ) continue; =20 - if ( hvm_send_ioreq(s, p, buffered) =3D=3D X86EMUL_UNHANDLEABLE ) + if ( hvm_send_ioreq(id, p, buffered) =3D=3D X86EMUL_UNHANDLEABLE ) failed++; } =20 diff --git a/xen/arch/x86/hvm/stdvga.c b/xen/arch/x86/hvm/stdvga.c index bd398dbb1b..a689269712 100644 --- a/xen/arch/x86/hvm/stdvga.c +++ b/xen/arch/x86/hvm/stdvga.c @@ -466,7 +466,7 @@ static int stdvga_mem_write(const struct hvm_io_handler= *handler, .dir =3D IOREQ_WRITE, .data =3D data, }; - struct hvm_ioreq_server *srv; + ioservid_t id; =20 if ( !stdvga_cache_is_enabled(s) || !s->stdvga ) goto done; @@ -507,11 +507,11 @@ static int stdvga_mem_write(const struct hvm_io_handl= er *handler, } =20 done: - srv =3D hvm_select_ioreq_server(current->domain, &p); - if ( !srv ) + id =3D hvm_select_ioreq_server(current->domain, &p); + if ( id =3D=3D XEN_INVALID_IOSERVID ) return X86EMUL_UNHANDLEABLE; =20 - return hvm_send_ioreq(srv, &p, 1); + return hvm_send_ioreq(id, &p, 1); } =20 static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler, diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 8a5229ee21..43849cbbd9 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -102,6 +102,7 @@ static int p2m_initialise(struct domain *d, struct p2m_= domain *p2m) p2m_pt_init(p2m); =20 spin_lock_init(&p2m->ioreq.lock); + p2m->ioreq.server =3D XEN_INVALID_IOSERVID; =20 return ret; } @@ -361,7 +362,7 @@ void p2m_memory_type_changed(struct domain *d) =20 int p2m_set_ioreq_server(struct domain *d, unsigned int flags, - struct hvm_ioreq_server *s) + ioservid_t id) { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); int rc; @@ -376,16 +377,16 @@ int p2m_set_ioreq_server(struct domain *d, if ( flags =3D=3D 0 ) { rc =3D -EINVAL; - if ( p2m->ioreq.server !=3D s ) + if ( p2m->ioreq.server !=3D id ) goto out; =20 - p2m->ioreq.server =3D NULL; + p2m->ioreq.server =3D XEN_INVALID_IOSERVID; p2m->ioreq.flags =3D 0; } else { rc =3D -EBUSY; - if ( p2m->ioreq.server !=3D NULL ) + if ( p2m->ioreq.server !=3D XEN_INVALID_IOSERVID ) goto out; =20 /* @@ -397,7 +398,7 @@ int p2m_set_ioreq_server(struct domain *d, if ( read_atomic(&p2m->ioreq.entry_count) ) goto out; =20 - p2m->ioreq.server =3D s; + p2m->ioreq.server =3D id; p2m->ioreq.flags =3D flags; } =20 @@ -409,19 +410,18 @@ int p2m_set_ioreq_server(struct domain *d, return rc; } =20 -struct hvm_ioreq_server *p2m_get_ioreq_server(struct domain *d, - unsigned int *flags) +ioservid_t p2m_get_ioreq_server(struct domain *d, unsigned int *flags) { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); - struct hvm_ioreq_server *s; + ioservid_t id; =20 spin_lock(&p2m->ioreq.lock); =20 - s =3D p2m->ioreq.server; + id =3D p2m->ioreq.server; *flags =3D p2m->ioreq.flags; =20 spin_unlock(&p2m->ioreq.lock); - return s; + return id; } =20 void p2m_enable_hardware_log_dirty(struct domain *d) diff --git a/xen/include/asm-x86/hvm/ioreq.h b/xen/include/asm-x86/hvm/iore= q.h index e2588e912f..65491c48d2 100644 --- a/xen/include/asm-x86/hvm/ioreq.h +++ b/xen/include/asm-x86/hvm/ioreq.h @@ -47,9 +47,8 @@ int hvm_all_ioreq_servers_add_vcpu(struct domain *d, stru= ct vcpu *v); void hvm_all_ioreq_servers_remove_vcpu(struct domain *d, struct vcpu *v); void hvm_destroy_all_ioreq_servers(struct domain *d); =20 -struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, - ioreq_t *p); -int hvm_send_ioreq(struct hvm_ioreq_server *s, ioreq_t *proto_p, +ioservid_t hvm_select_ioreq_server(struct domain *d, ioreq_t *p); +int hvm_send_ioreq(ioservid_t id, ioreq_t *proto_p, bool buffered); unsigned int hvm_broadcast_ioreq(ioreq_t *p, bool buffered); =20 diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 94285db1b4..99a1dab311 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -354,7 +354,7 @@ struct p2m_domain { * ioreq server who's responsible for the emulation of * gfns with specific p2m type(for now, p2m_ioreq_server). */ - struct hvm_ioreq_server *server; + ioservid_t server; /* * flags specifies whether read, write or both operations * are to be emulated by an ioreq server. @@ -819,7 +819,7 @@ static inline p2m_type_t p2m_recalc_type_range(bool rec= alc, p2m_type_t t, if ( !recalc || !p2m_is_changeable(t) ) return t; =20 - if ( t =3D=3D p2m_ioreq_server && p2m->ioreq.server !=3D NULL ) + if ( t =3D=3D p2m_ioreq_server && p2m->ioreq.server !=3D XEN_INVALID_I= OSERVID ) return t; =20 return p2m_is_logdirty_range(p2m, gfn_start, gfn_end) ? p2m_ram_logdir= ty @@ -938,9 +938,8 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type= _t p2mt, mfn_t mfn) } =20 int p2m_set_ioreq_server(struct domain *d, unsigned int flags, - struct hvm_ioreq_server *s); -struct hvm_ioreq_server *p2m_get_ioreq_server(struct domain *d, - unsigned int *flags); + ioservid_t id); +ioservid_t p2m_get_ioreq_server(struct domain *d, unsigned int *flags); =20 static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt, p2m_type_t ot, mfn_t nfn, mfn_t ofn, diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h index d3b554d019..8725cc20d3 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -54,6 +54,7 @@ */ =20 typedef uint16_t ioservid_t; +#define XEN_INVALID_IOSERVID 0xffff =20 /* * XEN_DMOP_create_ioreq_server: Instantiate a new IOREQ Server for a --=20 2.22.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel