From patchwork Thu Oct 24 14:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13849307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EE0ACE8E80 for ; Thu, 24 Oct 2024 14:27:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.825346.1239545 (Exim 4.92) (envelope-from ) id 1t3ynm-00048t-H6; Thu, 24 Oct 2024 14:27:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 825346.1239545; Thu, 24 Oct 2024 14:27: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 1t3ynm-00048m-EX; Thu, 24 Oct 2024 14:27:02 +0000 Received: by outflank-mailman (input) for mailman id 825346; Thu, 24 Oct 2024 14:27: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 1t3ynl-00048L-6M for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 14:27:01 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 07b73ecc-9214-11ef-a0bf-8be0dac302b0; Thu, 24 Oct 2024 16:27:00 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5c9362c26d8so3732613a12.1 for ; Thu, 24 Oct 2024 07:27:00 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66c6b4e4sm5707409a12.61.2024.10.24.07.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:26:58 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 07b73ecc-9214-11ef-a0bf-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729780019; x=1730384819; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dVXd7SoQfi1YRwuP/bchb8oFe7nMu7FPsr69BeMQRRM=; b=h/zWW9hfot0jC6bq1GDu4wIZadz8TduqHvPgF9xie0DvIp+FPMlG1oh9qJfmRkqNkx NG2znVzaCjZpfLy5QUysl2SPcp0pJ9QnN4mH4U+SAVNys3mtYmt41X9BAs1znEvQmjYj wAcfDIHmR7ItKlNeX75M50WCBeoWJsyAvGIsk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780019; x=1730384819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dVXd7SoQfi1YRwuP/bchb8oFe7nMu7FPsr69BeMQRRM=; b=ho+VXHkrhCsD0JE+40wtqz+gDAEAqGAI4zSU/aT/qaNUIrWSB4piCro2kndT2kf7jf N5TOJenNubGKhhXxRAx61R7LZ5jtYQHWqx7lqRNZUhtnxuf4gdkR6fTsnmmbFCtoeSJy q/SrzT50sVsBvWtNiHgcPCOS8ZxYFv36qWIrXa2Jgjb7nfsfb9N3RCHXGNFx23qpE/Yr zXQZ/Yzv+NHFj9Ucg1jHsOKpz4wKSSFdi1bhMW+3UymQhvZBBoc1TZE7oT8z/31XaYks iSj5RkkbKZQLXtjmfH9TIbPayJlmrf+jIMWQ+wpGMEE2aPZjJY6nHWigOIJ+zFQJMh2M jLvA== X-Gm-Message-State: AOJu0Yxb85EVYcKTG6u7TmdhJ2aPZ0tmkh6OLeVQ+XxGA5SusJ8dHfBa YoCJtRQJ7jL1Rxr+7/Eb7OA6vPJ46qBW99PCY6LwRu3OFefv2XJoirT3/Es5JajGI1BS/qrP9cK d X-Google-Smtp-Source: AGHT+IFdW0kax42rLgItyEEOWYAkOto/YtbLa80UVJKfCn0MH9m2V6QJhdd1EQujAwwV3XZEmg7iFA== X-Received: by 2002:a05:6402:538d:b0:5c5:c2a7:d535 with SMTP id 4fb4d7f45d1cf-5cba208256bmr2588565a12.16.1729780018684; Thu, 24 Oct 2024 07:26:58 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: "Daniel P. Smith" , Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 1/5] x86/boot: Drop initial_images pointer Date: Thu, 24 Oct 2024 15:26:50 +0100 Message-Id: <20241024142654.989980-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024142654.989980-1-andrew.cooper3@citrix.com> References: <20241024142654.989980-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: "Daniel P. Smith" Now that the module list is encapsulated inside boot_info, we can do away with the initial_images pointer. No functional change. Signed-off-by: Daniel P. Smith Signed-off-by: Andrew Cooper Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith v7.5: * Rearranged from several later patches --- xen/arch/x86/setup.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index fc18ba3e35b5..8c10fe51dfad 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,8 +276,6 @@ custom_param("acpi", parse_acpi_param); static const char *cmdline_cook(const char *p, const char *loader_name); -static const module_t *__initdata initial_images; - struct boot_info __initdata xen_boot_info = { .loader = "unknown", .cmdline = "", @@ -332,8 +330,8 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = initial_images[i].mod_start; - unsigned long end = start + PFN_UP(initial_images[i].mod_end); + unsigned long start = bi->mods[i].mod->mod_start; + unsigned long end = start + PFN_UP(bi->mods[i].mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -349,14 +347,13 @@ void __init discard_initial_images(void) for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; + uint64_t start = pfn_to_paddr(bi->mods[i].mod->mod_start); init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(bi->mods[i].mod->mod_end)); } bi->nr_modules = 0; - initial_images = NULL; } static void __init init_idle_domain(void) @@ -1376,8 +1373,6 @@ void asmlinkage __init noreturn __start_xen(void) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - initial_images = mod; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) From patchwork Thu Oct 24 14:26:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13849309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04635CE8E7F for ; Thu, 24 Oct 2024 14:27:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.825348.1239566 (Exim 4.92) (envelope-from ) id 1t3ynn-0004b6-Vj; Thu, 24 Oct 2024 14:27:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 825348.1239566; Thu, 24 Oct 2024 14:27: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 1t3ynn-0004az-RF; Thu, 24 Oct 2024 14:27:03 +0000 Received: by outflank-mailman (input) for mailman id 825348; Thu, 24 Oct 2024 14:27: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 1t3ynl-00048L-UH for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 14:27:01 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0890c943-9214-11ef-a0bf-8be0dac302b0; Thu, 24 Oct 2024 16:27:01 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5c9709c9b0cso1290425a12.1 for ; Thu, 24 Oct 2024 07:27:01 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66c6b4e4sm5707409a12.61.2024.10.24.07.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:26:58 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0890c943-9214-11ef-a0bf-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729780020; x=1730384820; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nlxvwzJVPPnRSm1WJDmkyMNWEmqNga8e4AWKAxVxRWA=; b=HRCg04WwAOI2f0GqWFgij3bAYN3/FPkao2mC6HtcA5YbFMzjsQFMUDnVBBPFE3gFUO KrCO/NkaDkYmE07bYUB8zf5kZktKDN7jSTAFUaCnslgcVx1hT9IIAalsctT+LeY20tXm 1mZEUC+jYh9+Tj/GrhlgBZO2q+IFHssubHh2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780020; x=1730384820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nlxvwzJVPPnRSm1WJDmkyMNWEmqNga8e4AWKAxVxRWA=; b=l98oc41f4kldqQJHaaFP08vXNwH9oYwmab5yzH15o9nAmUAg6j34RbmolBe1vnR6LL IGTTQ74w42Uz5CyUIsHlqbkSzYauOaQnSofN5F1Y+rfNvqGidZ51wT1tcccVxSrTazWu 32mpE8IgMJOfz+gXPr49dMwzt0kRjREsjDRLBkhHFxCZ6aynJQ4dE71uAbZ1UQBFiunx HpwCHS6eU5h5uC8eJiLCx7yzJ7GXzDVX3tfRdS0ddcZlxcbnry6QRxoKjY0/O4KKxr/1 C4cOj/dHeX+pHziwWD6MHSwgm0GZfpkQ7OdhOCgaxPFZHuubOJj2OapROii0DnJNQoBo gM3w== X-Gm-Message-State: AOJu0YzZWnUj39BwdlYJBFzi1l5jPURzeFrXlVQKyzraHny0V7GPMDZO vS/nXUszinkbEwVjr9O5//FRQ2jgjmE7TO37EWTfbQQiiA2O9Oryzb7ywqdVX4ry3M66/ZHYHB7 s X-Google-Smtp-Source: AGHT+IF9HdVMlJ7LWUwQaPIk62zIToVeIBN+RTzdkSEC2LQrfp3ljwUPiPjrJjR6BLnJNygnDlM/qA== X-Received: by 2002:a05:6402:3510:b0:5c9:8ac6:5f11 with SMTP id 4fb4d7f45d1cf-5cb8b1cefcamr5190098a12.36.1729780020357; Thu, 24 Oct 2024 07:27:00 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P . Smith" Subject: [PATCH 2/5] x86/boot: Introduce bootstrap_unmap() Date: Thu, 24 Oct 2024 15:26:51 +0100 Message-Id: <20241024142654.989980-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024142654.989980-1-andrew.cooper3@citrix.com> References: <20241024142654.989980-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 We're about to introduce alternative mapping functions, and passing NULL was always a slightly weird way to express unmap. Make an explicit unmap function, to avoid having two different valid ways of unmapping. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith v7.5: * New --- xen/arch/x86/cpu/microcode/core.c | 6 +++--- xen/arch/x86/include/asm/setup.h | 2 ++ xen/arch/x86/pv/dom0_build.c | 2 +- xen/arch/x86/setup.c | 10 ++++++---- xen/xsm/xsm_core.c | 4 ++-- xen/xsm/xsm_policy.c | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 1d58cb0f3bc1..cf6517293375 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -198,7 +198,7 @@ static void __init microcode_scan_module(struct boot_info *bi) ucode_blob.data = cd.data; break; } - bootstrap_map(NULL); + bootstrap_unmap(); } } @@ -763,13 +763,13 @@ static int __init cf_check microcode_init(void) */ if ( ucode_blob.size ) { - bootstrap_map(NULL); + bootstrap_unmap(); ucode_blob.size = 0; ucode_blob.data = NULL; } else if ( ucode_mod.mod_end ) { - bootstrap_map(NULL); + bootstrap_unmap(); ucode_mod.mod_end = 0; } diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 811855e57478..8b7843104ff7 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -37,7 +37,9 @@ extern struct boot_info xen_boot_info; unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); + void *bootstrap_map(const module_t *mod); +void bootstrap_unmap(void); int remove_xen_ranges(struct rangeset *r); diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index ee9ecdc2abbf..cdae17b27654 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -830,7 +830,7 @@ static int __init dom0_construct(struct domain *d, printk("Failed to load the kernel binary\n"); goto out; } - bootstrap_map(NULL); + bootstrap_unmap(); if ( UNSET_ADDR != parms.virt_hypercall ) { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8c10fe51dfad..8e32d6c49c54 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -471,13 +471,15 @@ static void *__init bootstrap_map_addr(paddr_t start, paddr_t end) void *__init bootstrap_map(const module_t *mod) { - if ( !mod ) - return bootstrap_map_addr(0, 0); - return bootstrap_map_addr(pfn_to_paddr(mod->mod_start), pfn_to_paddr(mod->mod_start) + mod->mod_end); } +void __init bootstrap_unmap(void) +{ + bootstrap_map_addr(0, 0); +} + static void __init move_memory( uint64_t dst, uint64_t src, unsigned int size) { @@ -1402,7 +1404,7 @@ void asmlinkage __init noreturn __start_xen(void) } modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); - bootstrap_map(NULL); + bootstrap_unmap(); #ifndef highmem_start /* Don't allow split below 4Gb. */ diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 6e3fac68c057..f255fb63bf6f 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -153,14 +153,14 @@ int __init xsm_multiboot_init(struct boot_info *bi) ret = xsm_multiboot_policy_init(bi, &policy_buffer, &policy_size); if ( ret ) { - bootstrap_map(NULL); + bootstrap_unmap(); printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); return -EINVAL; } } ret = xsm_core_init(policy_buffer, policy_size); - bootstrap_map(NULL); + bootstrap_unmap(); return 0; } diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 6f799dd28f5b..35f36c6f2359 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -63,7 +63,7 @@ int __init xsm_multiboot_policy_init( } - bootstrap_map(NULL); + bootstrap_unmap(); } return rc; From patchwork Thu Oct 24 14:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13849308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48FF5CE8E7F for ; Thu, 24 Oct 2024 14:27:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.825349.1239576 (Exim 4.92) (envelope-from ) id 1t3ynq-0004rW-A8; Thu, 24 Oct 2024 14:27:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 825349.1239576; Thu, 24 Oct 2024 14:27: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 1t3ynq-0004rL-7Y; Thu, 24 Oct 2024 14:27:06 +0000 Received: by outflank-mailman (input) for mailman id 825349; Thu, 24 Oct 2024 14:27:04 +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 1t3yno-00048O-Th for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 14:27:04 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 09bc6782-9214-11ef-99a3-01e77a169b0f; Thu, 24 Oct 2024 16:27:03 +0200 (CEST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5c948c41edeso1127887a12.1 for ; Thu, 24 Oct 2024 07:27:03 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66c6b4e4sm5707409a12.61.2024.10.24.07.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:27:00 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 09bc6782-9214-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729780022; x=1730384822; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k/1V36zu8pl8T7xYRf9La+mccrttDt5v1Zny77BeDlA=; b=oLJXcoQ2tWqUqHnNg+vTYDB7AFRbqlJHm0KRL/prGZ71CjRDGlpbhv9jXIRYnmv4OC UUr7wpjePTYUoEg7p+0REsrFv1WlcMwFSvg5DgZx9SIqdxayY/L3lj30pFt1zmWtAA4B 4baywjGUwXtAKogEvcGJ2ljfkphOhC5pU5vSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780022; x=1730384822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k/1V36zu8pl8T7xYRf9La+mccrttDt5v1Zny77BeDlA=; b=UZCl0vN4CjEAPsHHRwy3izVJbS7/FwXeTsuY3PGkFV56eSSgKVCbyE8Yez8NsaMW9n 2axhFktbQARLQ7tsvY0DxNA7jBSSIvg2onxhSK45ASgsPpjTKC6LKJc1HcqRJjwbPqkJ +wjI+QbB2oyMZDDli0F4Og1dkLIHTxM2QU9dEXsjOA+zbMszECceSRLAYM6Gf2elL4EA UGzsF4/FMvt2vr/55EkJ60PgknIv7bU096NHqiCzPCGsObtal4QC8WVsXUUgrcy1Jzbn iDDUaEjvaR+LFsz6MgGLg2JItOqJev8McFk/DIle0Q76GBjBaEK2UPH+XqrO2WhGAk8u pwEA== X-Gm-Message-State: AOJu0YwnLaVWKU/WhSr82VXShwK9vKcToHETQiCf7rEyoD4uEcGuLZAE zN4Y8dqivOwCt18PB0aFoXkdTpiJwPS1i7wM6T9QZuWYQ79Bl7OzDmsKU93kZy02T62QLwFMLEL l X-Google-Smtp-Source: AGHT+IH6p9gdO0AX6mLGCwEkRJD/oDfxz+x/AJPocHh/3hD6qDzdaNJNyDPqbrO7R32Qwdz4y9sHdg== X-Received: by 2002:a05:6402:254b:b0:5ca:da2:b2ca with SMTP id 4fb4d7f45d1cf-5cb8acba591mr6178431a12.19.1729780021899; Thu, 24 Oct 2024 07:27:01 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: "Daniel P. Smith" , Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 3/5] x86/boot: Introduce bootstrap_map_bm() to map boot_module's Date: Thu, 24 Oct 2024 15:26:52 +0100 Message-Id: <20241024142654.989980-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024142654.989980-1-andrew.cooper3@citrix.com> References: <20241024142654.989980-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: "Daniel P. Smith" Convert converting the call to bzimage_headroom(), as well as using bi->mod[0]. It will be used externally by later changes. No functional change. Signed-off-by: Daniel P. Smith Signed-off-by: Andrew Cooper Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith v7.5: * Refectored/extracted from later in the series. --- xen/arch/x86/include/asm/setup.h | 2 ++ xen/arch/x86/setup.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 8b7843104ff7..4874ee8936fc 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -38,6 +38,8 @@ extern struct boot_info xen_boot_info; unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); +struct boot_module; +void *bootstrap_map_bm(const struct boot_module *bm); void *bootstrap_map(const module_t *mod); void bootstrap_unmap(void); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8e32d6c49c54..ee03725af380 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -475,6 +475,11 @@ void *__init bootstrap_map(const module_t *mod) pfn_to_paddr(mod->mod_start) + mod->mod_end); } +void *__init bootstrap_map_bm(const struct boot_module *bm) +{ + return bootstrap_map(bm->mod); +} + void __init bootstrap_unmap(void) { bootstrap_map_addr(0, 0); @@ -1403,7 +1408,9 @@ void asmlinkage __init noreturn __start_xen(void) mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; } - modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); + modules_headroom = + bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), + bi->mods[0].mod->mod_end); bootstrap_unmap(); #ifndef highmem_start From patchwork Thu Oct 24 14:26:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13849316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69530CE8E7F for ; Thu, 24 Oct 2024 14:27:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.825351.1239596 (Exim 4.92) (envelope-from ) id 1t3yns-0005Oy-QR; Thu, 24 Oct 2024 14:27:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 825351.1239596; Thu, 24 Oct 2024 14:27:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3yns-0005O8-Ne; Thu, 24 Oct 2024 14:27:08 +0000 Received: by outflank-mailman (input) for mailman id 825351; Thu, 24 Oct 2024 14:27:07 +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 1t3ynr-00048O-4m for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 14:27:07 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0afba90a-9214-11ef-99a3-01e77a169b0f; Thu, 24 Oct 2024 16:27:05 +0200 (CEST) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5c957d8bce2so510635a12.2 for ; Thu, 24 Oct 2024 07:27:05 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66c6b4e4sm5707409a12.61.2024.10.24.07.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:27:02 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0afba90a-9214-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729780024; x=1730384824; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hkGTFmIsU8uVl1vUxZAmxH9TN/jWgRT2CVKi7nypqKo=; b=kgCXbykcUw0gGRmGf6wSTmo6C8NZE0lXcwCsNn152Yv73OQOZPXePPzrhWNZ+VwzSu NPaM8x9oZeJj8Y5CPul11qgxwuEXzn3SKMq9POt8PD6ZhoRGN+OPRqakBw1iIxlGdiID jtM1jHs28nZv8Wu5AzLqgCsqTSlnxc9IX61fE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780024; x=1730384824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkGTFmIsU8uVl1vUxZAmxH9TN/jWgRT2CVKi7nypqKo=; b=xVZD//rXhOc5H6Cu2Rfe+fujad2e2VGSjGe9hhpUct9RTytClrOOYhY1gOmgCjM8tP 1WW/ai3nUQcHHsBPMyQMeNMIJD+3K3i7pl4KZsip8KNBAUJfsEEvqnP+vh5qe5AJbQ9q fBpGdZu7kuNmRKqGbioIn/MDrDMe2B/l6B2GPxczKxNaIhkyPoB1RUy84TUBtH3JB9Iq VGfRLpkGbECV0hYwUWVOhFsRw1bcm603ynZf9OtV8bPmZS5Aj07BFecl0U/59SPCWn1c ebncySXJBxmA2b/Z4wW8BAzWSxGbnhICmMwI47bxCQXWJILHoJ+kAtl+Ua0FaSrcFh0o D10A== X-Gm-Message-State: AOJu0YyEeSaPXcSnBIqAlnOiUiIjqJsLnqv6Ggn2CcJRPO+IkgQvuXrY HXh+tI7roz+ch8srdJ3M8BXaIKXEH435ZVTEbhgoablU/0JIz/3qQ/6PMfnHX8w8LIAHRnHAePq a X-Google-Smtp-Source: AGHT+IGFmhwnmNKSrxMQ2nLtOFpPT2TfElRIUQMDZRSNandfpDYCYSVT9qRaApu/eTcVnyxk677kEQ== X-Received: by 2002:a05:6402:3489:b0:5c9:48df:713c with SMTP id 4fb4d7f45d1cf-5cb8af7defbmr6676395a12.2.1729780023866; Thu, 24 Oct 2024 07:27:03 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: "Daniel P. Smith" , Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 4/5] x86/boot: Convert mod[] to bi->mods[] in __start_xen() Date: Thu, 24 Oct 2024 15:26:53 +0100 Message-Id: <20241024142654.989980-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024142654.989980-1-andrew.cooper3@citrix.com> References: <20241024142654.989980-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 From: "Daniel P. Smith" The former is about to disappear. In some cases, introduce a local struct boot_module pointer. Judgement on where to do this, and on constness, is based on what creates least churn overall. No functional change. Signed-off-by: Daniel P. Smith Signed-off-by: Andrew Cooper Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith v7.5: * Rearranged from several later patches --- xen/arch/x86/setup.c | 59 +++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ee03725af380..5413e1c71be6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1382,11 +1382,11 @@ void asmlinkage __init noreturn __start_xen(void) for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - mod[i].mod_end -= mod[i].mod_start; - mod[i].mod_start >>= PAGE_SHIFT; - mod[i].reserved = 0; + bi->mods[i].mod->mod_end -= bi->mods[i].mod->mod_start; + bi->mods[i].mod->mod_start >>= PAGE_SHIFT; + bi->mods[i].mod->reserved = 0; } /* @@ -1397,6 +1397,8 @@ void asmlinkage __init noreturn __start_xen(void) if ( xen_phys_start ) { + struct boot_module *xen = &bi->mods[bi->nr_modules]; + relocated = true; /* @@ -1404,8 +1406,8 @@ void asmlinkage __init noreturn __start_xen(void) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[bi->nr_modules].mod_start = virt_to_mfn(_stext); - mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; + xen->mod->mod_start = virt_to_mfn(_stext); + xen->mod->mod_end = __2M_rwdata_end - _stext; } modules_headroom = @@ -1490,15 +1492,17 @@ void asmlinkage __init noreturn __start_xen(void) /* Is the region suitable for relocating the multiboot modules? */ for ( j = bi->nr_modules - 1; j >= 0; j-- ) { + struct boot_module *bm = &bi->mods[j]; + /* * 'headroom' is a guess for the decompressed size and * decompressor overheads of mod[0] (the dom0 kernel). When we * move mod[0], we incorporate this as extra space at the start. */ unsigned long headroom = j ? 0 : modules_headroom; - unsigned long size = PAGE_ALIGN(headroom + mod[j].mod_end); + unsigned long size = PAGE_ALIGN(headroom + bm->mod->mod_end); - if ( mod[j].reserved ) + if ( bm->mod->reserved ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1510,14 +1514,13 @@ void asmlinkage __init noreturn __start_xen(void) if ( s < end && (headroom || - ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) + ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) { move_memory(end - size + headroom, - (uint64_t)mod[j].mod_start << PAGE_SHIFT, - mod[j].mod_end); - mod[j].mod_start = (end - size) >> PAGE_SHIFT; - mod[j].mod_end += headroom; - mod[j].reserved = 1; + pfn_to_paddr(bm->mod->mod_start), bm->mod->mod_end); + bm->mod->mod_start = (end - size) >> PAGE_SHIFT; + bm->mod->mod_end += headroom; + bm->mod->reserved = 1; } } @@ -1543,13 +1546,14 @@ void asmlinkage __init noreturn __start_xen(void) #endif } - if ( modules_headroom && !mod->reserved ) + if ( modules_headroom && !bi->mods[0].mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; + const struct boot_module *bm = &bi->mods[i]; + uint64_t s = pfn_to_paddr(bm->mod->mod_start); - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end)); + reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(bm->mod->mod_end)); } if ( !xen_phys_start ) @@ -1627,8 +1631,8 @@ void asmlinkage __init noreturn __start_xen(void) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end = pfn_to_paddr(bi->mods[j].mod->mod_start) + + bi->mods[j].mod->mod_end; if ( map_e < end ) map_e = end; @@ -1702,11 +1706,13 @@ void asmlinkage __init noreturn __start_xen(void) for ( i = 0; i < bi->nr_modules; ++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); + const struct boot_module *bm = &bi->mods[i]; + + set_pdx_range(bm->mod->mod_start, + bm->mod->mod_start + PFN_UP(bm->mod->mod_end)); + map_pages_to_xen((unsigned long)mfn_to_virt(bm->mod->mod_start), + _mfn(bm->mod->mod_start), + PFN_UP(bm->mod->mod_end), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC @@ -2095,8 +2101,9 @@ void asmlinkage __init noreturn __start_xen(void) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(mod, modules_headroom, - initrdidx < bi->nr_modules ? mod + initrdidx : NULL, + dom0 = create_dom0(bi->mods[0].mod, modules_headroom, + initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod + : NULL, kextra, bi->loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Thu Oct 24 14:26:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13849306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57310CE8E7E for ; Thu, 24 Oct 2024 14:27:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.825350.1239586 (Exim 4.92) (envelope-from ) id 1t3ynr-00057U-JU; Thu, 24 Oct 2024 14:27:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 825350.1239586; Thu, 24 Oct 2024 14:27:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3ynr-00057H-Eb; Thu, 24 Oct 2024 14:27:07 +0000 Received: by outflank-mailman (input) for mailman id 825350; Thu, 24 Oct 2024 14:27:06 +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 1t3ynq-00048L-FE for xen-devel@lists.xenproject.org; Thu, 24 Oct 2024 14:27:06 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0b4e705e-9214-11ef-a0bf-8be0dac302b0; Thu, 24 Oct 2024 16:27:06 +0200 (CEST) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5cb72918bddso1308115a12.3 for ; Thu, 24 Oct 2024 07:27:05 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cb66c6b4e4sm5707409a12.61.2024.10.24.07.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 07:27:04 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0b4e705e-9214-11ef-a0bf-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1729780025; x=1730384825; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=26Kd1CZ5EW/rvd6sicVOHZnpVwSK6DqF92g9LkP2sKY=; b=LN+agBkzDbFDIvYPJbL2oCjm+JIKTvqpG7orGYGYkm67zySfejSgGW632EavNqqYkt Ytk9NBc8n6/aFFwBFlcOa3n8GFcQW9JfzkAPDnWpDkmc8xFcXzyKd0xs+50+1p5CQXaQ Cj5jOhqRIbo4izFyf2QTm1f4AuA3sCRI7mD8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780025; x=1730384825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=26Kd1CZ5EW/rvd6sicVOHZnpVwSK6DqF92g9LkP2sKY=; b=EaPW3NBA7lrBk80fh2Tt/ywLThLahF0ip5ue1a2f0NSb2kXMIZwbqO35gEw9bZBAlv +eXexfpMEfaeK5o9JuBFndlvWfXbH9cBor3BFJCR2JxTbfFAfT0zmeoakp4lqebnb7hc Ue9y5Z0t4OXkuYuvQ4uwcKMSsvL2rSr79iUH2enOfBFpkj2k1UF3fCJ8OPDuQrf8Cin8 cYDkNgdQvv85jxzh4YkuKKvGvlzuuf6EJhhDz6WK8ZGbSO2hd8pOAkhGmsILfTQYePfu IcRa91VuEGwUHphGjvQbthSVovrDOLvHiOQejPto+/fI0NaoREtWaYsr19MwmwNRX5P9 mdDg== X-Gm-Message-State: AOJu0YxKGDBx8GKnn9EPVcfdbbR0LfPLDVoqo4B0MyGogqPiWdTo/rRj NSHmmBFXKct/ogG4hJxGhbfRdyke+eyZCHR8lCLQuxFdXw2BiWeVjeP+DodhzUn+s1KmL8VBBMR J X-Google-Smtp-Source: AGHT+IHeJl50mZDISF1NQ6MLFe8fQzTOtXWRCvcbgTukvJ7hfs09TarAKjqp3QVYBzCgBU1kJbcCyw== X-Received: by 2002:a05:6402:254d:b0:5c9:4281:4515 with SMTP id 4fb4d7f45d1cf-5cb8acb7b0amr5833462a12.17.1729780024768; Thu, 24 Oct 2024 07:27:04 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P . Smith" Subject: [PATCH 5/5] x86/boot: Drop the mbi and mod pointers in __start_xen() Date: Thu, 24 Oct 2024 15:26:54 +0100 Message-Id: <20241024142654.989980-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024142654.989980-1-andrew.cooper3@citrix.com> References: <20241024142654.989980-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 We can't drop them fully yet, but we can limit their scope to almost nothing, which serves the same purpose. This removes the ability to accidentally reintroduce buggy uses of __va(mbi->mods_addr). No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Daniel P. Smith --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith v7.5: * New --- xen/arch/x86/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5413e1c71be6..511cf5b97909 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1026,8 +1026,6 @@ void asmlinkage __init noreturn __start_xen(void) struct cpu_info *info = get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked = 0; struct boot_info *bi; - multiboot_info_t *mbi; - module_t *mod; unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; int i, j, e820_warn = 0, bytes = 0; unsigned long eb_start, eb_end; @@ -1063,16 +1061,22 @@ void asmlinkage __init noreturn __start_xen(void) if ( pvh_boot ) { + multiboot_info_t *mbi; + module_t *mod; + pvh_init(&mbi, &mod); /* * mbi and mod are regular pointers to .initdata. These remain valid * across move_xen(). */ + + bi = multiboot_fill_boot_info(mbi, mod); } else { - mbi = __va(multiboot_ptr); - mod = __va(mbi->mods_addr); + multiboot_info_t *mbi = __va(multiboot_ptr); + + bi = multiboot_fill_boot_info(mbi, __va(mbi->mods_addr)); /* * For MB1/2, mbi and mod are directmap pointers into the trampoline. @@ -1085,12 +1089,8 @@ void asmlinkage __init noreturn __start_xen(void) ASSERT(multiboot_ptr < MB(1) || xen_phys_start); } - bi = multiboot_fill_boot_info(mbi, mod); bi->module_map = module_map; /* Temporary */ - /* Use bi-> instead */ -#define mbi DO_NOT_USE - /* Parse the command-line options. */ if ( (kextra = strstr(bi->cmdline, " -- ")) != NULL ) {