From nobody Fri Oct 31 09:28:40 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=1755789980; cv=none; d=zohomail.com; s=zohoarc; b=Sogv4y+3NsjaBcOtk1fcCfGkKMpciC7U0gV74ekNczdneS4rtszTsBk1mwHBCJT6RdkHKDr3+VnAwASUJtTKa4GgdvhH9WltTsVXnbqi9k8INJs1/xo7AEMK8Qrcrcw0syVxptdbEUDPTxHZWfpIViZiqtD4eH+h/CObDYZ9IOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755789980; 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=/Czx8f0L7Yqqc5qG+Tcn2zb8zTijEnp/eSv/Biuz900=; b=eDYsUb1UWS49+uRllL461gzPkixUmXmuoNhAGBpkqwRVtEARul9UbcElbIzFH0VgtVS8gi/R0I8AVdk8U63QtXqxcXcc89NCRJXDqve+SuYX52BOzc5RKGpX0K7FGBwS1iWNGGS2zgll4od5cvNJkd8vAnNYDNxUJoHVj3mQC+0= 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 1755789980268580.1979759036217; Thu, 21 Aug 2025 08:26:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1088820.1446572 (Exim 4.92) (envelope-from ) id 1up7Au-0006qD-S2; Thu, 21 Aug 2025 15:26:00 +0000 Received: by outflank-mailman (output) from mailman id 1088820.1446572; Thu, 21 Aug 2025 15:26:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up7Au-0006o8-JM; Thu, 21 Aug 2025 15:26:00 +0000 Received: by outflank-mailman (input) for mailman id 1088820; Thu, 21 Aug 2025 15:25:58 +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 1up7As-0005nU-Pv for xen-devel@lists.xenproject.org; Thu, 21 Aug 2025 15:25:58 +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 22aa5e85-7ea3-11f0-a32b-13f23c93f187; Thu, 21 Aug 2025 17:25:58 +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 4c76bQ578pzBsW3G6 for ; Thu, 21 Aug 2025 15:25:54 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id bb370819b5b149d495099cb9f5ca2153; Thu, 21 Aug 2025 15:25:54 +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: 22aa5e85-7ea3-11f0-a32b-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1755789954; x=1756059954; bh=/Czx8f0L7Yqqc5qG+Tcn2zb8zTijEnp/eSv/Biuz900=; 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=WTdQR4K5L6BWIfPcdAWHFo0zZvCS4cAGVXGqbSZRmQgmqt4mLDZ+qxvrQ//3XpzIL j2pdIi5GDO4gEmn+YXMW1NGjeCAfVljMIHyQSXtM4acroEuDLA0p5sIIfYsg2X1uGd 9xqP35TTNZqteTbS+5orl0fedIpEnTWcbMPt/rMhDmd7oADFH5Iz446INNDovqrkS8 XTIFX+OXvRTe4jx79YVhRzI9JOZxrmdRBYqmGZ7WZrU3HZLJa9lCN5SraG7vMWSpdx odlEYRurFBRA8M0lPVXZgcfm5fJIIuP4vpbrCOtQudGBTNoj4TQY6ZNIXuUX9qm1CM AqbBYevNr4Nlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1755789954; x=1756050454; i=teddy.astie@vates.tech; bh=/Czx8f0L7Yqqc5qG+Tcn2zb8zTijEnp/eSv/Biuz900=; 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=amLby1t3+xc6rNfVfowZdIU5xG+rg2l/Cq2si2st6wdmErRVoTUjuzzWzYqhINqg4 tuO/pScW/vzzwflpVCM8OR2rIBOtCtAz43RY/rJQiOR9OQ9EOyXxWm5TFMJPfwMQAC dkt1j7vTF3UrXgIg3ic47eyuAM8c3Uve5hlDKJCZOmLm6GYydGKWU/en7KMnpl9ct3 Bki/KHKQeFv+S6zB5qSXF3Uh1bIFkRLVR/76t86CejQuFW/73ZnDUeBVt992S1OpiD 6bFTInLWMKlLpREFgJvnU6G8+nXoUDQg2qpt9Mwdnni1XT+r8TDNuTsfdp70Oo+IZg sw2uxeWbfX+zA== From: "Teddy Astie" Subject: =?utf-8?Q?[RFC=20PATCH=206/9]=20sched:=20Extract=20do=5Fpoll=20main=20logic=20into=20vcpu=5Fpoll?= 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: 1755789954201 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Dario Faggioli" , "Juergen Gross" , "George Dunlap" Message-Id: <812a818e263cb8287634cea5241fe076beacc39f.1755785258.git.teddy.astie@vates.tech> 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.bb370819b5b149d495099cb9f5ca2153?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250821:md Date: Thu, 21 Aug 2025 15:25:54 +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: 1755789981439116600 Content-Type: text/plain; charset="utf-8" do_poll takes sched_poll* as parameter, but that's actually in guest memory (so it's more a guest handle). Split its copy from/to guest logic from the main logic, so that we have a separate vcpu_poll which takes the sched_= poll parameters directly. Signed-off-by: Teddy Astie --- xen/common/sched/core.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 13fdf57e57..b2c784c60e 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -1437,21 +1437,13 @@ static void vcpu_block_enable_events(void) vcpu_block(); } =20 -static long do_poll(const struct sched_poll *sched_poll) +static long vcpu_poll(unsigned int nr_ports, uint64_t timeout, evtchn_port= _t *ports) { struct vcpu *v =3D current; struct domain *d =3D v->domain; - evtchn_port_t port =3D 0; long rc; unsigned int i; =20 - /* Fairly arbitrary limit. */ - if ( sched_poll->nr_ports > 128 ) - return -EINVAL; - - if ( !guest_handle_okay(sched_poll->ports, sched_poll->nr_ports) ) - return -EFAULT; - set_bit(_VPF_blocked, &v->pause_flags); v->poll_evtchn =3D -1; set_bit(v->vcpu_id, d->poll_mask); @@ -1478,13 +1470,9 @@ static long do_poll(const struct sched_poll *sched_p= oll) if ( local_events_need_delivery() ) goto out; =20 - for ( i =3D 0; i < sched_poll->nr_ports; i++ ) + for ( i =3D 0; i < nr_ports; i++ ) { - rc =3D -EFAULT; - if ( __copy_from_guest_offset(&port, sched_poll->ports, i, 1) ) - goto out; - - rc =3D evtchn_port_poll(d, port); + rc =3D evtchn_port_poll(d, ports[i]); if ( rc ) { if ( rc > 0 ) @@ -1493,11 +1481,11 @@ static long do_poll(const struct sched_poll *sched_= poll) } } =20 - if ( sched_poll->nr_ports =3D=3D 1 ) - v->poll_evtchn =3D port; + if ( nr_ports =3D=3D 1 ) + v->poll_evtchn =3D ports[0]; =20 - if ( sched_poll->timeout !=3D 0 ) - set_timer(&v->poll_timer, sched_poll->timeout); + if ( timeout !=3D 0 ) + set_timer(&v->poll_timer, timeout); =20 TRACE_TIME(TRC_SCHED_BLOCK, d->domain_id, v->vcpu_id); raise_softirq(SCHEDULE_SOFTIRQ); @@ -1511,6 +1499,20 @@ static long do_poll(const struct sched_poll *sched_p= oll) return rc; } =20 +static long do_poll(struct sched_poll *sched_poll) +{ + evtchn_port_t ports[128]; + + /* Fairly arbitrary limit */ + if ( sched_poll->nr_ports > 128 ) + return -EINVAL; + + if ( copy_from_guest(ports, sched_poll->ports, sched_poll->nr_ports) ) + return -EFAULT; + + return vcpu_poll(sched_poll->nr_ports, sched_poll->timeout, ports); +} + /* Voluntarily yield the processor for this allocation. */ long vcpu_yield(void) { --=20 2.50.1 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech