From mboxrd@z Thu Jan 1 00:00:00 1970 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 C9DFAC43334 for ; Sat, 18 Jun 2022 12:14:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.351829.578585 (Exim 4.92) (envelope-from ) id 1o2XLC-00083K-KH; Sat, 18 Jun 2022 12:14:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 351829.578585; Sat, 18 Jun 2022 12:14:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o2XLC-000834-DV; Sat, 18 Jun 2022 12:14:14 +0000 Received: by outflank-mailman (input) for mailman id 351829; Sat, 18 Jun 2022 12:14:12 +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 1o2XLA-0007p5-MM for xen-devel@lists.xenproject.org; Sat, 18 Jun 2022 12:14:12 +0000 Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 28f3e525-ef00-11ec-b725-ed86ccbb4733; Sat, 18 Jun 2022 14:14:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id F36A220157; Sat, 18 Jun 2022 14:14:09 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YauqhsVtHHYl; Sat, 18 Jun 2022 14:14:09 +0200 (CEST) Received: from begin (cerbere11.aquilenet.fr [185.233.102.190]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id DE9D220154; Sat, 18 Jun 2022 14:14:09 +0200 (CEST) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1o2XL7-00BaWi-S0; Sat, 18 Jun 2022 14:14:09 +0200 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: 28f3e525-ef00-11ec-b725-ed86ccbb4733 Date: Sat, 18 Jun 2022 14:14:09 +0200 From: Samuel Thibault To: Juergen Gross Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org Subject: Re: [PATCH 2/3] mini-os: prefer memory map via start_info for PVH Message-ID: <20220618121409.mopy5vqf3z7gpjed@begin> Mail-Followup-To: Samuel Thibault , Juergen Gross , minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org References: <20220618104816.11527-1-jgross@suse.com> <20220618104816.11527-3-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220618104816.11527-3-jgross@suse.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) Juergen Gross, le sam. 18 juin 2022 12:48:15 +0200, a ecrit: > Since some time now a guest started in PVH mode will get the memory > map from Xen via the start_info structure. > > Modify the PVH initialization to prefer this memory map over the one > obtained via hypercall, as this will allow to add information to the > memory map for a new kernel when supporting kexec. > > In case the start_info structure doesn't contain memory map information > fall back to the hypercall. > > Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault > --- > arch/x86/mm.c | 6 ++++++ > e820.c | 25 +++++++++++++++++++++++++ > include/e820.h | 4 ++++ > 3 files changed, 35 insertions(+) > > diff --git a/arch/x86/mm.c b/arch/x86/mm.c > index 220c0b4d..41fcee67 100644 > --- a/arch/x86/mm.c > +++ b/arch/x86/mm.c > @@ -45,6 +45,7 @@ > #include > #include > #include > +#include > > #ifdef MM_DEBUG > #define DEBUG(_f, _a...) \ > @@ -108,6 +109,11 @@ void arch_mm_preinit(void *p) > { > long ret; > domid_t domid = DOMID_SELF; > + struct hvm_start_info *hsi = p; > + > + if ( hsi->version >= 1 && hsi->memmap_entries > 0 ) > + e820_init_memmap((struct hvm_memmap_table_entry *)(unsigned long) > + hsi->memmap_paddr, hsi->memmap_entries); > > pt_base = page_table_base; > first_free_pfn = PFN_UP(to_phys(&_end)); > diff --git a/e820.c b/e820.c > index 991ed382..ad91e00b 100644 > --- a/e820.c > +++ b/e820.c > @@ -54,6 +54,7 @@ static char *e820_types[E820_TYPES] = { > [E820_ACPI] = "ACPI", > [E820_NVS] = "NVS", > [E820_UNUSABLE] = "Unusable", > + [E820_DISABLED] = "Disabled", > [E820_PMEM] = "PMEM" > }; > > @@ -259,6 +260,30 @@ static void e820_get_memmap(void) > e820_sanitize(); > } > > +void e820_init_memmap(struct hvm_memmap_table_entry *entry, unsigned int num) > +{ > + unsigned int i; > + > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_RAM != E820_RAM); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_RESERVED != E820_RESERVED); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_ACPI != E820_ACPI); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_NVS != E820_NVS); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_UNUSABLE != E820_UNUSABLE); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_DISABLED != E820_DISABLED); > + BUILD_BUG_ON(XEN_HVM_MEMMAP_TYPE_PMEM != E820_PMEM); > + > + for ( i = 0; i < num; i++ ) > + { > + e820_map[i].addr = entry[i].addr; > + e820_map[i].size = entry[i].size; > + e820_map[i].type = entry[i].type; > + } > + > + e820_entries = num; > + > + e820_sanitize(); > +} > + > void arch_print_memmap(void) > { > int i; > diff --git a/include/e820.h b/include/e820.h > index aaf2f2ca..5438a7c8 100644 > --- a/include/e820.h > +++ b/include/e820.h > @@ -26,6 +26,8 @@ > > #if defined(__arm__) || defined(__aarch64__) || defined(CONFIG_PARAVIRT) > #define CONFIG_E820_TRIVIAL > +#else > +#include > #endif > > /* PC BIOS standard E820 types and structure. */ > @@ -34,6 +36,7 @@ > #define E820_ACPI 3 > #define E820_NVS 4 > #define E820_UNUSABLE 5 > +#define E820_DISABLED 6 > #define E820_PMEM 7 > #define E820_TYPES 8 > > @@ -54,6 +57,7 @@ unsigned long e820_get_max_contig_pages(unsigned long pfn, unsigned long pages); > #ifndef CONFIG_E820_TRIVIAL > unsigned long e820_get_reserved_pfns(int pages); > void e820_put_reserved_pfns(unsigned long start_pfn, int pages); > +void e820_init_memmap(struct hvm_memmap_table_entry *entry, unsigned int num); > #endif > > #endif /*__E820_HEADER*/ > -- > 2.35.3 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.