From nobody Mon Feb 9 14:34:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1565009077; cv=none; d=zoho.com; s=zohoarc; b=b8S00Dzrg0bNOGTRcsjusIV0FSzBD91wty3xYctJQ7mMBQTgG4vf+17PoxtP79Q4B8hC/rDb7HJSjYVn9Hep6PMPWwYih30DMy8PQirf47O5MwfL1dBPDFjAB5XuIaSa/9pJbk3SAriazndt3yOp018nbvPKX3TSVxElE6eV2YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565009077; 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:ARC-Authentication-Results; bh=fsGyilYpKGIRK8wMwydi/LFpbcnoxvzqbhES47FO+4U=; b=GQqhnkf2x0SuMPYBOb2oDpXqV0EEsB2L6G63Dy94Imu+gTktVncs8BatbNErrc40Dr9pjHrsXxicE8OYIk3bteNGbXbiB8wGTw9WBIXDXABLL+pWyvQMfDUPh3vPQNFmdahBdBXYYAXsoQxe77REwR9QX9XCp9tUqVgJpVopRrw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1565009077061758.3264272030376; Mon, 5 Aug 2019 05:44:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hucKX-0000c9-K8; Mon, 05 Aug 2019 12:43:13 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hucKW-0000bs-Ir for xen-devel@lists.xenproject.org; Mon, 05 Aug 2019 12:43:12 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 95bc5cbc-b77e-11e9-a59d-033b08eeb3fc; Mon, 05 Aug 2019 12:43:11 +0000 (UTC) X-Inumbo-ID: 95bc5cbc-b77e-11e9-a59d-033b08eeb3fc Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: SPjANT231gLeC0zLsrMZINjukTPdia3+ffk1aqdFLwe8lhgB3ZMtq4RkWs0OdIuFCjpSebFfnN jmuxqD3k4KvbLWQxuKGJvBx/EXwWvxqXF3ITHCshnLTiQahSt6SrJ2EWYH0AYf2Dky8YcPB5jf bwRqTatJNNuJN5AuwtG3A+dcTTtnK9w6MQMH09N8FgukaJok0zEmLVn0efhJg/bfACNPxwCNmH AWsBl3mScLdPKGuISngKMBjxSw3geRnc3vwL12qL9ZYAhn9p8Q6T466PNR1KTTeduWMCTd+Wb3 XNg= X-SBRS: 2.7 X-MesageID: 3859933 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,349,1559534400"; d="scan'208";a="3859933" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Aug 2019 13:42:59 +0100 Message-ID: <20190805124301.12887-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190805124301.12887-1-andrew.cooper3@citrix.com> References: <20190805124301.12887-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] x86/boot: Minor improvements to efi_arch_post_exit_boot() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Split up the long asm block by commenting the logical subsections. The movabs for obtaining __start_xen can be a rip-relative lea instead. Th= is has the added advantage that objdump can now cross reference it during disassembly. The stack handing is confusing to follow. %rsp is set up by reading stack_start which is a pointer to cpu0_stack, then constructing an lret fra= me under %rsp (to avoid clobbering whatever is adjacent to cpu0_stack), and us= es the Pascal form of lret to move %rsp to the base of cpu0_stack. Remove stack_start from the mix and use a single lea to load cpu0_stack base directly, and use the more common push/push/lretq sequence for reloading %c= s. Use unreachable() rather than an infinite for loop, which lets the compiler discard all the epilogue code that it inserted previously. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 Overall, the asm block is 10 bytes shorter, not that this was the point of = the change. In principle, the constraints for [cs] and [ds] could be relaxed to include "m", but Clang decided to insert 5 rip-relative memory operands for the segment loads, which isn't a clever optimisation to make. --- xen/arch/x86/efi/efi-boot.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 7a13a30bc0..2f59d8bdbd 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -249,17 +249,20 @@ static void __init noreturn efi_arch_post_exit_boot(v= oid) "or $"__stringify(X86_CR4_PGE)", %[cr4]\n\t" "mov %[cr4], %%cr4\n\t" #endif - "movabs $__start_xen, %[rip]\n\t" + /* Load data segments. */ "lgdt gdt_descr(%%rip)\n\t" - "mov stack_start(%%rip), %%rsp\n\t" "mov %[ds], %%ss\n\t" "mov %[ds], %%ds\n\t" "mov %[ds], %%es\n\t" "mov %[ds], %%fs\n\t" "mov %[ds], %%gs\n\t" - "movl %[cs], 8(%%rsp)\n\t" - "mov %[rip], (%%rsp)\n\t" - "lretq %[stkoff]-16" + + /* Switch stack, reload %cs and jump. */ + "lea %c[stkoff] + cpu0_stack(%%rip), %%rsp\n\t" + "lea __start_xen(%%rip), %[rip]\n\t" + "push %[cs]\n\t" + "push %[rip]\n\t" + "lretq" : [rip] "=3D&r" (efer/* any dead 64-bit variable */), [cr4] "+&r" (cr4) : [cr3] "r" (idle_pg_table), @@ -268,7 +271,7 @@ static void __init noreturn efi_arch_post_exit_boot(voi= d) [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)), "D" (&mbi) : "memory" ); - for( ; ; ); /* not reached */ + unreachable(); } =20 static void __init efi_arch_cfg_file_early(EFI_FILE_HANDLE dir_handle, cha= r *section) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel