From nobody Sat Dec 21 16:51:12 2024 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=1694636950; cv=none; d=zohomail.com; s=zohoarc; b=gwARizsfpomV+WWVEtB4V76cTK5whWHcbjnhEhnQdLXLBcWgIS1Bup3olqk2tzON6bWK4U6P7kjb9SEKBSR6rQX2YsEZazXXRlIi55FQ4Dqbr5GDHSS6P6lsIJKses7uzMVjn/xVL6Got/VdHZAd7Pa9lEhwiS59+zpn5FMNU5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694636950; 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=xTvj7qIHP2rSTn0vWDtuNlQklqFBR1DZ6LPS4jQICKM=; b=L+xcHLD0MF2HL+1egeOdgD0NpfTvYMd9K6BNKOOzxw6SdKPCKOx01FSYc0kEcyV1RGH5BDis0VRq8q13eR2TXcO0jZXNUqgze9YXXU9UFHJNbppkP4z5hpSsS7lSoYy5v4DScbISj80Vjpqg3fdcxyeeUxYSRIWAa7Ak8kRVppg= 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 1694636950119794.8110458040273; Wed, 13 Sep 2023 13:29:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.601590.937685 (Exim 4.92) (envelope-from ) id 1qgWTN-0006Wj-SX; Wed, 13 Sep 2023 20:28:29 +0000 Received: by outflank-mailman (output) from mailman id 601590.937685; Wed, 13 Sep 2023 20:28:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qgWTN-0006Tp-G3; Wed, 13 Sep 2023 20:28:29 +0000 Received: by outflank-mailman (input) for mailman id 601590; Wed, 13 Sep 2023 20:28:28 +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 1qgWTM-0004dA-0e for xen-devel@lists.xenproject.org; Wed, 13 Sep 2023 20:28:28 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1768456a-5274-11ee-8787-cb3800f73035; Wed, 13 Sep 2023 22:28:26 +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: 1768456a-5274-11ee-8787-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1694636905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jx4SOK+9S/IjqodWIlucBKoLHCAUVljbJYSnUX0zZyE=; b=KqoALMNqnBHPFSEGzbk7Z0Yy0R6I55TxlI4L7yUE634VynszxbZ1fW5c Jkq3KOfXLzcJNRqCRcMpJ3Etdo0hvZ8DSVggPgKgtZ7zhc59DR3oatP2M ALqe9jcaNQOx3HB8ypV3Sx+I2TAQiU8JonG6ca4qHXfIPQj0hUGTdmD94 w=; X-CSE-ConnectionGUID: tqLoj7ejQSK+P4DSBC/0tA== X-CSE-MsgGUID: Ve2Ajt9KQAWORAnfabEMKg== Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 125280891 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:9AOFYqwl9Z0HFCInghd6t+chxirEfRIJ4+MujC+fZmUNrF6WrkUEz WcbXGyGb/iCNDOhL9h2O4yzpB9Sup6HyIMxGwVtpCAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjPzOHvykTrecZkidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EkHUMja4mtC5QRvPKsT5zcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KX1X0 fsadz0PVyugxNrq7ImRYa40mu12eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+BgHXlfiIeg1WSvactuEDYzRBr0airO93QEjCPbZwPwxzI/ jKXpgwVBDkkOYa2yybU0UuFucj1tCX1UYg/MZ63o6sCbFq7mTVIVUx+uUGAiem0jAuyVsxSL 2QQ+zEytu4i+UqzVN7/Uhak5nmesXY0efBdDuk74wGl0bfP7kCSAW1sZiFFQMwrsokxXzNC6 7OSt4q3X3o16uTTEC/DsO7O9lteJBT5M0cefAsDT1QI4eDYg8IL0j70ZP0kSLKc24id9S7L/ xiGqy03hrM2hMEN1rmm8V2vvw9AtqQlXSZuuFyJAzvNAhdRIdf8Otf2sQSzAeNodt7xc7WXg JQTdyFyBsgqBIrFqiGCSf5l8FqBt6fca220bbKC8vAcG9WRF5yLJ9A4DNJWfh0B3iM4ldjBO RW7hO+pzMUPVEZGlIcuC25LN+wkzLL7CfPuXe3OY9xFb/BZLVHWoH81PRbMgT2zwSDAdJ3T3 r/BLa6R4YsyU/w7nFJauc9DuVPU+szO7TyKHs2qp/hW+bGfeGSUWd843KimN4gEAFe/iFyNq b53bpLaoyizpcWiOkE7B6ZPdwFVRZX6bLiqw/FqmhmrflY5QDx4W6+JqV7jEqQ895loei7z1 inVcidlJJDX1BUr9S3ihqhfVY7S IronPort-HdrOrdr: A9a23:zYTrlK1FUvlG6PzvXu3uKQqjBIokLtp133Aq2lEZdPRUGvb3qy nIpoVj6faUskd2ZJhOo7C90cW7LU80sKQFhLX5Xo3SOzUO2lHYT72KhLGKq1aLdhEWtNQtsZ uIG5IOcOEYZmIasS+V2maF+q4bsbu6zJw= X-Talos-CUID: =?us-ascii?q?9a23=3ACoiE/GrCSoCEODMpS+izFZXmUdw8Vnrfk3rSGnS?= =?us-ascii?q?bSl41ZIa/YhjI5Ioxxg=3D=3D?= X-Talos-MUID: =?us-ascii?q?9a23=3A/ObK0A0TCPcZP15Y9NPuwlvItTUj3an0IUIRwLY?= =?us-ascii?q?/kvajDwV2NT6XoRGUTdpy?= X-IronPort-AV: E=Sophos;i="6.02,144,1688443200"; d="scan'208";a="125280891" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/8] x86/spec-ctrl: Fold DO_SPEC_CTRL_EXIT_TO_XEN into it's single user Date: Wed, 13 Sep 2023 21:27:52 +0100 Message-ID: <20230913202758.508225-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230913202758.508225-1-andrew.cooper3@citrix.com> References: <20230913202758.508225-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: 1694636950639100011 With the SPEC_CTRL_EXIT_TO_XEN{,_IST} confusion fixed, it's now obvious that there's only a single EXIT_TO_XEN path. Fold DO_SPEC_CTRL_EXIT_TO_XEN into SPEC_CTRL_EXIT_TO_XEN to simplify further fixes. When merging labels, switch the name to .L\@_skip_sc_msr as "skip" on its o= wn is going to be too generic shortly. 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/include/asm/spec_ctrl_asm.h | 40 ++++++++++-------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/include/asm/spec_ctrl_asm.h b/xen/arch/x86/includ= e/asm/spec_ctrl_asm.h index 14ec40e8d32f..dd7c5e8bfc79 100644 --- a/xen/arch/x86/include/asm/spec_ctrl_asm.h +++ b/xen/arch/x86/include/asm/spec_ctrl_asm.h @@ -199,27 +199,6 @@ wrmsr .endm =20 -.macro DO_SPEC_CTRL_EXIT_TO_XEN -/* - * Requires %rbx=3Dstack_end - * Clobbers %rax, %rcx, %rdx - * - * When returning to Xen context, look to see whether SPEC_CTRL shadowing = is - * in effect, and reload the shadow value. This covers race conditions wh= ich - * exist with an NMI/MCE/etc hitting late in the return-to-guest path. - */ - xor %edx, %edx - - testb $SCF_use_shadow, STACK_CPUINFO_FIELD(spec_ctrl_flags)(%rbx) - jz .L\@_skip - - mov STACK_CPUINFO_FIELD(shadow_spec_ctrl)(%rbx), %eax - mov $MSR_SPEC_CTRL, %ecx - wrmsr - -.L\@_skip: -.endm - .macro DO_SPEC_CTRL_EXIT_TO_GUEST /* * Requires %eax=3Dspec_ctrl, %rsp=3Dregs/cpuinfo @@ -328,11 +307,24 @@ UNLIKELY_DISPATCH_LABEL(\@_serialise): * Clobbers %rax, %rcx, %rdx */ testb $SCF_ist_sc_msr, STACK_CPUINFO_FIELD(spec_ctrl_flags)(%rbx) - jz .L\@_skip + jz .L\@_skip_sc_msr =20 - DO_SPEC_CTRL_EXIT_TO_XEN + /* + * When returning to Xen context, look to see whether SPEC_CTRL shadow= ing + * is in effect, and reload the shadow value. This covers race condit= ions + * which exist with an NMI/MCE/etc hitting late in the return-to-guest + * path. + */ + xor %edx, %edx =20 -.L\@_skip: + testb $SCF_use_shadow, STACK_CPUINFO_FIELD(spec_ctrl_flags)(%rbx) + jz .L\@_skip_sc_msr + + mov STACK_CPUINFO_FIELD(shadow_spec_ctrl)(%rbx), %eax + mov $MSR_SPEC_CTRL, %ecx + wrmsr + +.L\@_skip_sc_msr: .endm =20 #endif /* __ASSEMBLY__ */ --=20 2.30.2