From nobody Mon Feb 9 16:18: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=1660248007; cv=none; d=zohomail.com; s=zohoarc; b=DZUGTgj2AEc/hq4dODcwJLBQUu3bX7ECur5rM+vIO4rqmzP4tvB9bOG8OD4ON8glqkgjP6wpt+g/6g+mGBY/QHpjj0I6h/UxkOJ1eMjT8avv7X78+FRcN97LAOTyaYMcawVUBQDqx/x82LXGjzJkv4bwh3OawmgrcMku/4o4y/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660248007; 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=L7j7u1Belq5OB3KzKDS/T9GgEI1M27SvVLXdx7YyVfI=; b=RDfmXv0MLH3yfdMITrrDnFKPBzKRCLLxuG4m/eh8Wy0EO1REIZTI0eJOQAkJbkGxxCGaj+aRVM5edghNSr+BwhkI0rCqzWbX9vhTpNeff7rq6suUt8jAHI7OEdTCKbGHyL6h+/U67ny3gwZ0TdQa9H0TspSjaw632XZ5aFHmN0M= 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 1660248007713863.6668841579387; Thu, 11 Aug 2022 13:00:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.385157.620709 (Exim 4.92) (envelope-from ) id 1oMELL-0002dm-63; Thu, 11 Aug 2022 19:59:47 +0000 Received: by outflank-mailman (output) from mailman id 385157.620709; Thu, 11 Aug 2022 19:59:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMELL-0002dd-3L; Thu, 11 Aug 2022 19:59:47 +0000 Received: by outflank-mailman (input) for mailman id 385157; Thu, 11 Aug 2022 19:59:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMELK-00024H-BH for xen-devel@lists.xenproject.org; Thu, 11 Aug 2022 19:59:46 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 24857ae3-19b0-11ed-bd2e-47488cf2e6aa; Thu, 11 Aug 2022 21:59: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: 24857ae3-19b0-11ed-bd2e-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1660247985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KqmmLAV1fvNf0oBH4lqcnCZIyCym+wndXbWemJjGv9k=; b=An7bHQGVImhToWA5kURC5Qym55fPU6wNhVV6V+MfsBa4lEsnxD2SBtPN 0jGkbUHLZP2/Z8CwPjYi8baVcY316XndDEhDv1VH5onaVgEuHNKLsjxUy X7oZ8BU119EcS8diIcc34HKYQixEoBFAuIR2KzW3kEuw7jzu7SgemyWYS Q=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 77912369 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: =?us-ascii?q?A9a23=3ANotJXqjJ3mrf7PzgkV/5MdGJX17brhtdyRrau?= =?us-ascii?q?qucSGfot9Go9fgcEakywXxxQyOjNFhxPkljTP6bFW25pS+9ulAPs3xUIucbH?= =?us-ascii?q?vvzWNVykLxy4vp2jvjRqeQtbf0FzuW0+S8j7v4RyZsu6L3zlaqkYpjA1iwa5?= =?us-ascii?q?/YFhfqyHuERCyUGMssI0eM2zLkCwG+afzIVeHItNofOuv1lYObgxFOLAecQN?= =?us-ascii?q?OV3IDbmIAdI9MO8de0CXOoTfc7drjqanKBqQaHJiFvUf6kuCXBThJaRR1OH4?= =?us-ascii?q?+RHDTnPJBiYkzttZeorOv4eA8+fU0ej4HZTzBRYhAvZgmdUj/l7SuxZcel8Y?= =?us-ascii?q?jvxK9p7tkdHBKWwRWS4nresLtvR3hhERsr1SWEdR2u8BAyMYLaKIZ7HuSCZf?= =?us-ascii?q?sekF67vnCve9Zmmt4ZU7r0QJ1LO2bCKjOZ/eWpwQRsBgyHBW5AZorQaGF6mQ?= =?us-ascii?q?jD5i3roBsdlZmFYMFEMclzmoGaGTuCXCIAoiMkzqlhdDxRElGASyvC/Prgh+?= =?us-ascii?q?52o6GKTIPEVqAuypmie1dfyn18cpYRo6mg83t8MNq/Ugmpho0NhettN9OGc4?= =?us-ascii?q?cffysQkhLrs+5OOLY55AWHF09GLCVeUFX3xVhcF6h9PrQFot2nUtYqvL1iNa?= =?us-ascii?q?T/hR3NexEyEXYXeK64XN/84jxVBya5pNAxO4RY+PKdWIZ+WnKvdziR+xlH54?= =?us-ascii?q?95P9I6yEgN6PCmIwPpe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?us-ascii?q?RflXhVveL5uRMtEn6exfeYWC+LLHjB1D+uNOMJBfeQS5uXdiCGZCqO+4+bTi?= =?us-ascii?q?20V90MgbJxq+o4N6dENn0Jr2WWqlKBk2LGh5jbVvG68Hwx380MLNtaiC2yK+?= =?us-ascii?q?1/sGoQ5q7nviIfV1a3wG5jW6iXu4fPjOUW7LvaPUcn7eXLloRmqCx9JMcqil?= =?us-ascii?q?KOSlf8jhoeNV8+tkqER7dQq+VAveHwDvSYCZ8a4kIwZq+xabCw=3D?= X-IronPort-AV: E=Sophos;i="5.93,230,1654574400"; d="scan'208";a="77912369" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 1/2] x86/svm: Remove regs param from asm-called functions Date: Thu, 11 Aug 2022 20:59:04 +0100 Message-ID: <20220811195905.7780-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220811195905.7780-1-andrew.cooper3@citrix.com> References: <20220811195905.7780-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: 1660248009193100003 A optimisation is going to want to conditionally have extra data on the sta= ck around VMExit. We could alternative between `mov %rsp, %rdi` and `lea 8(%rsp), %rdi`, but = it is easier just to make the functions void and let the compiler do the (not very) hard work. Passing regs is a bit weird for HVM guests anyway, because the resulting pointer is invariant (this isn't native exception handling where the regs pointers *are* important), and all functions calculate `current` themselves which is another invariant. Finally, the compiler can merge the get_cpu_info() calculation which is com= mon to both `current` and guest_cpu_user_regs(), meaning the delta in C really = is just one `lea`, and not any more expensive than `mov`'s in ASM anyway. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/arch/x86/hvm/svm/entry.S | 3 --- xen/arch/x86/hvm/svm/nestedsvm.c | 3 ++- xen/arch/x86/hvm/svm/svm.c | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S index a60d759f7108..be4ce52bd81d 100644 --- a/xen/arch/x86/hvm/svm/entry.S +++ b/xen/arch/x86/hvm/svm/entry.S @@ -26,7 +26,6 @@ ENTRY(svm_asm_do_resume) GET_CURRENT(bx) .Lsvm_do_resume: call svm_intr_assist - mov %rsp,%rdi call nsvm_vcpu_switch ASSERT_NOT_IN_ATOMIC =20 @@ -52,7 +51,6 @@ UNLIKELY_START(ne, nsvm_hap) jmp .Lsvm_do_resume __UNLIKELY_END(nsvm_hap) =20 - mov %rsp, %rdi call svm_vmenter_helper =20 clgi @@ -132,7 +130,6 @@ __UNLIKELY_END(nsvm_hap) */ stgi GLOBAL(svm_stgi_label) - mov %rsp,%rdi call svm_vmexit_handler jmp .Lsvm_do_resume =20 diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nested= svm.c index 9f5f35f16aff..77f754736023 100644 --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -1460,8 +1460,9 @@ nestedsvm_vcpu_vmexit(struct vcpu *v, struct cpu_user= _regs *regs, } =20 /* VCPU switch */ -void nsvm_vcpu_switch(struct cpu_user_regs *regs) +void nsvm_vcpu_switch(void) { + struct cpu_user_regs *regs =3D guest_cpu_user_regs(); struct vcpu *v =3D current; struct nestedvcpu *nv; struct nestedsvm *svm; diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 0849a9dc5f41..81f0cf55676b 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1040,8 +1040,9 @@ static void noreturn cf_check svm_do_resume(void) reset_stack_and_jump(svm_asm_do_resume); } =20 -void svm_vmenter_helper(const struct cpu_user_regs *regs) +void svm_vmenter_helper(void) { + const struct cpu_user_regs *regs =3D guest_cpu_user_regs(); struct vcpu *curr =3D current; struct vmcb_struct *vmcb =3D curr->arch.hvm.svm.vmcb; =20 @@ -2570,8 +2571,9 @@ static struct hvm_function_table __initdata_cf_clobbe= r svm_function_table =3D { }, }; =20 -void svm_vmexit_handler(struct cpu_user_regs *regs) +void svm_vmexit_handler(void) { + struct cpu_user_regs *regs =3D guest_cpu_user_regs(); uint64_t exit_reason; struct vcpu *v =3D current; struct vmcb_struct *vmcb =3D v->arch.hvm.svm.vmcb; --=20 2.11.0