From nobody Thu Nov 21 20:36:56 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1729780076; cv=none; d=zohomail.com; s=zohoarc; b=CSAO5RQEkfNLVRkn/akZaThBBMZrJFQSJNFYfaeZyIBVM1oql42IqmrTK44EA5ttzylV9unCTA5G1jKIrbIVLSIpYvixNn7RBAfJxj9p0qT9omr7n4fgwCiYabo7IvOOxmcJxKU5RIvWe0Ps+EtpwuBYsQ3LzNkm3BKBKbKMNRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729780076; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hkGTFmIsU8uVl1vUxZAmxH9TN/jWgRT2CVKi7nypqKo=; b=Vu/3qTl3PEYBF5EDnI/yKoFWgedKH0y1nBBcJBZdPPeA6zUaNpbrIzYbVo9Da/ck/KtQiX00Kphhmi8GT9K9nErJboYv24lPzdRsl9o2pyijjxdDcY4MTwg4FPgI2Y3+UgBppfCAk8PnDNjvg99fB37zWfASm0bAp5BlEgz7qR0= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 172978007668427.49020474873828; Thu, 24 Oct 2024 07:27:56 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 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=20Pau=20Monn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1729780077844116600 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=C3=A9 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) =20 for ( i =3D 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 -=3D mod[i].mod_start; - mod[i].mod_start >>=3D PAGE_SHIFT; - mod[i].reserved =3D 0; + bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; + bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; + bi->mods[i].mod->reserved =3D 0; } =20 /* @@ -1397,6 +1397,8 @@ void asmlinkage __init noreturn __start_xen(void) =20 if ( xen_phys_start ) { + struct boot_module *xen =3D &bi->mods[bi->nr_modules]; + relocated =3D true; =20 /* @@ -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 =3D virt_to_mfn(_stext); - mod[bi->nr_modules].mod_end =3D __2M_rwdata_end - _stext; + xen->mod->mod_start =3D virt_to_mfn(_stext); + xen->mod->mod_end =3D __2M_rwdata_end - _stext; } =20 modules_headroom =3D @@ -1490,15 +1492,17 @@ void asmlinkage __init noreturn __start_xen(void) /* Is the region suitable for relocating the multiboot modules? */ for ( j =3D bi->nr_modules - 1; j >=3D 0; j-- ) { + struct boot_module *bm =3D &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 star= t. */ unsigned long headroom =3D j ? 0 : modules_headroom; - unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); + unsigned long size =3D PAGE_ALIGN(headroom + bm->mod->mod_end); =20 - if ( mod[j].reserved ) + if ( bm->mod->reserved ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ @@ -1510,14 +1514,13 @@ void asmlinkage __init noreturn __start_xen(void) =20 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 =3D (end - size) >> PAGE_SHIFT; - mod[j].mod_end +=3D headroom; - mod[j].reserved =3D 1; + pfn_to_paddr(bm->mod->mod_start), bm->mod->mod= _end); + bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; + bm->mod->mod_end +=3D headroom; + bm->mod->reserved =3D 1; } } =20 @@ -1543,13 +1546,14 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - 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 =3D 0; i < bi->nr_modules; ++i ) { - uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; + const struct boot_module *bm =3D &bi->mods[i]; + uint64_t s =3D pfn_to_paddr(bm->mod->mod_start); =20 - 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)); } =20 if ( !xen_phys_start ) @@ -1627,8 +1631,8 @@ void asmlinkage __init noreturn __start_xen(void) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < bi->nr_modules; ++j ) { - uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end =3D pfn_to_paddr(bi->mods[j].mod->mod_sta= rt) + + bi->mods[j].mod->mod_end; =20 if ( map_e < end ) map_e =3D end; @@ -1702,11 +1706,13 @@ void asmlinkage __init noreturn __start_xen(void) =20 for ( i =3D 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 =3D &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); } =20 #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 sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, modules_headroom, - initrdidx < bi->nr_modules ? mod + initrdidx : NULL, + dom0 =3D 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"); --=20 2.39.5