From nobody Mon Feb 9 01:20:05 2026 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1640016468; cv=none; d=zohomail.com; s=zohoarc; b=mheyigw3isQe80SpFiNaZAVGztt1BdskgLPrboTkZu7YjiHUFvmnUmVFVFLtPj5kjTLATK8jnl7/4hqxYpy5Hfuj4h7fkWEA3kyUYTuJdrVJVS2J+kCou9OXF2waw3e3VSdZboH7FMXg1ME6KL0HLUghyUm6Txctg3SY6F01at8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640016468; 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=POjxJaAzzZfNKLwq8GHwwKNxLxPxY05Rtom00f9HoLs=; b=klSUJsljuGM3XXEkXQGz7Qr35Zlh0hhZEn08FPaaFXt3D8F5FEzdLLcKyyVFQ1OfvpuVajWCuKNURU+1xZeZrMCrGa+VXguJBxLQJlA/TAI4ckaqy+CE3oU4PdRqqYC/KjatSSjP9nZnXMyuODu06I//tu/yKrHA1pBWQOvEKKk= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640016468664714.9964661286654; Mon, 20 Dec 2021 08:07:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249854.430263 (Exim 4.92) (envelope-from ) id 1mzLC8-0005Sy-MX; Mon, 20 Dec 2021 16:07:24 +0000 Received: by outflank-mailman (output) from mailman id 249854.430263; Mon, 20 Dec 2021 16:07:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzLC8-0005RG-HJ; Mon, 20 Dec 2021 16:07:24 +0000 Received: by outflank-mailman (input) for mailman id 249854; Mon, 20 Dec 2021 16:07:23 +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 1mzLC7-00055w-8c for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 16:07:23 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e89f5515-61ae-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 17:07:20 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8C06B218F9; Mon, 20 Dec 2021 16:07:19 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 60D7B13DAC; Mon, 20 Dec 2021 16:07:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gIdVFjeqwGEUTAAAMHmgww (envelope-from ); Mon, 20 Dec 2021 16:07:19 +0000 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: e89f5515-61ae-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1640016439; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=POjxJaAzzZfNKLwq8GHwwKNxLxPxY05Rtom00f9HoLs=; b=DWDOfJA+puFbtAWZuJ7ORNsrBHHByIxVt5Ct3fW6WHOQwjgHh5Mct3pwvJBCgcxZ/gHkFe t1m8cf7IjZuS5omEBLcxBOJBVlNi3KG5Wb6mqSwxK+zr6/bD75NROoCs9H5MZ/6/X6Ehwp Z+3h7ZW693CQz7mU/TpRqUO+ViHT35c= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH v2 03/10] mini-os: don't assume contiguous RAM when initializing in PVH mode Date: Mon, 20 Dec 2021 17:07:09 +0100 Message-Id: <20211220160716.4159-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211220160716.4159-1-jgross@suse.com> References: <20211220160716.4159-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1640016469154100004 Content-Type: text/plain; charset="utf-8" Sizing the available memory should respect memory holes, so look at the memory map when setting the boundary for the memory allocator. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- V2: - rename "max" to "start" (Samuel Thibault) --- arch/x86/mm.c | 6 +----- e820.c | 14 ++++++++------ include/e820.h | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/x86/mm.c b/arch/x86/mm.c index 8df93da..3bf6170 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -107,7 +107,6 @@ void arch_mm_preinit(void *p) { long ret; domid_t domid =3D DOMID_SELF; - unsigned long max; =20 pt_base =3D page_table_base; first_free_pfn =3D PFN_UP(to_phys(&_end)); @@ -117,11 +116,8 @@ void arch_mm_preinit(void *p) xprintk("could not get memory size\n"); do_exit(); } - last_free_pfn =3D ret; =20 - max =3D e820_get_maxpfn(); - if ( max < last_free_pfn ) - last_free_pfn =3D max; + last_free_pfn =3D e820_get_maxpfn(ret); } #endif =20 diff --git a/e820.c b/e820.c index 1770158..6d15cdf 100644 --- a/e820.c +++ b/e820.c @@ -285,10 +285,10 @@ void arch_print_memmap(void) } #endif =20 -unsigned long e820_get_maxpfn(void) +unsigned long e820_get_maxpfn(unsigned long pages) { int i; - unsigned long pfn, max =3D 0; + unsigned long pfns, start =3D 0; =20 e820_get_memmap(); =20 @@ -296,10 +296,12 @@ unsigned long e820_get_maxpfn(void) { if ( e820_map[i].type !=3D E820_RAM ) continue; - pfn =3D (e820_map[i].addr + e820_map[i].size) >> PAGE_SHIFT; - if ( pfn > max ) - max =3D pfn; + pfns =3D e820_map[i].size >> PAGE_SHIFT; + start =3D e820_map[i].addr >> PAGE_SHIFT; + if ( pages <=3D pfns ) + return start + pages; + pages -=3D pfns; } =20 - return max; + return start + pfns; } diff --git a/include/e820.h b/include/e820.h index af2129f..6a57f05 100644 --- a/include/e820.h +++ b/include/e820.h @@ -49,6 +49,6 @@ struct __packed e820entry { extern struct e820entry e820_map[]; extern unsigned e820_entries; =20 -unsigned long e820_get_maxpfn(void); +unsigned long e820_get_maxpfn(unsigned long pages); =20 #endif /*__E820_HEADER*/ --=20 2.26.2