From nobody Thu Jul 23 21:53:42 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=1783352102; cv=none; d=zohomail.com; s=zohoarc; b=Ay31IElEgY+STyVhJmIUrulsMgB3H+bkLw/0cNVNKY5HPZDWp1JnIY/6StLAwaEiCXmdq6gVYpp81ewKFRLYHHVU7/1f28QE1mp/AV/EVtk0688/hw2p0VtdO8/cOuGUbnkxNKAFzeHoIfnxrTdPLHKzlIAcnmTLlDPMHQLHuBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783352102; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PHcjQ1xCF4fLVyfPs91K9Nneq4AcxnJkrKeQtPWGRmI=; b=K3KKBEDf0gzbSvylaDXcAgZJI9zzWvRnqQA2mfzmUxNlHPK4sEd09QsrItY9wcqk54UhRJsZI/bs1/mLPijEJXzmL3PGJcuqpAsAfVL2g9ZUB7L9z7IZZYUXB9YP8VDevv5Oil4UNZGt6W5mMuCkZFu5ANXU5Vt/NBjNiFQtqSs= 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 1783352102023915.366446544935; Mon, 6 Jul 2026 08:35:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355439.1610214 (Exim 4.92) (envelope-from ) id 1wglKx-0000z9-7m; Mon, 06 Jul 2026 15:34:23 +0000 Received: by outflank-mailman (output) from mailman id 1355439.1610214; Mon, 06 Jul 2026 15:34:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKx-0000xa-24; Mon, 06 Jul 2026 15:34:23 +0000 Received: by outflank-mailman (input) for mailman id 1355439; Mon, 06 Jul 2026 15:34:22 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKw-0000we-Bh for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:34:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglKv-000YCn-3d for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:34:21 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bcaea-5cb7-0a2a0a5109dd-0a2a450a95fe-22 for ; Mon, 06 Jul 2026 17:34:21 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bcafc-e40e-0a2a450a0019-d1558032bcd6-3 for ; Mon, 06 Jul 2026 17:34:21 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so22101625e9.0 for ; Mon, 06 Jul 2026 08:34:20 -0700 (PDT) Received: from localhost.localdomain (host-78-146-248-75.as13285.net. [78.146.248.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493c63bfba1sm433726505e9.15.2026.07.06.08.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:34:19 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1783352060; x=1783956860; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PHcjQ1xCF4fLVyfPs91K9Nneq4AcxnJkrKeQtPWGRmI=; b=crnPhurb8VFajf9bDQFa9skywLv6bvYlNkRf2aLdPfvWLCojTxsF0JKCqN9Y+c2QKX xfMI5CopS/ZEtHtNYkyMnNbFbdAkPM9Xs8ivnqsZ5xUVpbqXQFZM2D+UxwZ2zeTSvhIm rZoQ/ZYGWhbgEIIqN9EPMsFye2zsHWXdj5ULc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783352060; x=1783956860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PHcjQ1xCF4fLVyfPs91K9Nneq4AcxnJkrKeQtPWGRmI=; b=fCN7KT2DRkSzJujQRQhouwQAdVX7vjA2ES0ydXvRPKWZU6jU0FiJ1yImwSN/LtvUXW HatvPCT8WXRM0nKO/POHNyThNVBdbuj9R1oeGDkNKumuqt2MK9DWLUDiBHyvpjDe17Ug 4Gaod67UbRC7agHkSlDFOpNQJB2C9rbMVXac/6WtJOzRDJt3BsN+AuhE/qBR4H6k0mph uc29LiOt1/FDYovDe1ypNK5zEA7Ku3SnBTD4eqhquXRjSMEMI9Glm1e8izxsztQiJbtt 6elZ6Xqg8qXrve6Pb+/KVswu8DGmAuKYw6510gzM5n4WGPio2RW6rW/v5TnYIU8IbVeq uzxQ== X-Gm-Message-State: AOJu0Yz2efzilR2UcGeFImVJDlPVUFFZSlmMg68hNXVxYB1mndlleLqN AAErB5P6nN+CuKj+PbKqycFzkMca937h86UUDGALPtEve3LAFXzwMp3KcSJ38rFhokoLC+ip2dO 8WbQX X-Gm-Gg: AfdE7cm5FLjFmvDVWinV1Rb0ZkMiJEe1B107qPaMNEzQyqQnN/tR0Vsr4pg0ZzJooP9 u9AVWiuglBJekOJDWyR1Uk9emCV5llQADXUCSQa0meFWUol90bPsIEitH1IDjw0LMpGlrsZLbtp AjnC8pr3chmPFqyp4AN5qZKbPZSWBFDrQ9rMQc9HJHsqdDfUQ8pHo5D+CV1Hlh+8mHWbIHSXx4m /Pxic8qBYlFgXlgxFe5UKd2IBpZFD1pJyImw/Kwb+3GJlMmg6WvW2NbTLB01kH6krCKqJ0eNgil ImbOdqDq6V8emxI1TuLzrA+UP8ydCXiMamKBDQfHqYe20EdkjdVFcpvw8P+xcKq8ZB9FnWU/M7j +CbQIF6S2XD+yYYK4ShoChWcvLtY/m9vf3WAwvOa8sl+csK3dgqvmf65RJ7kZcp5GCnzOR+gn5d x1+oain8oMf5Qt0RI8xC8SvbHBWsFtacFk48bn3NeSppjJQZqJuYzhbfJBIChRK/Y= X-Received: by 2002:a05:600c:4e8e:b0:493:c194:4e7a with SMTP id 5b1f17b1804b1-493df0377e0mr11774875e9.3.1783352059809; Mon, 06 Jul 2026 08:34:19 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH 1/3] x86/hvm: Use PUSH_AND_CLEAR_GPRS in preference to SAVE_ALL Date: Mon, 6 Jul 2026 16:34:13 +0100 Message-Id: <20260706153415.1264750-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260706153415.1264750-1-andrew.cooper3@citrix.com> References: <20260706153415.1264750-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1783352061-D5129DDE-772D8F18/0/0 X-purgate-type: clean X-purgate-size: 1790 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1783352104313158500 SAVE_ALL hides a CLD instruction which is not needed anywhere here. * VMX VMExit always clears flags. VMX VMentry failure never switched away from the host flags, so they're still good. * SVM VMRUN always saves and restores the host flags. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Teddy Astie Bloat-o-meter reports: add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-168 (-168) Function old new delta svm_asm_do_resume 416 360 -56 vmx_asm_vmexit_handler 576 464 -112 --- xen/arch/x86/hvm/svm/entry.S | 2 +- xen/arch/x86/hvm/vmx/entry.S | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S index b6ea699bb9c0..d9613a2a8fed 100644 --- a/xen/arch/x86/hvm/svm/entry.S +++ b/xen/arch/x86/hvm/svm/entry.S @@ -89,7 +89,7 @@ __UNLIKELY_END(nsvm_hap) =20 vmrun =20 - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_CURRENT(bx) =20 diff --git a/xen/arch/x86/hvm/vmx/entry.S b/xen/arch/x86/hvm/vmx/entry.S index c34f5a1ee0af..cebc70064048 100644 --- a/xen/arch/x86/hvm/vmx/entry.S +++ b/xen/arch/x86/hvm/vmx/entry.S @@ -22,7 +22,7 @@ #include =20 FUNC(vmx_asm_vmexit_handler) - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 mov %cr2,%rax GET_CURRENT(bx) @@ -157,7 +157,7 @@ UNLIKELY_END(realmode) =20 .Lvmx_vmentry_fail: sti - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 /* * SPEC_CTRL_ENTRY notes --=20 2.39.5 From nobody Thu Jul 23 21:53:42 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=1783352104; cv=none; d=zohomail.com; s=zohoarc; b=BMhkvgD5FflorWBehiiPi9X7pM2rDgzbdR0xKhWyzBrGWOaDl5E3/1eiLAPhFv9nZsv2On+kMIkwUUbURjZUTplVQ+i6muRXk2xEVCkr0Evg8kvlRu8qJCWdz17Va95xEVlZl5/VZbT6akCn7i6NUk049DgGf4s8cx3M6wvuF1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783352104; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=US++6oXh7QmRtGgM9Ky45/VXvpj8kcMFRZ59/2f4CgI=; b=IMf+Q3Dt8lFiYqyzffsEOlPkOF175ZOhs6wvakmf49DASffFKpulK5D6ZWh9f/yM0OqcfAi9q2jNIiSHfNH/psbH99tE2eMMVdm0hA14Y8OxA1OKIA4qppimbl7Z/4FvkmFEiguVjWV+0kmn3rb+cx+3pHuljibSrp0q8sXp/rs= 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 1783352104019815.4003198865466; Mon, 6 Jul 2026 08:35:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355440.1610226 (Exim 4.92) (envelope-from ) id 1wglKy-0001MR-DJ; Mon, 06 Jul 2026 15:34:24 +0000 Received: by outflank-mailman (output) from mailman id 1355440.1610226; Mon, 06 Jul 2026 15:34:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKy-0001MJ-9Z; Mon, 06 Jul 2026 15:34:24 +0000 Received: by outflank-mailman (input) for mailman id 1355440; Mon, 06 Jul 2026 15:34:22 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKw-0000wn-Ot for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:34:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglKw-000YCn-5X for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:34:22 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bcafc-5cb7-0a2a0a5109dd-0a2a4507a422-6 for ; Mon, 06 Jul 2026 17:34:22 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bcafd-9c8e-0a2a45070019-d1558030ec53-3 for ; Mon, 06 Jul 2026 17:34:22 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-493d28b1930so24172985e9.0 for ; Mon, 06 Jul 2026 08:34:22 -0700 (PDT) Received: from localhost.localdomain (host-78-146-248-75.as13285.net. [78.146.248.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493c63bfba1sm433726505e9.15.2026.07.06.08.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:34:20 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1783352061; x=1783956861; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=US++6oXh7QmRtGgM9Ky45/VXvpj8kcMFRZ59/2f4CgI=; b=jJ9zhtcJ/q7XROAGTiLGjebJtD2vWUz1jWLHxyUwxk5VFkWZtLMRTMl4khCx47Au8W 9Awf822YbVLks7VOenwhwPnzC8zhA9WlCFoCx5fWGlckq2kJvkcVrzwBc0xdGFDQbt8S 57xdnj7ty29f4OZVf/VPC5uBRmrKVAuRAPmj0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783352061; x=1783956861; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=US++6oXh7QmRtGgM9Ky45/VXvpj8kcMFRZ59/2f4CgI=; b=aAtB1ALyYUfcu5Yf65PzHKPrVO7xmGj5ZxUNWsmhVYGSp5QZmpzgK+RICKwoM26qQI 0xpR4qyHnEuq6O2J4NRBkiCanefnY+15ruQLsgLYgADz5E5aWESrjQszCErkeb168/Pv nyY9aknmBifF3DbhUDomna0FCn18yDi3LcINUl5V44gjCUeS3IULaxskG8wORhY5DrwK eHI5mU3Ts9CApnFNkQIOVIL48WFZjDXT9rhFR0vP2uaPcIB83qHi6rIOLBBi2pbUX1Uj r35JxpxHgbEKVvrxJiFvy/OhY3+UFNlD1cdSiyGzGyb7Sc0g6UNTtQKnFwa19oVQ1y/I YyYw== X-Gm-Message-State: AOJu0Ywq77zyn0bq5NDYCwQUhoDmkBRAYyQ/1VDDQkOYOsR2d+pYNGUz yBOJ7ZiQvhyRT7/g0hp6Lj3yGJnTRXCb8UiXg8eD/NHpipaSGTsU0UBbx1qpXj56rrLAe2zS0za IWdNpR8U= X-Gm-Gg: AfdE7ck4hT8XG1Rljukg4SVdScDODlMrlQEoplBw5V2z3ZkqBSM5VThRhPWsd65yr6F QF53pImdJp2dlfbrCJAosQtJ8Pd6/Gg1zJL/6m6oAkproeiIHm3Pge8KQs8DbdEWE9hE5/WR/7M rZ6UZsLNatkKskHNJbLqz0aKcesIwvbnmbFsHnfwT4ly1OKaR68OpjJ8xQCrz3UY4Tt78JIyWrA 3yQq4yMBBu+ygkzuUsRey7XhItSdtolYPDQ3CxJE/iRBjS12RPiR4e3n7AsCRMJ1j7q7uki3yBX kymtdaDDfCnNwVP8JbKGnZ/JTjW2FyV5285HIcnGytxG4FRHki3cK7CSCQc6ulatuURIJ3nbI7s 6mfWCS+PPCeqIXH94WqdQSn7yySwr8P3iW2Yd9t29eAX34bds15j25T0l+i13LevsZN3sGmgMb3 v74pldzimmB7/HL4eo/fS1W1e8gU1/kIoFxs7z52HcQx2KPOxscXq808RsQFY4A78= X-Received: by 2002:a05:600c:154e:b0:493:d216:ed96 with SMTP id 5b1f17b1804b1-493df0b6a8emr11671105e9.9.1783352061219; Mon, 06 Jul 2026 08:34:21 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH 2/3] x86/entry: Use POP_GPRS and remove RESTORE_ALL Date: Mon, 6 Jul 2026 16:34:14 +0100 Message-Id: <20260706153415.1264750-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260706153415.1264750-1-andrew.cooper3@citrix.com> References: <20260706153415.1264750-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1783352062-7D72125E-81E483E4/0/0 X-purgate-type: clean X-purgate-size: 5688 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1783352106247158500 POP_GPRS is shorter than RESTORE_ALL in terms of emitted code. By separating the popping of entry_vector/error_code off the stack, SPEC_CTRL_COND_VERW doesn't need custom displacements. Get rid of the compat=3D1 special case for PV32. It's not obviously a win,= and PV32 is getting increasingly rare these days. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Teddy Astie Bloat-o-meter reports: add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-128 (-128) Function old new delta compat_restore_all_guest 187 158 -29 restore_all_guest 372 324 -48 restore_all_xen 165 114 -51 --- xen/arch/x86/include/asm/asm_defns.h | 50 +--------------------------- xen/arch/x86/x86_64/compat/entry.S | 9 +++-- xen/arch/x86/x86_64/entry.S | 12 +++---- 3 files changed, 10 insertions(+), 61 deletions(-) diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/as= m/asm_defns.h index 87bd6b1193e7..d1b80186c14c 100644 --- a/xen/arch/x86/include/asm/asm_defns.h +++ b/xen/arch/x86/include/asm/asm_defns.h @@ -264,54 +264,6 @@ static always_inline void stac(void) xor %r15d, %r15d .endm =20 -#define LOAD_ONE_REG(reg, compat) \ -.if !(compat); \ - movq UREGS_r##reg(%rsp),%r##reg; \ -.else; \ - movl UREGS_r##reg(%rsp),%e##reg; \ -.endif - -/* - * Restore all previously saved registers. - * - * @adj: extra stack pointer adjustment to be folded into the adjustment d= one - * anyway at the end of the macro - * @compat: R8-R15 don't need reloading, but they are clobbered for added - * safety against information leaks. - */ -.macro RESTORE_ALL adj=3D0, compat=3D0 -.if !\compat - movq UREGS_r15(%rsp), %r15 - movq UREGS_r14(%rsp), %r14 - movq UREGS_r13(%rsp), %r13 - movq UREGS_r12(%rsp), %r12 -.else - xor %r15d, %r15d - xor %r14d, %r14d - xor %r13d, %r13d - xor %r12d, %r12d -.endif - LOAD_ONE_REG(bp, \compat) - LOAD_ONE_REG(bx, \compat) -.if !\compat - movq UREGS_r11(%rsp),%r11 - movq UREGS_r10(%rsp),%r10 - movq UREGS_r9(%rsp),%r9 - movq UREGS_r8(%rsp),%r8 -.else - xor %r11d, %r11d - xor %r10d, %r10d - xor %r9d, %r9d - xor %r8d, %r8d -.endif - LOAD_ONE_REG(ax, \compat) - LOAD_ONE_REG(cx, \compat) - LOAD_ONE_REG(dx, \compat) - LOAD_ONE_REG(si, \compat) - LOAD_ONE_REG(di, \compat) - subq $-(UREGS_error_code-UREGS_r15+\adj), %rsp -.endm - /* * Push and clear GPRs */ @@ -369,7 +321,7 @@ static always_inline void stac(void) pop %r9 pop %r8 .if \skip_rax - pop %rcx + pop %rcx /* Any register yet to restore. */ .else pop %rax .endif diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compa= t/entry.S index 39925d80a677..4bf4ee7c944c 100644 --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -160,12 +160,11 @@ FUNC(compat_restore_all_guest) /* WARNING! `ret`, `call *`, `jmp *` not safe beyond this point. */ SPEC_CTRL_EXIT_TO_PV /* Req: a=3Dspec_ctrl %rsp=3Dregs/cpuinfo,= Clob: cd */ =20 - RESTORE_ALL adj=3D8, compat=3D1 + POP_GPRS =20 - /* Account for ev/ec having already been popped off the stack. */ - SPEC_CTRL_COND_VERW \ - scf=3DSTK_REL(CPUINFO_scf, CPUINFO_rip), \ - sel=3DSTK_REL(CPUINFO_verw_sel, CPUINFO_rip) + SPEC_CTRL_COND_VERW /* Req: %rsp=3Deframe C= lob: efl */ + + add $8, %rsp /* Pop ev/ec off the stack */ =20 jmp iret_to_guest END(compat_restore_all_guest) diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index de5d854f5533..cd3532d7d174 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -226,7 +226,8 @@ FUNC_LOCAL(restore_all_guest) /* WARNING! `ret`, `call *`, `jmp *` not safe beyond this point. */ SPEC_CTRL_EXIT_TO_PV /* Req: a=3Dspec_ctrl %rsp=3Dregs/cpuinfo,= Clob: cd */ =20 - RESTORE_ALL + POP_GPRS + BUILD_BUG_ON(TRAP_syscall & 0xff) testb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp) jz iret_exit_to_guest @@ -753,20 +754,17 @@ UNLIKELY_END(exit_cr3) /* WARNING! `ret`, `call *`, `jmp *` not safe beyond this point. */ SPEC_CTRL_EXIT_TO_XEN /* Req: %r12=3Dist_exit %r14=3Dend %rsp=3Dre= gs, Clob: abcd */ =20 - RESTORE_ALL adj=3D8 + POP_GPRS =20 /* * When the CPU pushed this exception frame, it zero-extended efla= gs. * For an IST exit, SPEC_CTRL_EXIT_TO_XEN stashed shadow copies of * scf and ver_sel above eflags, as we can't use any GPRs, * and we're at a random place on the stack, not in a CPUFINFO blo= ck. - * - * Account for ev/ec having already been popped off the stack. */ - SPEC_CTRL_COND_VERW \ - scf=3DSTK_REL(EFRAME_shadow_scf, EFRAME_rip), \ - sel=3DSTK_REL(EFRAME_shadow_sel, EFRAME_rip) + SPEC_CTRL_COND_VERW /* Req: %rsp=3Deframe C= lob: efl */ =20 + add $8, %rsp /* Pop ev/ec off the stack */ iretq END(restore_all_xen) =20 --=20 2.39.5 From nobody Thu Jul 23 21:53:42 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=1783352099; cv=none; d=zohomail.com; s=zohoarc; b=jl7U1n/fsZhLdgDakcUaWOCBZqKI/eKGO0iu73D0QsVKZGSpi7UEJ3gSassA6goV8xa0mWA4BdTFLklau03zfr36hxBXfaOo7s6TLtMp8eBsHLKmKpsX7wmQMpRJop9IUUs6CUIXspKc+2AYq5cQW+TIeS9pIHifRfkR1BZYfCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783352099; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tGuAPt56hrdactPgDfC0/MnL6+HEGuvGVBAIpjdl8Bg=; b=bzNh9HQStQu0bVACszmvp0hdUnbt78mbizwuyFmc5lWaGemqhx5dEN9sLsdVPMzaqMl6zr/hIONFZ49pR0JLxcos6O7pRLnV8VWmt+bn/ur4/gaupKp3tWt3vrrvisbyyB7zk6MJ/uHzwIw6PtDvqSV/uNztUas1X5bwU1w2Dvw= 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 1783352099042333.8251047306196; Mon, 6 Jul 2026 08:34:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355441.1610235 (Exim 4.92) (envelope-from ) id 1wglKz-0001Zy-OX; Mon, 06 Jul 2026 15:34:25 +0000 Received: by outflank-mailman (output) from mailman id 1355441.1610235; Mon, 06 Jul 2026 15:34:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKz-0001Zp-LJ; Mon, 06 Jul 2026 15:34:25 +0000 Received: by outflank-mailman (input) for mailman id 1355441; Mon, 06 Jul 2026 15:34:24 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglKy-0001H7-0t for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:34:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglKx-000YCn-Ds for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:34:23 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bcafc-5cb7-0a2a0a5109dd-0a2a4507a422-10 for ; Mon, 06 Jul 2026 17:34:23 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bcaff-9c8e-0a2a45070019-d155802cac51-3 for ; Mon, 06 Jul 2026 17:34:23 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493b6f1b14bso12808335e9.0 for ; Mon, 06 Jul 2026 08:34:23 -0700 (PDT) Received: from localhost.localdomain (host-78-146-248-75.as13285.net. [78.146.248.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493c63bfba1sm433726505e9.15.2026.07.06.08.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:34:21 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1783352063; x=1783956863; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tGuAPt56hrdactPgDfC0/MnL6+HEGuvGVBAIpjdl8Bg=; b=C+kXMHjBzNqWr5Di+/OAr7z7Yx2gFIGYbnUUxXk75/bLXNMZjlsUczRAtL2EzTfMT1 DHcpmoJkMdQ/NafDLRwgi9ZIRZRx25x6kQbo7TQR7bKuw1gdEaUV1yvQFDGUkGUv3CrI fBs9aRAjGj8WwIeVsEF+5jNzqztcT2sYDg9lk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783352063; x=1783956863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tGuAPt56hrdactPgDfC0/MnL6+HEGuvGVBAIpjdl8Bg=; b=Cf1lEPxWq0+aYP09H1GVa97l8I8OhhQQE0N1zY+gWG3JHNgdAMOrnrQMn19hk0xe7I DsSaglQG5w9015qzgXZ5gr3V5s9QjVKwR1R4ELJlC0brMEYmGGzECW/+cf41ibDZ6DmO u2xQYcEmDzntHSCK8IhaiYdxO5rsEHeTtk+pu30yfhKzWDvsqUYBC5t5aEXUfy011t4q CxtT7i4XC6MSuhWaWtVt/X5glJ+SbP3UlLA1Ph63jhlY+JIkTuHb3Efd8bMGaf6qVq/H fYxbMYfW+b1t5+ii0XpqCnDv7bA4SBs1EOTAv+YzWR3O1FVLnh19GrCGr2ja1V6/FsmK t+hg== X-Gm-Message-State: AOJu0YwYWEtxeRkLyl5Fbi9KbrMLlVvvSKVYvlpD1UYZVj7moFASnVs2 ng4uppaPhF98Xkn6nINFurvVAb6Mp4RRZaVSvraZvTQZVwjUFNcunBMV/lS2Uy5yfWoxYpX7EAF h3c/k X-Gm-Gg: AfdE7clR7rjEkECHTx4Kab+oZwDvYki10UzOKI+nRSdIyJMOC+Tq57VLatwk+KFX8m4 GaY8c6vIfKOYcEpd/ho4yR8/rvobAKmDqr4HwyQiZrNCcj4glZOVoz7SCeZK0YellLTHrPUlh9/ 9x0FnkXLzP41BpL5ktT5ugj2GNPBkLV+jqe2piKXVBdFR04zJezJnGYFPHryxz9aB9r/ZxFodil HupLLAu+sVr4+dhPddeaWuqQoaDVr8mFKJCARVXv9OBxdln3xay1SXyzq78TTG5tD8IBYL6nSYl D7iFaFYBQYMFe4oXafAa1Ewm7MmLIB+DtYbibQrppTLoOjACP2zJedjGKTuU6pVCM639jhyYEv4 5WV//9YdWPZIv/xReLuxcvTrBrmGZlO0nmN/baggfN5kOKdrjcLR/vJQmpinHp+jtSsK6OoJ4/l c9arqMsf3jjvp178gPfEgiwO2/kNZpAUXryHcJoE+KQcaKX5gkRFFfaC9QyzUhNio= X-Received: by 2002:a05:600c:6c07:b0:493:bc4a:9547 with SMTP id 5b1f17b1804b1-493df0a08dcmr8960075e9.39.1783352062251; Mon, 06 Jul 2026 08:34:22 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH 3/3] x86/entry: Use PUSH_AND_CLEAR_GPRS and drop SAVE_ALL Date: Mon, 6 Jul 2026 16:34:15 +0100 Message-Id: <20260706153415.1264750-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260706153415.1264750-1-andrew.cooper3@citrix.com> References: <20260706153415.1264750-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1783352063-FCF2D25E-888F2648/0/0 X-purgate-type: clean X-purgate-size: 6974 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1783352100285158500 PUSH_AND_CLEAR_GPRS is shorter than SAVE_ALL in terms of emitted code. lstar_enter() and cstar_enter() do not need CLD. The SYSCALL instruction sanitises flags based on MSR_SYSCALL_MASK. For all other cases, place the = CLD instruction next to STAC/CLAC so the flag handling is together. Get rid of the compat=3D1 special case for PV32. It's not obviously a win,= and PV32 is getting increasingly rare these days. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Teddy Astie Bloat-o-meter reports: add/remove: 0/0 grow/shrink: 0/12 up/down: 0/-518 (-518) Function old new delta symbols_names 135277 135276 -1 symbols_offsets 53664 53660 -4 entry_int82 229 213 -16 sysenter_entry 383 328 -55 handle_ist_exception 450 395 -55 handle_exception 683 628 -55 entry_int80 432 377 -55 entry_DF 294 239 -55 early_page_fault 139 84 -55 common_interrupt 327 272 -55 lstar_enter 322 266 -56 cstar_enter 323 267 -56 --- xen/arch/x86/include/asm/asm_defns.h | 45 ---------------------------- xen/arch/x86/x86_64/compat/entry.S | 3 +- xen/arch/x86/x86_64/entry.S | 25 ++++++++++------ 3 files changed, 18 insertions(+), 55 deletions(-) diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/as= m/asm_defns.h index d1b80186c14c..6c65acd08366 100644 --- a/xen/arch/x86/include/asm/asm_defns.h +++ b/xen/arch/x86/include/asm/asm_defns.h @@ -219,51 +219,6 @@ static always_inline void stac(void) #endif =20 #ifdef __ASSEMBLER__ -.macro SAVE_ALL compat=3D0 - addq $-(UREGS_error_code-UREGS_r15), %rsp - cld - movq %rdi,UREGS_rdi(%rsp) - xor %edi, %edi - movq %rsi,UREGS_rsi(%rsp) - xor %esi, %esi - movq %rdx,UREGS_rdx(%rsp) - xor %edx, %edx - movq %rcx,UREGS_rcx(%rsp) - xor %ecx, %ecx - movq %rax,UREGS_rax(%rsp) - xor %eax, %eax -.if !\compat - movq %r8,UREGS_r8(%rsp) - movq %r9,UREGS_r9(%rsp) - movq %r10,UREGS_r10(%rsp) - movq %r11,UREGS_r11(%rsp) -.endif - xor %r8d, %r8d - xor %r9d, %r9d - xor %r10d, %r10d - xor %r11d, %r11d - movq %rbx,UREGS_rbx(%rsp) - xor %ebx, %ebx - movq %rbp,UREGS_rbp(%rsp) -#ifdef CONFIG_FRAME_POINTER -/* Indicate special exception stack frame by inverting the frame pointer. = */ - leaq UREGS_rbp(%rsp), %rbp - notq %rbp -#else - xor %ebp, %ebp -#endif -.if !\compat - movq %r12,UREGS_r12(%rsp) - movq %r13,UREGS_r13(%rsp) - movq %r14,UREGS_r14(%rsp) - movq %r15,UREGS_r15(%rsp) -.endif - xor %r12d, %r12d - xor %r13d, %r13d - xor %r14d, %r14d - xor %r15d, %r15d -.endm - /* * Push and clear GPRs */ diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compa= t/entry.S index 4bf4ee7c944c..2503a973ffc2 100644 --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -13,10 +13,11 @@ =20 FUNC(entry_int82) ENDBR64 + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP pushq $0 movb $HYPERCALL_VECTOR, EFRAME_entry_vector(%rsp) - SAVE_ALL compat=3D1 /* DPL1 gate, restricted to 32bit PV guests on= ly. */ + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index cd3532d7d174..22729b1f43b8 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -305,7 +305,7 @@ FUNC(lstar_enter) pushq $0 BUILD_BUG_ON(TRAP_syscall & 0xff) movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp) - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -345,7 +345,7 @@ FUNC(cstar_enter) pushq $0 BUILD_BUG_ON(TRAP_syscall & 0xff) movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp) - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -383,13 +383,14 @@ FUNC(sysenter_entry) pushq $0 pushfq LABEL(sysenter_eflags_saved, 0) + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP pushq $3 /* ring 3 null cs */ pushq $0 /* null rip */ pushq $0 BUILD_BUG_ON(TRAP_syscall & 0xff) movb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp) - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -442,10 +443,11 @@ END(sysenter_entry) =20 FUNC(entry_int80) ENDBR64 + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP pushq $0 movb $0x80, EFRAME_entry_vector(%rsp) - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -722,8 +724,9 @@ END(ret_from_intr) .section .init.text, "ax", @progbits FUNC(early_page_fault) ENDBR64 + cld movb $X86_EXC_PF, EFRAME_entry_vector(%rsp) - SAVE_ALL + PUSH_AND_CLEAR_GPRS movq %rsp, %rdi call do_early_page_fault jmp restore_all_xen @@ -769,8 +772,9 @@ UNLIKELY_END(exit_cr3) END(restore_all_xen) =20 FUNC(common_interrupt) + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -805,8 +809,9 @@ FUNC(entry_PF) END(entry_PF) /* No special register assumptions. */ FUNC(handle_exception, 0) + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -1103,9 +1108,10 @@ END(entry_CP) FUNC(entry_DF) ENDBR64 movb $X86_EXC_DF, EFRAME_entry_vector(%rsp) + cld /* Set AC to reduce chance of further SMAP faults */ ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 @@ -1132,8 +1138,9 @@ FUNC(entry_NMI) END(entry_NMI) =20 FUNC(handle_ist_exception) + cld ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP - SAVE_ALL + PUSH_AND_CLEAR_GPRS =20 GET_STACK_END(14) =20 --=20 2.39.5