From nobody Tue Feb 10 01:14:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1575585071; cv=none; d=zohomail.com; s=zohoarc; b=JYT2BkcZhSC9rwRlAVM17o7zewYMf/UhleNMLf4OdvBJXz9zEUg5ZZPBxDWUjx6rflvSpfl7d1HbLXeMHMrn5Z2r+KaR9fFEtbAN/WCnngIM07qLA52KZwcdCVJLeT920oH5Z+z8/OKgzumEWClTxODk93LXVHZ4Fq/FN0qfcB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585071; 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; bh=b5JeRAM/o2dlnA+nb9uq76kNN6Tu8svuZpDUwZEQsic=; b=cJyCWZ7QUXZeNFJs0kufn36JfgwyHSFw/pqk61vz/s1CZX8+a74hDw+GLsg51wJwPSjGg5zeNBPwG40mXHC/mcnUmpI25yVoF13T93MUOT8sHy1HQj9R/g/fVoYtucGmNSMkKLuE1jwYJTLo0MoiMpihD+ou7jWhzFtH5wTTrp8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575585070925210.44703318087056; Thu, 5 Dec 2019 14:31:10 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdm-0002nW-CQ; Thu, 05 Dec 2019 22:30:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdl-0002n9-Gs for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:29 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cf95cea6-17ae-11ea-a4aa-bc764e2007e4; Thu, 05 Dec 2019 22:30:16 +0000 (UTC) X-Inumbo-ID: cf95cea6-17ae-11ea-a4aa-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1575585017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j7CtE/1wz8vFBRtLTHys7KdJMTnNCqEsnZtAVxueDqw=; b=hP8emzrNzWjlui5w6gqCNAatBGuPjTZi93vYDccS4z1Ek6Q7qOUC29Yr CrbsgtOIoCk2m5F7sR2Y1LyZ3ZdfvU1jupy9523BpP+mQ+azPjh1EDOVK P0jNYmVXJnm8YHHRsS+Ac0nfQILpU0QB39Ki2O49epjUTLIEdUDCuhFCz M=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.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 andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Andrew.Cooper3@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="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@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 ip4:168.245.78.127 ~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="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: UlepQX+pA9mrdTxuSXfxF9/c1TMfbFPv4GOwZvnKby4x12IWihCH1lmhBMG+0DH8gTydj0Ac/M X9lFKCQighUIpTZ+f9bTrxS0zBE9730y90qEnRSSWRGeW/eI8OAkSh/OnjQvzXdt3IZOKNlB+v 17youBcdMK6QFcjNUGUIWI4m/F1CUkitUOIciNMSKR7tr7DWHIz/xLDw90uocQTbsRTY4lucoY uxJrwIqiXAImv6hDyQGLE3nFu/pMgobAjNvH6zvPVRFTD86EgIfQrzgAeQlASEPCJmaJHSlhft vvY= X-SBRS: 2.7 X-MesageID: 9283666 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.69,282,1571716800"; d="scan'208";a="9283666" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:06 +0000 Message-ID: <20191205223008.8623-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191205223008.8623-1-andrew.cooper3@citrix.com> References: <20191205223008.8623-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/6] xen/hypercall: Cope with -ERESTART on more hypercall paths 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 , Julien Grall , Wei Liu , Andrew Cooper , Jan Beulich , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= 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) These hypercalls each use continue_hypercall_on_cpu(), whose API is about to switch to use -ERESTART. Update the soon-to-be affected paths to cope, folding existing contination logic where applicable. In addition: * For platform op and sysctl, insert a cpu_relax() into what is otherwise a tight spinlock loop, and make the continuation logic common at the epilogue. * Contrary to the comment in the code, kexec_exec() does return in the KEXEC_REBOOT case, needs to pass ret back to the caller. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk --- xen/arch/x86/platform_hypercall.c | 14 ++++++++++++-- xen/common/compat/domain.c | 9 ++++----- xen/common/domain.c | 8 ++++---- xen/common/kexec.c | 20 ++++++++++++++++---- xen/common/sysctl.c | 13 +++++++++++-- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index b19f6ec4ed..c0c209baac 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -201,9 +201,12 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platfo= rm_op_t) u_xenpf_op) * with this vcpu. */ while ( !spin_trylock(&xenpf_lock) ) + { + cpu_relax(); + if ( hypercall_preempt_check() ) - return hypercall_create_continuation( - __HYPERVISOR_platform_op, "h", u_xenpf_op); + goto create_continuation; + } =20 switch ( op->cmd ) { @@ -816,6 +819,13 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platfo= rm_op_t) u_xenpf_op) out: spin_unlock(&xenpf_lock); =20 + if ( ret =3D=3D -ERESTART ) + { + create_continuation: + ret =3D hypercall_create_continuation(__HYPERVISOR_platform_op, + "h", u_xenpf_op); + } + return ret; } =20 diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c index 11c6afc463..1a14403672 100644 --- a/xen/common/compat/domain.c +++ b/xen/common/compat/domain.c @@ -79,11 +79,6 @@ int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUE= ST_HANDLE_PARAM(void) ar =20 xfree(ctxt); } - - if ( rc =3D=3D -ERESTART ) - rc =3D hypercall_create_continuation(__HYPERVISOR_vcpu_op, "ii= h", - cmd, vcpuid, arg); - break; } =20 @@ -130,6 +125,10 @@ int compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_G= UEST_HANDLE_PARAM(void) ar break; } =20 + if ( rc =3D=3D -ERESTART ) + rc =3D hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); + return rc; } =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 865a1cb9d7..ab7e4d09c0 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1422,10 +1422,6 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GU= EST_HANDLE_PARAM(void) arg) return -EINVAL; =20 rc =3D arch_initialise_vcpu(v, arg); - if ( rc =3D=3D -ERESTART ) - rc =3D hypercall_create_continuation(__HYPERVISOR_vcpu_op, "ii= h", - cmd, vcpuid, arg); - break; =20 case VCPUOP_up: @@ -1598,6 +1594,10 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GU= EST_HANDLE_PARAM(void) arg) break; } =20 + if ( rc =3D=3D -ERESTART ) + rc =3D hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", + cmd, vcpuid, arg); + return rc; } =20 diff --git a/xen/common/kexec.c b/xen/common/kexec.c index a262cc5a18..2fca75cec0 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -842,7 +842,7 @@ static int kexec_exec(XEN_GUEST_HANDLE_PARAM(void) uarg) break; } =20 - return -EINVAL; /* never reached */ + return ret; } =20 static int kexec_swap_images(int type, struct kexec_image *new, @@ -1220,7 +1220,7 @@ static int do_kexec_op_internal(unsigned long op, return ret; =20 if ( test_and_set_bit(KEXEC_FLAG_IN_HYPERCALL, &kexec_flags) ) - return hypercall_create_continuation(__HYPERVISOR_kexec_op, "lh", = op, uarg); + return -ERESTART; =20 switch ( op ) { @@ -1263,13 +1263,25 @@ static int do_kexec_op_internal(unsigned long op, =20 long do_kexec_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) uarg) { - return do_kexec_op_internal(op, uarg, 0); + int ret =3D do_kexec_op_internal(op, uarg, 0); + + if ( ret =3D=3D -ERESTART ) + ret =3D hypercall_create_continuation(__HYPERVISOR_kexec_op, + "lh", op, uarg); + + return ret; } =20 #ifdef CONFIG_COMPAT int compat_kexec_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) uarg) { - return do_kexec_op_internal(op, uarg, 1); + int ret =3D do_kexec_op_internal(op, uarg, 1); + + if ( ret =3D=3D -ERESTART ) + ret =3D hypercall_create_continuation(__HYPERVISOR_kexec_op, + "lh", op, uarg); + + return ret; } #endif =20 diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index f88a285e7f..7b55047bb9 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -51,9 +51,12 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sy= sctl) * with this vcpu. */ while ( !spin_trylock(&sysctl_lock) ) + { + cpu_relax(); + if ( hypercall_preempt_check() ) - return hypercall_create_continuation( - __HYPERVISOR_sysctl, "h", u_sysctl); + goto create_continuation; + } =20 switch ( op->cmd ) { @@ -516,6 +519,12 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_= sysctl) __copy_to_guest(u_sysctl, op, 1) ) ret =3D -EFAULT; =20 + if ( ret =3D=3D -ERESTART ) + { + create_continuation: + ret =3D hypercall_create_continuation(__HYPERVISOR_sysctl, "h", u_= sysctl); + } + return ret; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel