From nobody Tue Aug 25 13:45:51 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