From nobody Sat May 4 01:18:41 2024 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=1575585074; cv=none; d=zohomail.com; s=zohoarc; b=QTZyzXzF7y+MgA3XFbTupeziQa2aZjU9og+w99bPnnWJFEJfT0/BJmkMH1955sGBddFhWa02DzsAfqZx1Ng7Oh6V/QpoAdxm0pKF62N9bYUGOmKgHCrH+0bJMzH605oxZlqS2jU+/yV33iV42Fe2tnqF7x3xyMJMPUievsflSpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585074; 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=ArBU5VlJ0pscy8TYrq/c/x2hnWbrSbItmau1HJRZFCM=; b=E0jWdTPWavzMntZ9Ylwxoc4iwo+vYGOXzvB5YGM95GS4CAkAmBwoUKeVsrapMyxNxukYHZ9fx7YVI+Fl7Ae6V+FF1hDgi6IsYKnq37C5jpZqC2x9zkhXfw8EPjoC10hMJzvu4xha1sPhk+LN2XOcXYvDuh9yi08mWWzPEC/pT5w= 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 1575585074139942.3285946264438; Thu, 5 Dec 2019 14:31:14 -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 1iczdc-0002ll-Lb; Thu, 05 Dec 2019 22:30:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdb-0002lc-G3 for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:19 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cdda68a6-17ae-11ea-b4e9-bc764e2007e4; Thu, 05 Dec 2019 22:30:13 +0000 (UTC) X-Inumbo-ID: cdda68a6-17ae-11ea-b4e9-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1575585013; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lpIOhYimmVKJ2BQvcE8WFnG5aSU4yCKnAe+zqmqTB10=; b=B8+jNZwawspah8E/tFZ9fjYQ1G3GjSdAERy4q6MgA9JoOeqCvMeLwZur 8aO0lx0Q0nEdEgFrWksp46GtEv0aBmjoSFWjTLilLAGLiyKBWgHinIw9K FIY2evFRondgq/Q40a+3btay8DqhLgcAZ+rSTdCwYOJW5+RpqQpHWczfn 4=; Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: FrxmuZyQPc6PdAqELH3XtLZm57rIrO+k0nuJORln7n9hF92sjvwcv6JIwHI2Jb2Ucaj8yBDB++ vHbNiMLkFvrwjXJwQSSIraPE4cGFAunAfdbZyJsZSbV18pjAz0aL6tYLdhNArytRkvMo8R+22g gCl66KN9zkhA4EigbaLxM45nBikX4rHMwoXWMPdlu2miZskuXyICRHQW8sd2yAsgMLNxcsKIK4 VZ0bFkgPHNdIjKe3TwZ+CM09mV+yWZ0f+ayvxiYXYj9g3FYieRx+OlR1lWxz0FHKOcxV7RVQ/i IRs= X-SBRS: 2.7 X-MesageID: 9693364 X-Ironport-Server: esa6.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="9693364" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:03 +0000 Message-ID: <20191205223008.8623-2-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 1/6] xen/tasklet: Fix return value truncation on arm64 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) The use of return_reg() assumes ARM's 32bit ABI. Therefore, a failure such= as -EINVAL will appear as a large positive number near 4 billion to a 64bit ARM guest which happens to use continue_hypercall_on_cpu(). Introduce a new arch_hypercall_tasklet_result() hook which is implemented by both architectures, and drop the return_reg() macros. This logic will be extended in a later change to make continuations out of the tasklet work. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Reviewed-by: Julien Grall --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk This was posted on its own previously, but is reset back to v1 now it is in its series. This can't be made static inline due to header constraints, but there is no inherent issue with doing so if the headers become less tangled. Failing the call with -EINVAL for missing the correct CPU is very rude, and addressed in a later patch. --- xen/arch/arm/traps.c | 7 +++++++ xen/arch/x86/hypercall.c | 7 +++++++ xen/common/domain.c | 9 +++++++-- xen/include/asm-arm/regs.h | 2 -- xen/include/asm-x86/regs.h | 2 -- xen/include/xen/domain.h | 6 ++++++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index d028ec9224..a20474f87c 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1485,6 +1485,13 @@ static void do_trap_hypercall(struct cpu_user_regs *= regs, register_t *nr, regs->pc -=3D 4; /* re-execute 'hvc #XEN_HYPERCALL_TAG' */ } =20 +void arch_hypercall_tasklet_result(struct vcpu *v, long res) +{ + struct cpu_user_regs *regs =3D &v->arch.cpu_info->guest_cpu_user_regs; + + HYPERCALL_RESULT_REG(regs) =3D res; +} + static bool check_multicall_32bit_clean(struct multicall_entry *multi) { int i; diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index 1d42702c6a..7f299d45c6 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -166,6 +166,13 @@ unsigned long hypercall_create_continuation( =20 #undef NEXT_ARG =20 +void arch_hypercall_tasklet_result(struct vcpu *v, long res) +{ + struct cpu_user_regs *regs =3D &v->arch.user_regs; + + regs->rax =3D res; +} + int hypercall_xlat_continuation(unsigned int *id, unsigned int nr, unsigned int mask, ...) { diff --git a/xen/common/domain.c b/xen/common/domain.c index 611116c7fc..ccf689fcbe 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1665,13 +1665,18 @@ static void continue_hypercall_tasklet_handler(unsi= gned long _info) { struct migrate_info *info =3D (struct migrate_info *)_info; struct vcpu *v =3D info->vcpu; + long res =3D -EINVAL; =20 /* Wait for vcpu to sleep so that we can access its register state. */ vcpu_sleep_sync(v); =20 this_cpu(continue_info) =3D info; - return_reg(v) =3D (info->cpu =3D=3D smp_processor_id()) - ? info->func(info->data) : -EINVAL; + + if ( likely(info->cpu =3D=3D smp_processor_id()) ) + res =3D info->func(info->data); + + arch_hypercall_tasklet_result(v, res); + this_cpu(continue_info) =3D NULL; =20 if ( info->nest-- =3D=3D 0 ) diff --git a/xen/include/asm-arm/regs.h b/xen/include/asm-arm/regs.h index 0e3e56b452..ec091a28a2 100644 --- a/xen/include/asm-arm/regs.h +++ b/xen/include/asm-arm/regs.h @@ -57,8 +57,6 @@ static inline bool guest_mode(const struct cpu_user_regs = *r) return (diff =3D=3D 0); } =20 -#define return_reg(v) ((v)->arch.cpu_info->guest_cpu_user_regs.r0) - register_t get_user_reg(struct cpu_user_regs *regs, int reg); void set_user_reg(struct cpu_user_regs *regs, int reg, register_t val); =20 diff --git a/xen/include/asm-x86/regs.h b/xen/include/asm-x86/regs.h index 725a664e0a..dc00b854e3 100644 --- a/xen/include/asm-x86/regs.h +++ b/xen/include/asm-x86/regs.h @@ -15,6 +15,4 @@ (diff =3D=3D 0); = \ }) =20 -#define return_reg(v) ((v)->arch.user_regs.rax) - #endif /* __X86_REGS_H__ */ diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 769302057b..1cb205d977 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -103,6 +103,12 @@ void domctl_lock_release(void); int continue_hypercall_on_cpu( unsigned int cpu, long (*func)(void *data), void *data); =20 +/* + * Companion to continue_hypercall_on_cpu(), to feed func()'s result back = into + * vcpu regsiter state. + */ +void arch_hypercall_tasklet_result(struct vcpu *v, long res); + extern unsigned int xen_processor_pmbits; =20 extern bool_t opt_dom0_vcpus_pin; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 01:18:41 2024 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=1575585074; cv=none; d=zohomail.com; s=zohoarc; b=nzrnaw9lEjfeNTt4d7Xq6hbInBDETXkmA46RrNSZQeORbyr6C5ApnlczAVn/mgUcTZDJHnSAjG7HoIT9nHpqNUx/BAsCeaGRQVz8Nhadv3nt8K8zxrbFvA8prVKYA+hoAyj+I6wK74PUUQFZ3xSkl1c96PT5O7fQxa1jmbUR8UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585074; 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=8rY1WUcqaUh21JHPqkTIhFFulE2ZlJFtqK+hInzp3uY=; b=XTVm/qWRzYkN0EhTqjIOXKVlvQwzxiLTp43bRlvUgPGvNv2K7cvMdHOU0hDupAUqczRP8wILdDtkqb+QDlGW9kVJAMCff81YN0JxqbqtqLOmScHLYPqckR6nvDO1KiUvtMQBgej4JJH93alLQOMnLCQ1dL1M3g6M7tvZFszh5jk= 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 15755850747401000.0710732356283; Thu, 5 Dec 2019 14:31:14 -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 1iczdh-0002mP-3N; Thu, 05 Dec 2019 22:30:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdg-0002mH-G4 for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:24 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ce4df294-17ae-11ea-a4aa-bc764e2007e4; Thu, 05 Dec 2019 22:30:14 +0000 (UTC) X-Inumbo-ID: ce4df294-17ae-11ea-a4aa-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1575585015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TWpK657P4Q9TvUsBYvgoVQV0UnIwAhfH5As98xFiTGE=; b=g+FOdUkGfeH391h02baEMMsxJHXS5YCbqd7GFfb4/kGChRJwM09+Ucp0 N4KmDlZLoLhBzLbLLpB/TanQcm0PxEuYBlG1grjbxuHGJ5zLhFpXEAjQ5 41ChQ1a8dnaNiUJUzEfXJDvcvRbaB4C5XNsFtYHl+zpdsPPLMyDLN4RTT A=; 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: F4JyJUdu1joLd6jcDtvvgBvuQNWJXmkqvC5aHeyJh7KlcM8yXF6y//wLH6CQAOJKf5O0ZdB8Y1 XFP8f79dqzhQq7hQH39Jnety2OLgVWLRuIrb+xZb/52Me3vnaBijTotLxwgq+JCDsuvUdQ4lIl e+QF9heBEFxAEw4XI8vX7yuv8cM8SAIX09BVWqopOvhnzUdJzYgi+NLpeKfnhutCbMzBGQRngT k5DiO8XBA9ZkLkyxe7aZf+uOg7dMg8y9ZDitjwjhksj4G/xHKWQkenrBIT+U6nXdfDtB08s703 LBE= X-SBRS: 2.7 X-MesageID: 9283663 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="9283663" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:04 +0000 Message-ID: <20191205223008.8623-3-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 2/6] xen/tasklet: Switch data parameter from unsigned long to void *. 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) Most users pass a vcpu pointer, and only stopmachine_action() takes an inte= ger parameter. Switch to using void * to substantially reduce the number of explicit casts. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Acked-by: Julien Grall --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk --- xen/arch/x86/hvm/hvm.c | 6 ++---- xen/arch/x86/hvm/vlapic.c | 8 +++----- xen/arch/x86/mm/shadow/common.c | 4 ++-- xen/common/domain.c | 15 ++++++--------- xen/common/keyhandler.c | 19 +++++++++---------- xen/common/stop_machine.c | 5 +++-- xen/common/tasklet.c | 6 ++---- xen/common/trace.c | 4 ++-- xen/drivers/char/console.c | 4 ++-- xen/drivers/passthrough/amd/iommu_guest.c | 7 +++---- xen/drivers/passthrough/amd/iommu_init.c | 6 +++--- xen/drivers/passthrough/iommu.c | 4 ++-- xen/drivers/passthrough/vtd/iommu.c | 4 ++-- xen/include/asm-x86/shadow.h | 5 ++--- xen/include/xen/tasklet.h | 10 ++++------ 15 files changed, 47 insertions(+), 60 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 47573f71b8..d909fec30d 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1525,10 +1525,8 @@ int hvm_vcpu_initialise(struct vcpu *v) if ( (rc =3D hvm_funcs.vcpu_initialise(v)) !=3D 0 ) /* teardown: hvm_f= uncs.vcpu_destroy */ goto fail3; =20 - softirq_tasklet_init( - &v->arch.hvm.assert_evtchn_irq_tasklet, - (void(*)(unsigned long))hvm_assert_evtchn_irq, - (unsigned long)v); + softirq_tasklet_init(&v->arch.hvm.assert_evtchn_irq_tasklet, + (void (*)(void *))hvm_assert_evtchn_irq, v); =20 v->arch.hvm.inject_event.vector =3D HVM_EVENT_VECTOR_UNSET; =20 diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 9b8afb72e8..06235f183e 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -309,9 +309,9 @@ static void vlapic_init_sipi_one(struct vcpu *target, u= int32_t icr) vcpu_unpause(target); } =20 -static void vlapic_init_sipi_action(unsigned long _vcpu) +static void vlapic_init_sipi_action(void *data) { - struct vcpu *origin =3D (struct vcpu *)_vcpu; + struct vcpu *origin =3D data; uint32_t icr =3D vcpu_vlapic(origin)->init_sipi.icr; uint32_t dest =3D vcpu_vlapic(origin)->init_sipi.dest; uint32_t short_hand =3D icr & APIC_SHORT_MASK; @@ -1637,9 +1637,7 @@ int vlapic_init(struct vcpu *v) =20 spin_lock_init(&vlapic->esr_lock); =20 - tasklet_init(&vlapic->init_sipi.tasklet, - vlapic_init_sipi_action, - (unsigned long)v); + tasklet_init(&vlapic->init_sipi.tasklet, vlapic_init_sipi_action, v); =20 if ( v->vcpu_id =3D=3D 0 ) register_mmio_handler(v->domain, &vlapic_mmio_ops); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/commo= n.c index 314d837602..6212ec2c4a 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3471,9 +3471,9 @@ void shadow_audit_tables(struct vcpu *v) =20 #ifdef CONFIG_PV =20 -void pv_l1tf_tasklet(unsigned long data) +void pv_l1tf_tasklet(void *data) { - struct domain *d =3D (void *)data; + struct domain *d =3D data; =20 domain_pause(d); paging_lock(d); diff --git a/xen/common/domain.c b/xen/common/domain.c index ccf689fcbe..865a1cb9d7 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -150,7 +150,7 @@ struct vcpu *vcpu_create(struct domain *d, unsigned int= vcpu_id) =20 spin_lock_init(&v->virq_lock); =20 - tasklet_init(&v->continue_hypercall_tasklet, NULL, 0); + tasklet_init(&v->continue_hypercall_tasklet, NULL, NULL); =20 grant_table_init_vcpu(v); =20 @@ -1661,9 +1661,9 @@ struct migrate_info { =20 static DEFINE_PER_CPU(struct migrate_info *, continue_info); =20 -static void continue_hypercall_tasklet_handler(unsigned long _info) +static void continue_hypercall_tasklet_handler(void *data) { - struct migrate_info *info =3D (struct migrate_info *)_info; + struct migrate_info *info =3D data; struct vcpu *v =3D info->vcpu; long res =3D -EINVAL; =20 @@ -1707,12 +1707,9 @@ int continue_hypercall_on_cpu( info->vcpu =3D curr; info->nest =3D 0; =20 - tasklet_kill( - &curr->continue_hypercall_tasklet); - tasklet_init( - &curr->continue_hypercall_tasklet, - continue_hypercall_tasklet_handler, - (unsigned long)info); + tasklet_kill(&curr->continue_hypercall_tasklet); + tasklet_init(&curr->continue_hypercall_tasklet, + continue_hypercall_tasklet_handler, info); =20 get_knownalive_domain(curr->domain); vcpu_pause_nosync(curr); diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index dc6396b225..f50490d0f3 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -71,12 +71,12 @@ static struct keyhandler { #undef KEYHANDLER }; =20 -static void keypress_action(unsigned long unused) +static void keypress_action(void *unused) { handle_keypress(keypress_key, NULL); } =20 -static DECLARE_TASKLET(keypress_tasklet, keypress_action, 0); +static DECLARE_TASKLET(keypress_tasklet, keypress_action, NULL); =20 void handle_keypress(unsigned char key, struct cpu_user_regs *regs) { @@ -199,11 +199,11 @@ static void dump_registers(unsigned char key, struct = cpu_user_regs *regs) watchdog_enable(); } =20 -static DECLARE_TASKLET(dump_hwdom_tasklet, NULL, 0); +static DECLARE_TASKLET(dump_hwdom_tasklet, NULL, NULL); =20 -static void dump_hwdom_action(unsigned long arg) +static void dump_hwdom_action(void *data) { - struct vcpu *v =3D (void *)arg; + struct vcpu *v =3D data; =20 for ( ; ; ) { @@ -212,7 +212,7 @@ static void dump_hwdom_action(unsigned long arg) break; if ( softirq_pending(smp_processor_id()) ) { - dump_hwdom_tasklet.data =3D (unsigned long)v; + dump_hwdom_tasklet.data =3D v; tasklet_schedule_on_cpu(&dump_hwdom_tasklet, v->processor); break; } @@ -233,8 +233,7 @@ static void dump_hwdom_registers(unsigned char key) if ( alt_key_handling && softirq_pending(smp_processor_id()) ) { tasklet_kill(&dump_hwdom_tasklet); - tasklet_init(&dump_hwdom_tasklet, dump_hwdom_action, - (unsigned long)v); + tasklet_init(&dump_hwdom_tasklet, dump_hwdom_action, v); tasklet_schedule_on_cpu(&dump_hwdom_tasklet, v->processor); return; } @@ -433,7 +432,7 @@ static void read_clocks(unsigned char key) maxdif_cycles, sumdif_cycles/count, count, dif_cycles); } =20 -static void run_all_nonirq_keyhandlers(unsigned long unused) +static void run_all_nonirq_keyhandlers(void *unused) { /* Fire all the non-IRQ-context diagnostic keyhandlers */ struct keyhandler *h; @@ -455,7 +454,7 @@ static void run_all_nonirq_keyhandlers(unsigned long un= used) } =20 static DECLARE_TASKLET(run_all_keyhandlers_tasklet, - run_all_nonirq_keyhandlers, 0); + run_all_nonirq_keyhandlers, NULL); =20 static void run_all_keyhandlers(unsigned char key, struct cpu_user_regs *r= egs) { diff --git a/xen/common/stop_machine.c b/xen/common/stop_machine.c index 681b40906d..33d9602217 100644 --- a/xen/common/stop_machine.c +++ b/xen/common/stop_machine.c @@ -134,8 +134,9 @@ int stop_machine_run(int (*fn)(void *), void *data, uns= igned int cpu) return ret; } =20 -static void stopmachine_action(unsigned long cpu) +static void stopmachine_action(void *data) { + unsigned int cpu =3D (unsigned long)data; enum stopmachine_state state =3D STOPMACHINE_START; =20 BUG_ON(cpu !=3D smp_processor_id()); @@ -181,7 +182,7 @@ static int cpu_callback( =20 if ( action =3D=3D CPU_UP_PREPARE ) tasklet_init(&per_cpu(stopmachine_tasklet, cpu), - stopmachine_action, cpu); + stopmachine_action, hcpu); =20 return NOTIFY_DONE; } diff --git a/xen/common/tasklet.c b/xen/common/tasklet.c index d4fea3151c..ac89511a09 100644 --- a/xen/common/tasklet.c +++ b/xen/common/tasklet.c @@ -199,8 +199,7 @@ static void migrate_tasklets_from_cpu(unsigned int cpu,= struct list_head *list) spin_unlock_irqrestore(&tasklet_lock, flags); } =20 -void tasklet_init( - struct tasklet *t, void (*func)(unsigned long), unsigned long data) +void tasklet_init(struct tasklet *t, void (*func)(void *), void *data) { memset(t, 0, sizeof(*t)); INIT_LIST_HEAD(&t->list); @@ -209,8 +208,7 @@ void tasklet_init( t->data =3D data; } =20 -void softirq_tasklet_init( - struct tasklet *t, void (*func)(unsigned long), unsigned long data) +void softirq_tasklet_init(struct tasklet *t, void (*func)(void *), void *d= ata) { tasklet_init(t, func, data); t->is_softirq =3D 1; diff --git a/xen/common/trace.c b/xen/common/trace.c index d1ef81407b..ebfc735b31 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -662,12 +662,12 @@ static inline void insert_lost_records(struct t_buf *= buf) * Notification is performed in qtasklet to avoid deadlocks with contexts * which __trace_var() may be called from (e.g., scheduler critical region= s). */ -static void trace_notify_dom0(unsigned long unused) +static void trace_notify_dom0(void *unused) { send_global_virq(VIRQ_TBUF); } static DECLARE_SOFTIRQ_TASKLET(trace_notify_dom0_tasklet, - trace_notify_dom0, 0); + trace_notify_dom0, NULL); =20 /** * __trace_var - Enters a trace tuple into the trace buffer for the curren= t CPU. diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 844c5de74e..b31d789a5d 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -505,12 +505,12 @@ static void serial_rx(char c, struct cpu_user_regs *r= egs) __serial_rx(c, regs); } =20 -static void notify_dom0_con_ring(unsigned long unused) +static void notify_dom0_con_ring(void *unused) { send_global_virq(VIRQ_CON_RING); } static DECLARE_SOFTIRQ_TASKLET(notify_dom0_con_ring_tasklet, - notify_dom0_con_ring, 0); + notify_dom0_con_ring, NULL); =20 #ifdef CONFIG_X86 static inline void xen_console_write_debug_port(const char *buf, size_t le= n) diff --git a/xen/drivers/passthrough/amd/iommu_guest.c b/xen/drivers/passth= rough/amd/iommu_guest.c index 1f2bcfbe15..4ed6519e6e 100644 --- a/xen/drivers/passthrough/amd/iommu_guest.c +++ b/xen/drivers/passthrough/amd/iommu_guest.c @@ -435,11 +435,11 @@ static int do_invalidate_dte(struct domain *d, cmd_en= try_t *cmd) return 0; } =20 -static void guest_iommu_process_command(unsigned long _d) +static void guest_iommu_process_command(void *data) { unsigned long opcode, tail, head, entries_per_page, cmd_mfn; cmd_entry_t *cmd, *cmd_base; - struct domain *d =3D (struct domain *)_d; + struct domain *d =3D data; struct guest_iommu *iommu; =20 iommu =3D domain_iommu(d); @@ -837,8 +837,7 @@ int guest_iommu_init(struct domain* d) iommu->domain =3D d; hd->arch.g_iommu =3D iommu; =20 - tasklet_init(&iommu->cmd_buffer_tasklet, - guest_iommu_process_command, (unsigned long)d); + tasklet_init(&iommu->cmd_buffer_tasklet, guest_iommu_process_command, = d); =20 spin_lock_init(&iommu->lock); =20 diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthr= ough/amd/iommu_init.c index 9509124158..2f26fed4a3 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -33,8 +33,8 @@ static int __initdata nr_amd_iommus; static bool __initdata pci_init; =20 -static void do_amd_iommu_irq(unsigned long data); -static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, do_amd_iommu_irq, 0); +static void do_amd_iommu_irq(void *data); +static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, do_amd_iommu_irq, NU= LL); =20 unsigned int __read_mostly ivrs_bdf_entries; u8 __read_mostly ivhd_type; @@ -723,7 +723,7 @@ static void iommu_check_ppr_log(struct amd_iommu *iommu) spin_unlock_irqrestore(&iommu->lock, flags); } =20 -static void do_amd_iommu_irq(unsigned long data) +static void do_amd_iommu_irq(void *unused) { struct amd_iommu *iommu; =20 diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 05e740757a..4e19cf56cc 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -369,7 +369,7 @@ int iommu_lookup_page(struct domain *d, dfn_t dfn, mfn_= t *mfn, return iommu_call(hd->platform_ops, lookup_page, d, dfn, mfn, flags); } =20 -static void iommu_free_pagetables(unsigned long unused) +static void iommu_free_pagetables(void *unused) { do { struct page_info *pg; @@ -500,7 +500,7 @@ int __init iommu_setup(void) iommu_hwdom_passthrough ? "Passthrough" : iommu_hwdom_strict ? "Strict" : "Relaxed"); printk("Interrupt remapping %sabled\n", iommu_intremap ? "en" : "d= is"); - tasklet_init(&iommu_pt_cleanup_tasklet, iommu_free_pagetables, 0); + tasklet_init(&iommu_pt_cleanup_tasklet, iommu_free_pagetables, NUL= L); } =20 return rc; diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 664556aa51..c56df8e58e 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -965,7 +965,7 @@ static void __do_iommu_page_fault(struct vtd_iommu *iom= mu) } } =20 -static void do_iommu_page_fault(unsigned long data) +static void do_iommu_page_fault(void *unused) { struct acpi_drhd_unit *drhd; =20 @@ -2309,7 +2309,7 @@ static int __init vtd_setup(void) } } =20 - softirq_tasklet_init(&vtd_fault_tasklet, do_iommu_page_fault, 0); + softirq_tasklet_init(&vtd_fault_tasklet, do_iommu_page_fault, NULL); =20 if ( !iommu_qinval && iommu_intremap ) { diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 8ebb89c027..907c71f497 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -230,7 +230,7 @@ static inline bool pv_l1tf_check_l4e(struct domain *d, = l4_pgentry_t l4e) return pv_l1tf_check_pte(d, 4, l4e.l4); } =20 -void pv_l1tf_tasklet(unsigned long data); +void pv_l1tf_tasklet(void *data); =20 static inline void pv_l1tf_domain_init(struct domain *d) { @@ -238,8 +238,7 @@ static inline void pv_l1tf_domain_init(struct domain *d) : opt_pv_l1tf_domu; =20 #ifdef CONFIG_SHADOW_PAGING - tasklet_init(&d->arch.paging.shadow.pv_l1tf_tasklet, - pv_l1tf_tasklet, (unsigned long)d); + tasklet_init(&d->arch.paging.shadow.pv_l1tf_tasklet, pv_l1tf_tasklet, = d); #endif } =20 diff --git a/xen/include/xen/tasklet.h b/xen/include/xen/tasklet.h index bc9ddace6d..ea73171f6e 100644 --- a/xen/include/xen/tasklet.h +++ b/xen/include/xen/tasklet.h @@ -21,8 +21,8 @@ struct tasklet bool_t is_softirq; bool_t is_running; bool_t is_dead; - void (*func)(unsigned long); - unsigned long data; + void (*func)(void *); + void *data; }; =20 #define _DECLARE_TASKLET(name, func, data, softirq) \ @@ -59,10 +59,8 @@ void tasklet_schedule_on_cpu(struct tasklet *t, unsigned= int cpu); void tasklet_schedule(struct tasklet *t); void do_tasklet(void); void tasklet_kill(struct tasklet *t); -void tasklet_init( - struct tasklet *t, void (*func)(unsigned long), unsigned long data); -void softirq_tasklet_init( - struct tasklet *t, void (*func)(unsigned long), unsigned long data); +void tasklet_init(struct tasklet *t, void (*func)(void *), void *data); +void softirq_tasklet_init(struct tasklet *t, void (*func)(void *), void *d= ata); void tasklet_subsys_init(void); =20 #endif /* __XEN_TASKLET_H__ */ --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 01:18:41 2024 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=1575585074; cv=none; d=zohomail.com; s=zohoarc; b=lQMQHAMA3/wF6zSQoFCoUBEN2MVeg3pS6ZurWouHIOkFpwy+oU/xGR2HgKHhNB+IQ7Ne5RCBDsrAQUEPkzYQ8flVmTorglgccBIcqGyh8N+FUlyADpY9iciusArggTMjus6QHlN/j5+ozJG7e/h79tYYqmxuU2DVVUbCGa1aCP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585074; 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=mqBcFC6/4tAlXQrvczD3ouwUZSjJjjZjya74/A8HUH8=; b=RgIi2cP/kWrwtw2B2XusoT0tYdQo715lECtQWl08EYA+zD905Jf+U8mO9Jx4L5ETR3tTGuvU2MNj8thARKmn04kmX1/R0j+2O3hy1FTUh48xahxs+ybAQUrKl9X3Tw8P2FpPHn9ilEf9LeHECl4mXbwCXkvW861LG51tRm+77hQ= 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 1575585074359489.8586501887427; Thu, 5 Dec 2019 14:31:14 -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 1iczda-0002lW-Ca; Thu, 05 Dec 2019 22:30:18 +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 1iczdY-0002lR-Q0 for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:16 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ce997b2e-17ae-11ea-8241-12813bfff9fa; Thu, 05 Dec 2019 22:30:15 +0000 (UTC) X-Inumbo-ID: ce997b2e-17ae-11ea-8241-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1575585015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yAjwg+Xqd72fHPRmgwB4RDDJxb9bQy9BUN53Jf7Acxs=; b=DHzPO0HA0Fxpvp2XUYjTS+Usn68Ikw0fn9NJQ+qeCgp7ay3x1yw1VdtH Bmdw4gsaOHTbgv39Nkir4gPhv7bwOj9ymaD26FrSdo2/e84KU7MXwD9OM 3CANoTYoTGVYe1Wbc6iNB62Kb/H0yht14CpT6uyHETtBxnp7qf7QAQHzr g=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: yu1Sxrv+8jCX5WEWSjdZUW7cde2HD1Uzf1Poin2y4uAdObjukiFd2XXeGrtraI8Brau0asiTB7 qHSj+bTUlBNbPZ3OsI7B4FHn5Pu7e4CU6neGhNHzJ83mrdi4GtN3xYIhm1lyhWPukLZwsUFu0D nCPLFoBXyVwUAFGWLs4qMVjpV9k5A3pAaQjPqQPApCsTf1S1VS+oN/KSAPi1c3teLWo/xT3p4c DIpXAk29UJd6FB7pX8JnMsyRm3g9bLtCHd+uEri6+3PnXeojjEKDdgfynuaaXZm3EzWIWirEiE sBo= X-SBRS: 2.7 X-MesageID: 9280003 X-Ironport-Server: esa3.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="9280003" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:05 +0000 Message-ID: <20191205223008.8623-4-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 3/6] xen/domctl: Consolidate hypercall continuation handling at the top level 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) More paths are going start using hypercall continuations. We could add ext= ra calls to hypercall_create_continuation() but it is much easier to handle -ERESTART once at the top level. One complication is XEN_DOMCTL_shadow_op, which for XSA-97 and ABI compatibility in a security fix, turn a DOMCTL continuation into __HYPERVISOR_arch_1. This remains as it was, gaining a comment explaining what is going on. With -ERESTART handling in place, the !domctl_lock_acquire() path can use t= he normal exit path, instead of opencoding a subset of it locally. 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 --- xen/arch/x86/domctl.c | 5 ++++- xen/arch/x86/mm/hap/hap.c | 3 +-- xen/arch/x86/mm/shadow/common.c | 3 +-- xen/common/domctl.c | 19 +++++-------------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index b461aadbd6..2fa0e7dda5 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -326,9 +326,12 @@ long arch_do_domctl( =20 switch ( domctl->cmd ) { - case XEN_DOMCTL_shadow_op: ret =3D paging_domctl(d, &domctl->u.shadow_op, u_domctl, 0); + /* + * Continuations from paging_domctl() switch index to arch_1, and + * can't use the common domctl continuation path. + */ if ( ret =3D=3D -ERESTART ) return hypercall_create_continuation(__HYPERVISOR_arch_1, "h", u_domctl); diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 3d93f3451c..3996e17b7e 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -600,8 +600,7 @@ int hap_domctl(struct domain *d, struct xen_domctl_shad= ow_op *sc, paging_unlock(d); if ( preempted ) /* Not finished. Set up to re-run the call. */ - rc =3D hypercall_create_continuation(__HYPERVISOR_domctl, "h", - u_domctl); + rc =3D -ERESTART; else /* Finished. Return the new allocation */ sc->mb =3D hap_get_allocation(d); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/commo= n.c index 6212ec2c4a..17ca21104f 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3400,8 +3400,7 @@ int shadow_domctl(struct domain *d, paging_unlock(d); if ( preempted ) /* Not finished. Set up to re-run the call. */ - rc =3D hypercall_create_continuation( - __HYPERVISOR_domctl, "h", u_domctl); + rc =3D -ERESTART; else /* Finished. Return the new allocation */ sc->mb =3D shadow_get_allocation(d); diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 03d0226039..cb0295085d 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -415,10 +415,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) =20 if ( !domctl_lock_acquire() ) { - if ( d && d !=3D dom_io ) - rcu_unlock_domain(d); - return hypercall_create_continuation( - __HYPERVISOR_domctl, "h", u_domctl); + ret =3D -ERESTART; + goto domctl_out_unlock_domonly; } =20 switch ( op->cmd ) @@ -438,9 +436,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) if ( guest_handle_is_null(op->u.vcpucontext.ctxt) ) { ret =3D vcpu_reset(v); - if ( ret =3D=3D -ERESTART ) - ret =3D hypercall_create_continuation( - __HYPERVISOR_domctl, "h", u_domctl); break; } =20 @@ -469,10 +464,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_= domctl) domain_pause(d); ret =3D arch_set_info_guest(v, c); domain_unpause(d); - - if ( ret =3D=3D -ERESTART ) - ret =3D hypercall_create_continuation( - __HYPERVISOR_domctl, "h", u_domctl); } =20 free_vcpu_guest_context(c.nat); @@ -585,9 +576,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) domain_lock(d); ret =3D domain_kill(d); domain_unlock(d); - if ( ret =3D=3D -ERESTART ) - ret =3D hypercall_create_continuation( - __HYPERVISOR_domctl, "h", u_domctl); goto domctl_out_unlock_domonly; =20 case XEN_DOMCTL_setnodeaffinity: @@ -1080,6 +1068,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u= _domctl) if ( copyback && __copy_to_guest(u_domctl, op, 1) ) ret =3D -EFAULT; =20 + if ( ret =3D=3D -ERESTART ) + ret =3D hypercall_create_continuation(__HYPERVISOR_domctl, + "h", u_domctl); return ret; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 01:18:41 2024 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 From nobody Sat May 4 01:18:41 2024 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 From nobody Sat May 4 01:18:41 2024 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=1575585072; cv=none; d=zohomail.com; s=zohoarc; b=hP/HS+hgFgRONDv7PUFfEyuV0SfKaJXiUIXY+NuNzX/UCIlxfynCwG0xfIO7TR5Z/myW3a9oWYEUdvBwZb/GC1k17fyYolm4zZ9aNHrFNNobss+MqHdCrMc5qX17Q19hwKk7G41tGGPB3NkQ/w0RIB5truqLc5rQnHrHHIwuGVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575585072; 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=oQYubRT3YXSRqFERZ0e6jwWhnkx1dGTu8si6O2EFn70=; b=Blh3p0Mkhz37DKLc00Zqo2ioFSYeYev1Ze7+rdRfkNsdzukBMaJBoHZhhXCI6PM8uFs2x32nz4oNNRdwGjyJ33dznX7x4tWJ15FMGQEOx8t/44qU/O+iXI47mo/GvLu5qRFbWARNC18xcmaFUYCYfkyiWiCQ31qwgrMj7Um3uoA= 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 1575585072814949.3038446321973; Thu, 5 Dec 2019 14:31:12 -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 1iczdr-0002qj-SJ; Thu, 05 Dec 2019 22:30:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iczdq-0002pS-Gz for xen-devel@lists.xenproject.org; Thu, 05 Dec 2019 22:30:34 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cf8a6412-17ae-11ea-b4e9-bc764e2007e4; Thu, 05 Dec 2019 22:30:16 +0000 (UTC) X-Inumbo-ID: cf8a6412-17ae-11ea-b4e9-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=4vUKHhWOBBpZPVW0zgr9Sb/Dri4wVVAAbrEofNa5NTc=; b=IEbfTClSActxDcqbSkmjTIyrG60H4aV/hJT0ZOOGTOKoAu+8QHk8I6NZ PHkxyjXDfRs6mPNexbBa5Ti/HPi7b38xZGWoG80i/1WvruoqlGbzXKtNH X6LVSI3F6LCBdBlNwkHp1ogjPjuIFhOvBb7DX2GfktcEimSxm9F6KgAvx 8=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: GT3yvoJqp2qzSnxTv1uxH33CLmQnDFdDNO1R0Jj+o/1aMqkKEJg+sq4pBNeTLcTaXvaYbDJwUb qLdMab/CTJFlA3CbjK/kUeIiSBqjCDwMH3kQftTWMSSSWUNyXl7QnqGmdEk3GbCoYEnXtB3KDw iC8b2p2ZoSfVP1XcM8w6zNY2vA+cQf5F5m2GkvCHic0Qya+/WHKFNMIh5drtybFocm1oi7jnOd ER46FaSL0w182pxYzNdAHpdH70hN79UYrC9mTUCILdsy4fpUkKY8VRHvXTCRVvFkz5v+hVV7LO nCI= X-SBRS: 2.7 X-MesageID: 9280004 X-Ironport-Server: esa3.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="9280004" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Dec 2019 22:30:08 +0000 Message-ID: <20191205223008.8623-7-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 6/6] x86/smt: Don't use -EBUSY for smt_up_down_helper() continuations 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: Andrew Cooper , Wei Liu , Jan Beulich , =?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) Tasklet context is now capable of using handling continuations. Use this rather than -EBUSY as it is a more efficient way to restart the hypercall. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/sysctl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 4a76f0f47f..06955fdc3e 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -85,6 +85,9 @@ long cpu_up_helper(void *data) /* On EBUSY, flush RCU work and have one more go. */ rcu_barrier(); ret =3D cpu_up(cpu); + + if ( ret =3D=3D -EBUSY ) + ret =3D -ERESTART; } =20 if ( !ret && !opt_smt && @@ -110,6 +113,9 @@ long cpu_down_helper(void *data) /* On EBUSY, flush RCU work and have one more go. */ rcu_barrier(); ret =3D cpu_down(cpu); + + if ( ret =3D=3D -EBUSY ) + ret =3D -ERESTART; } return ret; } @@ -143,8 +149,7 @@ static long smt_up_down_helper(void *data) */ if ( ret !=3D -EEXIST && general_preempt_check() ) { - /* In tasklet context - can't create a contination. */ - ret =3D -EBUSY; + ret =3D -ERESTART; break; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel