From nobody Fri Oct 31 09:50:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1755789986; cv=none; d=zohomail.com; s=zohoarc; b=ZmlfIyt0q3RV2/6ZWDiMvukBluCr5AfN5WNSPyOKtgMSEIEQm8vrwxYd4V4yKT3HtDAUViZVVFR6rBXzqB9IIwDaUdFGmqzXvJGrvjkPE8mJC5XN9zgQ8w6OcFcemHpN1wgTtFMTmD/TIulFzvdgHN6PVCAKKvmRrLin3LPtyDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755789986; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SbIlPsyNgTEwgIzXTJ1Jn4RTs8uee0L3+cFAML8sLR8=; b=gOjHMezhuRaKWpL2qBvqZrBMdP4vUzKKU5juL07ToxU0JsBkln6WWiZa7F/Hj+kBXsMAqVEhoJk7rGS1dolezsvrqaDjuNS5wOamoU8hp/eGYhsfugT2k26+QaI2rmSYLk73qiu/LzNK122AbgztdPuv4p6grBwba2ahxGWBeq4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1755789986778955.9054079542533; Thu, 21 Aug 2025 08:26:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1088817.1446543 (Exim 4.92) (envelope-from ) id 1up7As-0006AB-Oj; Thu, 21 Aug 2025 15:25:58 +0000 Received: by outflank-mailman (output) from mailman id 1088817.1446543; Thu, 21 Aug 2025 15:25:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up7As-00066t-Fc; Thu, 21 Aug 2025 15:25:58 +0000 Received: by outflank-mailman (input) for mailman id 1088817; Thu, 21 Aug 2025 15:25:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up7Ar-0005nU-CD for xen-devel@lists.xenproject.org; Thu, 21 Aug 2025 15:25:57 +0000 Received: from mail137-3.atl71.mandrillapp.com (mail137-3.atl71.mandrillapp.com [198.2.137.3]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1eb23df8-7ea3-11f0-a32b-13f23c93f187; Thu, 21 Aug 2025 17:25:51 +0200 (CEST) Received: from pmta07.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail137-3.atl71.mandrillapp.com (Mailchimp) with ESMTP id 4c76bL40mbzBsVD7B for ; Thu, 21 Aug 2025 15:25:50 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 3f408629188242329ca2147b15758713; Thu, 21 Aug 2025 15:25:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1eb23df8-7ea3-11f0-a32b-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1755789950; x=1756059950; bh=SbIlPsyNgTEwgIzXTJ1Jn4RTs8uee0L3+cFAML8sLR8=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=RrEDColLv3XLiy+Pvl2N0Rkll4OwKpU9CDzpuliBKDNj0dP/muYjABsxULNGI2PeH Tw1PIIy0Evg6Og3RYWkVSnvOLZqBkz0BzD3v3ogYXZorZm/abMLKYsbnHmpRZu2Obn VX5QApBlilJEm/9thqD0gmVW76Oar4QNjr8ukBruQjeqFw9oVlQWzVuO/aHeo2TDjU uRUdGmBZzCI+xl/p3BogKOp0vH7OIn5BTYpo50IWfYqaJv0z+G/S2gqaSuJTzr58C5 ZoWL61+MplY/3PPkq76cQpfiT8y6jcS0mFD74aKCzDCab4jTgYgJWO8jQe4qzuEiWs LDKFj4Ck04HcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1755789950; x=1756050450; i=teddy.astie@vates.tech; bh=SbIlPsyNgTEwgIzXTJ1Jn4RTs8uee0L3+cFAML8sLR8=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=buf6aQGC7jf864Xe0EzUrya0YgB08xs1kCH9qIHZ3T9fuFJTI86NIGWDEHRjDQLhs ppY8Qa88CBvW/CUVc/LgKw7mWjCih/AiHaLuTU4fe40FUxGzTc6vEn4Ms0KKat457X yeFhTbXsYv6NGumt34ve8fAIHZHpV0VTPFrd9zOFUnKOtxvobXEP/wgMVt9WJdzmD1 xkNp+bTgvdxDJmLZ6aK7TUDRUWSlXv3kB2/Drg/TL1q1h8dtHrYEAOdem5bvx7tDIb wGeA3ptW/YQvnx51n4peEl6ju1Zdu47X2IwnSYPMdnZor3OCLHzHS5oy0/ZhLT2Pka KoQtTC5cUKJew== From: "Teddy Astie" Subject: =?utf-8?Q?[RFC=20PATCH=201/9]=20x86/hvm:=20Use=20direct=20structures=20instead=20of=20guest=20handles?= X-Mailer: git-send-email 2.50.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1755789949800 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Jan Beulich" , "Andrew Cooper" , "=?utf-8?Q?Roger=20Pau=20Monn=C3=A9?=" Message-Id: In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.3f408629188242329ca2147b15758713?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250821:md Date: Thu, 21 Aug 2025 15:25:50 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity teddy.astie@vates.tech) X-ZM-MESSAGEID: 1755789987484116600 Content-Type: text/plain; charset="utf-8" Make these functions work with hypervisor-owned pointer rather than guest handles, so the function parameters don't have to live in guest memor= y. No functional changes intended. Signed-off-by: Teddy Astie --- xen/arch/x86/hvm/hvm.c | 126 +++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 56c7de3977..8bf59c63fe 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4142,19 +4142,14 @@ static int hvmop_flush_tlb_all(void) return paging_flush_tlb(NULL) ? 0 : -ERESTART; } =20 -static int hvmop_set_evtchn_upcall_vector( - XEN_GUEST_HANDLE_PARAM(xen_hvm_evtchn_upcall_vector_t) uop) +static int hvmop_set_evtchn_upcall_vector(xen_hvm_evtchn_upcall_vector_t o= p) { - xen_hvm_evtchn_upcall_vector_t op; struct domain *d =3D current->domain; struct vcpu *v; =20 if ( !is_hvm_domain(d) ) return -EINVAL; =20 - if ( copy_from_guest(&op, uop, 1) ) - return -EFAULT; - if ( op.vector < 0x10 ) return -EINVAL; =20 @@ -4434,26 +4429,21 @@ static int hvm_set_param(struct domain *d, uint32_t= index, uint64_t value) return rc; } =20 -static int hvmop_set_param( - XEN_GUEST_HANDLE_PARAM(xen_hvm_param_t) arg) +static int hvmop_set_param(struct xen_hvm_param op) { - struct xen_hvm_param a; struct domain *d; int rc; =20 - if ( copy_from_guest(&a, arg, 1) ) - return -EFAULT; - - if ( a.index >=3D HVM_NR_PARAMS ) + if ( op.index >=3D HVM_NR_PARAMS ) return -EINVAL; =20 - d =3D rcu_lock_domain_by_any_id(a.domid); + d =3D rcu_lock_domain_by_any_id(op.domid); if ( d =3D=3D NULL ) return -ESRCH; =20 rc =3D -EINVAL; if ( is_hvm_domain(d) ) - rc =3D hvm_set_param(d, a.index, a.value); + rc =3D hvm_set_param(d, op.index, op.value); =20 rcu_unlock_domain(d); return rc; @@ -4544,31 +4534,21 @@ int hvm_get_param(struct domain *d, uint32_t index,= uint64_t *value) return 0; }; =20 -static int hvmop_get_param( - XEN_GUEST_HANDLE_PARAM(xen_hvm_param_t) arg) +static int hvmop_get_param(struct xen_hvm_param *op) { - struct xen_hvm_param a; struct domain *d; int rc; =20 - if ( copy_from_guest(&a, arg, 1) ) - return -EFAULT; - - if ( a.index >=3D HVM_NR_PARAMS ) + if ( op->index >=3D HVM_NR_PARAMS ) return -EINVAL; =20 - d =3D rcu_lock_domain_by_any_id(a.domid); + d =3D rcu_lock_domain_by_any_id(op->domid); if ( d =3D=3D NULL ) return -ESRCH; =20 rc =3D -EINVAL; - if ( is_hvm_domain(d) && !(rc =3D hvm_get_param(d, a.index, &a.value))= ) - { - rc =3D __copy_to_guest(arg, &a, 1) ? -EFAULT : 0; - - HVM_DBG_LOG(DBG_LEVEL_HCALL, "get param %u =3D %"PRIx64, - a.index, a.value); - } + if ( is_hvm_domain(d) && !(rc =3D hvm_get_param(d, op->index, &op->val= ue)) ) + HVM_DBG_LOG(DBG_LEVEL_HCALL, "get param %u =3D %"PRIx64, a.index, = a.value); =20 rcu_unlock_domain(d); return rc; @@ -5046,18 +5026,13 @@ static int compat_altp2m_op( return rc; } =20 -static int hvmop_get_mem_type( - XEN_GUEST_HANDLE_PARAM(xen_hvm_get_mem_type_t) arg) +static int hvmop_get_mem_type(struct xen_hvm_get_mem_type *op) { - struct xen_hvm_get_mem_type a; struct domain *d; p2m_type_t t; int rc; =20 - if ( copy_from_guest(&a, arg, 1) ) - return -EFAULT; - - d =3D rcu_lock_domain_by_any_id(a.domid); + d =3D rcu_lock_domain_by_any_id(op->domid); if ( d =3D=3D NULL ) return -ESRCH; =20 @@ -5074,25 +5049,22 @@ static int hvmop_get_mem_type( * type, not in allocating or unsharing. That'll happen * on access. */ - get_gfn_query_unlocked(d, a.pfn, &t); + get_gfn_query_unlocked(d, op->pfn, &t); if ( p2m_is_mmio(t) ) - a.mem_type =3D HVMMEM_mmio_dm; + op->mem_type =3D HVMMEM_mmio_dm; else if ( t =3D=3D p2m_ioreq_server ) - a.mem_type =3D HVMMEM_ioreq_server; + op->mem_type =3D HVMMEM_ioreq_server; else if ( p2m_is_readonly(t) ) - a.mem_type =3D HVMMEM_ram_ro; + op->mem_type =3D HVMMEM_ram_ro; else if ( p2m_is_ram(t) ) - a.mem_type =3D HVMMEM_ram_rw; + op->mem_type =3D HVMMEM_ram_rw; else if ( p2m_is_pod(t) ) - a.mem_type =3D HVMMEM_ram_rw; + op->mem_type =3D HVMMEM_ram_rw; else if ( p2m_is_grant(t) ) - a.mem_type =3D HVMMEM_ram_rw; + op->mem_type =3D HVMMEM_ram_rw; else - a.mem_type =3D HVMMEM_mmio_dm; + op->mem_type =3D HVMMEM_mmio_dm; =20 - rc =3D -EFAULT; - if ( __copy_to_guest(arg, &a, 1) ) - goto out; rc =3D 0; =20 out: @@ -5115,28 +5087,70 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_P= ARAM(void) arg) switch ( op ) { case HVMOP_set_evtchn_upcall_vector: - rc =3D hvmop_set_evtchn_upcall_vector( - guest_handle_cast(arg, xen_hvm_evtchn_upcall_vector_t)); + { + struct xen_hvm_evtchn_upcall_vector op; + + if ( copy_from_guest(&op, arg, 1) ) + { + rc =3D -EFAULT; + break; + } + + rc =3D hvmop_set_evtchn_upcall_vector(op); break; + } =20 case HVMOP_set_param: - rc =3D hvmop_set_param( - guest_handle_cast(arg, xen_hvm_param_t)); + { + struct xen_hvm_param op; + =20 + if ( copy_from_guest(&op, arg, 1) ) + { + rc =3D -EFAULT; + break; + } + + rc =3D hvmop_set_param(op); break; + } =20 case HVMOP_get_param: - rc =3D hvmop_get_param( - guest_handle_cast(arg, xen_hvm_param_t)); + { + struct xen_hvm_param op; + =20 + if ( copy_from_guest(&op, arg, 1) ) + { + rc =3D -EFAULT; + break; + } + + rc =3D hvmop_get_param(&op); + + if ( !rc && copy_to_guest(arg, &op, 1) ) + rc =3D -EFAULT; break; + } =20 case HVMOP_flush_tlbs: rc =3D guest_handle_is_null(arg) ? hvmop_flush_tlb_all() : -EINVAL; break; =20 case HVMOP_get_mem_type: - rc =3D hvmop_get_mem_type( - guest_handle_cast(arg, xen_hvm_get_mem_type_t)); + { + struct xen_hvm_get_mem_type op; + + if ( copy_from_guest(&op, arg, 1) ) + { + rc =3D -EFAULT; + break; + } + =20 + rc =3D hvmop_get_mem_type(&op); + + if ( !rc && copy_to_guest(arg, &op, 1) ) + rc =3D -EFAULT; break; + } =20 case HVMOP_pagetable_dying: { --=20 2.50.1 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech