From nobody Sun Apr 28 23:06:32 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1571917837; cv=none; d=zoho.com; s=zohoarc; b=JS+81NpEZ/Y0xllYo35xCTjP5d6tgqF/gM/KCE22GvpQ+VlPiB3MIDG4LTzgSEAPPviKz4zSDj4OPOmqu+WPNej2gu0GGTewuiSg7hoa6T+geSGEI3kNE1knirE0jvwa3T0PuzH9Q1THcgHZtGdcBrQNMvjXeCFI14I+0pF76x0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571917837; 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; bh=YBgcNIb9gzd4Jn5kCP8Ovto1uQaehyUd+LLPJEtyoL4=; b=cIkRXHSpvozbHAUFbISQSj4hdhjDzdXctvz6pGOKhPkfR+eBoQlRM/N6tk8ejFPNGJ/9uxlK003kqT4JEJ5Uj3/ly08zyq8s3AC7g2O2MNpuRXO6hdyqDoWkqLiH9orpirrTp0E7U9Li9RtzvlxB3ET2Zu6MCPa6VU/VWLg68ng= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571917837985189.15695905954885; Thu, 24 Oct 2019 04:50: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 1iNbcN-0001zi-Pn; Thu, 24 Oct 2019 11:49:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbcM-0001zT-KO for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 11:49:26 +0000 Received: from aserp2120.oracle.com (unknown [141.146.126.78]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4da1830c-f654-11e9-beca-bc764e2007e4; Thu, 24 Oct 2019 11:49:15 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBdJhK027401; Thu, 24 Oct 2019 11:48:47 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2vqteq323e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:47 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBeBRp011561; Thu, 24 Oct 2019 11:48:46 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2vu0fp47d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:46 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x9OBmgf9021099; Thu, 24 Oct 2019 11:48:42 GMT Received: from tomti.i.net-space.pl (/10.175.165.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 04:48:41 -0700 X-Inumbo-ID: 4da1830c-f654-11e9-beca-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=DKkR9B0pyfeJWw3qfq3SJ4xhN9wi6hAARN2vGh5YHPc=; b=nfdPxQj40erJeqML+HngZ8z+IhxYAyJ+ss7L7qZKUD99xNrHPVL1H7teYxKTnjekwX9H U57pe6KcITRQbwwG7HB1S2X60iTpqVFUTRO6RUHrMEcOjV+s6BiqoWQLJytzOj7KfO5e n3S4snwV96+MWEwJdymAFAhxyMkYAxTrs6F8rDyw5f7rDG5Da/MrnX13zfjiu9itUqnq nzgX00WoZTBW1zsqhsrmyxTvJLFsdhC2K01vFOCsemzCV9PeMf2c1ySK4j1n9VEJJW8V 0rKEZR7PdIncQ42jPlalg0W3dae5Cs9al9B2u84gaac7h5mWbEsilIT9Ozyx/YDQKqKi RA== From: Daniel Kiper To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org Date: Thu, 24 Oct 2019 13:48:12 +0200 Message-Id: <20191024114814.6488-2-daniel.kiper@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191024114814.6488-1-daniel.kiper@oracle.com> References: <20191024114814.6488-1-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 Subject: [Xen-devel] [PATCH v4 1/3] x86/boot: Introduce the kernel_info 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: jgross@suse.com, eric.snowberg@oracle.com, ard.biesheuvel@linaro.org, konrad.wilk@oracle.com, corbet@lwn.net, peterz@infradead.org, ross.philipson@oracle.com, dave.hansen@linux.intel.com, mingo@redhat.com, bp@alien8.de, rdunlap@infradead.org, luto@kernel.org, hpa@zytor.com, kanth.ghatraju@oracle.com, boris.ostrovsky@oracle.com, tglx@linutronix.de MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The relationships between the headers are analogous to the various data sections: setup_header =3D .data boot_params/setup_data =3D .bss What is missing from the above list? That's right: kernel_info =3D .rodata We have been (ab)using .data for things that could go into .rodata or .bss = for a long time, for lack of alternatives and -- especially early on -- inertia. Also, the BIOS stub is responsible for creating boot_params, so it isn't available to a BIOS-based loader (setup_data is, though). setup_header is permanently limited to 144 bytes due to the reach of the 2-byte jump field, which doubles as a length field for the structure, combi= ned with the size of the "hole" in struct boot_params that a protected-mode loa= der or the BIOS stub has to copy it into. It is currently 119 bytes long, which leaves us with 25 very precious bytes. This isn't something that can be fix= ed without revising the boot protocol entirely, breaking backwards compatibili= ty. boot_params proper is limited to 4096 bytes, but can be arbitrarily extended by adding setup_data entries. It cannot be used to communicate properties of the kernel image, because it is .bss and has no image-provided content. kernel_info solves this by providing an extensible place for information ab= out the kernel image. It is readonly, because the kernel cannot rely on a bootloader copying its contents anywhere, but that is OK; if it becomes necessary it can still contain data items that an enabled bootloader would = be expected to copy into a setup_data chunk. This patch does not bump setup_header version in arch/x86/boot/header.S because it will be followed by additional changes coming into the Linux/x86 boot protocol. Suggested-by: H. Peter Anvin (Intel) Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Ross Philipson Reviewed-by: H. Peter Anvin (Intel) --- v4 - suggestions/fixes: - improve the documentation (suggested by Randy Dunlap and Konrad Rzeszutek Wilk). v3 - suggestions/fixes: - split kernel_info data into fixed and variable sized regions, (suggested by H. Peter Anvin), - change kernel_info.header value to "LToP" (0x506f544c), (suggested by H. Peter Anvin), - improve the comments, - improve the documentation. v2 - suggestions/fixes: - rename setup_header2 to kernel_info, (suggested by H. Peter Anvin), - change kernel_info.header value to "InfO" (0x4f666e49), - new kernel_info description in Documentation/x86/boot.rst, (suggested by H. Peter Anvin), - drop kernel_info_offset_update() as an overkill and update kernel_info offset directly from main(), (suggested by Eric Snowberg), - new commit message (suggested by H. Peter Anvin), - fix some commit message misspellings (suggested by Eric Snowberg). --- Documentation/x86/boot.rst | 126 +++++++++++++++++++++++++++++= ++++ arch/x86/boot/Makefile | 2 +- arch/x86/boot/compressed/Makefile | 4 +- arch/x86/boot/compressed/kernel_info.S | 17 +++++ arch/x86/boot/header.S | 1 + arch/x86/boot/tools/build.c | 5 ++ arch/x86/include/uapi/asm/bootparam.h | 1 + 7 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 arch/x86/boot/compressed/kernel_info.S diff --git a/Documentation/x86/boot.rst b/Documentation/x86/boot.rst index 08a2f100c0e6..c60fafda9427 100644 --- a/Documentation/x86/boot.rst +++ b/Documentation/x86/boot.rst @@ -68,8 +68,25 @@ Protocol 2.12 (Kernel 3.8) Added the xloadflags field an= d extension fields Protocol 2.13 (Kernel 3.14) Support 32- and 64-bit flags being set in xloadflags to support booting a 64-bit kernel from 32-bit EFI + +Protocol 2.14: BURNT BY INCORRECT COMMIT ae7e1238e68f2a472a125673ab506d491= 58c1889 + (x86/boot: Add ACPI RSDP address to setup_header) + DO NOT USE!!! ASSUME SAME AS 2.13. + +Protocol 2.15: (Kernel 5.5) Added the kernel_info. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 +.. note:: + The protocol version number should be changed only if the setup header + is changed. There is no need to update the version number if boot_par= ams + or kernel_info are changed. Additionally, it is recommended to use + xloadflags (in this case the protocol version number should not be + updated either) or kernel_info to communicate supported Linux kernel + features to the boot loader. Due to very limited space available in + the original setup header every update to it should be considered + with great care. Starting from the protocol 2.15 the primary way to + communicate things to the boot loader is the kernel_info. + =20 Memory Layout =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -207,6 +224,7 @@ Offset/Size Proto Name Meaning 0258/8 2.10+ pref_address Preferred loading address 0260/4 2.10+ init_size Linear memory required during initialization 0264/4 2.11+ handover_offset Offset of handover entry point +0268/4 2.15+ kernel_info_offset Offset of the kernel_info =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 .. note:: @@ -855,6 +873,114 @@ Offset/size: 0x264/4 =20 See EFI HANDOVER PROTOCOL below for more details. =20 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D +Field name: kernel_info_offset +Type: read +Offset/size: 0x268/4 +Protocol: 2.15+ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D + + This field is the offset from the beginning of the kernel image to the + kernel_info. The kernel_info structure is embedded in the Linux image + in the uncompressed protected mode region. + + +The kernel_info +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The relationships between the headers are analogous to the various data +sections: + + setup_header =3D .data + boot_params/setup_data =3D .bss + +What is missing from the above list? That's right: + + kernel_info =3D .rodata + +We have been (ab)using .data for things that could go into .rodata or .bss= for +a long time, for lack of alternatives and -- especially early on -- inerti= a. +Also, the BIOS stub is responsible for creating boot_params, so it isn't +available to a BIOS-based loader (setup_data is, though). + +setup_header is permanently limited to 144 bytes due to the reach of the +2-byte jump field, which doubles as a length field for the structure, comb= ined +with the size of the "hole" in struct boot_params that a protected-mode lo= ader +or the BIOS stub has to copy it into. It is currently 119 bytes long, which +leaves us with 25 very precious bytes. This isn't something that can be fi= xed +without revising the boot protocol entirely, breaking backwards compatibil= ity. + +boot_params proper is limited to 4096 bytes, but can be arbitrarily extend= ed +by adding setup_data entries. It cannot be used to communicate properties = of +the kernel image, because it is .bss and has no image-provided content. + +kernel_info solves this by providing an extensible place for information a= bout +the kernel image. It is readonly, because the kernel cannot rely on a +bootloader copying its contents anywhere, but that is OK; if it becomes +necessary it can still contain data items that an enabled bootloader would= be +expected to copy into a setup_data chunk. + +All kernel_info data should be part of this structure. Fixed size data hav= e to +be put before kernel_info_var_len_data label. Variable size data have to b= e put +after kernel_info_var_len_data label. Each chunk of variable size data has= to +be prefixed with header/magic and its size, e.g.: + + kernel_info: + .ascii "LToP" /* Header, Linux top (structure). */ + .long kernel_info_var_len_data - kernel_info + .long kernel_info_end - kernel_info + .long 0x01234567 /* Some fixed size data for the bootload= ers. */ + kernel_info_var_len_data: + example_struct: /* Some variable size data for the bootl= oaders. */ + .ascii "0123" /* Header/Magic. */ + .long example_struct_end - example_struct + .ascii "Struct" + .long 0x89012345 + example_struct_end: + example_strings: /* Some variable size data for the bootl= oaders. */ + .ascii "ABCD" /* Header/Magic. */ + .long example_strings_end - example_strings + .asciz "String_0" + .asciz "String_1" + example_strings_end: + kernel_info_end: + +This way the kernel_info is self-contained blob. + +.. note:: + Each variable size data header/magic can be any 4-character string, + without \0 at the end of the string, which does not collide with + existing variable length data headers/magics. + + +Details of the kernel_info Fields +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D +Field name: header +Offset/size: 0x0000/4 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D + + Contains the magic number "LToP" (0x506f544c). + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D +Field name: size +Offset/size: 0x0004/4 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D + + This field contains the size of the kernel_info including kernel_info.he= ader. + It does not count kernel_info.kernel_info_var_len_data size. This field = should be + used by the bootloaders to detect supported fixed size fields in the ker= nel_info + and beginning of kernel_info.kernel_info_var_len_data. + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D +Field name: size_total +Offset/size: 0x0008/4 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D + + This field contains the size of the kernel_info including kernel_info.he= ader + and kernel_info.kernel_info_var_len_data. + =20 The Image Checksum =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index e2839b5c246c..c30a9b642a86 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile @@ -87,7 +87,7 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE =20 SETUP_OBJS =3D $(addprefix $(obj)/,$(setup-y)) =20 -sed-zoffset :=3D -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startu= p_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_= ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p' +sed-zoffset :=3D -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startu= p_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|kernel_= info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p' =20 quiet_cmd_zoffset =3D ZOFFSET $@ cmd_zoffset =3D $(NM) $< | sed -n $(sed-zoffset) > $@ diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/M= akefile index 6b84afdd7538..fad3b18e2cc3 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -72,8 +72,8 @@ $(obj)/../voffset.h: vmlinux FORCE =20 $(obj)/misc.o: $(obj)/../voffset.h =20 -vmlinux-objs-y :=3D $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o= \ - $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \ +vmlinux-objs-y :=3D $(obj)/vmlinux.lds $(obj)/kernel_info.o $(obj)/head_$(= BITS).o \ + $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \ $(obj)/piggy.o $(obj)/cpuflags.o =20 vmlinux-objs-$(CONFIG_EARLY_PRINTK) +=3D $(obj)/early_serial_console.o diff --git a/arch/x86/boot/compressed/kernel_info.S b/arch/x86/boot/compres= sed/kernel_info.S new file mode 100644 index 000000000000..8ea6f6e3feef --- /dev/null +++ b/arch/x86/boot/compressed/kernel_info.S @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + + .section ".rodata.kernel_info", "a" + + .global kernel_info + +kernel_info: + /* Header, Linux top (structure). */ + .ascii "LToP" + /* Size. */ + .long kernel_info_var_len_data - kernel_info + /* Size total. */ + .long kernel_info_end - kernel_info + +kernel_info_var_len_data: + /* Empty for time being... */ +kernel_info_end: diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 2c11c0f45d49..22dcecaaa898 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -567,6 +567,7 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred loa= d addr =20 init_size: .long INIT_SIZE # kernel initialization size handover_offset: .long 0 # Filled in by build.c +kernel_info_offset: .long 0 # Filled in by build.c =20 # End of setup header ##################################################### =20 diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index a93d44e58f9c..55e669d29e54 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -56,6 +56,7 @@ u8 buf[SETUP_SECT_MAX*512]; unsigned long efi32_stub_entry; unsigned long efi64_stub_entry; unsigned long efi_pe_entry; +unsigned long kernel_info; unsigned long startup_64; =20 /*----------------------------------------------------------------------*/ @@ -321,6 +322,7 @@ static void parse_zoffset(char *fname) PARSE_ZOFS(p, efi32_stub_entry); PARSE_ZOFS(p, efi64_stub_entry); PARSE_ZOFS(p, efi_pe_entry); + PARSE_ZOFS(p, kernel_info); PARSE_ZOFS(p, startup_64); =20 p =3D strchr(p, '\n'); @@ -410,6 +412,9 @@ int main(int argc, char ** argv) =20 efi_stub_entry_update(); =20 + /* Update kernel_info offset. */ + put_unaligned_le32(kernel_info, &buf[0x268]); + crc =3D partial_crc32(buf, i, crc); if (fwrite(buf, 1, i, dest) !=3D i) die("Writing setup failed"); diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/= asm/bootparam.h index c895df5482c5..a1ebcd7a991c 100644 --- a/arch/x86/include/uapi/asm/bootparam.h +++ b/arch/x86/include/uapi/asm/bootparam.h @@ -88,6 +88,7 @@ struct setup_header { __u64 pref_address; __u32 init_size; __u32 handover_offset; + __u32 kernel_info_offset; } __attribute__((packed)); =20 struct sys_desc_table { --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 23:06:32 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1571917836; cv=none; d=zoho.com; s=zohoarc; b=k8Y0NSDOzY3cDbeNYLTYevy/U7yGK3e2OlYHAVa8877x+Vend7LVCPZOPjHCgb08JPoEBh8bCUppKyc2PPOV8eHluqel5bvOwfdfb2WxlCEeWaYLvUhWbJm/HS5XVM+Qth+i2zS5v2qvHyoQWoHZ/EzRbib/Uv1j/+uLvGfjdD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571917836; 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; bh=jDVGI8s1AdkI2WrD9kgyK+pO+6bs1cIcwI8Ng30dilk=; b=gOSj6Cv0wQ26E85kf1s6vfxZU9Lanm3B45FvoyriWpISCJceYiJPLbaqHmgAHlwwAVwwVpA8S6VwNiVFvPhJkN3SZPR3q7eXMSwX6XMw4kVGpxbPnF4duvcF3CDbZhzXaLML4OagSjXEA395sWOD21DvPKRb1qDKiJTEcTHuhA4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571917836573688.6186738873342; Thu, 24 Oct 2019 04:50:36 -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 1iNbcE-0001y8-5O; Thu, 24 Oct 2019 11:49:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNbcC-0001y3-MN for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 11:49:16 +0000 Received: from aserp2120.oracle.com (unknown [141.146.126.78]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4d94d77e-f654-11e9-bbab-bc764e2007e4; Thu, 24 Oct 2019 11:49:15 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBdxUn027790; Thu, 24 Oct 2019 11:48:48 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2vqteq323h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:48 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBdDSh050160; Thu, 24 Oct 2019 11:48:47 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2vtjkjcsf7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:47 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9OBmjeO010783; Thu, 24 Oct 2019 11:48:46 GMT Received: from tomti.i.net-space.pl (/10.175.165.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 04:48:45 -0700 X-Inumbo-ID: 4d94d77e-f654-11e9-bbab-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=z13BAF6ghH9YJkJPP/cOfQet3c3eWcpMKhNqVJkkLRM=; b=bWrkHXfqnm9iQapN5MJCYi1RPzf0CfNulUZ4eLSmNGn83Pg/jE/OBDfrGJWsbm0hvQfi qj9hwLqAKRC/OlqQ8JffjEb5wsFJF41FWAjXSwr29vDXHJ2fUIITjsjHOfCzNqnUFBGY EShZtABmBBD0CyQtpyXpOUFQHzNJLQhXXFFqwzYMjUM0UzMkcy4fbccV2+mGsN2DFFBm DVXnJUPgN+MQglCoq9T3j+lKkXqOtuiIfE/i9gBKrfoFX2vSxNzp6ctnS3gSB8cgrZSW 8U6m8nMA6o9Bn8Lm6LjD71b+43h6k7k4vB/xq5UDMgv5Skn08Rq+UmvWNjgnP2A4L33o Jw== From: Daniel Kiper To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org Date: Thu, 24 Oct 2019 13:48:13 +0200 Message-Id: <20191024114814.6488-3-daniel.kiper@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191024114814.6488-1-daniel.kiper@oracle.com> References: <20191024114814.6488-1-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 Subject: [Xen-devel] [PATCH v4 2/3] x86/boot: Introduce the kernel_info.setup_type_max 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: jgross@suse.com, eric.snowberg@oracle.com, ard.biesheuvel@linaro.org, konrad.wilk@oracle.com, corbet@lwn.net, peterz@infradead.org, ross.philipson@oracle.com, dave.hansen@linux.intel.com, mingo@redhat.com, bp@alien8.de, rdunlap@infradead.org, luto@kernel.org, hpa@zytor.com, kanth.ghatraju@oracle.com, boris.ostrovsky@oracle.com, tglx@linutronix.de MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This field contains maximal allowed type for setup_data. Now bump the setup_header version in arch/x86/boot/header.S. Suggested-by: H. Peter Anvin (Intel) Signed-off-by: Daniel Kiper Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Ross Philipson Reviewed-by: H. Peter Anvin (Intel) --- Documentation/x86/boot.rst | 9 ++++++++- arch/x86/boot/compressed/kernel_info.S | 5 +++++ arch/x86/boot/header.S | 2 +- arch/x86/include/uapi/asm/bootparam.h | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Documentation/x86/boot.rst b/Documentation/x86/boot.rst index c60fafda9427..8e523c23ede3 100644 --- a/Documentation/x86/boot.rst +++ b/Documentation/x86/boot.rst @@ -73,7 +73,7 @@ Protocol 2.14: BURNT BY INCORRECT COMMIT ae7e1238e68f2a47= 2a125673ab506d49158c188 (x86/boot: Add ACPI RSDP address to setup_header) DO NOT USE!!! ASSUME SAME AS 2.13. =20 -Protocol 2.15: (Kernel 5.5) Added the kernel_info. +Protocol 2.15: (Kernel 5.5) Added the kernel_info and kernel_info.setup_ty= pe_max. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 .. note:: @@ -981,6 +981,13 @@ Offset/size: 0x0008/4 This field contains the size of the kernel_info including kernel_info.he= ader and kernel_info.kernel_info_var_len_data. =20 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +Field name: setup_type_max +Offset/size: 0x0008/4 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + + This field contains maximal allowed type for setup_data and setup_indire= ct structs. + =20 The Image Checksum =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/arch/x86/boot/compressed/kernel_info.S b/arch/x86/boot/compres= sed/kernel_info.S index 8ea6f6e3feef..f818ee8fba38 100644 --- a/arch/x86/boot/compressed/kernel_info.S +++ b/arch/x86/boot/compressed/kernel_info.S @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ =20 +#include + .section ".rodata.kernel_info", "a" =20 .global kernel_info @@ -12,6 +14,9 @@ kernel_info: /* Size total. */ .long kernel_info_end - kernel_info =20 + /* Maximal allowed type for setup_data and setup_indirect structs. */ + .long SETUP_TYPE_MAX + kernel_info_var_len_data: /* Empty for time being... */ kernel_info_end: diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 22dcecaaa898..97d9b6d6c1af 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -300,7 +300,7 @@ _start: # Part 2 of the header, from the old setup.S =20 .ascii "HdrS" # header signature - .word 0x020d # header version number (>=3D 0x0105) + .word 0x020f # header version number (>=3D 0x0105) # or else old loadlin-1.5 will fail) .globl realmode_swtch realmode_swtch: .word 0, 0 # default_switch, SETUPSEG diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/= asm/bootparam.h index a1ebcd7a991c..dbb41128e5a0 100644 --- a/arch/x86/include/uapi/asm/bootparam.h +++ b/arch/x86/include/uapi/asm/bootparam.h @@ -11,6 +11,9 @@ #define SETUP_APPLE_PROPERTIES 5 #define SETUP_JAILHOUSE 6 =20 +/* max(SETUP_*) */ +#define SETUP_TYPE_MAX SETUP_JAILHOUSE + /* ram_size flags */ #define RAMDISK_IMAGE_START_MASK 0x07FF #define RAMDISK_PROMPT_FLAG 0x8000 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 23:06:32 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1571917939; cv=none; d=zoho.com; s=zohoarc; b=QHAxIp8EXOJT47tfbLJRTwW4StBn0hbo9IwQurXgyPIoOzK5L1j1vSynX8XMSRbeMUzmHTGgWuPpy4J8+yeliNfX8bxMbZXBX3w7OjrX7QXQ+21kBl9ztPw+Ygk1oVCJHhVOWKowr3aGUD/+1lnRRc3TCR9AqJOWCjn3FmIJbPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571917939; 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; bh=ge2FWcAVmUACsYZlCnR/0Se2GhocTSwipVLB9zmx+Xk=; b=KGFLhuEGoCJLvGtL3tWSp87Cb/1abcYAHGXV5jdTm5VQD4TOX2CySIUKFZUgBgUD3tIkXl8rjYEeHsYvBuns/G2jrtIbX1fTaKEqbYpgNPcwuT/Rn6f9rfNV1BOKZcKVUzoNO5kYD6E5xGCgYnd9aZ4dCivVAKhN086EnStU7s8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571917939386719.9366293979311; Thu, 24 Oct 2019 04:52:19 -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 1iNbeA-0002qt-6z; Thu, 24 Oct 2019 11:51:18 +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 1iNbe9-0002qm-N7 for xen-devel@lists.xenproject.org; Thu, 24 Oct 2019 11:51:17 +0000 Received: from aserp2120.oracle.com (unknown [141.146.126.78]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 95227830-f654-11e9-949e-12813bfff9fa; Thu, 24 Oct 2019 11:51:15 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBdJG0027398; Thu, 24 Oct 2019 11:48:52 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2vqteq323y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:52 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9OBeF8v147903; Thu, 24 Oct 2019 11:48:51 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2vtsk4kdru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 11:48:51 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x9OBmoqV017116; Thu, 24 Oct 2019 11:48:50 GMT Received: from tomti.i.net-space.pl (/10.175.165.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 04:48:49 -0700 X-Inumbo-ID: 95227830-f654-11e9-949e-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=LUzRexjL28yJiqsxlCEDrO6ZjBR5UcznsiT108Fhh90=; b=c5LL9ICuhAvct5zCXTyJVAtUedOprRdHfzs7b9FO0qi9KYEgislnjRhBKw3kCuAKfbBy hLa167hW8lhJDP/FM04kaq5BvanyzB/dHCtee8PxjoqjnxPUgyylwuhy+AhO85s6ySnA 2Tkoi6hFc8h4P4vUY9FGbFylgBMyv7CQxwBk/Rdu6L+KiWWhXYZJWymRoxA2nwado/Us z/api8S63nY9yFE63KEzXLCeebCrjgXlr2KF+ayZyS1txfuOJME47EbJ/WAJuZu8RLey ll9ya1muIMGj4J7gNEVdXBn+TeQ+cRHaDswL0dGMd7OoylthlyKzs/FinQAhKVJb1OSv XA== From: Daniel Kiper To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org Date: Thu, 24 Oct 2019 13:48:14 +0200 Message-Id: <20191024114814.6488-4-daniel.kiper@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191024114814.6488-1-daniel.kiper@oracle.com> References: <20191024114814.6488-1-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240116 Subject: [Xen-devel] [PATCH v4 3/3] x86/boot: Introduce the setup_indirect 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: jgross@suse.com, eric.snowberg@oracle.com, ard.biesheuvel@linaro.org, konrad.wilk@oracle.com, corbet@lwn.net, peterz@infradead.org, ross.philipson@oracle.com, dave.hansen@linux.intel.com, mingo@redhat.com, bp@alien8.de, rdunlap@infradead.org, luto@kernel.org, hpa@zytor.com, kanth.ghatraju@oracle.com, boris.ostrovsky@oracle.com, tglx@linutronix.de MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The setup_data is a bit awkward to use for extremely large data objects, both because the setup_data header has to be adjacent to the data object and because it has a 32-bit length field. However, it is important that intermediate stages of the boot process have a way to identify which chunks of memory are occupied by kernel data. Thus we introduce an uniform way to specify such indirect data as setup_indirect struct and SETUP_INDIRECT type. Suggested-by: H. Peter Anvin (Intel) Signed-off-by: Daniel Kiper Acked-by: Konrad Rzeszutek Wilk Reviewed-by: Ross Philipson Reviewed-by: H. Peter Anvin (Intel) --- v4 - suggestions/fixes: - change "Note:" to ".. note::". v3 - suggestions/fixes: - add setup_indirect mapping/KASLR avoidance/etc. code (suggested by H. Peter Anvin), - the SETUP_INDIRECT sets most significant bit right now; this way it is possible to differentiate regular setup_data and setup_indirect objects in the debugfs filesystem. v2 - suggestions/fixes: - add setup_indirect usage example (suggested by Eric Snowberg and Ross Philipson). --- Documentation/x86/boot.rst | 41 +++++++++++++++++++++++++++++++= ++++ arch/x86/boot/compressed/kaslr.c | 12 ++++++++++ arch/x86/include/uapi/asm/bootparam.h | 16 +++++++++++--- arch/x86/kernel/e820.c | 11 ++++++++++ arch/x86/kernel/kdebugfs.c | 20 +++++++++++++---- arch/x86/kernel/ksysfs.c | 30 +++++++++++++++++++------ arch/x86/kernel/setup.c | 4 ++++ arch/x86/mm/ioremap.c | 11 ++++++++++ 8 files changed, 131 insertions(+), 14 deletions(-) diff --git a/Documentation/x86/boot.rst b/Documentation/x86/boot.rst index 8e523c23ede3..38155ba8740f 100644 --- a/Documentation/x86/boot.rst +++ b/Documentation/x86/boot.rst @@ -827,6 +827,47 @@ Protocol: 2.09+ sure to consider the case where the linked list already contains entries. =20 + The setup_data is a bit awkward to use for extremely large data objects, + both because the setup_data header has to be adjacent to the data object + and because it has a 32-bit length field. However, it is important that + intermediate stages of the boot process have a way to identify which + chunks of memory are occupied by kernel data. + + Thus setup_indirect struct and SETUP_INDIRECT type were introduced in + protocol 2.15. + + struct setup_indirect { + __u32 type; + __u32 reserved; /* Reserved, must be set to zero. */ + __u64 len; + __u64 addr; + }; + + The type member is a SETUP_INDIRECT | SETUP_* type. However, it cannot be + SETUP_INDIRECT itself since making the setup_indirect a tree structure + could require a lot of stack space in something that needs to parse it + and stack space can be limited in boot contexts. + + Let's give an example how to point to SETUP_E820_EXT data using setup_in= direct. + In this case setup_data and setup_indirect will look like this: + + struct setup_data { + __u64 next =3D 0 or ; + __u32 type =3D SETUP_INDIRECT; + __u32 len =3D sizeof(setup_data); + __u8 data[sizeof(setup_indirect)] =3D struct setup_indirect { + __u32 type =3D SETUP_INDIRECT | SETUP_E820_EXT; + __u32 reserved =3D 0; + __u64 len =3D ; + __u64 addr =3D ; + } + } + +.. note:: + SETUP_INDIRECT | SETUP_NONE objects cannot be properly distinguished + from SETUP_INDIRECT itself. So, this kind of objects cannot be provid= ed + by the bootloaders. + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Field name: pref_address Type: read (reloc) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/ka= slr.c index 2e53c056ba20..bb9bfef174ae 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -459,6 +459,18 @@ static bool mem_avoid_overlap(struct mem_vector *img, is_overlapping =3D true; } =20 + if (ptr->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)ptr->data)->type !=3D SETUP_INDIRECT) { + avoid.start =3D ((struct setup_indirect *)ptr->data)->addr; + avoid.size =3D ((struct setup_indirect *)ptr->data)->len; + + if (mem_overlaps(img, &avoid) && (avoid.start < earliest)) { + *overlap =3D avoid; + earliest =3D overlap->start; + is_overlapping =3D true; + } + } + ptr =3D (struct setup_data *)(unsigned long)ptr->next; } =20 diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/= asm/bootparam.h index dbb41128e5a0..949066b5398a 100644 --- a/arch/x86/include/uapi/asm/bootparam.h +++ b/arch/x86/include/uapi/asm/bootparam.h @@ -2,7 +2,7 @@ #ifndef _ASM_X86_BOOTPARAM_H #define _ASM_X86_BOOTPARAM_H =20 -/* setup_data types */ +/* setup_data/setup_indirect types */ #define SETUP_NONE 0 #define SETUP_E820_EXT 1 #define SETUP_DTB 2 @@ -11,8 +11,10 @@ #define SETUP_APPLE_PROPERTIES 5 #define SETUP_JAILHOUSE 6 =20 -/* max(SETUP_*) */ -#define SETUP_TYPE_MAX SETUP_JAILHOUSE +#define SETUP_INDIRECT (1<<31) + +/* SETUP_INDIRECT | max(SETUP_*) */ +#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_JAILHOUSE) =20 /* ram_size flags */ #define RAMDISK_IMAGE_START_MASK 0x07FF @@ -52,6 +54,14 @@ struct setup_data { __u8 data[0]; }; =20 +/* extensible setup indirect data node */ +struct setup_indirect { + __u32 type; + __u32 reserved; /* Reserved, must be set to zero. */ + __u64 len; + __u64 addr; +}; + struct setup_header { __u8 setup_sects; __u16 root_flags; diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 7da2bcd2b8eb..0bfe9a685b3b 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -999,6 +999,17 @@ void __init e820__reserve_setup_data(void) data =3D early_memremap(pa_data, sizeof(*data)); e820__range_update(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820= _TYPE_RESERVED_KERN); e820__range_update_kexec(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM= , E820_TYPE_RESERVED_KERN); + + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) { + e820__range_update(((struct setup_indirect *)data->data)->addr, + ((struct setup_indirect *)data->data)->len, + E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); + e820__range_update_kexec(((struct setup_indirect *)data->data)->addr, + ((struct setup_indirect *)data->data)->len, + E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); + } + pa_data =3D data->next; early_memunmap(data, sizeof(*data)); } diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c index edaa30b20841..701a98300f86 100644 --- a/arch/x86/kernel/kdebugfs.c +++ b/arch/x86/kernel/kdebugfs.c @@ -44,7 +44,11 @@ static ssize_t setup_data_read(struct file *file, char _= _user *user_buf, if (count > node->len - pos) count =3D node->len - pos; =20 - pa =3D node->paddr + sizeof(struct setup_data) + pos; + pa =3D node->paddr + pos; + + if (!(node->type & SETUP_INDIRECT) || node->type =3D=3D SETUP_INDIRECT) + pa +=3D sizeof(struct setup_data); + p =3D memremap(pa, count, MEMREMAP_WB); if (!p) return -ENOMEM; @@ -108,9 +112,17 @@ static int __init create_setup_data_nodes(struct dentr= y *parent) goto err_dir; } =20 - node->paddr =3D pa_data; - node->type =3D data->type; - node->len =3D data->len; + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) { + node->paddr =3D ((struct setup_indirect *)data->data)->addr; + node->type =3D ((struct setup_indirect *)data->data)->type; + node->len =3D ((struct setup_indirect *)data->data)->len; + } else { + node->paddr =3D pa_data; + node->type =3D data->type; + node->len =3D data->len; + } + create_setup_data_node(d, no, node); pa_data =3D data->next; =20 diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c index 7969da939213..14ef8121aa53 100644 --- a/arch/x86/kernel/ksysfs.c +++ b/arch/x86/kernel/ksysfs.c @@ -100,7 +100,11 @@ static int __init get_setup_data_size(int nr, size_t *= size) if (!data) return -ENOMEM; if (nr =3D=3D i) { - *size =3D data->len; + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) + *size =3D ((struct setup_indirect *)data->data)->len; + else + *size =3D data->len; memunmap(data); return 0; } @@ -130,7 +134,10 @@ static ssize_t type_show(struct kobject *kobj, if (!data) return -ENOMEM; =20 - ret =3D sprintf(buf, "0x%x\n", data->type); + if (data->type =3D=3D SETUP_INDIRECT) + ret =3D sprintf(buf, "0x%x\n", ((struct setup_indirect *)data->data)->ty= pe); + else + ret =3D sprintf(buf, "0x%x\n", data->type); memunmap(data); return ret; } @@ -142,7 +149,7 @@ static ssize_t setup_data_data_read(struct file *fp, loff_t off, size_t count) { int nr, ret =3D 0; - u64 paddr; + u64 paddr, len; struct setup_data *data; void *p; =20 @@ -157,19 +164,28 @@ static ssize_t setup_data_data_read(struct file *fp, if (!data) return -ENOMEM; =20 - if (off > data->len) { + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) { + paddr =3D ((struct setup_indirect *)data->data)->addr; + len =3D ((struct setup_indirect *)data->data)->len; + } else { + paddr +=3D sizeof(*data); + len =3D data->len; + } + + if (off > len) { ret =3D -EINVAL; goto out; } =20 - if (count > data->len - off) - count =3D data->len - off; + if (count > len - off) + count =3D len - off; =20 if (!count) goto out; =20 ret =3D count; - p =3D memremap(paddr + sizeof(*data), data->len, MEMREMAP_WB); + p =3D memremap(paddr, len, MEMREMAP_WB); if (!p) { ret =3D -ENOMEM; goto out; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 77ea96b794bd..4603702dbfc1 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -438,6 +438,10 @@ static void __init memblock_x86_reserve_range_setup_da= ta(void) while (pa_data) { data =3D early_memremap(pa_data, sizeof(*data)); memblock_reserve(pa_data, sizeof(*data) + data->len); + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) + memblock_reserve(((struct setup_indirect *)data->data)->addr, + ((struct setup_indirect *)data->data)->len); pa_data =3D data->next; early_memunmap(data, sizeof(*data)); } diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index a39dcdb5ae34..1ff9c2030b4f 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -626,6 +626,17 @@ static bool memremap_is_setup_data(resource_size_t phy= s_addr, paddr_next =3D data->next; len =3D data->len; =20 + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) { + memunmap(data); + return true; + } + + if (data->type =3D=3D SETUP_INDIRECT && + ((struct setup_indirect *)data->data)->type !=3D SETUP_INDIRECT) { + paddr =3D ((struct setup_indirect *)data->data)->addr; + len =3D ((struct setup_indirect *)data->data)->len; + } + memunmap(data); =20 if ((phys_addr > paddr) && (phys_addr < (paddr + len))) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel