From nobody Mon Feb 9 16:35:17 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=1575585076; cv=none; d=zohomail.com; s=zohoarc; b=Ly6z8KA1YCVi+lKy0p1wDilxBvFHRp7w2i46ztgUs+njYwth/gBETivfVbsH7NyvIE3bE67eY4ntRxXtqMDcCP27lLco1A/0iF8fHc3504vAjwl6KarRDLaDDUnpC7lJqBd23z/cBVWvmxzOr0WPxgRAnOKcLlupWcj9ClpdG1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585076; 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=jyzKupKwfBusyRazjc3U5E5DWJIVxZVE30USI4ErS0A=; b=MydoXGpCzxkwtE2Dr1d1YmNDoZCYQkJfZSIyNhhxEMn/yOyMWjf1bhsZbWVP04e/RbCa0sQAPe91rS9arzXYGL2h/ceTcoPDSPBoybK1wwi8YqrOnDRVqLxi8wyEqotHmppybBE8Y9AqL0jn0qFRKyzs6yHXZz9qGdvekuNGgE8= 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 1575585076975570.3853003201488; Thu, 5 Dec 2019 14:31:16 -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 1iczdw-0002tJ-5D; Thu, 05 Dec 2019 22:30:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdv-0002sy-HK for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:39 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d05222c2-17ae-11ea-a4fd-bc764e2007e4; Thu, 05 Dec 2019 22:30:17 +0000 (UTC) X-Inumbo-ID: d05222c2-17ae-11ea-a4fd-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1575585018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=joi+VZd3mz5B32uwmuHcitbgODO0/CfV0/+okJBJSME=; b=CfYEtc0OC6apiJjqxUMWklFsFnGytxBAUU6tgoG42tkbEG3H/drh8Qjd veQOL80gRsyj0j1iscrI5shDbMdwti5x5+rPdUC0SlwVDrf+b5GWQ8Nuw FdfwuYmt09YxVO3FIKxKzP0gnDbhYj0HnKIgaLP2spKyK8fEu78IUuT7n U=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: sgFanSAODiDFXas1xU1JiqRKoM5HlSpicKQgquHrZ86mRJRa2iWXNKxb97m74net1STy0p3WbX x0Qump4ICp5Tggs52I4BfU+Cn+xOyXDZ6B6R5oFgb/4AIvZbVw4DotjCLV3ktPc186sVmbHlgn cVqptJr7P93ldzG9q5PiNFwND9nxu36ZS9Uu8zhYSd824udA5X53J4m49Z0uM9VAuFsboJYoXw 0dgu4217FJIMFVOlfX4+Uxu4EX0X6YN52VU8BFWr8PdaveNo6RqsxHxZIWU+9i1ptA9ePH4mDU y9Q= X-SBRS: 2.7 X-MesageID: 9407209 X-Ironport-Server: esa1.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="9407209" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:07 +0000 Message-ID: <20191205223008.8623-6-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 5/6] xen/tasklet: Return -ERESTART from continue_hypercall_on_cpu() 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) Some hypercalls tasklets want to create a continuation, rather than fail the hypercall with a hard error. By the time the tasklet is executing, it is t= oo late to create the continuation, and even continue_hypercall_on_cpu() doesn= 't have enough state to do it correctly. All callers of continue_hypercall_on_cpu() have been updated to turn -EREST= ART into a continuation, where appropriate modifications can be made to register and/or memory parameters. This changes the continue_hypercall_on_cpu() behaviour to unconditionally create a hypercall continuation, in case the tasklet wants to use it, and t= hen to have arch_hypercall_tasklet_result() cancel the continuation when a resu= lt is available. None of these hypercalls are fast paths. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk There is one RFC point. The statement in the header file of "If this funct= ion returns 0 then the function is guaranteed to run at some point in the futur= e." was never true. In the case of a CPU miss, the hypercall would be blindly failed with -EINVAL. The current behaviour with this patch is to not cancel the continuation, wh= ich I think is less bad, but still not great. Thoughts? --- xen/arch/arm/traps.c | 1 + xen/arch/x86/hypercall.c | 7 +++++++ xen/common/domain.c | 9 +++++---- xen/include/xen/domain.h | 11 ++++++++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index a20474f87c..5d35d2b7e9 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1489,6 +1489,7 @@ void arch_hypercall_tasklet_result(struct vcpu *v, lo= ng res) { struct cpu_user_regs *regs =3D &v->arch.cpu_info->guest_cpu_user_regs; =20 + regs->pc +=3D 4; /* Skip over 'hvc #XEN_HYPERCALL_TAG' */ HYPERCALL_RESULT_REG(regs) =3D res; } =20 diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index 7f299d45c6..42d95f9b9a 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -170,6 +170,13 @@ void arch_hypercall_tasklet_result(struct vcpu *v, lon= g res) { struct cpu_user_regs *regs =3D &v->arch.user_regs; =20 + /* + * PV hypercalls are all 2-byte instructions (INT $0x82, SYSCALL). HVM + * hypercalls are all 3-byte instructions (VMCALL, VMMCALL). + * + * Move %rip forwards to complete the continuation. + */ + regs->rip +=3D 2 + is_hvm_vcpu(v); regs->rax =3D res; } =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index ab7e4d09c0..eb69db3078 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1665,7 +1665,7 @@ static void continue_hypercall_tasklet_handler(void *= data) { struct migrate_info *info =3D data; struct vcpu *v =3D info->vcpu; - long res =3D -EINVAL; + long res =3D -ERESTART; =20 /* Wait for vcpu to sleep so that we can access its register state. */ vcpu_sleep_sync(v); @@ -1675,7 +1675,8 @@ static void continue_hypercall_tasklet_handler(void *= data) if ( likely(info->cpu =3D=3D smp_processor_id()) ) res =3D info->func(info->data); =20 - arch_hypercall_tasklet_result(v, res); + if ( res !=3D -ERESTART ) + arch_hypercall_tasklet_result(v, res); =20 this_cpu(continue_info) =3D NULL; =20 @@ -1726,8 +1727,8 @@ int continue_hypercall_on_cpu( =20 tasklet_schedule_on_cpu(&info->vcpu->continue_hypercall_tasklet, cpu); =20 - /* Dummy return value will be overwritten by tasklet. */ - return 0; + /* Start a continuation. Value will be overwritten by the tasklet. */ + return -ERESTART; } =20 /* diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 1cb205d977..83c737bca4 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -96,9 +96,11 @@ void domctl_lock_release(void); =20 /* * Continue the current hypercall via func(data) on specified cpu. - * If this function returns 0 then the function is guaranteed to run at so= me - * point in the future. If this function returns an error code then the - * function has not been and will not be executed. + * + * This function returns -ERESTART in the success case, and a higher level + * caller is required to set up a hypercall continuation. func() will be = run + * at some point in the future. If this function returns any other error = code + * then func() has not, and will not be executed. */ int continue_hypercall_on_cpu( unsigned int cpu, long (*func)(void *data), void *data); @@ -106,6 +108,9 @@ int continue_hypercall_on_cpu( /* * Companion to continue_hypercall_on_cpu(), to feed func()'s result back = into * vcpu regsiter state. + * + * Must undo the effects of the hypercall continuation created by + * continue_hypercall_on_cpu()'s caller. */ void arch_hypercall_tasklet_result(struct vcpu *v, long res); =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel