From nobody Fri Dec 19 07:53:24 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1745334453; cv=none; d=zohomail.com; s=zohoarc; b=IsSORqQk5jyhGp0IRYpH4An0hOfLZSlz8KbZPfoCQxhd12q9zjCWP/OwBDoI5Knoh7qp6svahjK60hDTkfZchvLGPu11cfsNATn8+FhPjeTZAovn4KxlB+ugcE3IOFn8AC0iwaiq9KO6t0UvG8Mn7ADIHRHgjIptQrBv6EF9+sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745334453; h=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=C/zzp0aIagiRDRrNb1hyYGPHNAie/7wpVquzYMh9D/s=; b=SH6c67CeAvz4FqBudKVMrlR/CRwfWijxU8fv1sM2ajJWj997eVYsyjUi63l9lR7Nd6HX8+7ME0x5TnGLWhQKz9PEIGJFbOl/Pdu0KjMqE0KzaF1wa0eAbLilPC4K6+LSkRQQSJOxod6WEYSPg9SVz5D1P0izViGgq4X5fmNpGE8= 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1745334453953163.17561855533802; Tue, 22 Apr 2025 08:07:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.962759.1353928 (Exim 4.92) (envelope-from ) id 1u7FDO-0000mS-Hv; Tue, 22 Apr 2025 15:07:14 +0000 Received: by outflank-mailman (output) from mailman id 962759.1353928; Tue, 22 Apr 2025 15:07:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7FDO-0000mL-FL; Tue, 22 Apr 2025 15:07:14 +0000 Received: by outflank-mailman (input) for mailman id 962759; Tue, 22 Apr 2025 15:07:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7FDN-0000lQ-U4 for xen-devel@lists.xenproject.org; Tue, 22 Apr 2025 15:07:13 +0000 Received: from 9.mo584.mail-out.ovh.net (9.mo584.mail-out.ovh.net [46.105.40.176]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 784a0c4c-1f8b-11f0-9eb0-5ba50f476ded; Tue, 22 Apr 2025 17:07:13 +0200 (CEST) Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.139.54]) by mo584.mail-out.ovh.net (Postfix) with ESMTP id 4Zhlvh2KgYz1YL3 for ; Tue, 22 Apr 2025 15:07:12 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-w2sd9 (unknown [10.110.178.161]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 05C811FEDD; Tue, 22 Apr 2025 15:07:10 +0000 (UTC) Received: from 3mdeb.com ([37.59.142.106]) by ghost-submission-5b5ff79f4f-w2sd9 with ESMTPSA id gjHvMp6wB2hCUgIAGwf5/A (envelope-from ); Tue, 22 Apr 2025 15:07:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 784a0c4c-1f8b-11f0-9eb0-5ba50f476ded Authentication-Results: garm.ovh; auth=pass (GARM-106R00600220e96-ded3-40a4-a6af-caa494199e46, 7E508E014E7E7C169EB13C6E22C3C4EBF1F0FDD7) smtp.auth=sergii.dmytruk@3mdeb.com X-OVh-ClientIp: 176.111.181.178 From: Sergii Dmytruk To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , trenchboot-devel@googlegroups.com Subject: [PATCH 03/21] x86/boot: add MLE header and new entry point Date: Tue, 22 Apr 2025 18:06:37 +0300 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 12727172547972674716 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvgeegtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgvrhhgihhiucffmhihthhruhhkuceoshgvrhhgihhirdgumhihthhruhhkseefmhguvggsrdgtohhmqeenucggtffrrghtthgvrhhnpeekudegfeduieegudeijeelleekfedvvdfhheehvefhudekjeeifeegtdduveehtdenucffohhmrghinhephhgvrggurdhssgenucfkphepuddvjedrtddrtddruddpudejiedrudduuddrudekuddrudejkedpfeejrdehledrudegvddruddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepshgvrhhgihhirdgumhihthhruhhkseefmhguvggsrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepgigvnhdquggvvhgvlheslhhishhtshdrgigvnhhprhhojhgvtghtrdhorhhgpdfovfetjfhoshhtpehmohehkeegmgdpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=C/zzp0aIagiRDRrNb1hyYGPHNAie/7wpVquzYMh9D/s=; c=relaxed/relaxed; d=3mdeb.com; h=From; s=ovhmo3617313-selector1; t=1745334432; v=1; b=auk5A/R6YHWHvx1XnF4GvLDHLDBtWcmvNNfqC7u2is7mNE5UMP0AzCURaqHc5VcWnMoU8Sfc t4O+v5Gh2ynvSqGtOmbf8TIuacg/jqjxA9l59nwogPyEfv3e/c8txFV8U5hZ5WmpVmDbtNVwagb ToAIyn/bihPLHBderKuCWCU9RusWgl/qCTGQ66QA+Xin73jPC093zNuBtDStXuisAkztwvg98Mv 0Xm3RRoM7HNwuIe/zzjePj8b0IYpiYGUK+RysuEOIGqHbjwW+RKsjMvcGf6YDmgtkiLSlffvLoG TGjlN07ALlNihncoDcwKVidPf4MhTQPHx22uLk6QdRVqg== X-ZohoMail-DKIM: pass (identity @3mdeb.com) X-ZM-MESSAGEID: 1745334456207019100 Content-Type: text/plain; charset="utf-8" From: Kacper Stojek Signed-off-by: Kacper Stojek Signed-off-by: Krystian Hebel Signed-off-by: Sergii Dmytruk --- docs/hypervisor-guide/x86/how-xen-boots.rst | 5 ++ xen/arch/x86/boot/head.S | 53 +++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/docs/hypervisor-guide/x86/how-xen-boots.rst b/docs/hypervisor-= guide/x86/how-xen-boots.rst index 8b3229005c..050fe9c61f 100644 --- a/docs/hypervisor-guide/x86/how-xen-boots.rst +++ b/docs/hypervisor-guide/x86/how-xen-boots.rst @@ -55,6 +55,11 @@ If ``CONFIG_PVH_GUEST`` was selected at build time, an E= lf note is included which indicates the ability to use the PVH boot protocol, and registers ``__pvh_start`` as the entrypoint, entered in 32bit mode. =20 +A combination of Multiboot 2 and MLE headers is used to implement DRTM for +legacy (BIOS) boot. The separate entry point is used mainly to differentia= te +from other kinds of boots. It moves a magic number to EAX before jumping i= nto +common startup code. + =20 xen.gz ~~~~~~ diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 77bb7a9e21..cd951ad2dc 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +127,25 @@ multiboot2_header: .size multiboot2_header, . - multiboot2_header .type multiboot2_header, @object =20 + .balign 16 +mle_header: + .long 0x9082ac5a /* UUID0 */ + .long 0x74a7476f /* UUID1 */ + .long 0xa2555c0f /* UUID2 */ + .long 0x42b651cb /* UUID3 */ + .long 0x00000034 /* MLE header size */ + .long 0x00020002 /* MLE version 2.2 */ + .long (slaunch_stub_entry - start) /* Linear entry point of MLE= (SINIT virt. address) */ + .long 0x00000000 /* First valid page of MLE */ + .long 0x00000000 /* Offset within binary of first byte of MLE */ + .long (_end - start) /* Offset within binary of last byte + 1 o= f MLE */ + .long 0x00000723 /* Bit vector of MLE-supported capabilities */ + .long 0x00000000 /* Starting linear address of command line (un= used) */ + .long 0x00000000 /* Ending linear address of command line (unus= ed) */ + + .size mle_header, .-mle_header + .type mle_header, @object + .section .init.rodata, "a", @progbits =20 .Lbad_cpu_msg: .asciz "ERR: Not a 64-bit CPU!" @@ -332,6 +352,38 @@ cs32_switch: /* Jump to earlier loaded address. */ jmp *%edi =20 + /* + * Entry point for TrenchBoot Secure Launch on Intel TXT platforms. + * + * CPU is in 32b protected mode with paging disabled. On entry: + * - %ebx =3D %eip =3D MLE entry point, + * - stack pointer is undefined, + * - CS is flat 4GB code segment, + * - DS, ES, SS, FS and GS are undefined according to TXT SDG, but= this + * would make it impossible to initialize GDTR, because GDT base= must + * be relocated in the descriptor, which requires write access t= hat + * CS doesn't provide. Instead we have to assume that DS is set = by + * SINIT ACM as flat 4GB data segment. + * + * Additional restrictions: + * - some MSRs are partially cleared, among them IA32_MISC_ENABLE,= so + * some capabilities might be reported as disabled even if they = are + * supported by CPU + * - interrupts (including NMIs and SMIs) are disabled and must be + * enabled later + * - trying to enter real mode results in reset + * - APs must be brought up by MONITOR or GETSEC[WAKEUP], dependin= g on + * which is supported by a given SINIT ACM + */ +slaunch_stub_entry: + /* Calculate the load base address. */ + mov %ebx, %esi + sub $sym_offs(slaunch_stub_entry), %esi + + /* Mark Secure Launch boot protocol and jump to common entry. */ + mov $SLAUNCH_BOOTLOADER_MAGIC, %eax + jmp .Lset_stack + #ifdef CONFIG_PVH_GUEST ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long sym_offs(__pvh_start)) =20 @@ -371,6 +423,7 @@ __start: /* Restore the clobbered field. */ mov %edx, (%ebx) =20 +.Lset_stack: /* Set up stack. */ lea STACK_SIZE - CPUINFO_sizeof + sym_esi(cpu0_stack), %esp =20 --=20 2.49.0