From nobody Mon Feb 9 23:58:00 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=1638775448; cv=none; d=zohomail.com; s=zohoarc; b=OCo8RO+ZqV5ljjHo6ThmnHXsLaUwoFOkWLGsm0AgcrsIumf6uOsIYqQUs7c6zeOWSFvrdQvbpu3FLYG9s2/mFZ0IqxphsmdhBXfrMXT5Bp07pgG24HKEw3LY3Ol5b5tqmaJehkrWu/OqIUiIrtVQPQrz1GsneUVdJeFejyE0lMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638775448; 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=2T/0NcFBUay+umzcIVeBLzt93p/NF1ROTt/i4aaQWm8=; b=hgEhQqe5UV0R/6dSFaY6bAGUhdqLyGgfcombuEdIGwBBuZQVo3PrHrHij5a4hxKfGje7qAm+OAzF/GiQBcgKodEIOtmmshY6zm3N6SOpuQDhvlqolI7gY+AhJkIDWy/wwboBaS8KialqrLXfA6E81areJNMlzgszFs6PkmXSLIw= 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 1638775448107398.1166890737737; Sun, 5 Dec 2021 23:24:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.238642.413624 (Exim 4.92) (envelope-from ) id 1mu8Li-0000Uz-N3; Mon, 06 Dec 2021 07:23:46 +0000 Received: by outflank-mailman (output) from mailman id 238642.413624; Mon, 06 Dec 2021 07:23:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mu8Li-0000U6-EV; Mon, 06 Dec 2021 07:23:46 +0000 Received: by outflank-mailman (input) for mailman id 238642; Mon, 06 Dec 2021 07:23:44 +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 1mu8Lg-0008Mk-P7 for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 07:23:44 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6f7d7449-5665-11ec-8a4d-196798b21f7b; Mon, 06 Dec 2021 08:23:41 +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-out2.suse.de (Postfix) with ESMTPS id 395151FDF2; Mon, 6 Dec 2021 07:23:40 +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 0E8A01330B; Mon, 6 Dec 2021 07:23:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8D9LAny6rWHVdAAAMHmgww (envelope-from ); Mon, 06 Dec 2021 07:23:40 +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: 6f7d7449-5665-11ec-8a4d-196798b21f7b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1638775420; 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=2T/0NcFBUay+umzcIVeBLzt93p/NF1ROTt/i4aaQWm8=; b=Efh8bL88xHn6VBERl0JJiPtNHp4+hYDaguiD7BajgSnsl1zjovl6LdewERRMNpnIvJ+zAg +N/0Aw1awnndKXgPYBx7VqGyfzGegxatcKxZnM2tdUBUNqmw4p+gSU/wEyCxlNpAKvf6GH 9sxgiwDdn7genYuvrgcOIKLeZ0DmU8k= 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 03/10] mini-os: don't assume contiguous RAM when initializing in PVH mode Date: Mon, 6 Dec 2021 08:23:30 +0100 Message-Id: <20211206072337.9517-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211206072337.9517-1-jgross@suse.com> References: <20211206072337.9517-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1638775449366100005 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 --- arch/x86/mm.c | 6 +----- e820.c | 13 ++++++++----- include/e820.h | 2 +- 3 files changed, 10 insertions(+), 11 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 336a8b8..14fd3cd 100644 --- a/e820.c +++ b/e820.c @@ -155,10 +155,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, max =3D 0; =20 e820_get_memmap(); =20 @@ -166,9 +166,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; + max =3D e820_map[i].addr >> PAGE_SHIFT; + if ( pages <=3D pfns ) + return max + pages; + pages -=3D pfns; + max +=3D pfns; } =20 return max; 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