From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195959; cv=none; d=zohomail.com; s=zohoarc; b=UZta0kmh0HBjiM/z1mrAZtonOcmaewqLN9gt5n8sgwIt8rw9XaOm5QBKFxhE2yWoZxRbaDwfLcQXo8t7i+mSehjJBtBvmKRGe4arIpSD7JGs4rLkUdMW0/gfbYe+HLEF/+5asOffXvFRzRrfWmvi9KMiLFh2ZmuFNSlp5diN/Ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195959; h=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=4c9WAF4kmb19tJcbTDjvohxu3kd3fgp5qdmTKmSCTJE=; b=P2KXcHS5DufQ/qji0rJjd3Fpi50BJqmLeeiMmU6ZVNuPAA9cvxG5L7yYBUy3hqwUyosOBiVhaxaZWZZc6Lz8N3KEQtDjm3AozfYMbvcibtGDJeJfx97kUJT9Ti3PeToN/JV6/H525zVhfU3n5Qt2OLJvlFaEXaddLJlLeDEpl1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195959113287.67848673732874; Sat, 1 Jul 2023 00:19:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557771.871399 (Exim 4.92) (envelope-from ) id 1qFUsg-0006cx-Va; Sat, 01 Jul 2023 07:18:54 +0000 Received: by outflank-mailman (output) from mailman id 557771.871399; Sat, 01 Jul 2023 07:18:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsg-0006cq-T3; Sat, 01 Jul 2023 07:18:54 +0000 Received: by outflank-mailman (input) for mailman id 557771; Sat, 01 Jul 2023 07:18:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsf-0006No-Gx for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:53 +0000 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [2607:f8b0:4864:20::22e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 86e20dce-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:18:51 +0200 (CEST) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a1d9b64837so2114109b6e.0 for ; Sat, 01 Jul 2023 00:18:51 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 86e20dce-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195929; x=1690787929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=4c9WAF4kmb19tJcbTDjvohxu3kd3fgp5qdmTKmSCTJE=; b=CrY0CL1mRL0QPuwcnmaQkblnBE5P1R9sxQMKRcx7enujbSgBR6HAPycMDb2gS1AY4c GSMdg9Ho2X7dHe+o+SmkXoOa4APm8vLJjz8ed+7vxoyBsabHF/6zFJRtNNnBW4mZqgs0 /Kh9Zwyvg3GVC2GvbUXvWfC+Zl6imp1Dt83c7Gz7W64GM7H2PsLp9Qawd4CWiMdGbfJ+ 4ZpLlj4Ud3KBQNyr/lOBs7ci3hfKCUjakzYDIIoGJTg8cCPtn9eEPJMUhg1WXlHQsVCH 55FvRh0m8bfNjA2aTWhCErJlfX/ZnGxZaK4J45t8b1wnqNp9Gr9qRZ6PvA6RDY+LPK40 MFzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195929; x=1690787929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4c9WAF4kmb19tJcbTDjvohxu3kd3fgp5qdmTKmSCTJE=; b=SR70FPibjtK197iqGpuAocUm0X2cDizdg/b5smcuB/qjgWHuBK4bf5+aS2eY0Lylm+ tiJArrRTZpqAyauRqBFksKgcXP+gaI7OqOvuG5Gc7tqdP+utbVkifE3QwEuDA0ENiT9c 1sLdARp4psY5vz14g6eXO0L3YFG13DaQHt887/9OqaoFEZqbRQo80OgXw24onADATt7G Bx7eZjln+wMmetrJJ0ovP86NDofQ+2C8LG1JBqVthUBx7VPhiW6ZHuF4uS/QkVG9r95F qgO5o6RfCW4pNvMc5+iqN1E9zKj0dbGez4k5Upe5hoCB7aMjeyna7+qF1TCknygWHq2n pjJw== X-Gm-Message-State: AC+VfDyiX59a5d3b9UJhgPXVnpUgr2rMyZxbvCcIP9j1ob5yiDOH8HQ5 HFYikFMPxGKhnj1eONz4J7MPV9m1Cyc= X-Google-Smtp-Source: ACHHUZ5mpapv9SYTUsV6xBXMbudnVg/NReuMAxR+qtoCnfL+g9iPwcEvsPkpPiGylED5la1TTi9fsw== X-Received: by 2002:a05:6808:1b0c:b0:3a1:b309:a409 with SMTP id bx12-20020a0568081b0c00b003a1b309a409mr6482050oib.4.1688195929359; Sat, 01 Jul 2023 00:18:49 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 01/10] x86 setup: move x86 boot module counting into a new boot_info struct Date: Sat, 1 Jul 2023 00:18:26 -0700 Message-Id: <20230701071835.41599-2-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195961028100003 Content-Type: text/plain; charset="utf-8" An initial step towards a non-multiboot internal representation of boot modules for common code, starting with x86 setup and converting the fields that are accessed for the startup calculations. Introduce a new header, , and populate it with a new boot_info structure initially containing a count of the number of boot modules. The naming of the header, structure and fields is intended to respect the boot structures on Arm -- see arm/include/asm/setup.h -- as part of work towards aligning common architecture-neutral boot logic and structures. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v1: patch is a subset of v1 series patches 2 and 3. xen/arch/x86/setup.c | 58 +++++++++++++++++++++++--------------- xen/include/xen/bootinfo.h | 20 +++++++++++++ 2 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 xen/include/xen/bootinfo.h diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 74e3915a4d..708639b236 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -268,7 +269,16 @@ static int __init cf_check parse_acpi_param(const char= *s) custom_param("acpi", parse_acpi_param); =20 static const module_t *__initdata initial_images; -static unsigned int __initdata nr_initial_images; +static struct boot_info __initdata *boot_info; + +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +{ + static struct boot_info __initdata info; + + info.nr_mods =3D mbi->mods_count; + + boot_info =3D &info; +} =20 unsigned long __init initial_images_nrpages(nodeid_t node) { @@ -277,7 +287,7 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) unsigned long nr; unsigned int i; =20 - for ( nr =3D i =3D 0; i < nr_initial_images; ++i ) + for ( nr =3D i =3D 0; i < boot_info->nr_mods; ++i ) { unsigned long start =3D initial_images[i].mod_start; unsigned long end =3D start + PFN_UP(initial_images[i].mod_end); @@ -293,7 +303,7 @@ void __init discard_initial_images(void) { unsigned int i; =20 - for ( i =3D 0; i < nr_initial_images; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { uint64_t start =3D (uint64_t)initial_images[i].mod_start << PAGE_S= HIFT; =20 @@ -301,7 +311,7 @@ void __init discard_initial_images(void) start + PAGE_ALIGN(initial_images[i].mod_end)); } =20 - nr_initial_images =3D 0; + boot_info->nr_mods =3D 0; initial_images =3D NULL; } =20 @@ -1020,6 +1030,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod =3D __va(mbi->mods_addr); } =20 + multiboot_to_bootinfo(mbi); + loader =3D (mbi->flags & MBI_LOADERNAME) ? (char *)__va(mbi->boot_loader_name) : "unknown"; =20 @@ -1127,18 +1139,18 @@ void __init noreturn __start_xen(unsigned long mbi_= p) bootsym(boot_edd_info_nr)); =20 /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count =3D=3D 0) ) + if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods =3D=3D 0) ) panic("dom0 kernel not specified. Check bootloader configuration\n= "); =20 /* Check that we don't have a silly number of modules. */ - if ( mbi->mods_count > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > sizeof(module_map) * 8 ) { - mbi->mods_count =3D sizeof(module_map) * 8; + boot_info->nr_mods =3D sizeof(module_map) * 8; printk("Excessive multiboot modules - using the first %u only\n", - mbi->mods_count); + boot_info->nr_mods); } =20 - bitmap_fill(module_map, mbi->mods_count); + bitmap_fill(module_map, boot_info->nr_mods); __clear_bit(0, module_map); /* Dom0 kernel is always first */ =20 if ( pvh_boot ) @@ -1311,9 +1323,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) kexec_reserve_area(&boot_e820); =20 initial_images =3D mod; - nr_initial_images =3D mbi->mods_count; + boot_info->nr_mods =3D boot_info->nr_mods; =20 - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < mbi->mods_count; i++ ) + for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++= ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); @@ -1337,8 +1349,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[mbi->mods_count].mod_start =3D virt_to_mfn(_stext); - mod[mbi->mods_count].mod_end =3D __2M_rwdata_end - _stext; + mod[boot_info->nr_mods].mod_start =3D virt_to_mfn(_stext); + mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 modules_headroom =3D bzimage_headroom(bootstrap_map(mod), mod->mod_end= ); @@ -1398,7 +1410,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end =3D consider_modules(s, e, reloc_size + mask, - mod, mbi->mods_count, -1); + mod, boot_info->nr_mods, -1); end &=3D ~mask; } else @@ -1419,7 +1431,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) } =20 /* Is the region suitable for relocating the multiboot modules? */ - for ( j =3D mbi->mods_count - 1; j >=3D 0; j-- ) + for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { unsigned long headroom =3D j ? 0 : modules_headroom; unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); @@ -1429,7 +1441,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 /* Don't overlap with other modules (or Xen itself). */ end =3D consider_modules(s, e, size, mod, - mbi->mods_count + relocated, j); + boot_info->nr_mods + relocated, j); =20 if ( highmem_start && end > highmem_start ) continue; @@ -1456,7 +1468,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules (or Xen itself). */ e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , mod, - mbi->mods_count + relocated, -1); + boot_info->nr_mods + relocated, -1); if ( s >=3D e ) break; if ( e > kexec_crash_area_limit ) @@ -1471,7 +1483,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 if ( modules_headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); - for ( i =3D 0; i < mbi->mods_count; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; =20 @@ -1540,7 +1552,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) ASSERT(j); } map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; - for ( j =3D 0; j < mbi->mods_count; ++j ) + for ( j =3D 0; j < boot_info->nr_mods; ++j ) { uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + mod[j].mod_end; @@ -1616,7 +1628,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) } } =20 - for ( i =3D 0; i < mbi->mods_count; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { set_pdx_range(mod[i].mod_start, mod[i].mod_start + PFN_UP(mod[i].mod_end)); @@ -1999,8 +2011,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, mbi->mods_count); - if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) + initrdidx =3D find_first_bit(module_map, boot_info->nr_mods); + if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2010,7 +2022,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * above our heap. The second module, if present, is an initrd ramdisk. */ dom0 =3D create_dom0(mod, modules_headroom, - initrdidx < mbi->mods_count ? mod + initrdidx : NUL= L, + initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h new file mode 100644 index 0000000000..6a7d55d20e --- /dev/null +++ b/xen/include/xen/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __XEN_BOOTINFO_H__ +#define __XEN_BOOTINFO_H__ + +#include + +struct boot_info { + unsigned int nr_mods; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195964; cv=none; d=zohomail.com; s=zohoarc; b=aW49raWWPLf5x+jBng38IJDwLZVl0kLcGSxSvjh4HGEMpbF+xs7F/EeEPf1xw8oKg0IEMP3wxwU3WBLD+whUPorcNqehv/P51amR5bgyEDBgrs5Zp9kp2z5Pzk5AN+ox70rM6LHN+NNzQ8LpSDxF/y1U+qXiUwrdnFdTbQX9/4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195964; h=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=Y6HSin/PPuTe3wUBWgklxdNFxDnMlcE+0e39paE0fXc=; b=hZ6Zu7zBSt8JRxZfy2bNiw3FvaFQUquwj9y7P9/Wgqob6X4DhjffflAOVLFgdlxHM8MbDCxfJca/QnvCTac6tuqyaBWKKRQdkvlFODhkCqFrCj8mvvC+tDEOAbj6ihZf6unINfBkXg0vVcr6uIaazkfoYdJs0tY3A8SiLCUTg/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195964893551.2569274257316; Sat, 1 Jul 2023 00:19:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557772.871410 (Exim 4.92) (envelope-from ) id 1qFUsi-0006sV-Cc; Sat, 01 Jul 2023 07:18:56 +0000 Received: by outflank-mailman (output) from mailman id 557772.871410; Sat, 01 Jul 2023 07:18:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsi-0006sI-9F; Sat, 01 Jul 2023 07:18:56 +0000 Received: by outflank-mailman (input) for mailman id 557772; Sat, 01 Jul 2023 07:18:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsg-0006No-Gx for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:54 +0000 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [2607:f8b0:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 87ad859c-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:18:52 +0200 (CEST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6687446eaccso2060682b3a.3 for ; Sat, 01 Jul 2023 00:18:52 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:49 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 87ad859c-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195930; x=1690787930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Y6HSin/PPuTe3wUBWgklxdNFxDnMlcE+0e39paE0fXc=; b=rsJIkClYspba3EEC1R7kK3NAtOk5jq9qbQKs6V3a1+OyaOU9EdE4lyaLRwCxYjjR5y waqpW/joeTxkdrxBi10PoK/AZjaG5MFU0TAC4LNcWBKn/PdHFbpAAomjyxPEv6v8d6Wc My/L3c/7RcgdXVx8B4gdBlsXxc3Kyv5vQA3JMgm+XixOc9HLxFkHCAmkV/0cvQs3bmfF deiblMs2mJRWQ7elSOZskM4iJObW2t7Xd8DwX7/zQtYw3KUtyw9NnAup3AVYAzNlHXKQ eX9C1FZmaQKqFUMAAfRY08tDeXn8UUqcTPaQmf6U/vydMK1vxc+SUhlED09efS3rWVsM a/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195930; x=1690787930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Y6HSin/PPuTe3wUBWgklxdNFxDnMlcE+0e39paE0fXc=; b=E/UuqHWhozUqX7eS/KnX0J7d5LjhTtQfG+MHTtD8xQpvICPYsOrN1EjbdotvgZFLyz frB2sMfEr5L896R7go33msGrw2Ge4XJuGZ18nC4f98Ft66gDNEEaSzS4+33ziKhRaeQd VOFonzS0pHphu3y8JY/LwKX8cOzMtBZnFR59HmVCLUCIZ2fydoGyjtOTkXuYe38K9KHS qco0w9MHe5vpG/KckdRI935qgkRXpCj+5IXCw3gGXAeki2SS5By/lSiMMqg/IlDWMFiI Rr9tp1YMgWZ4lYA9zQ37X+fChUb0jFWPOhxO9ZSqYUifEkmtyh5gjRxveh+/WvO01/cp MSVw== X-Gm-Message-State: ABy/qLaSAYxV1Qs7XMUcnRwz34tjvR57xcLzRBH1GF7b887T4SWpT/5K p6R4uNAq1WxwJi6vi6xuYmZm2seU060= X-Google-Smtp-Source: APBJJlGazLVsxb16uFiIRgEsb22Vr4uL3fUVX8OBI0LxxvRLHfsnva3PurQ+L5rtOrS/CANPnVhzgw== X-Received: by 2002:a05:6a00:24c9:b0:682:37be:c9fe with SMTP id d9-20020a056a0024c900b0068237bec9femr6300448pfv.10.1688195930443; Sat, 01 Jul 2023 00:18:50 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 02/10] x86 setup: per-arch bootmodule structure, headroom field Date: Sat, 1 Jul 2023 00:18:27 -0700 Message-Id: <20230701071835.41599-3-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195966623100005 Content-Type: text/plain; charset="utf-8" Next step in incremental work towards adding a non-multiboot internal representation of boot modules, converting the fields being accessed for the startup calculations. Add a new array of structs for per-boot-module state, though only allocate space for a single array entry in this change since that is all that is required for functionality modified in this patch: moving the headroom field for the image decompression calculation into a new per-arch boot module struct and then using it in x86 dom0 construction. Introduces a per-arch header for x86 for arch-specific boot module structures, and add a member to the common boot module structure for access to it. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v1: patch is a subset of v1 series patches 2 and 3. xen/arch/x86/bzimage.c | 10 +++++----- xen/arch/x86/hvm/dom0_build.c | 3 ++- xen/arch/x86/include/asm/bootinfo.h | 18 ++++++++++++++++++ xen/arch/x86/include/asm/bzimage.h | 2 +- xen/arch/x86/pv/dom0_build.c | 3 ++- xen/arch/x86/setup.c | 23 ++++++++++++++++------- xen/include/xen/bootinfo.h | 11 +++++++++++ 7 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootinfo.h diff --git a/xen/arch/x86/bzimage.c b/xen/arch/x86/bzimage.c index ac4fd428be..dac2399b89 100644 --- a/xen/arch/x86/bzimage.c +++ b/xen/arch/x86/bzimage.c @@ -69,8 +69,6 @@ static __init int bzimage_check(struct setup_header *hdr,= unsigned long len) return 1; } =20 -static unsigned long __initdata orig_image_len; - unsigned long __init bzimage_headroom(void *image_start, unsigned long image_length) { @@ -91,7 +89,6 @@ unsigned long __init bzimage_headroom(void *image_start, if ( elf_is_elfbinary(image_start, image_length) ) return 0; =20 - orig_image_len =3D image_length; headroom =3D output_length(image_start, image_length); if (gzip_check(image_start, image_length)) { @@ -105,11 +102,14 @@ unsigned long __init bzimage_headroom(void *image_sta= rt, } =20 int __init bzimage_parse(void *image_base, void **image_start, + unsigned int headroom, unsigned long *image_len) { struct setup_header *hdr =3D (struct setup_header *)(*image_start); int err =3D bzimage_check(hdr, *image_len); - unsigned long output_len; + unsigned long output_len, orig_image_len; + + orig_image_len =3D *image_len - headroom; =20 if ( err < 0 ) return err; @@ -125,7 +125,7 @@ int __init bzimage_parse(void *image_base, void **image= _start, =20 BUG_ON(!(image_base < *image_start)); =20 - output_len =3D output_length(*image_start, orig_image_len); + output_len =3D output_length(*image_start, *image_len); =20 if ( (err =3D perform_gunzip(image_base, *image_start, orig_image_len)= ) > 0 ) err =3D decompress(*image_start, orig_image_len, image_base); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index fd2cbf68bc..bf08998862 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -545,7 +545,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, struct vcpu *v =3D d->vcpu[0]; int rc; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) + if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + &image_len)) !=3D 0 ) { printk("Error trying to detect bz compressed kernel\n"); return rc; diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h new file mode 100644 index 0000000000..a25054f372 --- /dev/null +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -0,0 +1,18 @@ +#ifndef __ARCH_X86_BOOTINFO_H__ +#define __ARCH_X86_BOOTINFO_H__ + +struct arch_bootmodule { + unsigned headroom; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/bzimage.h b/xen/arch/x86/include/asm/= bzimage.h index 7ed69d3910..dd784f32ef 100644 --- a/xen/arch/x86/include/asm/bzimage.h +++ b/xen/arch/x86/include/asm/bzimage.h @@ -5,7 +5,7 @@ =20 unsigned long bzimage_headroom(void *image_start, unsigned long image_leng= th); =20 -int bzimage_parse(void *image_base, void **image_start, +int bzimage_parse(void *image_base, void **image_start, unsigned int headr= oom, unsigned long *image_len); =20 #endif /* __X86_BZIMAGE_H__ */ diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index c99135a552..6ed9f8bbed 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -416,7 +416,8 @@ int __init dom0_construct_pv(struct domain *d, =20 d->max_pages =3D ~0U; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) + if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + &image_len)) !=3D 0 ) return rc; =20 if ( (rc =3D elf_init(&elf, image_start, image_len)) !=3D 0 ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 708639b236..c0e8fc6ab7 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -273,10 +273,16 @@ static struct boot_info __initdata *boot_info; =20 static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) { - static struct boot_info __initdata info; + static struct boot_info __initdata info; + static struct boot_module __initdata boot_mods[1]; + static struct arch_bootmodule __initdata arch_boot_mods[1]; + + info.mods =3D boot_mods; =20 info.nr_mods =3D mbi->mods_count; =20 + boot_mods[0].arch =3D &arch_boot_mods[0]; + boot_info =3D &info; } =20 @@ -961,7 +967,8 @@ static struct domain *__init create_dom0(const module_t= *image, write_cr4(read_cr4() & ~X86_CR4_SMAP); } =20 - if ( construct_dom0(d, image, headroom, initrd, cmdline) !=3D 0 ) + if ( construct_dom0(d, image, boot_info->mods[0].arch->headroom, initr= d, + cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 if ( cpu_has_smap ) @@ -985,7 +992,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked =3D 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; + unsigned long nr_pages, raw_max_page, module_map[1]; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1353,7 +1360,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 - modules_headroom =3D bzimage_headroom(bootstrap_map(mod), mod->mod_end= ); + boot_info->mods[0].arch->headroom =3D bzimage_headroom(bootstrap_map(m= od), + mod->mod_end); bootstrap_map(NULL); =20 #ifndef highmem_start @@ -1433,7 +1441,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Is the region suitable for relocating the multiboot modules? */ for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { - unsigned long headroom =3D j ? 0 : modules_headroom; + struct boot_module *boot_mods =3D boot_info->mods; + unsigned long headroom =3D j ? 0 : boot_mods[0].arch->headroom; unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); =20 if ( mod[j].reserved ) @@ -1481,7 +1490,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) #endif } =20 - if ( modules_headroom && !mod->reserved ) + if ( boot_info->mods[0].arch->headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < boot_info->nr_mods; ++i ) { @@ -2021,7 +2030,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, modules_headroom, + dom0 =3D create_dom0(mod, boot_info->mods[0].arch->headroom, initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, kextra, loader); if ( !dom0 ) diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 6a7d55d20e..b72ae31a66 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -3,8 +3,19 @@ =20 #include =20 +#ifdef CONFIG_X86 +#include +#else + struct arch_bootmodule { }; +#endif + +struct boot_module { + struct arch_bootmodule *arch; +}; + struct boot_info { unsigned int nr_mods; + struct boot_module *mods; }; =20 #endif --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195957; cv=none; d=zohomail.com; s=zohoarc; b=XXNGsS2GiRhHGUooIHxzptQcC866Edf5v9bX0FyRHAr8HxzG7momQdgh3j4QAczLlpJ7m/NnWgr28eNmjEx2FWdLC6JtOoIjixbIvbAgZErUauMkn9GHWb1uUE+Ylk1z2bas2ooBqH5HZXsjJZGjmEluOt38K6fQCnsIC+dzYbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195957; h=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=VZN0HVDL3v266tIzCxp1Au3MTDvSJDRQFEKwXgYQOKg=; b=MBa9sXXQwVVgLBnY2uPo84D3p3PzItcW5OxcQ4HxKXKQXyRx2f8ErLEFXgPLxAnhEpI3iAEpXBob822FK7HW2458EjYsLT7pdJrdjDneeoRiIR4ksS/mBQmrdwfe9UGeUHh2y0VXM/ObglHm8clJBgmv6BSgluUmPwTCfU+blgQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195957763174.83952077082665; Sat, 1 Jul 2023 00:19:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557773.871420 (Exim 4.92) (envelope-from ) id 1qFUsj-00078X-La; Sat, 01 Jul 2023 07:18:57 +0000 Received: by outflank-mailman (output) from mailman id 557773.871420; Sat, 01 Jul 2023 07:18:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsj-00077S-Go; Sat, 01 Jul 2023 07:18:57 +0000 Received: by outflank-mailman (input) for mailman id 557773; Sat, 01 Jul 2023 07:18:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsh-0006No-Hn for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:55 +0000 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [2607:f8b0:4864:20::435]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 885db715-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:18:53 +0200 (CEST) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666e6541c98so2162693b3a.2 for ; Sat, 01 Jul 2023 00:18:53 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 885db715-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195932; x=1690787932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=VZN0HVDL3v266tIzCxp1Au3MTDvSJDRQFEKwXgYQOKg=; b=YpX7sawsKZYhNUkXDrP6r+4b0ejLipURz01felmUeInxxsFgxrRszTnLYke1My3tUF 07LH6tcTz2c2CX3LDds0yu7k5LeZO8mi3Xs1B8NEhbf5U8XuO713vF8UKegIVWbRGkPo tTagkO4t7k+a8h23i2OXydHe/qLeHvgvYpA+CqIkGzxMbpDy6e8B8DwvEyHV88NA+Nsj Q4BA1MovO51sb5uLAa5vKGi6o9qcZtZHNCDpjxPBBWlmzHA3R6NyeKfMwsWrzPEt/TJp j0nwnTCn+yOhFyHjujJ70n+JvuUyTED5o59t9ykYnNKsg0CxJZDewB8vVRxgmIuSnxjV s1pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195932; x=1690787932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VZN0HVDL3v266tIzCxp1Au3MTDvSJDRQFEKwXgYQOKg=; b=VubMhGoR5sLZvesgzl4NarPaQ/FN3m/9Ro3fsTcfH9VZIOAUaDfpAaTlMyzFdb4bUE jHTWLBJ+EglgrN+ywNYnHLZp/I1WUeeHwTaLPPQlE9qLZUBaeR7rPhnMptdQs5J9OP0I ctLwZP3wu4mNUj6XoieFG1OFBQKSypjbM1ATxcUMpPVmiqyWjQ0nfxzvH7HB0VHTA5ig lpjfJw07/b208Ihl+ooGo0RDN559iDHopA3OceklifHGVmdJN5e/Rn8DdczxfcUHZCrc 9gY7wQOTQp+4RWiEd66UzWXQ9i4ckRJZ2krAbS8RtiQ0VL0SGvsKvLP3VF5MWgi0gKcH V2Cw== X-Gm-Message-State: AC+VfDy+lc/itCuWmyEOHDFBaXpfU3u0BBxTctuPhW9LchB7LWG+ZGhv mHlWjBNg6/X+t4Tth3KTGWq2QnZYTaA= X-Google-Smtp-Source: ACHHUZ6n2a0BgJsHOuyBxhZoYcbAmTWwBgBp7Scj2tR+LuLllrO5p7qgwk+xteUe1+RZDeaLy+AScQ== X-Received: by 2002:a05:6a20:448:b0:126:a5e3:3938 with SMTP id b8-20020a056a20044800b00126a5e33938mr4329586pzb.19.1688195931673; Sat, 01 Jul 2023 00:18:51 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 03/10] x86 setup: change bootstrap map to accept new boot module structures Date: Sat, 1 Jul 2023 00:18:28 -0700 Message-Id: <20230701071835.41599-4-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195959079100001 Content-Type: text/plain; charset="utf-8" To convert the x86 boot logic from multiboot to boot module structures, change the bootstrap map function to accept a boot module parameter. To allow incremental change from multiboot to boot modules across all x86 setup logic, provide a temporary inline wrapper that still accepts a multiboot module parameter and use it where necessary. The wrapper is placed in a new arch/x86 header to avoid putting a static inline function into an existing header that has no such functions already. This new header will be expanded with additional functions in subsequent patches in this series. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- A new patch so v1 series patch 3 can be implemented incrementally instead. xen/arch/x86/cpu/microcode/core.c | 7 ++++--- xen/arch/x86/hvm/dom0_build.c | 4 +++- xen/arch/x86/include/asm/boot.h | 32 +++++++++++++++++++++++++++++++ xen/arch/x86/include/asm/setup.h | 3 ++- xen/arch/x86/pv/dom0_build.c | 3 ++- xen/arch/x86/setup.c | 18 +++++++++-------- xen/include/xen/bootinfo.h | 3 +++ xen/xsm/xsm_policy.c | 3 ++- 8 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/include/asm/boot.h diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index c3fee62906..ce3c8042a2 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -34,6 +34,7 @@ #include =20 #include +#include #include #include #include @@ -180,7 +181,7 @@ void __init microcode_scan_module( if ( !test_bit(i, module_map) ) continue; =20 - _blob_start =3D bootstrap_map(&mod[i]); + _blob_start =3D bootstrap_map_multiboot(&mod[i]); _blob_size =3D mod[i].mod_end; if ( !_blob_start ) { @@ -798,7 +799,7 @@ int __init microcode_init_cache(unsigned long *module_m= ap, microcode_scan_module(module_map, mbi); =20 if ( ucode_mod.mod_end ) - rc =3D early_update_cache(bootstrap_map(&ucode_mod), + rc =3D early_update_cache(bootstrap_map_multiboot(&ucode_mod), ucode_mod.mod_end); else if ( ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); @@ -821,7 +822,7 @@ static int __init early_microcode_update_cpu(void) else if ( ucode_mod.mod_end ) { len =3D ucode_mod.mod_end; - data =3D bootstrap_map(&ucode_mod); + data =3D bootstrap_map_multiboot(&ucode_mod); } =20 if ( !data ) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index bf08998862..56fe89632b 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -16,6 +16,7 @@ =20 #include =20 +#include #include #include #include @@ -1208,7 +1209,8 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map= (image), + rc =3D pvh_load_kernel(d, image, image_headroom, initrd, + bootstrap_map_multiboot(image), cmdline, &entry, &start_info); if ( rc ) { diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h new file mode 100644 index 0000000000..10b17f12b2 --- /dev/null +++ b/xen/arch/x86/include/asm/boot.h @@ -0,0 +1,32 @@ +#ifndef __ASM_X86_BOOT_H__ +#define __ASM_X86_BOOT_H__ + +#include +#include + +#include + +static inline void *bootstrap_map_multiboot(const module_t *mod) +{ + struct boot_module bm; + + if ( !mod ) + return bootstrap_map(NULL); + + bm.start =3D mod->mod_start << PAGE_SHIFT; + bm.size =3D mod->mod_end; + + return bootstrap_map(&bm); +} + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index ae0dd3915a..80d0bb2a21 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -1,6 +1,7 @@ #ifndef __X86_SETUP_H_ #define __X86_SETUP_H_ =20 +#include #include #include =20 @@ -40,7 +41,7 @@ void setup_io_bitmap(struct domain *d); =20 unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); -void *bootstrap_map(const module_t *mod); +void *bootstrap_map(const struct boot_module *mod); =20 int xen_in_range(unsigned long mfn); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 6ed9f8bbed..4fe806b60d 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -14,6 +14,7 @@ #include #include =20 +#include #include #include #include @@ -374,7 +375,7 @@ int __init dom0_construct_pv(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map(image); + void *image_base =3D bootstrap_map_multiboot(image); unsigned long image_len =3D image->mod_end; void *image_start =3D image_base + image_headroom; unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c0e8fc6ab7..3b623a4149 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include #include @@ -405,14 +406,14 @@ static void __init normalise_cpu_order(void) * Ensure a given physical memory range is present in the bootstrap mappin= gs. * Use superpage mappings to ensure that pagetable memory needn't be alloc= ated. */ -void *__init bootstrap_map(const module_t *mod) +void *__init bootstrap_map(const struct boot_module *mod) { static unsigned long __initdata map_cur =3D BOOTSTRAP_MAP_BASE; uint64_t start, end, mask =3D (1L << L2_PAGETABLE_SHIFT) - 1; void *ret; =20 if ( system_state !=3D SYS_STATE_early_boot ) - return mod ? mfn_to_virt(mod->mod_start) : NULL; + return mod ? maddr_to_virt(mod->start) : NULL; =20 if ( !mod ) { @@ -421,8 +422,8 @@ void *__init bootstrap_map(const module_t *mod) return NULL; } =20 - start =3D (uint64_t)mod->mod_start << PAGE_SHIFT; - end =3D start + mod->mod_end; + start =3D (uint64_t)mod->start; + end =3D start + mod->size; if ( start >=3D end ) return NULL; =20 @@ -460,7 +461,7 @@ static void __init move_memory( if ( mod.mod_end > blksz ) mod.mod_end =3D blksz; sz =3D mod.mod_end - soffs; - s =3D bootstrap_map(&mod); + s =3D bootstrap_map_multiboot(&mod); =20 mod.mod_start =3D (dst - doffs) >> PAGE_SHIFT; mod.mod_end =3D doffs + size; @@ -468,7 +469,7 @@ static void __init move_memory( mod.mod_end =3D blksz; if ( sz > mod.mod_end - doffs ) sz =3D mod.mod_end - doffs; - d =3D bootstrap_map(&mod); + d =3D bootstrap_map_multiboot(&mod); =20 memmove(d + doffs, s + soffs, sz); =20 @@ -1360,8 +1361,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 - boot_info->mods[0].arch->headroom =3D bzimage_headroom(bootstrap_map(m= od), - mod->mod_end); + boot_info->mods[0].arch->headroom =3D + bzimage_headroom(bootstrap_map_multiboot(mod), mod->mod_end); + bootstrap_map(NULL); =20 #ifndef highmem_start diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index b72ae31a66..eb93cc3439 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -10,6 +10,9 @@ #endif =20 struct boot_module { + paddr_t start; + size_t size; + struct arch_bootmodule *arch; }; =20 diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc9381..c6df8c6e06 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -20,6 +20,7 @@ =20 #include #ifdef CONFIG_MULTIBOOT +#include #include #include #endif @@ -49,7 +50,7 @@ int __init xsm_multiboot_policy_init( if ( !test_bit(i, module_map) ) continue; =20 - _policy_start =3D bootstrap_map(mod + i); + _policy_start =3D bootstrap_map_multiboot(mod + i); _policy_len =3D mod[i].mod_end; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195970; cv=none; d=zohomail.com; s=zohoarc; b=NeAFMDCweghYmIM2NthEs4clDgmsIzyKzAxWmXwaTBhmb+TMvkxKQeaC8zlf+FiJyJhEXaJeEplG9k6Ko/fZeujJ/eTAkmAFxeQ6eXuhiaxmAJi30F7dZ9QK11hp+grUGCD3rZChnFrZaTReqZ6UCd1QYLA4hLE0/MzK2qfNLEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195970; h=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=VdOYeE2v8wd7pgUEWtK6DPA0Re6RRRDIL0/eXfCMrB4=; b=JZJmGV2yVhcLBP9ss1HhGt2+FakTPt5DhmX5AI79iftbE8jqmJcOWNPJaTPdKI0hPq3HuAog90YkuoDn+1PCBEAsUMsGX2x4IZFHf4PJgxFSeF2JI0I5OyY5MDpX4ygRXSvI6zEPgJqJLz1BealNwa/sxnaVrpgJYcJW7L1C80I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195970742945.5753021323154; Sat, 1 Jul 2023 00:19:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557774.871430 (Exim 4.92) (envelope-from ) id 1qFUsl-0007Re-Vg; Sat, 01 Jul 2023 07:18:59 +0000 Received: by outflank-mailman (output) from mailman id 557774.871430; Sat, 01 Jul 2023 07:18:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsl-0007RH-Q2; Sat, 01 Jul 2023 07:18:59 +0000 Received: by outflank-mailman (input) for mailman id 557774; Sat, 01 Jul 2023 07:18:57 +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 1qFUsj-00074A-Ev for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:57 +0000 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [2607:f8b0:4864:20::52e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 895951b8-17df-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 09:18:55 +0200 (CEST) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-54290603887so1404339a12.1 for ; Sat, 01 Jul 2023 00:18:55 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 895951b8-17df-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195933; x=1690787933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=VdOYeE2v8wd7pgUEWtK6DPA0Re6RRRDIL0/eXfCMrB4=; b=M26WsnkTZSOxTGNSkakaGyhkyNClmHwRJrKRp1N75lO7bD5GT6kPQALOP7zlWX7gKm I3KG2qmBZpmrOKz8R14XWa+tidHoDNawk/qGcYhzw/FJi3lqHtuZVKeWo47H+jfSHn5E XdU1+g2puyG9SktPWFJmJjYeZNpGQ155oZWd3UghsHDEyUDDiankrfReLoBSsfG4D8a7 hFkpcBSo6jCP/SWCkH28CA4vtBSSpho+IqcadOHA8DkY5zXLdaiZUvOfGKu+ZChE+GIT TPcRE9N2VFQ+dq9Ou0ANf/E0ivSit7ow6HZv6spzaxuI/gregJW9UO5G9jpxRU7U1Oae IKeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195933; x=1690787933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VdOYeE2v8wd7pgUEWtK6DPA0Re6RRRDIL0/eXfCMrB4=; b=c/pwCAhKi7Nqn+jX5gS/jpyYfZC5hdtDKdZHPBp4jky+IllYOlgspCe7a9ypV8YLLg B4Y0A9Hm2bKX6Dz2YdVYl69LRMdAyDDsiKuwpzxU0GGpTTIGRFGHXdImi51dfbzPehpQ Wjv7hdrrIPFp3ihax1prkx4SprCvd2GlkTYZBCUKp6RzWBHyL1bXnHfOrVqf86GMaXrF aOGV0V/Y9hW5bzMeUlJ52QcZ8pu8Xz4ExMBMKbCp0572/wf9d8cB2K7ux5dh0au7z3ZS oTJ1GPuRZxqTuVkqJYI8mWK/tjI5WSevPivopuEOur+fjxCdhVmIiWes6rpgnxZkdf4e R1jw== X-Gm-Message-State: ABy/qLb53kvM6pA0WLqbPI4/8bTijooSvHshTWVDRU9OT4IQEzei2x7f IXn6Wr3KyZ6EGeQSEPED9uNfhiKZk1Q= X-Google-Smtp-Source: APBJJlF7jbiJpd/xcLRqHauN6U7/NRmIJP9XETRlf0zI9EMG4ip+NRTzFW0GrgaAnu8NEOSFJHXePg== X-Received: by 2002:a05:6a00:190c:b0:682:1319:a169 with SMTP id y12-20020a056a00190c00b006821319a169mr4904419pfi.31.1688195933125; Sat, 01 Jul 2023 00:18:53 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 04/10] x86 setup: porting dom0 construction logic to boot module structures Date: Sat, 1 Jul 2023 00:18:29 -0700 Message-Id: <20230701071835.41599-5-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195973131100014 Content-Type: text/plain; charset="utf-8" Adjust the PV and PVH dom0 construction entry points to take boot module structures as parameters, and add further fields to the boot module structures to plumb the data needed to support this use. Populate these from the multiboot module data. This change removes multiboot from the PV and PVH dom0 construction logic. Introduce and use new inline accessor functions for navigating the boot module structures. The per-boot-module arrays are expanded from singletons to accommodate all modules, up to a static maximum of 64 modules including Xen that can be accepted from a bootloader to match the previous value from the module map check. The field that identifies the type of a boot module (kernel, ramdisk, etc) is introduced to the common boot module structure and declared as a non-enum integer type to allow the field to be of a known-size and so structure can be packed in a subsequent patch in the series, and it will then be reconciled with the equivalent Arm boot field type. The command line provided by multiboot for each boot module is added directly to the boot_module structure, which is appropriate for this logic just replacing multiboot. The maximum number of boot modules that a bootloader can provide in addition to the Xen hypervisor is preserved from prior logic with the module_map at 63. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v1: patch is a subset of v1 series patches 2 and 3. - The module_map is kept for now since still in use. - Move the static inline functions into a separate dedicated header. - and replace prior inclusion of for simpler dependencies. xen/arch/x86/dom0_build.c | 10 +- xen/arch/x86/hvm/dom0_build.c | 43 +++--- xen/arch/x86/include/asm/boot.h | 36 +++++ xen/arch/x86/include/asm/bootinfo.h | 24 +++ xen/arch/x86/include/asm/dom0_build.h | 13 +- xen/arch/x86/include/asm/setup.h | 4 +- xen/arch/x86/pv/dom0_build.c | 32 ++-- xen/arch/x86/setup.c | 206 +++++++++++++++----------- xen/include/xen/bootinfo.h | 27 ++++ 9 files changed, 254 insertions(+), 141 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 9f5300a3ef..42310202a2 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -4,6 +4,7 @@ * Copyright (c) 2002-2005, K A Fraser */ =20 +#include #include #include #include @@ -562,9 +563,8 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct domain *d, const module_t *image, - unsigned long image_headroom, module_t *initrd, - char *cmdline) +int __init construct_dom0(struct domain *d, const struct boot_module *imag= e, + struct boot_module *initrd, char *cmdline) { int rc; =20 @@ -576,9 +576,9 @@ int __init construct_dom0(struct domain *d, const modul= e_t *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image, image_headroom, initrd, cmdlin= e); + rc =3D dom0_construct_pvh(d, image, initrd, cmdline); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, image_headroom, initrd, cmdline= ); + rc =3D dom0_construct_pv(d, image, initrd, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 56fe89632b..c094863bb8 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -8,9 +8,9 @@ */ =20 #include +#include #include #include -#include #include #include =20 @@ -530,14 +530,13 @@ static paddr_t __init find_memory( return INVALID_PADDR; } =20 -static int __init pvh_load_kernel(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, void *image_base, - char *cmdline, paddr_t *entry, - paddr_t *start_info_addr) +static int __init pvh_load_kernel( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, void *image_base, char *cmdline, paddr_t *= entry, + paddr_t *start_info_addr) { - void *image_start =3D image_base + image_headroom; - unsigned long image_len =3D image->mod_end; + void *image_start =3D image_base + image->arch->headroom; + unsigned long image_len =3D image->size; struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -546,7 +545,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, struct vcpu *v =3D d->vcpu[0]; int rc; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + if ( (rc =3D bzimage_parse(image_base, &image_start, image->arch->head= room, &image_len)) !=3D 0 ) { printk("Error trying to detect bz compressed kernel\n"); @@ -594,7 +593,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, * simplify it. */ last_addr =3D find_memory(d, &elf, sizeof(start_info) + - (initrd ? ROUNDUP(initrd->mod_end, PAGE_SIZE) + + (initrd ? ROUNDUP(initrd->size, PAGE_SIZE) + sizeof(mod) : 0) + (cmdline ? ROUNDUP(strlen(cmdline) + 1, @@ -608,8 +607,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_s= tart), - initrd->mod_end, v); + rc =3D hvm_copy_to_guest_phys(last_addr, maddr_to_virt(initrd->sta= rt), + initrd->size, v); if ( rc ) { printk("Unable to copy initrd to guest\n"); @@ -617,11 +616,11 @@ static int __init pvh_load_kernel(struct domain *d, c= onst module_t *image, } =20 mod.paddr =3D last_addr; - mod.size =3D initrd->mod_end; - last_addr +=3D ROUNDUP(initrd->mod_end, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + mod.size =3D initrd->size; + last_addr +=3D ROUNDUP(initrd->size, elf_64bit(&elf) ? 8 : 4); + if ( initrd->string.len ) { - char *str =3D __va(initrd->string); + char *str =3D initrd->string.bytes; size_t len =3D strlen(str) + 1; =20 rc =3D hvm_copy_to_guest_phys(last_addr, str, len, v); @@ -1176,10 +1175,9 @@ static void __hwdom_init pvh_setup_mmcfg(struct doma= in *d) } } =20 -int __init dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline) +int __init dom0_construct_pvh( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline) { paddr_t entry, start_info; int rc; @@ -1209,9 +1207,8 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, - bootstrap_map_multiboot(image), - cmdline, &entry, &start_info); + rc =3D pvh_load_kernel(d, image, initrd, bootstrap_map(image), cmdline, + &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h index 10b17f12b2..bcf4f2e2e3 100644 --- a/xen/arch/x86/include/asm/boot.h +++ b/xen/arch/x86/include/asm/boot.h @@ -19,6 +19,42 @@ static inline void *bootstrap_map_multiboot(const module= _t *mod) return bootstrap_map(&bm); } =20 +static inline unsigned long bootmodule_index( + const struct boot_info *info, bootmod_type_t bootmod_type, + unsigned long start) +{ + for ( ; start < info->nr_mods; start++ ) + if ( info->mods[start].bootmod_type =3D=3D bootmod_type ) + return start; + + return info->nr_mods + 1; +} + +static inline struct boot_module *bootmodule_next( + const struct boot_info *info, bootmod_type_t bootmod_type) +{ + unsigned long i; + + for ( i =3D 0; i < info->nr_mods; i++ ) + if ( info->mods[i].bootmod_type =3D=3D bootmod_type ) + return &info->mods[i]; + + return NULL; +} + +static inline void bootmodule_update_start(struct boot_module *bm, + paddr_t new_start) +{ + bm->start =3D new_start; + bm->mfn =3D maddr_to_mfn(new_start); +} + +static inline void bootmodule_update_mfn(struct boot_module *bm, mfn_t new= _mfn) +{ + bm->mfn =3D new_mfn; + bm->start =3D mfn_to_maddr(new_mfn); +} + #endif =20 /* diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index a25054f372..30c27980e0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -2,9 +2,33 @@ #define __ARCH_X86_BOOTINFO_H__ =20 struct arch_bootmodule { +#define BOOTMOD_FLAG_X86_RELOCATED 1U << 0 + uint32_t flags; unsigned headroom; }; =20 +struct arch_boot_info { + uint32_t flags; +#define BOOTINFO_FLAG_X86_CMDLINE 1U << 2 +#define BOOTINFO_FLAG_X86_MODULES 1U << 3 +#define BOOTINFO_FLAG_X86_MEMMAP 1U << 6 +#define BOOTINFO_FLAG_X86_LOADERNAME 1U << 9 + + char *boot_loader_name; + + uint32_t mmap_length; + paddr_t mmap_addr; +}; + +struct __packed mb_memmap { + uint32_t size; + uint32_t base_addr_low; + uint32_t base_addr_high; + uint32_t length_low; + uint32_t length_high; + uint32_t type; +}; + #endif =20 /* diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index a5f8c9e67f..ca502269f2 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -1,6 +1,7 @@ #ifndef _DOM0_BUILD_H_ #define _DOM0_BUILD_H_ =20 +#include #include #include =20 @@ -13,15 +14,11 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -int dom0_construct_pv(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline); +int dom0_construct_pv(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline); =20 -int dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline); +int dom0_construct_pvh(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline); =20 unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 80d0bb2a21..2d620d04c7 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -34,8 +34,8 @@ static inline void vesa_init(void) {}; =20 int construct_dom0( struct domain *d, - const module_t *kernel, unsigned long kernel_headroom, - module_t *initrd, + const struct boot_module *kernel, + struct boot_module *initrd, char *cmdline); void setup_io_bitmap(struct domain *d); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 4fe806b60d..bc0af7cf27 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -4,12 +4,12 @@ * Copyright (c) 2002-2005, K A Fraser */ =20 +#include #include #include #include #include #include -#include #include #include #include @@ -356,9 +356,8 @@ static struct page_info * __init alloc_chunk(struct dom= ain *d, } =20 int __init dom0_construct_pv(struct domain *d, - const module_t *image, - unsigned long image_headroom, - module_t *initrd, + const struct boot_module *image, + struct boot_module *initrd, char *cmdline) { int i, rc, order, machine; @@ -375,10 +374,10 @@ int __init dom0_construct_pv(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map_multiboot(image); - unsigned long image_len =3D image->mod_end; - void *image_start =3D image_base + image_headroom; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + void *image_base =3D bootstrap_map(image); + unsigned long image_len =3D image->size; + void *image_start =3D image_base + image->arch->headroom; + unsigned long initrd_len =3D initrd ? initrd->size : 0; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; l2_pgentry_t *l2tab =3D NULL, *l2start =3D NULL; @@ -417,7 +416,7 @@ int __init dom0_construct_pv(struct domain *d, =20 d->max_pages =3D ~0U; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + if ( (rc =3D bzimage_parse(image_base, &image_start, image->arch->head= room, &image_len)) !=3D 0 ) return rc; =20 @@ -612,7 +611,7 @@ int __init dom0_construct_pv(struct domain *d, initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D mfn =3D initrd->mod_start; + initrd_mfn =3D mfn =3D mfn_x(initrd->mfn); count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) @@ -627,12 +626,13 @@ int __init dom0_construct_pv(struct domain *d, free_domheap_pages(page, order); page +=3D 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), + memcpy(page_to_virt(page), maddr_to_virt(initrd->start), initrd_len); - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D (paddr_t)initrd->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); - initrd->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(page)); + bootmodule_update_mfn(initrd, page_to_mfn(page)); + initrd_mfn =3D mfn_x(initrd->mfn); } else { @@ -640,7 +640,7 @@ int __init dom0_construct_pv(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->mod_end =3D 0; + initrd->size =3D 0; =20 iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); @@ -654,7 +654,7 @@ int __init dom0_construct_pv(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D initrd->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -880,7 +880,7 @@ int __init dom0_construct_pv(struct domain *d, if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D initrd->mod_start + (pfn - initrd_pfn); + mfn =3D mfn_x(initrd->mfn) + (pfn - initrd_pfn); else mfn -=3D PFN_UP(initrd_len); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3b623a4149..f9b04daebd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,9 @@ #include #include =20 +/* Max number of boot modules a bootloader can provide in addition to Xen = */ +#define MAX_NR_BOOTMODS 63 + /* opt_nosmp: If true, secondary processors are ignored. */ static bool __initdata opt_nosmp; boolean_param("nosmp", opt_nosmp); @@ -269,20 +273,44 @@ static int __init cf_check parse_acpi_param(const cha= r *s) } custom_param("acpi", parse_acpi_param); =20 -static const module_t *__initdata initial_images; static struct boot_info __initdata *boot_info; =20 -static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *= mods) { static struct boot_info __initdata info; - static struct boot_module __initdata boot_mods[1]; - static struct arch_bootmodule __initdata arch_boot_mods[1]; + static struct arch_boot_info __initdata arch_info; + static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1= ]; + static struct arch_bootmodule __initdata arch_boot_mods[ + MAX_NR_BOOTMODS + 1= ]; =20 + int i; + + info.arch =3D &arch_info; info.mods =3D boot_mods; =20 + info.cmdline =3D __va(mbi->cmdline); + + /* The BOOTINFO_FLAG_X86_* flags are a 1-1 map to MBI_* */ + arch_info.flags =3D mbi->flags; + arch_info.mmap_length =3D mbi->mmap_length; + arch_info.mmap_addr =3D mbi->mmap_addr; + arch_info.boot_loader_name =3D __va(mbi->boot_loader_name); + info.nr_mods =3D mbi->mods_count; + for ( i =3D 0; i <=3D MAX_NR_BOOTMODS; i++ ) + { + boot_mods[i].arch =3D &arch_boot_mods[i]; =20 - boot_mods[0].arch =3D &arch_boot_mods[0]; + if ( i < info.nr_mods ) + { + bootmodule_update_start(&boot_mods[i], mods[i].mod_start); + boot_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + + boot_mods[i].string.len =3D strlcpy(boot_mods[i].string.bytes, + __va(mods[i].string), + BOOTMOD_STRING_MAX_LEN); + } + } =20 boot_info =3D &info; } @@ -296,8 +324,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < boot_info->nr_mods; ++i ) { - unsigned long start =3D initial_images[i].mod_start; - unsigned long end =3D start + PFN_UP(initial_images[i].mod_end); + unsigned long start =3D mfn_x(boot_info->mods[i].mfn); + unsigned long end =3D start + PFN_UP(boot_info->mods[i].size); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -312,14 +340,13 @@ void __init discard_initial_images(void) =20 for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - uint64_t start =3D (uint64_t)initial_images[i].mod_start << PAGE_S= HIFT; + uint64_t start =3D boot_info->mods[i].start; =20 init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(boot_info->mods[i].size)); } =20 boot_info->nr_mods =3D 0; - initial_images =3D NULL; } =20 extern unsigned char __init_begin[], __init_end[]; @@ -450,26 +477,26 @@ static void __init move_memory( =20 while ( size ) { - module_t mod; + struct boot_module mod; unsigned int soffs =3D src & mask; unsigned int doffs =3D dst & mask; unsigned int sz; void *d, *s; =20 - mod.mod_start =3D (src - soffs) >> PAGE_SHIFT; - mod.mod_end =3D soffs + size; - if ( mod.mod_end > blksz ) - mod.mod_end =3D blksz; - sz =3D mod.mod_end - soffs; - s =3D bootstrap_map_multiboot(&mod); - - mod.mod_start =3D (dst - doffs) >> PAGE_SHIFT; - mod.mod_end =3D doffs + size; - if ( mod.mod_end > blksz ) - mod.mod_end =3D blksz; - if ( sz > mod.mod_end - doffs ) - sz =3D mod.mod_end - doffs; - d =3D bootstrap_map_multiboot(&mod); + mod.start =3D src - soffs; + mod.size =3D soffs + size; + if ( mod.size > blksz ) + mod.size =3D blksz; + sz =3D mod.size - soffs; + s =3D bootstrap_map(&mod); + + mod.start =3D dst - doffs; + mod.size =3D doffs + size; + if ( mod.size > blksz ) + mod.size =3D blksz; + if ( sz > mod.size - doffs ) + sz =3D mod.size - doffs; + d =3D bootstrap_map(&mod); =20 memmove(d + doffs, s + soffs, sz); =20 @@ -602,7 +629,7 @@ static void __init noinline move_xen(void) #undef BOOTSTRAP_MAP_LIMIT =20 static uint64_t __init consider_modules( - uint64_t s, uint64_t e, uint32_t size, const module_t *mod, + uint64_t s, uint64_t e, uint32_t size, const struct boot_module *mod, unsigned int nr_mods, unsigned int this_mod) { unsigned int i; @@ -612,8 +639,8 @@ static uint64_t __init consider_modules( =20 for ( i =3D 0; i < nr_mods ; ++i ) { - uint64_t start =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; - uint64_t end =3D start + PAGE_ALIGN(mod[i].mod_end); + uint64_t start =3D mod[i].start; + uint64_t end =3D start + PAGE_ALIGN(mod[i].size); =20 if ( i =3D=3D this_mod ) continue; @@ -883,9 +910,8 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kex= tra, +static struct domain *__init create_dom0(const struct boot_info *bootinfo, + const char *kextra, const char *loader) { struct xen_domctl_createdomain dom0_cfg =3D { @@ -899,9 +925,14 @@ static struct domain *__init create_dom0(const module_= t *image, .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + struct boot_module *image =3D bootmodule_next(bootinfo, BOOTMOD_KERNEL= ); + struct boot_module *initrd =3D bootmodule_next(bootinfo, BOOTMOD_RAMDI= SK); struct domain *d; char *cmdline; - domid_t domid; + domid_t domid =3D 0; + + if ( image =3D=3D NULL ) + panic("Error creating d%uv0\n", domid); =20 if ( opt_dom0_pvh ) { @@ -928,7 +959,7 @@ static struct domain *__init create_dom0(const module_t= *image, panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - cmdline =3D image->string ? __va(image->string) : NULL; + cmdline =3D image->string.len ? image->string.bytes : NULL; if ( cmdline || kextra ) { static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; @@ -968,8 +999,7 @@ static struct domain *__init create_dom0(const module_t= *image, write_cr4(read_cr4() & ~X86_CR4_SMAP); } =20 - if ( construct_dom0(d, image, boot_info->mods[0].arch->headroom, initr= d, - cmdline) !=3D 0 ) + if ( construct_dom0(d, image, initrd, cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 if ( cpu_has_smap ) @@ -1038,14 +1068,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) mod =3D __va(mbi->mods_addr); } =20 - multiboot_to_bootinfo(mbi); + multiboot_to_bootinfo(mbi, mod); =20 - loader =3D (mbi->flags & MBI_LOADERNAME) - ? (char *)__va(mbi->boot_loader_name) : "unknown"; + loader =3D (boot_info->arch->flags & BOOTINFO_FLAG_X86_LOADERNAME) + ? boot_info->arch->boot_loader_name : "unknown"; =20 /* Parse the command-line options. */ - cmdline =3D cmdline_cook((mbi->flags & MBI_CMDLINE) ? - __va(mbi->cmdline) : NULL, + cmdline =3D cmdline_cook((boot_info->arch->flags & BOOTINFO_FLAG_X86_C= MDLINE) ? + boot_info->cmdline : NULL, loader); if ( (kextra =3D strstr(cmdline, " -- ")) !=3D NULL ) { @@ -1147,19 +1177,22 @@ void __init noreturn __start_xen(unsigned long mbi_= p) bootsym(boot_edd_info_nr)); =20 /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods =3D=3D 0) ) + if ( !(boot_info->arch->flags & BOOTINFO_FLAG_X86_MODULES) || + (boot_info->nr_mods =3D=3D 0) ) panic("dom0 kernel not specified. Check bootloader configuration\n= "); =20 /* Check that we don't have a silly number of modules. */ - if ( boot_info->nr_mods > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > MAX_NR_BOOTMODS + 1 ) { - boot_info->nr_mods =3D sizeof(module_map) * 8; + boot_info->nr_mods =3D MAX_NR_BOOTMODS + 1; printk("Excessive multiboot modules - using the first %u only\n", boot_info->nr_mods); } =20 - bitmap_fill(module_map, boot_info->nr_mods); + /* Dom0 kernel is the first boot module */ + bitmap_fill(module_map, mbi->mods_count); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + boot_info->mods[0].bootmod_type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) { @@ -1189,13 +1222,13 @@ void __init noreturn __start_xen(unsigned long mbi_= p) { memmap_type =3D "Xen-e820"; } - else if ( mbi->flags & MBI_MEMMAP ) + else if ( boot_info->arch->flags & BOOTINFO_FLAG_X86_MEMMAP ) { memmap_type =3D "Multiboot-e820"; - while ( bytes < mbi->mmap_length && + while ( bytes < boot_info->arch->mmap_length && e820_raw.nr_map < ARRAY_SIZE(e820_raw.map) ) { - memory_map_t *map =3D __va(mbi->mmap_addr + bytes); + struct mb_memmap *map =3D __va(boot_info->arch->mmap_addr + by= tes); =20 /* * This is a gross workaround for a BIOS bug. Some bootloaders= do @@ -1330,17 +1363,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(&boot_e820); =20 - initial_images =3D mod; - boot_info->nr_mods =3D boot_info->nr_mods; - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++= ) - { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( boot_info->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - mod[i].mod_end -=3D mod[i].mod_start; - mod[i].mod_start >>=3D PAGE_SHIFT; - mod[i].reserved =3D 0; - } =20 /* * TODO: load ucode earlier once multiboot modules become accessible @@ -1357,12 +1382,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[boot_info->nr_mods].mod_start =3D virt_to_mfn(_stext); - mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; + bootmodule_update_start(&boot_info->mods[boot_info->nr_mods], + virt_to_maddr(_stext)); + boot_info->mods[boot_info->nr_mods].size =3D __2M_rwdata_end - _st= ext; } =20 boot_info->mods[0].arch->headroom =3D - bzimage_headroom(bootstrap_map_multiboot(mod), mod->mod_end); + bzimage_headroom(bootstrap_map(&boot_info->mods[0]), + boot_info->mods[0].size); =20 bootstrap_map(NULL); =20 @@ -1420,7 +1447,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end =3D consider_modules(s, e, reloc_size + mask, - mod, boot_info->nr_mods, -1); + boot_info->mods, boot_info->nr_mods, -1= ); end &=3D ~mask; } else @@ -1443,15 +1470,15 @@ void __init noreturn __start_xen(unsigned long mbi_= p) /* Is the region suitable for relocating the multiboot modules? */ for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { - struct boot_module *boot_mods =3D boot_info->mods; - unsigned long headroom =3D j ? 0 : boot_mods[0].arch->headroom; - unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); + struct boot_module *boot_mod =3D boot_info->mods; + unsigned long headroom =3D j ? 0 : boot_mod[0].arch->headroom; + unsigned long size =3D PAGE_ALIGN(headroom + boot_mod[j].size); =20 - if ( mod[j].reserved ) + if ( boot_mod[j].arch->flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ - end =3D consider_modules(s, e, size, mod, + end =3D consider_modules(s, e, size, boot_info->mods, boot_info->nr_mods + relocated, j); =20 if ( highmem_start && end > highmem_start ) @@ -1459,14 +1486,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 if ( s < end && (headroom || - ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) + ((end - size) >> PAGE_SHIFT) > mfn_x(boot_mod[j].mfn)) ) { move_memory(end - size + headroom, - (uint64_t)mod[j].mod_start << PAGE_SHIFT, - mod[j].mod_end); - mod[j].mod_start =3D (end - size) >> PAGE_SHIFT; - mod[j].mod_end +=3D headroom; - mod[j].reserved =3D 1; + (uint64_t)boot_mod[j].start, + boot_mod[j].size); + bootmodule_update_start(&boot_mod[j], end - size); + boot_mod[j].size +=3D headroom; + boot_mod[j].arch->flags |=3D BOOTMOD_FLAG_X86_RELOCATED; } } =20 @@ -1478,7 +1505,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) while ( !kexec_crash_area.start ) { /* Don't overlap with modules (or Xen itself). */ - e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , mod, + e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), + boot_info->mods, boot_info->nr_mods + relocated, -1); if ( s >=3D e ) break; @@ -1492,13 +1520,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) #endif } =20 - if ( boot_info->mods[0].arch->headroom && !mod->reserved ) + if ( boot_info->mods[0].arch->headroom && + !(boot_info->mods[0].arch->flags & BOOTMOD_FLAG_X86_RELOCATED) ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s =3D (uint64_t)boot_info->mods[i].start; =20 - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end)); + reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(boot_info->mods[i].= size)); } =20 if ( !xen_phys_start ) @@ -1565,8 +1594,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < boot_info->nr_mods; ++j ) { - uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end =3D mfn_to_maddr(boot_info->mods[j].mfn) + + boot_info->mods[j].size; =20 if ( map_e < end ) map_e =3D end; @@ -1641,11 +1670,12 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - set_pdx_range(mod[i].mod_start, - mod[i].mod_start + PFN_UP(mod[i].mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(mod[i].mod_start), - _mfn(mod[i].mod_start), - PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR); + set_pdx_range(mfn_x(boot_info->mods[i].mfn), + mfn_x(boot_info->mods[i].mfn) + + PFN_UP(boot_info->mods[i].size)); + map_pages_to_xen((unsigned long)maddr_to_virt(boot_info->mods[i].s= tart), + boot_info->mods[i].mfn, + PFN_UP(boot_info->mods[i].size), PAGE_HYPERVISOR); } =20 #ifdef CONFIG_KEXEC @@ -2022,8 +2052,12 @@ void __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, boot_info->nr_mods); - if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) + initrdidx =3D bootmodule_index(boot_info, BOOTMOD_UNKNOWN, 0); + if ( initrdidx < boot_info->nr_mods ) + boot_info->mods[initrdidx].bootmod_type =3D BOOTMOD_RAMDISK; + + if ( bootmodule_index(boot_info, BOOTMOD_UNKNOWN, 0) > + boot_info->nr_mods ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2032,9 +2066,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, boot_info->mods[0].arch->headroom, - initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, - kextra, loader); + dom0 =3D create_dom0(boot_info, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index eb93cc3439..2f4284a91f 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -2,23 +2,50 @@ #define __XEN_BOOTINFO_H__ =20 #include +#include +#include =20 #ifdef CONFIG_X86 #include #else struct arch_bootmodule { }; + struct arch_boot_info { }; #endif =20 +/* Boot module binary type / purpose */ +#define BOOTMOD_UNKNOWN 0 +#define BOOTMOD_XEN 1 +#define BOOTMOD_FDT 2 +#define BOOTMOD_KERNEL 3 +#define BOOTMOD_RAMDISK 4 +#define BOOTMOD_XSM 5 +#define BOOTMOD_UCODE 6 +#define BOOTMOD_GUEST_DTB 7 +typedef unsigned int bootmod_type_t; + +#define BOOTMOD_STRING_MAX_LEN 1024 +struct boot_string { + char bytes[BOOTMOD_STRING_MAX_LEN]; + size_t len; +}; + struct boot_module { + bootmod_type_t bootmod_type; paddr_t start; + mfn_t mfn; size_t size; =20 struct arch_bootmodule *arch; + struct boot_string string; }; =20 struct boot_info { + char *cmdline; + unsigned int nr_mods; struct boot_module *mods; + + struct arch_boot_info *arch; }; =20 #endif --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195963; cv=none; d=zohomail.com; s=zohoarc; b=lTeouhSEl2pRceFqfYDolkT/vH3aaStBRhi8eTm8N/dTyW8z78j0FIA1VEDEMRxEUCiks3ApxWEiqLIPnvHdbTxVw69cv2lqhWznMxl6FjYHAzqJD25zmBnJroT7HBGooM7ffx3aqBxOQkLRm7JdWzhmnsSPVF2Fyce0cS4dAmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195963; h=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=2CCuYNE2IdEGJiRf9KcQxz9oSopCuIZzH05nVBt98V4=; b=B+CWg+y/lSDC/HxmC3CmrfAPvEGvhRzhWyv1IyY8XSoTUWjTfUMWLlusHU3ATokRRwMi8I2/blQs5ZxP5wA2vBRUukuKmjocmbR+NnKwDXRffk+Kt9DPFDlIPrMQffdnh6ej9IDqLDnYO0KxJqAaR2dVXujX2rx/DRPthOXUF9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195963888150.35491925910605; Sat, 1 Jul 2023 00:19:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557775.871435 (Exim 4.92) (envelope-from ) id 1qFUsm-0007VE-Bn; Sat, 01 Jul 2023 07:19:00 +0000 Received: by outflank-mailman (output) from mailman id 557775.871435; Sat, 01 Jul 2023 07:19:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsm-0007Tv-4v; Sat, 01 Jul 2023 07:19:00 +0000 Received: by outflank-mailman (input) for mailman id 557775; Sat, 01 Jul 2023 07:18:58 +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 1qFUsk-00074A-4S for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:58 +0000 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [2607:f8b0:4864:20::436]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8a442a66-17df-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 09:18:56 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-666e97fcc60so1887762b3a.3 for ; Sat, 01 Jul 2023 00:18:56 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:53 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8a442a66-17df-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195934; x=1690787934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=2CCuYNE2IdEGJiRf9KcQxz9oSopCuIZzH05nVBt98V4=; b=L/C1FJaAKKXcrKwwbXfoXKbQbJyRAJdJNLqD8rSSdTsYDwF3QnFSP2qbAA042bSu5Z OFZIrW0J+Zhh+BmakoPWDH4ZzFTQsvVUEeVlHYaCl918lGW6Wh1jbVC1a924pKTMIMLT ixYBYRX9jRyGqkbarfkYRUMvVl5fs3x8ji0pYYcTxKG4Let565+Wt7m4ReGqVoGYWV/Q eZAegTnZa6qvgzw7JfcDFp7OBQWvL2j5oe7Y+LfTbHhysp/YtRNS3at1rUL4Y9/Ctk9C 0nM3B33hMsgll472cqdFo+kHWDEq4HWIonXRH9BcfTq55X2I9HyYK3UkD8bHLjcEwR6W CSSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195934; x=1690787934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2CCuYNE2IdEGJiRf9KcQxz9oSopCuIZzH05nVBt98V4=; b=BLwRZZzEoDJzHnnwu9u+6xKgS38426q7sDor8LUo5G9n1xX+eM9GItEq65nOWeUyZ9 DnWseHP9hzHpvh7FuwDsMogLViTUOEo5qGByRb6dSMrFMZkC9w93CSbdksJDCh1gSwYO QLTiXu8vVjsIgHAgDN4PJFCkC5YHDZmMXT/Cmu4LOISBJ5cp0Zo456YUM9LNnCUBWJfT GtvSqeAHVPTdzcH+XyaSR7mDpMT7/+k/nEsw2HsczTs5qNWPJJ98BWM+J8AXDZRuIHzV UpNTah1Qq6i+qRSYwepddB277+r+5vaWBy+FSDbhlkp3wbar3bkciF99bo+nfk7CLpZw j24g== X-Gm-Message-State: ABy/qLZ9tzvuTjkna5RzisUUdxkxoNud6/YggGePXYZ+Dz2xXuWoOVWN OYoRrxonIbDhan10ZXkD8WW8fWvo7zE= X-Google-Smtp-Source: APBJJlFwakyPH8XJc7p5VcZt6PmkVcFDYaVMV4ECD1CzygH3D1pud2JwVpwTI/RepQYB4r6d0mLbRQ== X-Received: by 2002:a05:6a00:1792:b0:64d:1c59:6767 with SMTP id s18-20020a056a00179200b0064d1c596767mr4767504pfg.24.1688195934527; Sat, 01 Jul 2023 00:18:54 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 05/10] xsm: switch XSM init to boot info structures Date: Sat, 1 Jul 2023 00:18:30 -0700 Message-Id: <20230701071835.41599-6-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195964853100001 Content-Type: text/plain; charset="utf-8" Change the XSM implementation to use the boot info structure instead of the multiboot module_map. Drops a dependency on CONFIG_MULTIBOOT, so boot module logic is now used whenever the DEVICE_TREE specific logic (for Arm) is not, with the bootinfo header conditionally included to ensure no change on Arm. Adds a multiboot header inclusion into guest/xen/pvh-boot.c since it is no longer provided via transitive inclusion and the source in that file uses multiboot structures. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v1: patch is a subset of v1 series patches 2 and 3. - Added the inclusion to pvh-boot.c - Use conditional inclusion for xen/arch/x86/guest/xen/pvh-boot.c | 1 + xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 28 +++++++-------- xen/xsm/xsm_core.c | 47 +++++++++++++++--------- xen/xsm/xsm_policy.c | 59 ++++++++++++++++--------------- 5 files changed, 77 insertions(+), 60 deletions(-) diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh= -boot.c index 9cbe87b61b..1ed04d035c 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include #include diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f9b04daebd..a616ccc0a8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1835,7 +1835,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges =3D rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); =20 - xsm_multiboot_init(module_map, mbi); + xsm_bootmodule_init(boot_info); =20 /* * IOMMU-related ACPI table parsing may require some of the system dom= ains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 8dad03fd3d..d409c30be6 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -16,8 +16,10 @@ #define __XSM_H__ =20 #include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif #include -#include =20 /* policy magic number (defined by XSM_MAGIC) */ typedef uint32_t xsm_magic_t; @@ -776,15 +778,14 @@ static inline int xsm_argo_send(const struct domain *= d, const struct domain *t) =20 #endif /* XSM_NO_WRAPPERS */ =20 -#ifdef CONFIG_MULTIBOOT -int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi); -int xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, - void **policy_buffer, size_t *policy_size); -#endif +#ifndef CONFIG_HAS_DEVICE_TREE +int xsm_bootmodule_init(const struct boot_info *info); +int xsm_bootmodule_policy_init( + const struct boot_info *info, const unsigned char **policy_buffer, + size_t *policy_size); + +#else =20 -#ifdef CONFIG_HAS_DEVICE_TREE /* * Initialize XSM * @@ -826,15 +827,14 @@ static const inline struct xsm_ops *silo_init(void) =20 #include =20 -#ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init ( - unsigned long *module_map, const multiboot_info_t *mbi) +#ifndef CONFIG_HAS_DEVICE_TREE +static inline int xsm_bootmodule_init(const struct boot_info *info) { return 0; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + static inline int xsm_dt_init(void) { return 0; diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index eaa028109b..301ae4dc8b 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -10,8 +10,12 @@ * as published by the Free Software Foundation. */ =20 -#include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif #include +#include +#include #include #include =20 @@ -138,26 +142,35 @@ static int __init xsm_core_init(const void *policy_bu= ffer, size_t policy_size) return 0; } =20 -#ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi) +/* + * ifdef'ing this against multiboot is no longer valid as the boot module + * is agnostic and it will be possible to dropped the ifndef should Arm + * adopt boot info + */ +#ifndef CONFIG_HAS_DEVICE_TREE +int __init xsm_bootmodule_init(const struct boot_info *bootinfo) { int ret =3D 0; - void *policy_buffer =3D NULL; + const unsigned char *policy_buffer =3D NULL; size_t policy_size =3D 0; =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 if ( XSM_MAGIC ) { - ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, - &policy_size); - if ( ret ) - { - bootstrap_map(NULL); - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; - } + int ret =3D xsm_bootmodule_policy_init(bootinfo, &policy_buffer, + &policy_size); + bootstrap_map(NULL); + + if ( ret =3D=3D -ENOENT ) + /* + * The XSM module needs a policy file but one was not located. + * Report as a warning and continue as the XSM module may late + * load a policy file. + */ + printk(XENLOG_WARNING "xsm: starting without a policy loaded!\= n"); + else if ( ret ) + panic("Error %d initializing XSM policy\n", ret); } =20 ret =3D xsm_core_init(policy_buffer, policy_size); @@ -165,9 +178,9 @@ int __init xsm_multiboot_init( =20 return 0; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + int __init xsm_dt_init(void) { int ret =3D 0; @@ -215,9 +228,9 @@ bool __init has_xsm_magic(paddr_t start) =20 return false; } -#endif +#endif /* CONFIG_HAS_DEVICE_TREE */ =20 -#endif +#endif /* CONFIG_XSM */ =20 long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index c6df8c6e06..f1970c8964 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -18,62 +18,65 @@ * */ =20 -#include -#ifdef CONFIG_MULTIBOOT -#include -#include -#include -#endif #include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif +#include #ifdef CONFIG_HAS_DEVICE_TREE -# include # include +#else +#include #endif =20 -#ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, - void **policy_buffer, size_t *policy_size) +#include + +#ifndef CONFIG_HAS_DEVICE_TREE +int __init xsm_bootmodule_policy_init( + const struct boot_info *bootinfo, const unsigned char **policy_buffer, + size_t *policy_size) { - int i; - module_t *mod =3D (module_t *)__va(mbi->mods_addr); - int rc =3D 0; + unsigned long i; + int rc =3D -ENOENT; u32 *_policy_start; unsigned long _policy_len; =20 - /* - * Try all modules and see whichever could be the binary policy. - * Adjust module_map for the module that is the binary policy. - */ - for ( i =3D mbi->mods_count-1; i >=3D 1; i-- ) - { - if ( !test_bit(i, module_map) ) - continue; +#ifdef CONFIG_XSM_FLASK_POLICY + /* Initially set to builtin policy, overriden if boot module is found.= */ + *policy_buffer =3D xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; + rc =3D 0; +#endif =20 - _policy_start =3D bootstrap_map_multiboot(mod + i); - _policy_len =3D mod[i].mod_end; + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, 0); + while ( i < bootinfo->nr_mods ) + { + _policy_start =3D bootstrap_map(&bootinfo->mods[i]); + _policy_len =3D bootinfo->mods[i].size; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { - *policy_buffer =3D _policy_start; + *policy_buffer =3D (unsigned char *)_policy_start; *policy_size =3D _policy_len; =20 printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - __clear_bit(i, module_map); + bootinfo->mods[i].bootmod_type =3D BOOTMOD_XSM; + rc =3D 0; break; =20 } =20 bootstrap_map(NULL); + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, ++i); } =20 return rc; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size) { struct bootmodule *mod =3D boot_module_find_by_kind(BOOTMOD_XSM); --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195972; cv=none; d=zohomail.com; s=zohoarc; b=W9Ernnrmwfd6cASRWWYstdv+odLbv3nhsza/cFZAw5InQ90osGnqnLHC8yBPIgAWBiAa/O69zjbbvZiEvDsKfj5h4dchioKDMGEwptO+yDoL34fhzUjOuf1BfyGkaJpmLeIGGj4GWYP8jJjB5MTVWovOG6/za63b2geffgZI8iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195972; h=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=zZcp6XBY1YAC9oeotb5zJ/fGSdzt/Mx/a1Oe4w1mVBI=; b=PbRxbwnOX7jrO+nUkF/NPlfiC/MSIcK9f+fW9x0lqaH85zbvb2Dg2pANolf4jBj8K8LHLF+e7Ez4oL66iann2fwO7vLyfaNgPnSfzeNOmDlneRME9fq6ibwvhwl+S3rSsUPx0FzGUS/FUWdajaTd2XPl1fgFpeeYkcdghtkDWto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195972084198.2792343084019; Sat, 1 Jul 2023 00:19:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557776.871444 (Exim 4.92) (envelope-from ) id 1qFUsn-0007hy-BI; Sat, 01 Jul 2023 07:19:01 +0000 Received: by outflank-mailman (output) from mailman id 557776.871444; Sat, 01 Jul 2023 07:19:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsm-0007fn-TN; Sat, 01 Jul 2023 07:19:00 +0000 Received: by outflank-mailman (input) for mailman id 557776; Sat, 01 Jul 2023 07:18:59 +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 1qFUsl-00074A-4k for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:18:59 +0000 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [2607:f8b0:4864:20::733]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8ae6847b-17df-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 09:18:57 +0200 (CEST) Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-765a7768f1dso259805885a.0 for ; Sat, 01 Jul 2023 00:18:57 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:55 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8ae6847b-17df-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195936; x=1690787936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=zZcp6XBY1YAC9oeotb5zJ/fGSdzt/Mx/a1Oe4w1mVBI=; b=ILmm9e/9lTp9GTg1saAsg7g1OS7yf4jCGZwg0akeM2mI0eRae5so14i3XdhUMh+qaa WvicC4epjfhJ1KgZeK/e5xz4jBIFr1AvNW1MB8zRZGTP3UqrTmEKUDwdJ7lYGNrL0kYo W7eJJCHmsS1p5VVGOTbmnt9B25qJIGISHnW/KS3zoRc6b0p5zTwjPDP1RlEkxvb9ai26 Ff3gpgsic09OIQkUbADqfAmHETGZJiy3Lm/8TvvJqr6fuh3R7hBi4Mqs8pY02gL+6K7m Q+oAco6AU+2LzNqpPKBAyn2krxQOaAyH+0px9DeXfCeULpV16sLShIA+hMsZgendVEpi DGjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195936; x=1690787936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zZcp6XBY1YAC9oeotb5zJ/fGSdzt/Mx/a1Oe4w1mVBI=; b=gMstzg2ZJq6aYPb2GEvCv8vqtB2zsXuRZIvehsreBf9UcaAXI5F3HvfgFGfrU6XGea G6+u38UvLdQDOfJecvHaFgDEFnOlXXsnparkLx3XXYQQTFAqzrzWPWf0jBhrJdJx2cYn gWbu/JPva7D6/oyTNHuBXbTJOU6/sFR2YWpYh7BYt5YT/VjJmJXcCcG1cY9An5ARexlQ xrtLWWcSk1PiTeL1dnZuhUQqnQKiJ8cvMoEO52T9up/psg3VrGvA/ba1E5DIZU2O/m4V y3gKZczkTL6bymO536zkmgvLZrnaDTHFnE19GcMuj/mfeat9A7NjxxIe3SeXw5+G+RW+ 4toQ== X-Gm-Message-State: AC+VfDzsuUMqzIcxBqUcyjhsOotH0TOLONiN8rttpgO2EFu0+vZZV8ez OWNB8X/AVzaR9h23vdp3gjxbnZqtBLI= X-Google-Smtp-Source: ACHHUZ6G4ziS9OlcacmAYXEWytMGOapbZ5lrvuY5UYngxSJMQYFoJYsz5UXL9WWUNXBnxHWZfGdaKA== X-Received: by 2002:a05:620a:450b:b0:767:2bb9:d187 with SMTP id t11-20020a05620a450b00b007672bb9d187mr6726381qkp.1.1688195936202; Sat, 01 Jul 2023 00:18:56 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 06/10] x86 setup, microcode: switch to the new bootinfo structures Date: Sat, 1 Jul 2023 00:18:31 -0700 Message-Id: <20230701071835.41599-7-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195972664100011 Content-Type: text/plain; charset="utf-8" Next step in incremental work towards adding a non-multiboot internal representation of boot modules, converting the fields being accessed for the startup calculations. Move the per-module scan logic into a dedicated function from the iteration loop and set the BOOTMOD_UCODE module type when microcode is foun= d. Completes the conversion from the module_map bitmap in x86 setup so it can be removed, along with the temporary bootstrap_map multiboot wrapper since the last code that uses it is removed in this change. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith Reviewed-by: Stefano Stabellini --- Changes since v1: patch is a subset of v1 series patches 2 and 3. - Added the removal of the temporary bootstrap map function xen/arch/x86/cpu/microcode/core.c | 148 +++++++++++++++------------ xen/arch/x86/include/asm/boot.h | 13 --- xen/arch/x86/include/asm/microcode.h | 7 +- xen/arch/x86/setup.c | 8 +- 4 files changed, 89 insertions(+), 87 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index ce3c8042a2..d2cae9b6b4 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -22,12 +22,12 @@ */ =20 #include +#include #include #include #include #include #include -#include #include #include #include @@ -57,7 +57,6 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 =20 -static module_t __initdata ucode_mod; static signed int __initdata ucode_mod_idx; static bool_t __initdata ucode_mod_forced; static unsigned int nr_cores; @@ -150,75 +149,109 @@ static int __init cf_check parse_ucode(const char *s) } custom_param("ucode", parse_ucode); =20 -void __init microcode_scan_module( - unsigned long *module_map, - const multiboot_info_t *mbi) +#define MICROCODE_MODULE_MATCH 1 +#define MICROCODE_MODULE_NONMATCH 0 + +static int __init microcode_check_module(struct boot_module *mod) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); uint64_t *_blob_start; unsigned long _blob_size; - struct cpio_data cd; + struct cpio_data cd =3D { NULL, 0 }; long offset; const char *p =3D NULL; - int i; - - ucode_blob.size =3D 0; - if ( !ucode_scan ) - return; =20 if ( boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD ) p =3D "kernel/x86/microcode/AuthenticAMD.bin"; else if ( boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL ) p =3D "kernel/x86/microcode/GenuineIntel.bin"; else + return -EFAULT; + + _blob_start =3D bootstrap_map(mod); + _blob_size =3D mod->size; + if ( !_blob_start ) + { + printk("Could not map multiboot module (0x%lx) (size: %ld)\n", + mod->start, _blob_size); + /* Non-fatal error, so just say no match */ + return MICROCODE_MODULE_NONMATCH; + } + + cd =3D find_cpio_data(p, _blob_start, _blob_size, &offset /* ignore */= ); + + if ( cd.data ) + { + ucode_blob.size =3D cd.size; + ucode_blob.data =3D cd.data; + + mod->bootmod_type =3D BOOTMOD_UCODE; + return MICROCODE_MODULE_MATCH; + } + + bootstrap_map(NULL); + + return MICROCODE_MODULE_NONMATCH; +} + +void __init microcode_scan_module(struct boot_info *bootinfo) +{ + int i; + + if ( !ucode_scan ) return; =20 - /* - * Try all modules and see whichever could be the microcode blob. - */ - for ( i =3D 1 /* Ignore dom0 kernel */; i < mbi->mods_count; i++ ) + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, 0); + while ( i < bootinfo->nr_mods ) { - if ( !test_bit(i, module_map) ) - continue; + int ret =3D microcode_check_module(&bootinfo->mods[i]); =20 - _blob_start =3D bootstrap_map_multiboot(&mod[i]); - _blob_size =3D mod[i].mod_end; - if ( !_blob_start ) + switch ( ret ) { - printk("Could not map multiboot module #%d (size: %ld)\n", - i, _blob_size); + case MICROCODE_MODULE_MATCH: + return; + case MICROCODE_MODULE_NONMATCH: + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, ++i); continue; + default: + printk("%s: (err: %d) unable to check microcode\n", + __func__, ret); + return; } - cd.data =3D NULL; - cd.size =3D 0; - cd =3D find_cpio_data(p, _blob_start, _blob_size, &offset /* ignor= e */); - if ( cd.data ) - { - ucode_blob.size =3D cd.size; - ucode_blob.data =3D cd.data; - break; - } - bootstrap_map(NULL); } } =20 -static void __init microcode_grab_module( - unsigned long *module_map, - const multiboot_info_t *mbi) +static void __init microcode_grab_module(struct boot_info *bootinfo) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); + ucode_blob.size =3D 0; =20 if ( ucode_mod_idx < 0 ) - ucode_mod_idx +=3D mbi->mods_count; - if ( ucode_mod_idx <=3D 0 || ucode_mod_idx >=3D mbi->mods_count || - !__test_and_clear_bit(ucode_mod_idx, module_map) ) - goto scan; - ucode_mod =3D mod[ucode_mod_idx]; -scan: + ucode_mod_idx +=3D bootinfo->nr_mods; + if ( ucode_mod_idx >=3D 0 && ucode_mod_idx <=3D bootinfo->nr_mods && + bootinfo->mods[ucode_mod_idx].bootmod_type =3D=3D BOOTMOD_UNKNOWN= ) + { + int ret =3D microcode_check_module(&bootinfo->mods[ucode_mod_idx]); + + switch ( ret ) + { + case MICROCODE_MODULE_MATCH: + return; + case MICROCODE_MODULE_NONMATCH: + break; + default: + printk("%s: (err: %d) unable to check microcode\n", + __func__, ret); + return; + } + } + if ( ucode_scan ) - microcode_scan_module(module_map, mbi); + microcode_scan_module(bootinfo); } =20 +/* Undefining as they are not needed anymore */ +#undef MICROCODE_MODULE_MATCH +#undef MICROCODE_MODULE_NONMATCH + static struct microcode_ops __ro_after_init ucode_ops; =20 static DEFINE_SPINLOCK(microcode_mutex); @@ -738,11 +771,6 @@ static int __init cf_check microcode_init(void) ucode_blob.size =3D 0; ucode_blob.data =3D NULL; } - else if ( ucode_mod.mod_end ) - { - bootstrap_map(NULL); - ucode_mod.mod_end =3D 0; - } =20 return 0; } @@ -786,8 +814,7 @@ static int __init early_update_cache(const void *data, = size_t len) return rc; } =20 -int __init microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init microcode_init_cache(struct boot_info *bootinfo) { int rc =3D 0; =20 @@ -796,12 +823,9 @@ int __init microcode_init_cache(unsigned long *module_= map, =20 if ( ucode_scan ) /* Need to rescan the modules because they might have been relocat= ed */ - microcode_scan_module(module_map, mbi); + microcode_scan_module(bootinfo); =20 - if ( ucode_mod.mod_end ) - rc =3D early_update_cache(bootstrap_map_multiboot(&ucode_mod), - ucode_mod.mod_end); - else if ( ucode_blob.size ) + if ( ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); =20 return rc; @@ -819,11 +843,6 @@ static int __init early_microcode_update_cpu(void) len =3D ucode_blob.size; data =3D ucode_blob.data; } - else if ( ucode_mod.mod_end ) - { - len =3D ucode_mod.mod_end; - data =3D bootstrap_map_multiboot(&ucode_mod); - } =20 if ( !data ) return -ENOMEM; @@ -842,8 +861,7 @@ static int __init early_microcode_update_cpu(void) return microcode_update_cpu(patch); } =20 -int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init early_microcode_init(struct boot_info *bootinfo) { const struct cpuinfo_x86 *c =3D &boot_cpu_data; int rc =3D 0; @@ -867,11 +885,11 @@ int __init early_microcode_init(unsigned long *module= _map, return -ENODEV; } =20 - microcode_grab_module(module_map, mbi); + microcode_grab_module(bootinfo); =20 ucode_ops.collect_cpu_info(); =20 - if ( ucode_mod.mod_end || ucode_blob.size ) + if ( ucode_blob.size ) rc =3D early_microcode_update_cpu(); =20 return rc; diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h index bcf4f2e2e3..e51fd32280 100644 --- a/xen/arch/x86/include/asm/boot.h +++ b/xen/arch/x86/include/asm/boot.h @@ -6,19 +6,6 @@ =20 #include =20 -static inline void *bootstrap_map_multiboot(const module_t *mod) -{ - struct boot_module bm; - - if ( !mod ) - return bootstrap_map(NULL); - - bm.start =3D mod->mod_start << PAGE_SHIFT; - bm.size =3D mod->mod_end; - - return bootstrap_map(&bm); -} - static inline unsigned long bootmodule_index( const struct boot_info *info, bootmod_type_t bootmod_type, unsigned long start) diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/as= m/microcode.h index 62ce3418f7..803fbbb270 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -1,6 +1,7 @@ #ifndef ASM_X86__MICROCODE_H #define ASM_X86__MICROCODE_H =20 +#include #include #include =20 @@ -23,10 +24,8 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig); =20 void microcode_set_module(unsigned int idx); int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); -int early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi); -int microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi); +int early_microcode_init(struct boot_info *bootinfo); +int microcode_init_cache(struct boot_info *bootinfo); int microcode_update_one(void); =20 #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a616ccc0a8..50a1a124b0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1023,7 +1023,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked =3D 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, module_map[1]; + unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1190,8 +1190,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) } =20 /* Dom0 kernel is the first boot module */ - bitmap_fill(module_map, mbi->mods_count); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ boot_info->mods[0].bootmod_type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) @@ -1371,7 +1369,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * TODO: load ucode earlier once multiboot modules become accessible * at an earlier stage. */ - early_microcode_init(module_map, mbi); + early_microcode_init(boot_info); =20 if ( xen_phys_start ) { @@ -1906,7 +1904,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 timer_init(); =20 - microcode_init_cache(module_map, mbi); /* Needs xmalloc() */ + microcode_init_cache(boot_info); /* Needs xmalloc() */ =20 tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ =20 --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195967; cv=none; d=zohomail.com; s=zohoarc; b=nndUO22CcU1hSYnfJCPip5iq+HqM+B8V7azy1GkrfPVmbzhMAeV7QzVEj72xAGQ9IZFPAgrJczfXfD2Fs7w/OU0zBGQra9qtXRJla5M1Lu3ugZZYy4ir+2cPvfbA7OHoxmLqziKtD9fOPRzYY/b4gQtcNrsz4ysqdJ6NA+CSTXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195967; h=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=S6Cu78312/uyuTtWf3JY9jjpC+4RgagbuKLSP43QOoI=; b=S+3zChSLIfAf57yqWNJmApFgkEi0us7FQC2sZxEzZ5s7+P86LZ+WjmccvyQQnDXTOYazhCgZg7HNPl4Ysfuf5sqNCXK+Qm0/ZpDtEBJ00OVeipWuaHxvSIryCNTepEqmGjoZYEvAWiY7ZU8r5Ku3mLzjmnfu5kxu8qrAOoA6r0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168819596768782.64224644225476; Sat, 1 Jul 2023 00:19:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557778.871457 (Exim 4.92) (envelope-from ) id 1qFUso-00087N-JZ; Sat, 01 Jul 2023 07:19:02 +0000 Received: by outflank-mailman (output) from mailman id 557778.871457; Sat, 01 Jul 2023 07:19:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUso-00085r-A4; Sat, 01 Jul 2023 07:19:02 +0000 Received: by outflank-mailman (input) for mailman id 557778; Sat, 01 Jul 2023 07:19:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsm-0006No-Mf for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:19:00 +0000 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [2607:f8b0:4864:20::22c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8b9c26ca-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:18:59 +0200 (CEST) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3a3373211a1so1922940b6e.0 for ; Sat, 01 Jul 2023 00:18:58 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8b9c26ca-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195937; x=1690787937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=S6Cu78312/uyuTtWf3JY9jjpC+4RgagbuKLSP43QOoI=; b=UPbuVkZz1oAK/2LyG2d2Jw8INSlnXa/NlmFvB4kRqCC2gVqMidnQRphhgxR0TSHT+3 0s32mnwZ5C2MiyRI81PFiG2f3X7YsruBzmry+l2xRuxLJooDABjPUd+qXphVLrAW/B+y 6xxLai7iGBBcCRX9fk/IIKGyDalggyofNzF//yvHePzXSplMvL5ZaLhzY/JrPkWjxaqX D6SRMilMh4UjMDBVz35siAbBdhGqP/ThyZryTLkDquTjEDgVeLyQU2nu+7oabv4Fmg4k 02BmtpWmfzce0nwrfyeA5AltLslsexA90Qc7lLM01L0VCpHq2WUAfmBo/Jp4+3M2gjMV Vmjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195937; x=1690787937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=S6Cu78312/uyuTtWf3JY9jjpC+4RgagbuKLSP43QOoI=; b=RdSZPZBDpO2eSdqIUe7ETNoJ3aJ+B7n2f/NGW5SeC3KXHpcE/hC6pq6f92V+ZifejX ZiGjER0sfM9QcOuAZjlP0lGTGyGLh+uk3/VDk9o+KB4BL7qDl/mbpWVv+UYHkL23DSpv HWPtPmsDf9G9qKmj/CnrOiHUIG6qRBQ2zAEeI43J+DTj/T8J5x/zfGc76aYJYyHnxQpb WXqQB5D1Qn604Wf5+o+F0eo9xFaR4WfLtp0pPJvKLwdT5Hyzjfht7rFFjUaVWCTTILAH fRwYVSoOMIe3nbqfv4XgpSKkFP0O3gel7hpViWsq+IVfU4EVM1W+e8rRWMFIYupBJ4GY BODA== X-Gm-Message-State: AC+VfDw80XbqQGGoPB5ca8mtmc4/RHNjaWUeNCbB5xMoKJ/ADRIkMSb5 hJ8Gu2lhOLUkRVrrGiTiw4vtxwV2fqk= X-Google-Smtp-Source: ACHHUZ5bs2jo7O3BDp2NAaVYCHQcw/ounbIgX+But52KUkZXfA77A5ZAv/5/HHJcZPqmWMwDeEj4RQ== X-Received: by 2002:a05:6808:1917:b0:3a0:6949:c884 with SMTP id bf23-20020a056808191700b003a06949c884mr6924756oib.34.1688195937374; Sat, 01 Jul 2023 00:18:57 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 07/10] x86 boot: define paddr_t and add macros for typedefing struct pointers Date: Sat, 1 Jul 2023 00:18:32 -0700 Message-Id: <20230701071835.41599-8-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195968610100007 Content-Type: text/plain; charset="utf-8" Pointer fields within structs need to be defined as fixed size types in the x86 boot build environment. Using a typedef for the field type rather than a struct pointer type enables the type definition to be changed in the 32-bit boot build and the main hypervisor build, allowing for a single common structure definition and a common header file. Introduces DEFINE_STRUCT_PTR_TYPE and DEFINE_PTR_TYPE which will generate typedefs with a _ptr_t suffix for pointers to the specified type. This is then used in for pointers within structs as preparation for using these headers in the x86 boot build. The 32-bit behaviour is obtained by inclusion of "defs.h" first with a check for such an existing definition on the version. paddr_t is used in so a definition is added here to the x86 boot environment defs.h header. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v2: This is two v2 patches merged into one for v3. Changes since v1: New in v2 of series. xen/arch/x86/boot/defs.h | 9 +++++++++ xen/arch/x86/include/asm/bootinfo.h | 4 +++- xen/include/xen/bootinfo.h | 9 +++++---- xen/include/xen/types.h | 11 +++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index f9840044ec..bc0f1b5cf8 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -60,4 +60,13 @@ typedef u64 uint64_t; #define U16_MAX ((u16)(~0U)) #define UINT_MAX (~0U) =20 +typedef unsigned long long paddr_t; + +#define DEFINE_STRUCT_PTR_TYPE(struct_name) \ + typedef uint64_t struct_name ## _ptr_t; + +#define DEFINE_PTR_TYPE(type) \ + typedef uint64_t type ## _ptr_t; +DEFINE_PTR_TYPE(char); + #endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 30c27980e0..989fb7a1da 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -6,6 +6,7 @@ struct arch_bootmodule { uint32_t flags; unsigned headroom; }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); =20 struct arch_boot_info { uint32_t flags; @@ -14,11 +15,12 @@ struct arch_boot_info { #define BOOTINFO_FLAG_X86_MEMMAP 1U << 6 #define BOOTINFO_FLAG_X86_LOADERNAME 1U << 9 =20 - char *boot_loader_name; + char_ptr_t boot_loader_name; =20 uint32_t mmap_length; paddr_t mmap_addr; }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); =20 struct __packed mb_memmap { uint32_t size; diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 2f4284a91f..8389da4f72 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -35,17 +35,18 @@ struct boot_module { mfn_t mfn; size_t size; =20 - struct arch_bootmodule *arch; + arch_bootmodule_ptr_t arch; struct boot_string string; }; +DEFINE_STRUCT_PTR_TYPE(boot_module); =20 struct boot_info { - char *cmdline; + char_ptr_t cmdline; =20 unsigned int nr_mods; - struct boot_module *mods; + boot_module_ptr_t mods; =20 - struct arch_boot_info *arch; + arch_boot_info_ptr_t arch; }; =20 #endif diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 6aba80500a..e807ffe255 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -71,4 +71,15 @@ typedef bool bool_t; #define test_and_set_bool(b) xchg(&(b), true) #define test_and_clear_bool(b) xchg(&(b), false) =20 +#ifndef DEFINE_STRUCT_PTR_TYPE +#define DEFINE_STRUCT_PTR_TYPE(struct_name) \ + typedef struct struct_name * struct_name ## _ptr_t; +#endif + +#ifndef DEFINE_PTR_TYPE +#define DEFINE_PTR_TYPE(type) \ + typedef type * type ## _ptr_t; +DEFINE_PTR_TYPE(char); +#endif + #endif /* __TYPES_H__ */ --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195969; cv=none; d=zohomail.com; s=zohoarc; b=mNaAq/YNOX2svMWx9dUrw+fd14aZglglRWUGuHBnriJo2SbOM+HK5N0/NnWW50rMwVOpWWeEi/0rlnnvHLOHKeI9Bn6vimfHZqUuUzkl4LHTF/5tmXNs0hxtn1+pnCD6ZdIQdB2JMa3Q2E3BW+TzWuce820eSrI8cF6jlKAYhJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195969; h=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=+QhG22aQsFtoXwrbtiP3WpdRgLLL1OgLfVThRSuYPKs=; b=WLGqScplQb8y9QdKTvhOH8eXudXJdaZcJldivSMgTEzHNcB/8lsHh4Pcozwo/pCsxKxZJSD2PV2BJ9+1lNJxktS12S5JJUyCnOPbbMiZtINoXb0QXesCqZGezjXYY3OrjyU5FoDsLnTi8mS/CBCff1LFjpv3PBaEGQ5aOr2ceng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195969601978.4634692587263; Sat, 1 Jul 2023 00:19:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557780.871469 (Exim 4.92) (envelope-from ) id 1qFUsp-0008Pl-QP; Sat, 01 Jul 2023 07:19:03 +0000 Received: by outflank-mailman (output) from mailman id 557780.871469; Sat, 01 Jul 2023 07:19:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsp-0008Mf-FC; Sat, 01 Jul 2023 07:19:03 +0000 Received: by outflank-mailman (input) for mailman id 557780; Sat, 01 Jul 2023 07:19:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsn-0006No-Mk for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:19:01 +0000 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [2607:f8b0:4864:20::72d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8c2d35ba-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:18:59 +0200 (CEST) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-765a1690003so243658785a.0 for ; Sat, 01 Jul 2023 00:18:59 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8c2d35ba-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195938; x=1690787938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=+QhG22aQsFtoXwrbtiP3WpdRgLLL1OgLfVThRSuYPKs=; b=Xufe3eFixvp3WBnPziVs80DQh009NwLwQM6EmrmrWavtVCOa8YgwA9pfjao+cAXVas Kyh7NFdj2mutOKU6e/K9NmVnVRMHMvvsxAHM2H7s/wdfwNUJqty255GlKJlQCu5vQg96 yMvmF4cr8adBv12o8hV8+Gb6TT1qKi+BOtZsVa9JgUGb91VptVwDYhxigH7Plvht5kFk hQ/2poKjMCSRtoxMxmmCSgVCA1NxfbetFR38XRkeTHBaPjoW/7sJORRNsEHFsi/D9xsE bZgAsWrgM4RD3RrSSUWizUz9rFrt4Au3FDfBgUA6zCTlgR7lva9PPIsa/Ji9tGStjP2z jB/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195938; x=1690787938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+QhG22aQsFtoXwrbtiP3WpdRgLLL1OgLfVThRSuYPKs=; b=GSxg7PyvpWJqFMZpfXtx4qBks6uNAhGXozvuXZ2cZ1yfOOFu1QKtUHoMcvfqJJUt6r 4CORg7jPzuI8XbnNnt4uX3n46gBNqm+GtqQvIXgZVwrJsNJ1JFYldpCOVRmgvH9Tc1WL 7h7vRafMgsXrYxY1LH6GF66MDx+J7vgSADyiYd4qVscK+VT1G1degNTGXEt7nt557F2z Z+Qu3S8dGuQuv6lGiaRnHbKksNOSrHPtJEA71jo/tb35V9kWyeMslQw1uhMVHcku6ZOX Ij40XVFrHazidwcutEJgyvVDMa7gHCgt6yhU2kuY0JduptZXUEWy4guetiTBkd3mmmf3 3EYQ== X-Gm-Message-State: AC+VfDxSRZ4h6HhRklzePlI35OemwAa2XePstlp/6nqR88wmfhsIMGzZ LO3NDhPIfC0mEVC7O0ZkdojQ+PlZG2Q= X-Google-Smtp-Source: ACHHUZ6vQvz5edMFsBO0yDqxfBhGyFJGqYSD7CweucRlegb7fUq3Gfct1s2EEfK8Q/Zr5W+gSLpFLg== X-Received: by 2002:a05:620a:4010:b0:766:fa1f:4ea4 with SMTP id h16-20020a05620a401000b00766fa1f4ea4mr5546488qko.1.1688195938407; Sat, 01 Jul 2023 00:18:58 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 08/10] x86, arm, riscv: add per-arch bootinfo headers Date: Sat, 1 Jul 2023 00:18:33 -0700 Message-Id: <20230701071835.41599-9-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195970625100009 Content-Type: text/plain; charset="utf-8" Changes to ensure that inclusion of succeeds in each of the main archtecture builds and in the 32-bit early x86 boot build. The header contains structures that will be used in efi logic prior to the main start of Xen, so it needs to be suitable for inclusion in Arm source files. The same header will also be included in early x86 boot logic, where asm/* headers are not reachable, and so they cannot be transitively included, so a ifdef condition is needed to prevent an attempt to include from within in that case. The early x86 boot logic can then directly include via a specified directory path where it can be included successfully. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- New for v2 series. xen/arch/arm/include/asm/bootinfo.h | 20 ++++++++++++++++++++ xen/arch/riscv/include/asm/bootinfo.h | 20 ++++++++++++++++++++ xen/include/xen/bootinfo.h | 7 ++----- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/include/asm/bootinfo.h create mode 100644 xen/arch/riscv/include/asm/bootinfo.h diff --git a/xen/arch/arm/include/asm/bootinfo.h b/xen/arch/arm/include/asm= /bootinfo.h new file mode 100644 index 0000000000..5316c87a3d --- /dev/null +++ b/xen/arch/arm/include/asm/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_ARM_BOOTINFO_H__ +#define __ARCH_ARM_BOOTINFO_H__ + +struct __packed arch_bootmodule { }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); + +struct __packed arch_boot_info { }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/riscv/include/asm/bootinfo.h b/xen/arch/riscv/include= /asm/bootinfo.h new file mode 100644 index 0000000000..5316c87a3d --- /dev/null +++ b/xen/arch/riscv/include/asm/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_ARM_BOOTINFO_H__ +#define __ARCH_ARM_BOOTINFO_H__ + +struct __packed arch_bootmodule { }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); + +struct __packed arch_boot_info { }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); + +#endif + +/* + * 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/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 8389da4f72..bf5586a76b 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -5,11 +5,8 @@ #include #include =20 -#ifdef CONFIG_X86 -#include -#else - struct arch_bootmodule { }; - struct arch_boot_info { }; +#if defined CONFIG_X86 || CONFIG_ARM || CONFIG_RISCV +# include #endif =20 /* Boot module binary type / purpose */ --=20 2.25.1 From nobody Fri May 17 22:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195971; cv=none; d=zohomail.com; s=zohoarc; b=kicXQpLojQyzjSowum6iZkBmdFwDWcsls1TA8fHhnYPcs00t3Kn9cFaUw57mKIysS+aZ8NkHouXu3DOsboAifgqtOzkNPHD0X07Tw4eto9Om/eWKPuOQBJUim3fQZ87NNl56FD5TxgRvEmWhbL16wwFuj4T9NwzKMJg5mZzvXEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195971; h=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=RNpBclJ1QG7nOEKI0nkpyN963wBmUeNZP6vxgwU4hxE=; b=EEwqYdA1K8q72ogeGvJsrbY/VRI6sW8VbU5fqjAj5zJEywh9wpWUA2HXTOnTRyTagOd9tGvq5gcVZoVvE3SgrmIGOgHqGSSiNgdwnZFYL6aw0rZSjUV3gJghCi97E9cjsq0knkNYmHNFXjmXsDtIA/ilQxZx07sZMLD+50t7sEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195971569712.1117396300325; Sat, 1 Jul 2023 00:19:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557779.871463 (Exim 4.92) (envelope-from ) id 1qFUsp-0008F6-6P; Sat, 01 Jul 2023 07:19:03 +0000 Received: by outflank-mailman (output) from mailman id 557779.871463; Sat, 01 Jul 2023 07:19:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUso-0008CO-Rw; Sat, 01 Jul 2023 07:19:02 +0000 Received: by outflank-mailman (input) for mailman id 557779; Sat, 01 Jul 2023 07:19:01 +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 1qFUsn-00074A-Me for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:19:01 +0000 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [2607:f8b0:4864:20::22d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8cedc5e3-17df-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 09:19:01 +0200 (CEST) Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a37909a64eso1780698b6e.1 for ; Sat, 01 Jul 2023 00:19:01 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:18:58 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8cedc5e3-17df-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195939; x=1690787939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=RNpBclJ1QG7nOEKI0nkpyN963wBmUeNZP6vxgwU4hxE=; b=kkt/3rzfOezqwdUdfeP22+AXirxs+V7vl98qrWv4iiVvJsilE8IFJzXmBmEaX/PLUX lw/OLqRFNRDap66MC+0gdgpB/Ap2zXzSIBFEE0S+1g7Z5yE5mqysVH6CJTGwGKVvXCEv pcetQV5sppLEG8Tn/5o/JgQm7GVCRfWToQacCEtPstUhrfKSmOFvUkrebntKu44THLG8 GKi4rtOS+2hjrykz+X62a0+lZXAHzKPErnP1WmR5Zqpb7YJXCLmeOTih25cPXCfWOUld 15dFSnZ0YQrnqdx+nDhNAzqzmzceDG1UJXNK8uM7Q1G+2GSsRsRJ0BnjJL3igJL1Bmyt JXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195939; x=1690787939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RNpBclJ1QG7nOEKI0nkpyN963wBmUeNZP6vxgwU4hxE=; b=Vcml0c+Zwcyn1Hi3mZSxVUMiBbYKgXnlUcBF9h/Xj4YKuu4icXyQ9ZYH1VkBgVfANS D/xWXb03YoHyxtjEOH5z/1ABssV/LoOjG2nv0OAu41FcNMJmaLpa7EpqkUMUEjb45M6l oRqAD0ykz0nLNTCsAA3myN0Xw3IaH048xolTpPEbM27loL/7MUHA8nSGh+aKhxpFm+PR 2p1ag9q3J3ztQ3A2fpqzracsVipprANFhT7g3YufW7/UeTMWUXo/+kY9ua6ZVvmlw1Sg uCAuBJBRIkFl67d1XU+larkq7Zl4Nj2jnTyBWjh1I7Q1OAYMvgz4tmiY41AY4THypHpx LdKA== X-Gm-Message-State: AC+VfDznT4f16VH4NUrHOLSDSuy1UOU+Isd5cxug6CT9p7hw7iqjKnW2 S/el3BxJ77RRlSDhXmy06bXi+jBQpg0= X-Google-Smtp-Source: ACHHUZ5bYgzOgosZ6acapmMuq/fA7HvOVTh6FdoBs81Xwt7bcxLG96FryDU7aohNQTBeWJXvKMyaTg== X-Received: by 2002:a05:6808:140d:b0:3a1:aef1:bbf3 with SMTP id w13-20020a056808140d00b003a1aef1bbf3mr5761717oiv.23.1688195939678; Sat, 01 Jul 2023 00:18:59 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 09/10] arm setup: use common integer-typed bootmod definition Date: Sat, 1 Jul 2023 00:18:34 -0700 Message-Id: <20230701071835.41599-10-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195973060100013 Content-Type: text/plain; charset="utf-8" This change enables inclusion of in Arm builds, required for subsequent patches in this series. It replaces the enum definition of bootmodule_kind with bootmod_type_t as enums are not fixed size as needed for packed structs which are needed for boot structures in subsequent changes. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- New for v2 series. xen/arch/arm/include/asm/setup.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 19dc637d55..7e0598217a 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -3,6 +3,7 @@ =20 #include #include +#include #include =20 #define MIN_FDT_ALIGN 8 @@ -12,15 +13,7 @@ =20 #define MAX_MODULES 32 /* Current maximum useful modules */ =20 -typedef enum { - BOOTMOD_XEN, - BOOTMOD_FDT, - BOOTMOD_KERNEL, - BOOTMOD_RAMDISK, - BOOTMOD_XSM, - BOOTMOD_GUEST_DTB, - BOOTMOD_UNKNOWN -} bootmodule_kind; +typedef bootmod_type_t bootmodule_kind; =20 enum membank_type { /* --=20 2.25.1 From nobody Fri May 17 22:38:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688195981; cv=none; d=zohomail.com; s=zohoarc; b=Drgxe5Ln0KJWsRc4uZxSgLsi8B4PSv8belP+79N7R9WikCAufPCy5lfqYvEFhmw6f5C7clMt5q2NsR850R8a2HorrfORS3nRwai/HF4ly8kGCquyOW0QYjMBWOPvIohNszn/JR869fTTpIYXIKCJG67sRTFrohr+B4qA7v5ltPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688195981; 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=kNW+AYrQKnLKNbbn3YFHqN8Eo0KMGaoZgm6SWc5V5+U=; b=DgpoD5gV8EvzdLT+Tr4tdBXHh6F4BXkQrUCMJrIjpTLToxmlNZGiN01Tq5qzCrtox8u1QS0JBWHKoaHgc5p4YMd6zu2aZCAaDpp+xpKEaWylpkMw5EtzcQ9xluf0cYx4Ce6HaakJqALnCzyZU1KXbo+Y25awV7h5oAkYJwknEhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688195981028845.3437104241232; Sat, 1 Jul 2023 00:19:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557782.871489 (Exim 4.92) (envelope-from ) id 1qFUss-0000iV-He; Sat, 01 Jul 2023 07:19:06 +0000 Received: by outflank-mailman (output) from mailman id 557782.871489; Sat, 01 Jul 2023 07:19:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUss-0000hD-BG; Sat, 01 Jul 2023 07:19:06 +0000 Received: by outflank-mailman (input) for mailman id 557782; Sat, 01 Jul 2023 07:19:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFUsr-0006No-4Y for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 07:19:05 +0000 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [2607:f8b0:4864:20::736]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8dd6c1a5-17df-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 09:19:02 +0200 (CEST) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-76243a787a7so258385885a.2 for ; Sat, 01 Jul 2023 00:19:02 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s19-20020aa78d53000000b00673e652985bsm4108866pfe.118.2023.07.01.00.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jul 2023 00:19:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 8dd6c1a5-17df-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688195941; x=1690787941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=kNW+AYrQKnLKNbbn3YFHqN8Eo0KMGaoZgm6SWc5V5+U=; b=qvF+gtJkoOs75NZJtm/YNXiKKQiLpYV8Y3dP7sx/ZVMfFQucgbJ4JPROG2R+wI/TQi a45pGXHMyaE0jPCw7+//2MUPsVP9KgAysnKEicYtp3WZovkZQQPlxCuA719HmyD74HO1 unyeo+6N4GSUUDY/sgkLbehx0YyLJ2o97ems715x8/oHTNjpivLHonYtCgMz+Q0f7+CG zAx4YUuqf3WfpkY1ZSzqlQWmphc6LSVZojpSYHpqBWmmCUsIMxlBuzfmJ2PJgkRqt/l5 7OJ6GJKmx+qSaaNCfsdhuOKIk2hhC33IzQkm6bAfGj9Zq+7GsSRBTlI48iWkpMGpNVIl +8iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688195941; x=1690787941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kNW+AYrQKnLKNbbn3YFHqN8Eo0KMGaoZgm6SWc5V5+U=; b=LYMPLgOObjJDJQ9abW1bEqxVRVB0a0sJ6Q1OJ0TBjXzIU883r65zWgAxe0Dgj+9k+y ueKpRDY3oSJ3OlQFQKlp+Atnbfi/AJSLlRzFQemnaHpVsMvgaN/zJFJW1LMBC98caJ/3 pYcRNMlyZvolvTgHNXiVYAF6ZRggXbYC14lVOjQAkvD0J6ErTL7sMpiifq6LjwTfEI1H I7iLX/NG45aQpBSWKrV6NHxN14xom1ak/gyiYkCEqgsQCtcrF5NJvWqqWgNDqvRVAlor B8EGL/guAC5wEBgFpL7Jm0leR/pMXN8U6Es4q2ZHQcPwyg53ZUk7ixVE9zexQSMvRWqI Z3Cg== X-Gm-Message-State: AC+VfDw2h2rGKn68hsyPwWJY/EFLhzLRW1JQG+DcT7/BTS9HV6QKtL6g o94eiNEnQ+G9eAawjSpO7/uHLaFY3w0= X-Google-Smtp-Source: APBJJlFJOLvrQlTlbqeQdDwnW6s8Hbn/JAaopGLjUO8Ra0690Bt6OVuKd2cSZp766Vnno7X0T+4SJQ== X-Received: by 2002:a05:620a:2807:b0:767:382d:a203 with SMTP id f7-20020a05620a280700b00767382da203mr4959710qkp.36.1688195940769; Sat, 01 Jul 2023 00:19:00 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 10/10] x86 setup: refactor efi, pvh and multiboot entrypoints to new boot info Date: Sat, 1 Jul 2023 00:18:35 -0700 Message-Id: <20230701071835.41599-11-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701071835.41599-1-christopher.w.clark@gmail.com> References: <20230701071835.41599-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688195982868100001 Previous commits added a transition point from multiboot v1 structures to the new boot info structures at the earliest common point for all the x86 entrypoints. The result is that each of the entrypoints would construct a multiboot v1 structure from the structures used by each entrypoint. =C2=A0This meant that multiboot2, EFI, and PVH all converted their structures over to mutliboot v1 to only be converted again upon entering __start_xen(). This commit drops the translation function and moves the population of the new boot info structures down into the various entrypoints. This change increases the maximum number of boot modules accepted on the EFI entry path and the PVH entry path to the same fixed maximum number accepted via multiboot, making it common across all x86 entry points. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- Changes since v1: patch is based on v1 series patch 4. - use main bootinfo headers in boot logic instead of adding a 32-bit version - apply packing to boot structures here rather than in earlier changes - use a defined maximum number of boot modules rather than Kconfig'd variab= le xen/arch/arm/efi/efi-boot.h | 6 + xen/arch/x86/boot/defs.h | 1 + xen/arch/x86/boot/reloc.c | 192 +++++++++++++++------- xen/arch/x86/efi/efi-boot.h | 95 ++++++----- xen/arch/x86/guest/xen/pvh-boot.c | 64 +++++--- xen/arch/x86/include/asm/bootinfo.h | 7 +- xen/arch/x86/include/asm/guest/pvh-boot.h | 6 +- xen/arch/x86/setup.c | 73 +++----- xen/common/efi/boot.c | 4 +- xen/include/xen/bootinfo.h | 9 +- 10 files changed, 278 insertions(+), 179 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index bb64925d70..d931fe06ed 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -1003,6 +1003,12 @@ static void __init efi_arch_flush_dcache_area(const = void *vaddr, UINTN size) __flush_dcache_area(vaddr, size); } =20 +static struct boot_info __init *efi_arch_bootinfo_init(void) +{ + /* boot modules not currently in use on Arm so no init required here */ + return NULL; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index bc0f1b5cf8..519ca4dae6 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -44,6 +44,7 @@ _x > _y ? _x : _y; }) =20 #define _p(val) ((void *)(unsigned long)(val)) +#define _addr(val) ((unsigned long)(void *)(val)) =20 #define tolower(c) ((c) | 0x20) =20 diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index e22bb974bf..8a48572d5f 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -27,6 +27,8 @@ asm ( ); =20 #include "defs.h" +#include "../include/asm/bootinfo.h" +#include "../../../include/xen/bootinfo.h" #include "../../../include/xen/multiboot.h" #include "../../../include/xen/multiboot2.h" =20 @@ -138,65 +140,116 @@ static struct hvm_start_info *pvh_info_reloc(u32 in) return out; } =20 -static multiboot_info_t *mbi_reloc(u32 mbi_in) +static struct boot_info *mbi_reloc(u32 mbi_in) { + const multiboot_info_t *mbi =3D _p(mbi_in); + struct boot_info *binfo; + struct arch_boot_info *arch_binfo; int i; - multiboot_info_t *mbi_out; + uint32_t ptr; =20 - mbi_out =3D _p(copy_mem(mbi_in, sizeof(*mbi_out))); + ptr =3D alloc_mem(sizeof(*binfo)); + zero_mem(ptr, sizeof(*binfo)); + binfo =3D _p(ptr); =20 - if ( mbi_out->flags & MBI_CMDLINE ) - mbi_out->cmdline =3D copy_string(mbi_out->cmdline); + ptr =3D alloc_mem(sizeof(*arch_binfo)); + zero_mem(ptr, sizeof(*arch_binfo)); + binfo->arch =3D ptr; + arch_binfo =3D _p(ptr); =20 - if ( mbi_out->flags & MBI_MODULES ) + if ( mbi->flags & MBI_CMDLINE ) + { + ptr =3D copy_string(mbi->cmdline); + binfo->cmdline =3D ptr; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_CMDLINE; + } + + if ( mbi->flags & MBI_MODULES ) { module_t *mods; + struct boot_module *bi_mods; + struct arch_bootmodule *arch_bi_mods; + + /* + * We have to allocate one more module slot here. At some point + * __start_xen() may put Xen image placement into it. + */ + ptr =3D alloc_mem((mbi->mods_count + 1) * sizeof(*bi_mods)); + binfo->nr_mods =3D mbi->mods_count; + binfo->mods =3D ptr; + bi_mods =3D _p(ptr); =20 - mbi_out->mods_addr =3D copy_mem(mbi_out->mods_addr, - mbi_out->mods_count * sizeof(module_= t)); + ptr =3D alloc_mem((mbi->mods_count + 1) * sizeof(*arch_bi_mods)); + arch_bi_mods =3D _p(ptr); =20 - mods =3D _p(mbi_out->mods_addr); + /* map the +1 allocated for Xen image */ + bi_mods[mbi->mods_count].arch =3D _addr(&arch_bi_mods[mbi->mods_co= unt]); =20 - for ( i =3D 0; i < mbi_out->mods_count; i++ ) + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MODULES; + + mods =3D _p(mbi->mods_addr); + + for ( i =3D 0; i < mbi->mods_count; i++ ) { + bi_mods[i].start =3D mods[i].mod_start; + bi_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + if ( mods[i].string ) - mods[i].string =3D copy_string(mods[i].string); + { + int j; + char *c =3D _p(mods[i].string); + + for ( j =3D 0; *c !=3D '\0'; j++, c++ ) + bi_mods[i].string.bytes[j] =3D *c; + + bi_mods[i].string.len =3D j + 1; + } + + bi_mods[i].arch =3D _addr(&arch_bi_mods[i]); } } =20 - if ( mbi_out->flags & MBI_MEMMAP ) - mbi_out->mmap_addr =3D copy_mem(mbi_out->mmap_addr, mbi_out->mmap_= length); - - if ( mbi_out->flags & MBI_LOADERNAME ) - mbi_out->boot_loader_name =3D copy_string(mbi_out->boot_loader_nam= e); + if ( mbi->flags & MBI_MEMMAP ) + { + arch_binfo->mmap_addr =3D copy_mem(mbi->mmap_addr, mbi->mmap_lengt= h); + arch_binfo->mmap_length =3D mbi->mmap_length; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MEMMAP; + } =20 - /* Mask features we don't understand or don't relocate. */ - mbi_out->flags &=3D (MBI_MEMLIMITS | - MBI_CMDLINE | - MBI_MODULES | - MBI_MEMMAP | - MBI_LOADERNAME); + if ( mbi->flags & MBI_LOADERNAME ) + { + ptr =3D copy_string(mbi->boot_loader_name); + arch_binfo->boot_loader_name =3D ptr; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_LOADERNAME; + } =20 - return mbi_out; + return binfo; } =20 -static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) +static struct boot_info *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) { const multiboot2_fixed_t *mbi_fix =3D _p(mbi_in); const multiboot2_memory_map_t *mmap_src; const multiboot2_tag_t *tag; - module_t *mbi_out_mods =3D NULL; memory_map_t *mmap_dst; - multiboot_info_t *mbi_out; + struct boot_info *binfo; + struct arch_boot_info *arch_binfo; + struct boot_module *bi_mods; + struct arch_bootmodule *arch_bi_mods; #ifdef CONFIG_VIDEO struct boot_video_info *video =3D NULL; #endif u32 ptr; unsigned int i, mod_idx =3D 0; =20 - ptr =3D alloc_mem(sizeof(*mbi_out)); - mbi_out =3D _p(ptr); - zero_mem(ptr, sizeof(*mbi_out)); + ptr =3D alloc_mem(sizeof(*binfo)); + zero_mem(ptr, sizeof(*binfo)); + binfo =3D _p(ptr); + + ptr =3D alloc_mem(sizeof(*arch_binfo)); + zero_mem(ptr, sizeof(*arch_binfo)); + binfo->arch =3D ptr; + arch_binfo =3D _p(ptr); =20 /* Skip Multiboot2 information fixed part. */ ptr =3D ALIGN_UP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); @@ -206,21 +259,28 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) tag =3D _p(ALIGN_UP((u32)tag + tag->size, MULTIBOOT2_TAG_ALIGN))= ) { if ( tag->type =3D=3D MULTIBOOT2_TAG_TYPE_MODULE ) - ++mbi_out->mods_count; + ++binfo->nr_mods; else if ( tag->type =3D=3D MULTIBOOT2_TAG_TYPE_END ) break; } =20 - if ( mbi_out->mods_count ) + if ( binfo->nr_mods ) { - mbi_out->flags |=3D MBI_MODULES; /* * We have to allocate one more module slot here. At some point * __start_xen() may put Xen image placement into it. */ - mbi_out->mods_addr =3D alloc_mem((mbi_out->mods_count + 1) * - sizeof(*mbi_out_mods)); - mbi_out_mods =3D _p(mbi_out->mods_addr); + ptr =3D alloc_mem((binfo->nr_mods + 1) * sizeof(*bi_mods)); + binfo->mods =3D ptr; + bi_mods =3D _p(ptr); + + ptr =3D alloc_mem((binfo->nr_mods + 1) * sizeof(*arch_bi_mods)); + arch_bi_mods =3D _p(ptr); + + /* map the +1 allocated for Xen image */ + bi_mods[binfo->nr_mods].arch =3D _addr(&arch_bi_mods[binfo->nr_mod= s]); + + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MODULES; } =20 /* Skip Multiboot2 information fixed part. */ @@ -232,39 +292,42 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) switch ( tag->type ) { case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME: - mbi_out->flags |=3D MBI_LOADERNAME; ptr =3D get_mb2_string(tag, string, string); - mbi_out->boot_loader_name =3D copy_string(ptr); + arch_binfo->boot_loader_name =3D copy_string(ptr); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_LOADERNAME; break; =20 case MULTIBOOT2_TAG_TYPE_CMDLINE: - mbi_out->flags |=3D MBI_CMDLINE; ptr =3D get_mb2_string(tag, string, string); - mbi_out->cmdline =3D copy_string(ptr); + binfo->cmdline =3D copy_string(ptr); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_CMDLINE; break; =20 case MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO: - mbi_out->flags |=3D MBI_MEMLIMITS; - mbi_out->mem_lower =3D get_mb2_data(tag, basic_meminfo, mem_lo= wer); - mbi_out->mem_upper =3D get_mb2_data(tag, basic_meminfo, mem_up= per); + arch_binfo->mem_lower =3D get_mb2_data(tag, basic_meminfo, + mem_lower); + arch_binfo->mem_upper =3D get_mb2_data(tag, basic_meminfo, + mem_upper); break; =20 case MULTIBOOT2_TAG_TYPE_MMAP: if ( get_mb2_data(tag, mmap, entry_size) < sizeof(*mmap_src) ) break; =20 - mbi_out->flags |=3D MBI_MEMMAP; - mbi_out->mmap_length =3D get_mb2_data(tag, mmap, size); - mbi_out->mmap_length -=3D sizeof(multiboot2_tag_mmap_t); - mbi_out->mmap_length /=3D get_mb2_data(tag, mmap, entry_size); - mbi_out->mmap_length *=3D sizeof(*mmap_dst); + arch_binfo->mmap_length =3D get_mb2_data(tag, mmap, size); + arch_binfo->mmap_length -=3D sizeof(multiboot2_tag_mmap_t); + arch_binfo->mmap_length /=3D get_mb2_data(tag, mmap, entry_siz= e); + arch_binfo->mmap_length *=3D sizeof(*mmap_dst); =20 - mbi_out->mmap_addr =3D alloc_mem(mbi_out->mmap_length); + arch_binfo->mmap_addr =3D alloc_mem(arch_binfo->mmap_length); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MEMMAP; =20 mmap_src =3D get_mb2_data(tag, mmap, entries); - mmap_dst =3D _p(mbi_out->mmap_addr); + mmap_dst =3D _p(arch_binfo->mmap_addr); =20 - for ( i =3D 0; i < mbi_out->mmap_length / sizeof(*mmap_dst); i= ++ ) + for ( i =3D 0; + i < arch_binfo->mmap_length / sizeof(*mmap_dst); + i++ ) { /* Init size member properly. */ mmap_dst[i].size =3D sizeof(*mmap_dst); @@ -280,14 +343,27 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) break; =20 case MULTIBOOT2_TAG_TYPE_MODULE: - if ( mod_idx >=3D mbi_out->mods_count ) + if ( mod_idx >=3D binfo->nr_mods ) break; =20 - mbi_out_mods[mod_idx].mod_start =3D get_mb2_data(tag, module, = mod_start); - mbi_out_mods[mod_idx].mod_end =3D get_mb2_data(tag, module, mo= d_end); + bi_mods[mod_idx].start =3D get_mb2_data(tag, module, mod_start= ); + bi_mods[mod_idx].size =3D get_mb2_data(tag, module, mod_end) + - bi_mods[mod_idx].start; + ptr =3D get_mb2_string(tag, module, cmdline); - mbi_out_mods[mod_idx].string =3D copy_string(ptr); - mbi_out_mods[mod_idx].reserved =3D 0; + if ( ptr ) + { + int i; + char *c =3D _p(ptr); + + for ( i =3D 0; *c !=3D '\0'; i++, c++ ) + bi_mods[mod_idx].string.bytes[i] =3D *c; + + bi_mods[mod_idx].string.len =3D i + 1; + } + + bi_mods[mod_idx].arch =3D _addr(&arch_bi_mods[mod_idx]); + ++mod_idx; break; =20 @@ -344,11 +420,11 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) video->orig_video_isVGA =3D 0x23; #endif =20 - return mbi_out; + return binfo; } =20 -void *__stdcall reloc(uint32_t magic, uint32_t in, uint32_t trampoline, - uint32_t video_info) +void *__stdcall reloc( + uint32_t magic, uint32_t in, uint32_t trampoline, uint32_t video_info) { alloc =3D trampoline; =20 diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 64c1a02cf1..c05759b761 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -11,14 +11,17 @@ #include =20 static struct file __initdata ucode; -static multiboot_info_t __initdata mbi =3D { - .flags =3D MBI_MODULES | MBI_LOADERNAME -}; + +static struct boot_info __initdata efi_bi; +static struct arch_boot_info __initdata efi_bi_arch; /* * The array size needs to be one larger than the number of modules we * support - see __start_xen(). */ -static module_t __initdata mb_modules[5]; +static struct boot_module __initdata efi_mods[MAX_NR_BOOTMODS + 1]; +static struct arch_bootmodule __initdata efi_arch_mods[MAX_NR_BOOTMODS + 1= ]; + +static const char *__initdata efi_loader =3D "PVH Directboot"; =20 static void __init edd_put_string(u8 *dst, size_t n, const char *src) { @@ -271,20 +274,37 @@ static void __init noreturn efi_arch_post_exit_boot(v= oid) : [cr3] "r" (idle_pg_table), [cs] "i" (__HYPERVISOR_CS), [ds] "r" (__HYPERVISOR_DS), - "D" (&mbi) + "D" (&efi_bi) : "memory" ); unreachable(); } =20 -static void __init efi_arch_cfg_file_early(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, - const char *section) +static struct boot_info __init *efi_arch_bootinfo_init(void) { + int i; + + efi_bi.arch =3D &efi_bi_arch; + efi_bi.mods =3D efi_mods; + + for ( i=3D0; i <=3D MAX_NR_BOOTMODS; i++ ) + efi_bi.mods[i].arch =3D &efi_arch_mods[i]; + + efi_bi_arch.boot_loader_name =3D _p(efi_loader); + + efi_bi_arch.flags =3D BOOTINFO_FLAG_X86_MODULES | + BOOTINFO_FLAG_X86_LOADERNAME; + return &efi_bi; } =20 -static void __init efi_arch_cfg_file_late(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, - const char *section) +static void __init efi_arch_cfg_file_early( + const EFI_LOADED_IMAGE *image, EFI_FILE_HANDLE dir_handle, + const char *section) +{ +} + +static void __init efi_arch_cfg_file_late( + const EFI_LOADED_IMAGE *image, EFI_FILE_HANDLE dir_handle, + const char *section) { union string name; =20 @@ -296,16 +316,15 @@ static void __init efi_arch_cfg_file_late(const EFI_L= OADED_IMAGE *image, name.s =3D get_value(&cfg, "global", "ucode"); if ( name.s ) { - microcode_set_module(mbi.mods_count); + microcode_set_module(efi_bi.nr_mods); split_string(name.s); read_file(dir_handle, s2w(&name), &ucode, NULL); efi_bs->FreePool(name.w); } } =20 -static void __init efi_arch_handle_cmdline(CHAR16 *image_name, - CHAR16 *cmdline_options, - const char *cfgfile_options) +static void __init efi_arch_handle_cmdline( + CHAR16 *image_name, CHAR16 *cmdline_options, const char *cfgfile_optio= ns) { union string name; =20 @@ -313,10 +332,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *im= age_name, { name.w =3D cmdline_options; w2s(&name); - place_string(&mbi.cmdline, name.s); + place_string((uint32_t *)efi_bi.cmdline, name.s); } if ( cfgfile_options ) - place_string(&mbi.cmdline, cfgfile_options); + place_string((uint32_t *)efi_bi.cmdline, cfgfile_options); /* Insert image name last, as it gets prefixed to the other options. */ if ( image_name ) { @@ -325,16 +344,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *im= age_name, } else name.s =3D "xen"; - place_string(&mbi.cmdline, name.s); + place_string((uint32_t *)efi_bi.cmdline, name.s); =20 - if ( mbi.cmdline ) - mbi.flags |=3D MBI_CMDLINE; - /* - * These must not be initialized statically, since the value must - * not get relocated when processing base relocations later. - */ - mbi.boot_loader_name =3D (long)"EFI"; - mbi.mods_addr =3D (long)mb_modules; + if ( efi_bi.cmdline ) + efi_bi_arch.flags |=3D BOOTINFO_FLAG_X86_CMDLINE; } =20 static void __init efi_arch_edd(void) @@ -704,9 +717,8 @@ static void __init efi_arch_memory_setup(void) #undef l2_4G_offset } =20 -static void __init efi_arch_handle_module(const struct file *file, - const CHAR16 *name, - const char *options) +static void __init efi_arch_handle_module( + const struct file *file, const CHAR16 *name, const char *options) { union string local_name; void *ptr; @@ -724,17 +736,24 @@ static void __init efi_arch_handle_module(const struc= t file *file, w2s(&local_name); =20 /* - * If options are provided, put them in - * mb_modules[mbi.mods_count].string after the filename, with a space - * separating them. place_string() prepends strings and adds separati= ng - * spaces, so the call order is reversed. + * Set module string to filename and if options are provided, put them= in + * after the filename, with a space separating them. */ + strlcpy(efi_bi.mods[efi_bi.nr_mods].string.bytes, local_name.s, + BOOTMOD_STRING_MAX_LEN); if ( options ) - place_string(&mb_modules[mbi.mods_count].string, options); - place_string(&mb_modules[mbi.mods_count].string, local_name.s); - mb_modules[mbi.mods_count].mod_start =3D file->addr >> PAGE_SHIFT; - mb_modules[mbi.mods_count].mod_end =3D file->size; - ++mbi.mods_count; + { + strlcat(efi_bi.mods[efi_bi.nr_mods].string.bytes, " ", + BOOTMOD_STRING_MAX_LEN); + strlcat(efi_bi.mods[efi_bi.nr_mods].string.bytes, options, + BOOTMOD_STRING_MAX_LEN); + } + + efi_bi.mods[efi_bi.nr_mods].start =3D file->addr; + efi_bi.mods[efi_bi.nr_mods].mfn =3D maddr_to_mfn(file->addr); + efi_bi.mods[efi_bi.nr_mods].size =3D file->size; + + ++efi_bi.nr_mods; efi_bs->FreePool(ptr); } =20 diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh= -boot.c index 1ed04d035c..dd10a358da 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -6,6 +6,7 @@ * * Copyright (c) 2017 Citrix Systems Ltd. */ +#include #include #include #include @@ -20,12 +21,28 @@ bool __initdata pvh_boot; uint32_t __initdata pvh_start_info_pa; =20 -static multiboot_info_t __initdata pvh_mbi; -static module_t __initdata pvh_mbi_mods[8]; -static const char *__initdata pvh_loader =3D "PVH Directboot"; +static struct boot_info __initdata pvh_bi; +static struct arch_boot_info __initdata arch_pvh_bi; +static struct boot_module __initdata pvh_mods[MAX_NR_BOOTMODS + 1]; +static struct arch_bootmodule __initdata arch_pvh_mods[MAX_NR_BOOTMODS + 1= ]; +static char __initdata *pvh_loader =3D "PVH Directboot"; =20 -static void __init convert_pvh_info(multiboot_info_t **mbi, - module_t **mod) +static struct boot_info __init *init_pvh_info(void) +{ + int i; + + pvh_bi.arch =3D &arch_pvh_bi; + pvh_bi.mods =3D pvh_mods; + + for ( i=3D0; i <=3D MAX_NR_BOOTMODS; i++ ) + pvh_bi.mods[i].arch =3D &arch_pvh_mods[i]; + + pvh_bi.arch->boot_loader_name =3D pvh_loader; + + return &pvh_bi; +} + +static void __init convert_pvh_info(struct boot_info *bi) { const struct hvm_start_info *pvh_info =3D __va(pvh_start_info_pa); const struct hvm_modlist_entry *entry; @@ -39,23 +56,22 @@ static void __init convert_pvh_info(multiboot_info_t **= mbi, * required. The extra element is used to aid relocation. See * arch/x86/setup.c:__start_xen(). */ - if ( ARRAY_SIZE(pvh_mbi_mods) <=3D pvh_info->nr_modules ) + if ( ARRAY_SIZE(pvh_mods) <=3D pvh_info->nr_modules ) panic("The module array is too small, size %zu, requested %u\n", - ARRAY_SIZE(pvh_mbi_mods), pvh_info->nr_modules); + ARRAY_SIZE(pvh_mods), pvh_info->nr_modules); =20 /* * Turn hvm_start_info into mbi. Luckily all modules are placed under = 4GB * boundary on x86. */ - pvh_mbi.flags =3D MBI_CMDLINE | MBI_MODULES | MBI_LOADERNAME; + bi->arch->flags =3D BOOTINFO_FLAG_X86_CMDLINE | BOOTINFO_FLAG_X86_MODU= LES + | BOOTINFO_FLAG_X86_LOADERNAME; =20 BUG_ON(pvh_info->cmdline_paddr >> 32); - pvh_mbi.cmdline =3D pvh_info->cmdline_paddr; - pvh_mbi.boot_loader_name =3D __pa(pvh_loader); + bi->cmdline =3D _p(__va(pvh_info->cmdline_paddr)); =20 - BUG_ON(pvh_info->nr_modules >=3D ARRAY_SIZE(pvh_mbi_mods)); - pvh_mbi.mods_count =3D pvh_info->nr_modules; - pvh_mbi.mods_addr =3D __pa(pvh_mbi_mods); + BUG_ON(pvh_info->nr_modules >=3D ARRAY_SIZE(pvh_mods)); + bi->nr_mods =3D pvh_info->nr_modules; =20 entry =3D __va(pvh_info->modlist_paddr); for ( i =3D 0; i < pvh_info->nr_modules; i++ ) @@ -63,15 +79,18 @@ static void __init convert_pvh_info(multiboot_info_t **= mbi, BUG_ON(entry[i].paddr >> 32); BUG_ON(entry[i].cmdline_paddr >> 32); =20 - pvh_mbi_mods[i].mod_start =3D entry[i].paddr; - pvh_mbi_mods[i].mod_end =3D entry[i].paddr + entry[i].size; - pvh_mbi_mods[i].string =3D entry[i].cmdline_paddr; + bi->mods[i].start =3D entry[i].paddr; + bi->mods[i].size =3D entry[i].size; + if ( entry[i].cmdline_paddr) + { + char *c =3D _p(__va(entry[i].cmdline_paddr)); + + safe_strcpy(bi->mods[i].string.bytes, c); + bi->mods[i].string.kind =3D BOOTSTR_CMDLINE; + } } =20 rsdp_hint =3D pvh_info->rsdp_paddr; - - *mbi =3D &pvh_mbi; - *mod =3D pvh_mbi_mods; } =20 static void __init get_memory_map(void) @@ -88,13 +107,16 @@ static void __init get_memory_map(void) sanitize_e820_map(e820_raw.map, &e820_raw.nr_map); } =20 -void __init pvh_init(multiboot_info_t **mbi, module_t **mod) +void __init pvh_init(struct boot_info **bi) { - convert_pvh_info(mbi, mod); + *bi =3D init_pvh_info(); + convert_pvh_info(*bi); =20 hypervisor_probe(); ASSERT(xen_guest); =20 + (*bi)->arch->xen_guest =3D xen_guest; + get_memory_map(); } =20 diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 989fb7a1da..c1ed76fd3e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -1,14 +1,14 @@ #ifndef __ARCH_X86_BOOTINFO_H__ #define __ARCH_X86_BOOTINFO_H__ =20 -struct arch_bootmodule { +struct __packed arch_bootmodule { #define BOOTMOD_FLAG_X86_RELOCATED 1U << 0 uint32_t flags; unsigned headroom; }; DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); =20 -struct arch_boot_info { +struct __packed arch_boot_info { uint32_t flags; #define BOOTINFO_FLAG_X86_CMDLINE 1U << 2 #define BOOTINFO_FLAG_X86_MODULES 1U << 3 @@ -17,6 +17,9 @@ struct arch_boot_info { =20 char_ptr_t boot_loader_name; =20 + uint32_t mem_lower; + uint32_t mem_upper; + uint32_t mmap_length; paddr_t mmap_addr; }; diff --git a/xen/arch/x86/include/asm/guest/pvh-boot.h b/xen/arch/x86/inclu= de/asm/guest/pvh-boot.h index 247ba6899e..c820b0bf88 100644 --- a/xen/arch/x86/include/asm/guest/pvh-boot.h +++ b/xen/arch/x86/include/asm/guest/pvh-boot.h @@ -8,13 +8,13 @@ #ifndef __X86_PVH_BOOT_H__ #define __X86_PVH_BOOT_H__ =20 -#include +#include =20 #ifdef CONFIG_PVH_GUEST =20 extern bool pvh_boot; =20 -void pvh_init(multiboot_info_t **mbi, module_t **mod); +void __init pvh_init(struct boot_info **bi); void pvh_print_info(void); =20 #else @@ -23,7 +23,7 @@ void pvh_print_info(void); =20 #define pvh_boot 0 =20 -static inline void pvh_init(multiboot_info_t **mbi, module_t **mod) +static inline void __init pvh_init(struct boot_info **bi) { ASSERT_UNREACHABLE(); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 50a1a124b0..05a76a5959 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -60,9 +59,6 @@ #include #include =20 -/* Max number of boot modules a bootloader can provide in addition to Xen = */ -#define MAX_NR_BOOTMODS 63 - /* opt_nosmp: If true, secondary processors are ignored. */ static bool __initdata opt_nosmp; boolean_param("nosmp", opt_nosmp); @@ -275,46 +271,6 @@ custom_param("acpi", parse_acpi_param); =20 static struct boot_info __initdata *boot_info; =20 -static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *= mods) -{ - static struct boot_info __initdata info; - static struct arch_boot_info __initdata arch_info; - static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1= ]; - static struct arch_bootmodule __initdata arch_boot_mods[ - MAX_NR_BOOTMODS + 1= ]; - - int i; - - info.arch =3D &arch_info; - info.mods =3D boot_mods; - - info.cmdline =3D __va(mbi->cmdline); - - /* The BOOTINFO_FLAG_X86_* flags are a 1-1 map to MBI_* */ - arch_info.flags =3D mbi->flags; - arch_info.mmap_length =3D mbi->mmap_length; - arch_info.mmap_addr =3D mbi->mmap_addr; - arch_info.boot_loader_name =3D __va(mbi->boot_loader_name); - - info.nr_mods =3D mbi->mods_count; - for ( i =3D 0; i <=3D MAX_NR_BOOTMODS; i++ ) - { - boot_mods[i].arch =3D &arch_boot_mods[i]; - - if ( i < info.nr_mods ) - { - bootmodule_update_start(&boot_mods[i], mods[i].mod_start); - boot_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; - - boot_mods[i].string.len =3D strlcpy(boot_mods[i].string.bytes, - __va(mods[i].string), - BOOTMOD_STRING_MAX_LEN); - } - } - - boot_info =3D &info; -} - unsigned long __init initial_images_nrpages(nodeid_t node) { unsigned long node_start =3D node_start_pfn(node); @@ -1014,15 +970,13 @@ static struct domain *__init create_dom0(const struc= t boot_info *bootinfo, /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) =20 -void __init noreturn __start_xen(unsigned long mbi_p) +void __init noreturn __start_xen(unsigned long bi_p) { char *memmap_type =3D NULL; char *cmdline, *kextra, *loader; void *bsp_stack; struct cpu_info *info =3D get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked =3D 0; - multiboot_info_t *mbi; - module_t *mod; unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; @@ -1059,16 +1013,29 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 if ( pvh_boot ) { - ASSERT(mbi_p =3D=3D 0); - pvh_init(&mbi, &mod); + ASSERT(bi_p =3D=3D 0); + pvh_init(&boot_info); } else { - mbi =3D __va(mbi_p); - mod =3D __va(mbi->mods_addr); - } + /* + * Since addresses were setup before virtual addressing was enable= d, + * fixup pointers to virtual addresses for proper dereferencing. + */ + boot_info =3D __va(bi_p); + boot_info->cmdline =3D __va(boot_info->cmdline); + boot_info->mods =3D __va(boot_info->mods); + boot_info->arch =3D __va(boot_info->arch); + + boot_info->arch->boot_loader_name =3D + __va(boot_info->arch->boot_loader_name); =20 - multiboot_to_bootinfo(mbi, mod); + for ( i =3D 0; i <=3D boot_info->nr_mods; i++ ) + { + boot_info->mods[i].mfn =3D maddr_to_mfn(boot_info->mods[i].sta= rt); + boot_info->mods[i].arch =3D __va(boot_info->mods[i].arch); + } + } =20 loader =3D (boot_info->arch->flags & BOOTINFO_FLAG_X86_LOADERNAME) ? boot_info->arch->boot_loader_name : "unknown"; diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index c5850c26af..09b38b497c 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -1359,6 +1359,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *S= ystemTable) =20 efi_arch_relocate_image(0); =20 + efi_arch_bootinfo_init(); + if ( use_cfg_file ) { EFI_FILE_HANDLE dir_handle; diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index bf5586a76b..6e09be6899 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -20,13 +20,16 @@ #define BOOTMOD_GUEST_DTB 7 typedef unsigned int bootmod_type_t; =20 +/* Max number of boot modules a bootloader can provide in addition to Xen = */ +#define MAX_NR_BOOTMODS 63 + #define BOOTMOD_STRING_MAX_LEN 1024 -struct boot_string { +struct __packed boot_string { char bytes[BOOTMOD_STRING_MAX_LEN]; size_t len; }; =20 -struct boot_module { +struct __packed boot_module { bootmod_type_t bootmod_type; paddr_t start; mfn_t mfn; @@ -37,7 +40,7 @@ struct boot_module { }; DEFINE_STRUCT_PTR_TYPE(boot_module); =20 -struct boot_info { +struct __packed boot_info { char_ptr_t cmdline; =20 unsigned int nr_mods; --=20 2.25.1