From nobody Mon Feb 9 19:05:54 2026 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; 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=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1658128768; cv=none; d=zohomail.com; s=zohoarc; b=HyPMANwc7ISipuKNmt7ophbFWE9D4krF+D20AKPrcBM6a/+Tq9NsyTJahjvXKIiBlY41gxsXnl7gmwSxV0TjRDGHNNVLrYCNxbsVdVJdubpd+0F3N2fWMj3D5tESOauvlmd2e3fbM3KCJFmiNEVUV4krialmeSl4Nfp2vxX5yL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658128768; 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=icQ0OKk7jzwxARSdjZlLFPwy60/6FsvW69msOPoUU+c=; b=EXLUAE4kJlirkbdq8yYdweDE46hkHiyzdwG3Z8NFTUhgnk6RmXRfc871LCGHCL1/BoEUw2sQsr1jAGpQ5YJnl+0Kf1ZEJPg+Ep2P6C/QvMcrY1VFDFOvM1GUAmdduGBZRQwXF0h1NFnXlB67MS4kgeFfofPAOdjiWG7/5I/gf/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1658128768809142.0043961356729; Mon, 18 Jul 2022 00:19:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.369272.600595 (Exim 4.92) (envelope-from ) id 1oDL1k-0004uv-8b; Mon, 18 Jul 2022 07:18:48 +0000 Received: by outflank-mailman (output) from mailman id 369272.600595; Mon, 18 Jul 2022 07:18:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDL1k-0004uT-55; Mon, 18 Jul 2022 07:18:48 +0000 Received: by outflank-mailman (input) for mailman id 369272; Mon, 18 Jul 2022 07:18:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDL1i-0004to-Vl for xen-devel@lists.xenproject.org; Mon, 18 Jul 2022 07:18:46 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id daf19339-0669-11ed-924f-1f966e50362f; Mon, 18 Jul 2022 09:18:45 +0200 (CEST) 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: daf19339-0669-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1658128725; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F6JK8R4vklGJZNuhaf1bZprn0UinPkgJRlwtPk8D4E8=; b=HZK3hd3kiqWSIHd/x1jXWXR8ib2eGtSumJ/y/am1jHgNUn3jQnwoxrJV PiVyrphtfpQ4a1saxqDjdYAXNEtepVzCMeAfIhoI4HVIst5awZCN3UL+X hDnBmx4shia/Yo4UsiXSNt7r/9tSH8WkDhvYspbURR6cV+gXq4D9xJL5S 8=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76007331 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: =?us-ascii?q?A9a23=3Ae1brrKP0+ugpJ/zvrXNrnJYgzKimJRAgMBhAA?= =?us-ascii?q?5OJyBtyWkJYtZNa93r/TTRbcNWNAwAcmmIG0TFDXW4DK0JKoVnUygFF/X7yB?= =?us-ascii?q?ptrHy3eogHlySd64WL/45REHnRZwXvr0cO00x4icwyFQPofEgcEg2A9myiYE?= =?us-ascii?q?v9wJDbu2DlYKfYgvPGDMBIhVKJL48ReOvCXKqpniY5GLvlbxIQggiE59Xnbz?= =?us-ascii?q?Zi68uGBRy3+JDcSLhVh36GdRVC1ubN0aWN7JSUWeWN1V0phqE4k8tAatNnXP?= =?us-ascii?q?ck7dADaMfnpsO2IhMoGwUIXklH7v6FVIQVsPe3YflA2/L+ABkPjXNH1bo8mv?= =?us-ascii?q?pQEH5eAXkPLTEEqCK2N5HnFphwakPmhBHBSn+slivtfCFQG81Z5/ll82YUld?= =?us-ascii?q?xN/GbdiKQiE1aVCJMHx5Jkc2yBM1T9NgtjHVF93U8cvndjzBQdNiU8ADZNtF?= =?us-ascii?q?E0mrCzvbbyl0QJ/9z1iY/lY2zNr+e+vKHFq21Wy8Y/aExTk/Fk03u55Xb7/l?= =?us-ascii?q?p01yOrhe++d1rZAaqYxosbi+GZO8SMQfUfj4cWE3pX6tCtSnN+hdDJmwKPSQ?= =?us-ascii?q?WNNjyv3WowYP9eByCdtkVdnZffBSlWokb3JTU8KFyZ7cWVN5uWMHvE2TB/mV?= =?us-ascii?q?7dCC/lMbsVxFDgztceO+m1hk6WE8rover18RBGHyMun3r8akIqLlc8X0BxB8?= =?us-ascii?q?KPKzwSLKKLaZox7dC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yrS1CY2D962FtyO2dx4JK3rNmYvyNzvO8TcOlT6T0k59Z+i75bhUJ22nQB?= =?us-ascii?q?ZJdTJLGCa7p5v3lYydZv895/k9Z9sm1y8f2BQT62NLFXxPTgn3lyl/zKh/qo?= =?us-ascii?q?nB546CCFVDSfOf7POkesdYW7JoYRAiL/TpX6052YL5WuP4pGkHKZGtTgzULq?= =?us-ascii?q?M7bW+pvYtmKR31NWyTiSvhi4LFh9n5LAtJ3IRwypxKfo99J/J7lh/0aTvtAL?= =?us-ascii?q?s6gfUde9hNuCIImQ1hroMfyxGvr+/H9CpgM9Hq1q12r1IAPp6WQxWwmA3YaB?= =?us-ascii?q?/Jy4WQ4Wt05qDYHzk/iuLHbwAAqgl3AsdQMvfmoxGzhuv9NXtC7v4r5axjTd?= =?us-ascii?q?92RR/meuYTlHeIda7xUsKX2aedzBaEYldB8RxCQrnfavPTHHb6DtZaHMft7O?= =?us-ascii?q?JCPzOX6ag5biexcO3FvUdXJzEGG3jVS50ekjgjUsGB7PyGJ5iHKxArTZTFEb?= =?us-ascii?q?MXcdhQIJKo4wliWOQgpRGnbMlOUiosvkXS70eQTKzIdGXE/JDyAxRskUVTVw?= =?us-ascii?q?hHRZnIYfwFbVZZlgT0BAolCfDaFiT7+P9wGOgZXS2+ELeDsQYHjGLKr8A1cE?= =?us-ascii?q?X8iWEbjjeseBC8MZidyaJdQHbs/iOH9mdEkImoumGZ/QEAqg2VxFoLAYv3UR?= =?us-ascii?q?FHrAcI64UkNnn3Df0ywgniN6sD0YL/hDiuBmEdOXs5opcKG4cjy+Exv7UVIL?= =?us-ascii?q?KvO218hY+LgAtJI7Gh1wugXAad2NS8kJQh2D4fl1YqykeZLwsoBzzwL4TyUy?= =?us-ascii?q?YnYvVpHY7q7xgWCG6qbKm001crSPd0Kop7xDQMTZwRzcqumEVY6eYQKtu8R6?= =?us-ascii?q?HELunW1qxXW4IiRKJ+6U5BIUmtJ9P+1hjfUyesROhwOL6COc5liJF0GFudPm?= =?us-ascii?q?IU0nkWdbSFsjlnf63+9LmQLdmEtn4D05fUOHgVUEC8ZXYMn/UHyP0lwFdZhV?= =?us-ascii?q?t8h/jpwdnXf6EFB9uZoBIAGBpTKbOTYxzBtxVkC8bF0zufqLP23uQYoaqaVT?= =?us-ascii?q?mFUgAHWUkdkPJd0vIFlObk5KSStdVqJvtvCC0SPIliCTn6tNuPIk/riYAsnp?= =?us-ascii?q?g1gUW2P+m2O6PiPWtyeW6tq?= X-IronPort-AV: E=Sophos;i="5.92,280,1650945600"; d="scan'208";a="76007331" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/5] xen/wait: Extend the description of how this logic actually works Date: Mon, 18 Jul 2022 08:18:22 +0100 Message-ID: <20220718071825.22113-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220718071825.22113-1-andrew.cooper3@citrix.com> References: <20220718071825.22113-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1658128770881100002 Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/common/wait.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/xen/common/wait.c b/xen/common/wait.c index 3ebb884fe738..4dcfa17a8a3f 100644 --- a/xen/common/wait.c +++ b/xen/common/wait.c @@ -137,7 +137,19 @@ static void __prepare_to_wait(struct waitqueue_vcpu *w= qv) do_softirq(); } =20 - /* Hand-rolled setjmp(). */ + /* + * Hand-rolled setjmp(). + * + * __prepare_to_wait() is the leaf of a deep calltree. Preserve the G= PRs, + * bounds check what we want to stash in wqv->stack, copy the active s= tack + * (up to cpu_info) into wqv->stack, then return normally. Our caller + * will shortly schedule() and discard the current context. + * + * The copy out is performed with a rep movsb. When + * check_wakeup_from_wait() longjmp()'s back into us, %rsp is pre-adju= sted + * to be suitable and %rsi/%rdi are swapped, so the rep movsb instead + * copies in from wqv->stack over the active stack. + */ asm volatile ( "push %%rax; push %%rbx; push %%rdx; push %%rbp;" "push %%r8; push %%r9; push %%r10; push %%r11;" @@ -199,9 +211,18 @@ void check_wakeup_from_wait(void) } =20 /* - * Hand-rolled longjmp(). Returns to __prepare_to_wait(), and lands o= n a - * `rep movs` instruction. All other GPRs are restored from the stack= , so - * are available for use here. + * Hand-rolled longjmp(). + * + * check_wakeup_from_wait() is always called with a shallow stack, + * immediately after the vCPU has been rescheduled. + * + * Adjust %rsp to be the correct depth for the (deeper) stack we want = to + * restore, then prepare %rsi, %rdi and %rcx such that when we interce= pt + * the rep movs in __prepare_to_wait(), it copies from wqv->stack over= the + * active stack. + * + * All other GPRs are available for use; they're either restored from + * wqv->stack or explicitly clobbered. */ asm volatile ( "mov %1,%%"__OP"sp; jmp .L_wq_resume;" --=20 2.11.0