From nobody Sat May 4 10:18:57 2024 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=1565009080; cv=none; d=zoho.com; s=zohoarc; b=CRbylwMqzj5wXx3aXwqmkE0ehtE2R2SU0y43PN1ob4neXPq6Ewk/0qhUVdV3NqJKMxTz1NfqFaSDzI5Kpj6xQzwtC6I7TfDY14LvVb9cby2ETCXA/TNc+ZInzuGq7I8jWwaMSMWyCR9AK94agZyN1ysarpgn/TBnP06rqx9jXd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565009080; 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=F1rP75et7ivelHofWkNBgQitzZBUFlafoyzW6y84MwM=; b=Vj+rBfKAoxwL24nfnRGhCJGMMn/TvsL5HQahLB8ukNe/1sPXkcxEqFwYsGCxDWZXJaxY7bla72trkPQLWE/X+tEDNnoCaIQrUtCsEKRXkiVBZyZCyuzrFN3Stx+RC6QijsNTq0wMD7mXjcXYkKNnbC0ej5i7HJpcyLvnFL9MCpw= 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 1565009080145674.4343581102349; Mon, 5 Aug 2019 05:44:40 -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-0000bx-24; 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-0000bf-56 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 92c76bfa-b77e-11e9-b10e-ebcefecdaf85; Mon, 05 Aug 2019 12:43:07 +0000 (UTC) X-Inumbo-ID: 92c76bfa-b77e-11e9-b10e-ebcefecdaf85 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: thI0nk3aE+pepOXHNB3/TTVCXu2WO1oR8LtCldt4N+pULzhd+Adqk4MncBMf6RC/uMrW0qSXSZ hHz4V0tbbi70OtnH5Z3JHJqwf6G1ehvkQUpKuf/2FF+l3nBGwQbBC9n/b2OrYQT4DvTmfDSpiT 4XK5JcYr7dX4XLLGmwY7I7gSPfx4glZTLq9vocywAq3C6TYUpXpEp0S+XugS0SxnVMM/VajI+Z nU5JwIGB6Sg3pbZ2ENMatrcr8agPShdsL4ATz4RavWACgi6BEgeGknC2GPeASswMCNJk7p2c0g mOM= X-SBRS: 2.7 X-MesageID: 3859932 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="3859932" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Aug 2019 13:42:58 +0100 Message-ID: <20190805124301.12887-2-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 1/4] x86/asm: Include msr-index.h rather than msr.h 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" There is nothing interesting for assembly code in msr.h Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/boot/head.S | 2 +- xen/arch/x86/x86_64/kexec_reloc.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index d78bed394a..ab2d52a79d 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include =20 diff --git a/xen/arch/x86/x86_64/kexec_reloc.S b/xen/arch/x86/x86_64/kexec_= reloc.S index 4d527dbfce..5bf61d5c2d 100644 --- a/xen/arch/x86/x86_64/kexec_reloc.S +++ b/xen/arch/x86/x86_64/kexec_reloc.S @@ -16,7 +16,7 @@ #include =20 #include -#include +#include #include #include =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 10:18:57 2024 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 From nobody Sat May 4 10:18:57 2024 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=1565009079; cv=none; d=zoho.com; s=zohoarc; b=P2Mse9hAzQTweiDb2a0UzhehCrBCp1MgPpzsU1uz6rvfEJ3xdCNgjlHpKfBvTVJ/R9+BqipVgnOcYgt77yQHQ27v402GDfl+UA4PZo8BAL5oXaKaO8J2JysTpeX9Rj+AJpmKDBNj+sTq2FJXelZV1lKTCcpSY4LpeL6I5YsKnck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565009079; 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=1oZFX453EbQMLloeo7NTuSPniM65Ern6g1rcVb8R25k=; b=bDKTFeQAvsACX35vKMkAUw7YSOxuL5T22cszcMYXZ+6H923YKR7CLJSjUzj02ZR5CjOveBJorL7gx5evlMdquILGRNA9Cf2QfNmyRiGxa/Cl5nKZYJzi2G5Hk7h1zM4wzTQH4q5jAkV7QNIg3RiMuCA57EpCA6YSENFqYvFX5ws= 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 1565009079622981.4530857120542; Mon, 5 Aug 2019 05:44:39 -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 1hucKb-0000cv-Co; Mon, 05 Aug 2019 12:43:17 +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 1hucKa-0000cX-Cc for xen-devel@lists.xenproject.org; Mon, 05 Aug 2019 12:43:16 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 95f9c430-b77e-11e9-98fa-fb38854f42ba; Mon, 05 Aug 2019 12:43:12 +0000 (UTC) X-Inumbo-ID: 95f9c430-b77e-11e9-98fa-fb38854f42ba 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: sMscg5SJLSEIy+f8nnxntp1V4z/XA/yImLrvMo+KGxBfxqHsf7ZArVFCfpwzajAnFDlL1dQNeR 9uF67LP8TUTY+JvL71R/tKPkYD2/wtOXXdxuvSjnPnr/nBCYsX3kG10EoT/4M5uoK0Norlb/c6 D8UxW0e8LZHgNdlvPQaGsB+pjPzOAJuO1M2UoImU7Jnx5wHAjJSgfYboiJPJE1AvWTqGoK/lZ6 qTKGmYkZyPd/DRzgROeYEmDmYc3Hzu7EL3fMLeZx+yxLGE54xS7lGHTVu2DkWg2/qivjfEcKg2 Nuo= X-SBRS: 2.7 X-MesageID: 3859934 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="3859934" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Aug 2019 13:43:00 +0100 Message-ID: <20190805124301.12887-4-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 3/4] x86/desc: Shorten boot_{, comat_}gdt[] variable names 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" The current names, boot_cpu_{,compat_}gdt_table, have a table suffix which = is redundant with the T of GDT, and the cpu infix doesn't provide any meaningf= ul context. Drop them both. Likewise, shorten the {,compat_}gdt{,_l1e} variables. Finally, rename gdt_descr to boot_gdtr to more clearly identify its purpose. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/boot/x86_64.S | 10 +++++----- xen/arch/x86/cpu/common.c | 4 ++-- xen/arch/x86/domain.c | 7 +++---- xen/arch/x86/efi/efi-boot.h | 2 +- xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/smpboot.c | 18 +++++++++--------- xen/arch/x86/traps.c | 30 ++++++++++++++---------------- xen/common/efi/runtime.c | 2 +- xen/include/asm-x86/desc.h | 12 ++++++------ xen/include/asm-x86/ldt.h | 3 +-- 11 files changed, 44 insertions(+), 48 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index cf47e019f5..3909363ca3 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -3,7 +3,7 @@ =20 ENTRY(__high_start) /* Install relocated data selectors. */ - lgdt gdt_descr(%rip) + lgdt boot_gdtr(%rip) mov $(__HYPERVISOR_DS64),%ecx mov %ecx,%ds mov %ecx,%es @@ -44,16 +44,16 @@ multiboot_ptr: .long 0 =20 .word 0 -GLOBAL(gdt_descr) +GLOBAL(boot_gdtr) .word LAST_RESERVED_GDT_BYTE - .quad boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE + .quad boot_gdt - FIRST_RESERVED_GDT_BYTE =20 GLOBAL(stack_start) .quad cpu0_stack =20 .section .data.page_aligned, "aw", @progbits .align PAGE_SIZE, 0 -GLOBAL(boot_cpu_gdt_table) +GLOBAL(boot_gdt) .quad 0x0000000000000000 /* unused */ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode = */ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data = */ @@ -68,7 +68,7 @@ GLOBAL(boot_cpu_gdt_table) .align PAGE_SIZE, 0 /* NB. Even rings !=3D 0 get access to the full 4Gb, as only the = */ /* (compatibility) machine->physical mapping table lives there. = */ -GLOBAL(boot_cpu_compat_gdt_table) +GLOBAL(boot_compat_gdt) .quad 0x0000000000000000 /* unused */ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode = */ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data = */ diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 7478e21177..dc2dea4d6d 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -709,9 +709,9 @@ void load_system_tables(void) =20 struct tss_struct *tss =3D &this_cpu(init_tss); seg_desc_t *gdt =3D - this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY; + this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY; seg_desc_t *compat_gdt =3D - this_cpu(compat_gdt_table) - FIRST_RESERVED_GDT_ENTRY; + this_cpu(compat_gdt) - FIRST_RESERVED_GDT_ENTRY; =20 const struct desc_ptr gdtr =3D { .base =3D (unsigned long)gdt, diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5933b3f51b..612afb683f 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1666,8 +1666,8 @@ static inline bool need_full_gdt(const struct domain = *d) static void update_xen_slot_in_full_gdt(const struct vcpu *v, unsigned int= cpu) { l1e_write(pv_gdt_ptes(v) + FIRST_RESERVED_GDT_PAGE, - !is_pv_32bit_vcpu(v) ? per_cpu(gdt_table_l1e, cpu) - : per_cpu(compat_gdt_table_l1e, cpu)); + !is_pv_32bit_vcpu(v) ? per_cpu(gdt_l1e, cpu) + : per_cpu(compat_gdt_l1e, cpu)); } =20 static void load_full_gdt(const struct vcpu *v, unsigned int cpu) @@ -1686,8 +1686,7 @@ static void load_default_gdt(unsigned int cpu) { struct desc_ptr gdt_desc =3D { .limit =3D LAST_RESERVED_GDT_BYTE, - .base =3D (unsigned long)(per_cpu(gdt_table, cpu) - - FIRST_RESERVED_GDT_ENTRY), + .base =3D (unsigned long)(per_cpu(gdt, cpu) - FIRST_RESERVED_GDT_= ENTRY), }; =20 lgdt(&gdt_desc); diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 2f59d8bdbd..5324149f93 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -250,7 +250,7 @@ static void __init noreturn efi_arch_post_exit_boot(voi= d) "mov %[cr4], %%cr4\n\t" #endif /* Load data segments. */ - "lgdt gdt_descr(%%rip)\n\t" + "lgdt boot_gdtr(%%rip)\n\t" "mov %[ds], %%ss\n\t" "mov %[ds], %%ds\n\t" "mov %[ds], %%es\n\t" diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index d81401dbc0..deafa3864e 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1568,7 +1568,7 @@ bool svm_load_segs(unsigned int ldt_ents, unsigned lo= ng ldt_base, { /* Keep GDT in sync. */ seg_desc_t *desc =3D - this_cpu(gdt_table) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; + this_cpu(gdt) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; =20 _set_tssldt_desc(desc, ldt_base, ldt_ents * 8 - 1, SYS_DESC_ldt); =20 diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 45d18493df..098613822a 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -793,7 +793,7 @@ static void vmx_set_host_env(struct vcpu *v) unsigned int cpu =3D smp_processor_id(); =20 __vmwrite(HOST_GDTR_BASE, - (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENT= RY)); + (unsigned long)(this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY)); __vmwrite(HOST_IDTR_BASE, (unsigned long)idt_tables[cpu]); =20 __vmwrite(HOST_TR_BASE, (unsigned long)&per_cpu(init_tss, cpu)); diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 65e9ceeece..8d5fef0012 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -944,11 +944,11 @@ static void cpu_smpboot_free(unsigned int cpu, bool r= emove) free_domheap_page(mfn_to_page(mfn)); } =20 - FREE_XENHEAP_PAGE(per_cpu(compat_gdt_table, cpu)); + FREE_XENHEAP_PAGE(per_cpu(compat_gdt, cpu)); =20 if ( remove ) { - FREE_XENHEAP_PAGE(per_cpu(gdt_table, cpu)); + FREE_XENHEAP_PAGE(per_cpu(gdt, cpu)); FREE_XENHEAP_PAGE(idt_tables[cpu]); =20 if ( stack_base[cpu] ) @@ -976,22 +976,22 @@ static int cpu_smpboot_alloc(unsigned int cpu) goto out; memguard_guard_stack(stack_base[cpu]); =20 - gdt =3D per_cpu(gdt_table, cpu) ?: alloc_xenheap_pages(0, memflags); + gdt =3D per_cpu(gdt, cpu) ?: alloc_xenheap_pages(0, memflags); if ( gdt =3D=3D NULL ) goto out; - per_cpu(gdt_table, cpu) =3D gdt; - per_cpu(gdt_table_l1e, cpu) =3D + per_cpu(gdt, cpu) =3D gdt; + per_cpu(gdt_l1e, cpu) =3D l1e_from_pfn(virt_to_mfn(gdt), __PAGE_HYPERVISOR_RW); - memcpy(gdt, boot_cpu_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE); + memcpy(gdt, boot_gdt, NR_RESERVED_GDT_PAGES * PAGE_SIZE); BUILD_BUG_ON(NR_CPUS > 0x10000); gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a =3D cpu; =20 - per_cpu(compat_gdt_table, cpu) =3D gdt =3D alloc_xenheap_pages(0, memf= lags); + per_cpu(compat_gdt, cpu) =3D gdt =3D alloc_xenheap_pages(0, memflags); if ( gdt =3D=3D NULL ) goto out; - per_cpu(compat_gdt_table_l1e, cpu) =3D + per_cpu(compat_gdt_l1e, cpu) =3D l1e_from_pfn(virt_to_mfn(gdt), __PAGE_HYPERVISOR_RW); - memcpy(gdt, boot_cpu_compat_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SI= ZE); + memcpy(gdt, boot_compat_gdt, NR_RESERVED_GDT_PAGES * PAGE_SIZE); gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a =3D cpu; =20 if ( idt_tables[cpu] =3D=3D NULL ) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 38d12013db..162f708ac3 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -96,10 +96,10 @@ string_param("nmi", opt_nmi); DEFINE_PER_CPU(uint64_t, efer); static DEFINE_PER_CPU(unsigned long, last_extable_addr); =20 -DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, gdt_table); -DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, gdt_table_l1e); -DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt_table); -DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, compat_gdt_table_l1e); +DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, gdt); +DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, gdt_l1e); +DEFINE_PER_CPU_READ_MOSTLY(seg_desc_t *, compat_gdt); +DEFINE_PER_CPU_READ_MOSTLY(l1_pgentry_t, compat_gdt_l1e); =20 /* Master table, used by CPU0. */ idt_entry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) @@ -1899,17 +1899,17 @@ void load_TR(void) { struct tss_struct *tss =3D &this_cpu(init_tss); struct desc_ptr old_gdt, tss_gdt =3D { - .base =3D (long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY), + .base =3D (long)(this_cpu(gdt) - FIRST_RESERVED_GDT_ENTRY), .limit =3D LAST_RESERVED_GDT_BYTE }; =20 _set_tssldt_desc( - this_cpu(gdt_table) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, + this_cpu(gdt) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, (unsigned long)tss, offsetof(struct tss_struct, __cacheline_filler) - 1, SYS_DESC_tss_avail); _set_tssldt_desc( - this_cpu(compat_gdt_table) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, + this_cpu(compat_gdt) + TSS_ENTRY - FIRST_RESERVED_GDT_ENTRY, (unsigned long)tss, offsetof(struct tss_struct, __cacheline_filler) - 1, SYS_DESC_tss_busy); @@ -2000,8 +2000,8 @@ void __init init_idt_traps(void) /* CPU0 uses the master IDT. */ idt_tables[0] =3D idt_table; =20 - this_cpu(gdt_table) =3D boot_cpu_gdt_table; - this_cpu(compat_gdt_table) =3D boot_cpu_compat_gdt_table; + this_cpu(gdt) =3D boot_gdt; + this_cpu(compat_gdt) =3D boot_compat_gdt; } =20 extern void (*const autogen_entrypoints[NR_VECTORS])(void); @@ -2029,13 +2029,11 @@ void __init trap_init(void) } } =20 - /* Cache {,compat_}gdt_table_l1e now that physically relocation is don= e. */ - this_cpu(gdt_table_l1e) =3D - l1e_from_pfn(virt_to_mfn(boot_cpu_gdt_table), - __PAGE_HYPERVISOR_RW); - this_cpu(compat_gdt_table_l1e) =3D - l1e_from_pfn(virt_to_mfn(boot_cpu_compat_gdt_table), - __PAGE_HYPERVISOR_RW); + /* Cache {,compat_}gdt_l1e now that physically relocation is done. */ + this_cpu(gdt_l1e) =3D + l1e_from_pfn(virt_to_mfn(boot_gdt), __PAGE_HYPERVISOR_RW); + this_cpu(compat_gdt_l1e) =3D + l1e_from_pfn(virt_to_mfn(boot_compat_gdt), __PAGE_HYPERVISOR_RW); =20 percpu_traps_init(); =20 diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index 3d118d571d..ab53ebcc55 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -104,7 +104,7 @@ struct efi_rs_state efi_rs_enter(void) { struct desc_ptr gdt_desc =3D { .limit =3D LAST_RESERVED_GDT_BYTE, - .base =3D (unsigned long)(per_cpu(gdt_table, smp_processor_id= ()) - + .base =3D (unsigned long)(per_cpu(gdt, smp_processor_id()) - FIRST_RESERVED_GDT_ENTRY) }; =20 diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h index c011c03ae2..0be9348d29 100644 --- a/xen/include/asm-x86/desc.h +++ b/xen/include/asm-x86/desc.h @@ -204,12 +204,12 @@ struct __packed desc_ptr { unsigned long base; }; =20 -extern seg_desc_t boot_cpu_gdt_table[]; -DECLARE_PER_CPU(seg_desc_t *, gdt_table); -DECLARE_PER_CPU(l1_pgentry_t, gdt_table_l1e); -extern seg_desc_t boot_cpu_compat_gdt_table[]; -DECLARE_PER_CPU(seg_desc_t *, compat_gdt_table); -DECLARE_PER_CPU(l1_pgentry_t, compat_gdt_table_l1e); +extern seg_desc_t boot_gdt[]; +DECLARE_PER_CPU(seg_desc_t *, gdt); +DECLARE_PER_CPU(l1_pgentry_t, gdt_l1e); +extern seg_desc_t boot_compat_gdt[]; +DECLARE_PER_CPU(seg_desc_t *, compat_gdt); +DECLARE_PER_CPU(l1_pgentry_t, compat_gdt_l1e); DECLARE_PER_CPU(bool, full_gdt_loaded); =20 extern void load_TR(void); diff --git a/xen/include/asm-x86/ldt.h b/xen/include/asm-x86/ldt.h index da502329fb..1383f55308 100644 --- a/xen/include/asm-x86/ldt.h +++ b/xen/include/asm-x86/ldt.h @@ -13,8 +13,7 @@ static inline void load_LDT(struct vcpu *v) lldt(0); else { - desc =3D (!is_pv_32bit_vcpu(v) - ? this_cpu(gdt_table) : this_cpu(compat_gdt_table)) + desc =3D (!is_pv_32bit_vcpu(v) ? this_cpu(gdt) : this_cpu(compat_g= dt)) + LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY; _set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, SYS_DESC_ldt); lldt(LDT_ENTRY << 3); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 10:18:57 2024 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=1565009079; cv=none; d=zoho.com; s=zohoarc; b=g6tqhurFcK+W8z15MZJaO9sxqbAB3uujyTSedcH21T5UwQ7ttMrVKv8D5+HOA/0yw0du/T44uyXk+DNaMprwKJODCpIXKR6X09xmNMQRCGa6YvtnDhN9FvWgX17iEwcUsNiJQ8LPZi22ePbM0iwytV31+uDqeORYgtmK3Z9el/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565009079; 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=JzqVaWPchOVH2tPt71rjTITT488dyIAfQxhxNbVdT9g=; b=LXciCJAjWjmDFnMcdDlhozCACQure7agMHJOdy+MmrqGUACoA5O3rFxU4ctDO6gdIMMuGRuIGoi00Utpx9Nf5+tN3azLDp5BZuBKH6RmlE4U2MdP5B0F36NkvzkwuLfT7OT2Us2XM/lMTWLh13YeuAm4KVpA0TmLn+G6CDq4do8= 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 1565009079386829.7514114223859; Mon, 5 Aug 2019 05:44:39 -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 1hucKZ-0000cK-TU; Mon, 05 Aug 2019 12:43:15 +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 1hucKY-0000cF-Ed for xen-devel@lists.xenproject.org; Mon, 05 Aug 2019 12:43:14 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 951605a6-b77e-11e9-8a3d-638e0cad4229; Mon, 05 Aug 2019 12:43:11 +0000 (UTC) X-Inumbo-ID: 951605a6-b77e-11e9-8a3d-638e0cad4229 Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: WReaJLVIY5EDwPZubsCpn+9OBhe1qwqb8OPKg9X7rkj5z9x2IwK3VfqC+FFtM3WN/PWklG2GA9 X42NkDBpx17BDuP/GKLHiTE5DIJoouURcr7ZuhF/7Mvras37WAjgc1yoEJSHO5dAumvdQq7DI1 qUfL5T3BuR8HaC6RGC3aWqIEdGzporT7Y4bMXEObGN1EM3ZDz13kxVflOs4hoJaVWl1A5+itT8 yK+IkQ7+d7PlDG7GqjVHR2WyEH43JBUvCWFBtFleENyfIp1HU1jvzTodkdab8yM0OohA+BhCfK MS0= X-SBRS: 2.7 X-MesageID: 3986069 X-Ironport-Server: esa5.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="3986069" From: Andrew Cooper To: Xen-devel Date: Mon, 5 Aug 2019 13:43:01 +0100 Message-ID: <20190805124301.12887-5-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 4/4] x86/desc: Build boot_{,compat_}gdt[] in C 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" ... where we can at least get the compiler to fill in the surrounding space without having to do it manually. This also reults in the symbols having proper type/size information in the debug symbols. Reorder 'raw' in the seg_desc_t union to allow for easier initialisation. Leave a comment explaining the various restrictions we have on altering the GDT layout. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monn=C3=A9 --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 There is plenty more cleanup which can be done in the future. As we are 64-bit, there is no need for load_TR() to keep the TSS in sync between the = two GDTs, which means it can drop all sgdt/lgdt instructions. Also, __HYPERVISOR_CS32 is unused and could be dropped. As is demonstrated by the required includes, asm/desc.h is a tangle in need= of some cleanup. The SYSEXIT GDT requirements are: R0 long code, R0 data, R3 compat code, R3 data, R3 long code, R3 data. We could make Xen compatible by shifting the R0 code/data down by one slot, moving R0 compat code elsewhere and replacing it with another R3 data. However, this seems like a fairly pointless exercise, as the only thing it will do is change the magic numbers which developers have become accustom to seeing in backtraces. --- xen/arch/x86/Makefile | 1 + xen/arch/x86/boot/head.S | 1 - xen/arch/x86/boot/x86_64.S | 33 -------------------- xen/arch/x86/desc.c | 75 ++++++++++++++++++++++++++++++++++++++++++= ++++ xen/include/asm-x86/desc.h | 2 +- 5 files changed, 77 insertions(+), 35 deletions(-) create mode 100644 xen/arch/x86/desc.c diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 5e3840084b..2443fd2cc5 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_PV) +=3D compat.o x86_64/compat.o obj-$(CONFIG_KEXEC) +=3D crash.o obj-y +=3D debug.o obj-y +=3D delay.o +obj-y +=3D desc.o obj-bin-y +=3D dmi_scan.init.o obj-y +=3D domctl.o obj-y +=3D domain.o diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ab2d52a79d..782deac0d4 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 3909363ca3..f762dfea11 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -43,44 +43,11 @@ ENTRY(__high_start) multiboot_ptr: .long 0 =20 - .word 0 -GLOBAL(boot_gdtr) - .word LAST_RESERVED_GDT_BYTE - .quad boot_gdt - FIRST_RESERVED_GDT_BYTE - GLOBAL(stack_start) .quad cpu0_stack =20 .section .data.page_aligned, "aw", @progbits .align PAGE_SIZE, 0 -GLOBAL(boot_gdt) - .quad 0x0000000000000000 /* unused */ - .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode = */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 data = */ - .quad 0x0000000000000000 /* reserved = */ - .quad 0x00cffa000000ffff /* 0xe023 ring 3 code, compatibility = */ - .quad 0x00cff2000000ffff /* 0xe02b ring 3 data = */ - .quad 0x00affa000000ffff /* 0xe033 ring 3 code, 64-bit mode = */ - .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility = */ - .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0 - .quad 0x0000910000000000 /* per-CPU entry (limit =3D=3D cpu) = */ - - .align PAGE_SIZE, 0 -/* NB. Even rings !=3D 0 get access to the full 4Gb, as only the = */ -/* (compatibility) machine->physical mapping table lives there. = */ -GLOBAL(boot_compat_gdt) - .quad 0x0000000000000000 /* unused */ - .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode = */ - .quad 0x00cf92000000ffff /* 0xe010 ring 0 data = */ - .quad 0x00cfba000000ffff /* 0xe019 ring 1 code, compatibility = */ - .quad 0x00cfb2000000ffff /* 0xe021 ring 1 data = */ - .quad 0x00cffa000000ffff /* 0xe02b ring 3 code, compatibility = */ - .quad 0x00cff2000000ffff /* 0xe033 ring 3 data = */ - .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility = */ - .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0 - .quad 0x0000910000000000 /* per-CPU entry (limit =3D=3D cpu) = */ - .align PAGE_SIZE, 0 - /* * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings * to avoid type conflicts with fixed-range MTRRs covering the lowest mega= byte diff --git a/xen/arch/x86/desc.c b/xen/arch/x86/desc.c new file mode 100644 index 0000000000..c5dad90cdd --- /dev/null +++ b/xen/arch/x86/desc.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include + +#include + +/* + * Native and Compat GDTs used by Xen. + * + * The R1 and R3 descriptors are fixed in Xen's ABI for PV guests. All ot= her + * descriptors are in principle variable, with the following restrictions. + * + * All R0 descriptors must line up in both GDTs to allow for correct + * interrupt/exception handling. + * + * The SYSCALL/SYSRET GDT layout requires: + * - R0 long mode code followed by R0 data. + * - R3 compat code, followed by R3 data, followed by R3 long mode code. + * + * The SYSENTER GDT layout requirements are compatible with SYSCALL. Xen = does + * not use the SYSEXIT instruction, and does not provide a compatible GDT. + * + * These tables are used directly by CPU0, and used as the template for the + * GDTs of other CPUs. Everything from the TSS onwards is unique per CPU. + */ +__section(".data.page_aligned") __aligned(PAGE_SIZE) +seg_desc_t boot_gdt[PAGE_SIZE / sizeof(seg_desc_t)] =3D +{ + [ 1] =3D { 0x00af9a000000ffff }, /* 0xe008 - Ring 0 code, 64bit mode = */ + [ 2] =3D { 0x00cf92000000ffff }, /* 0xe010 - Ring 0 data = */ + /* 0xe018 - reserved = */ + [ 4] =3D { 0x00cffa000000ffff }, /* 0xe023 - Ring 3 code, compatibilit= y */ + [ 5] =3D { 0x00cff2000000ffff }, /* 0xe02b - Ring 3 data = */ + [ 6] =3D { 0x00affa000000ffff }, /* 0xe033 - Ring 3 code, 64-bit mode = */ + [ 7] =3D { 0x00cf9a000000ffff }, /* 0xe038 - Ring 0 code, compatibilit= y */ + /* 0xe040 - TSS = */ + /* 0xe050 - LDT = */ + [12] =3D { 0x0000910000000000 }, /* 0xe060 - per-CPU entry (limit =3D= =3D cpu) */ +}; + +__section(".data.page_aligned") __aligned(PAGE_SIZE) +seg_desc_t boot_compat_gdt[PAGE_SIZE / sizeof(seg_desc_t)] =3D +{ + [ 1] =3D { 0x00af9a000000ffff }, /* 0xe008 - Ring 0 code, 64-bit mode = */ + [ 2] =3D { 0x00cf92000000ffff }, /* 0xe010 - Ring 0 data = */ + [ 3] =3D { 0x00cfba000000ffff }, /* 0xe019 - Ring 1 code, compatibilit= y */ + [ 4] =3D { 0x00cfb2000000ffff }, /* 0xe021 - Ring 1 data = */ + [ 5] =3D { 0x00cffa000000ffff }, /* 0xe02b - Ring 3 code, compatibilit= y */ + [ 6] =3D { 0x00cff2000000ffff }, /* 0xe033 - Ring 3 data = */ + [ 7] =3D { 0x00cf9a000000ffff }, /* 0xe038 - Ring 0 code, compatibilit= y */ + /* 0xe040 - TSS = */ + /* 0xe050 - LDT = */ + [12] =3D { 0x0000910000000000 }, /* 0xe060 - per-CPU entry (limit =3D= =3D cpu) */ +}; + +/* + * Used by each CPU as it starts up, to enter C with a suitable %cs. + * References boot_cpu_gdt_table for a short period, until the CPUs switch + * onto their per-CPU GDTs. + */ +struct desc_ptr boot_gdtr =3D { + .limit =3D LAST_RESERVED_GDT_BYTE, + .base =3D (unsigned long)(boot_gdt - FIRST_RESERVED_GDT_ENTRY), +}; + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h index 0be9348d29..0ebdcd05a9 100644 --- a/xen/include/asm-x86/desc.h +++ b/xen/include/asm-x86/desc.h @@ -103,10 +103,10 @@ #define SYS_DESC_trap_gate 15 =20 typedef union { + uint64_t raw; struct { uint32_t a, b; }; - uint64_t raw; } seg_desc_t; =20 typedef union { --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel