From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org,
Juergen Gross <jgross@suse.com>
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 [thread overview]
Message-ID: <20211206072337.9517-4-jgross@suse.com> (raw)
In-Reply-To: <20211206072337.9517-1-jgross@suse.com>
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 <jgross@suse.com>
---
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 = DOMID_SELF;
- unsigned long max;
pt_base = page_table_base;
first_free_pfn = 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 = ret;
- max = e820_get_maxpfn();
- if ( max < last_free_pfn )
- last_free_pfn = max;
+ last_free_pfn = e820_get_maxpfn(ret);
}
#endif
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
-unsigned long e820_get_maxpfn(void)
+unsigned long e820_get_maxpfn(unsigned long pages)
{
int i;
- unsigned long pfn, max = 0;
+ unsigned long pfns, max = 0;
e820_get_memmap();
@@ -166,9 +166,12 @@ unsigned long e820_get_maxpfn(void)
{
if ( e820_map[i].type != E820_RAM )
continue;
- pfn = (e820_map[i].addr + e820_map[i].size) >> PAGE_SHIFT;
- if ( pfn > max )
- max = pfn;
+ pfns = e820_map[i].size >> PAGE_SHIFT;
+ max = e820_map[i].addr >> PAGE_SHIFT;
+ if ( pages <= pfns )
+ return max + pages;
+ pages -= pfns;
+ max += pfns;
}
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;
-unsigned long e820_get_maxpfn(void);
+unsigned long e820_get_maxpfn(unsigned long pages);
#endif /*__E820_HEADER*/
--
2.26.2
next prev parent reply other threads:[~2021-12-06 7:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 7:23 [PATCH 00/10] mini-os: add missing PVH features Juergen Gross
2021-12-06 7:23 ` [PATCH 01/10] mini-os: split e820 map handling into new source file Juergen Gross
2021-12-11 23:56 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 02/10] mini-os: sort and sanitize e820 memory map Juergen Gross
2021-12-12 0:05 ` Samuel Thibault
2021-12-13 14:56 ` Juergen Gross
2021-12-13 21:19 ` Samuel Thibault
2021-12-14 6:33 ` Juergen Gross
2021-12-06 7:23 ` Juergen Gross [this message]
2021-12-12 0:15 ` [PATCH 03/10] mini-os: don't assume contiguous RAM when initializing in PVH mode Samuel Thibault
2021-12-13 14:58 ` Juergen Gross
2021-12-13 21:22 ` Samuel Thibault
2021-12-14 6:35 ` Juergen Gross
2021-12-14 7:40 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 04/10] mini-os: respect memory map when ballooning up Juergen Gross
2021-12-12 0:26 ` Samuel Thibault
2021-12-13 15:05 ` Juergen Gross
2021-12-06 7:23 ` [PATCH 05/10] mini-os: don't repeat definition available via header file Juergen Gross
2021-12-12 0:27 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 06/10] mini-os: add memory map service functions Juergen Gross
2021-12-12 0:37 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 07/10] mini-os: move x86 specific gnttab coding into arch/x86/gnttab.c Juergen Gross
2021-12-12 0:41 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 08/10] mini-os: add proper pvh grant table handling Juergen Gross
2021-12-12 0:43 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 09/10] mini-os: prepare grantmap entry interface for use by PVH mode Juergen Gross
2021-12-12 0:50 ` Samuel Thibault
2021-12-06 7:23 ` [PATCH 10/10] mini-os: modify grant mappings to work in " Juergen Gross
2021-12-12 0:51 ` Samuel Thibault
2021-12-06 12:46 ` [PATCH] mini-os: support event channel 0 for console Juergen Gross
2021-12-06 13:24 ` Jan Beulich
2021-12-06 13:30 ` Juergen Gross
2021-12-06 14:17 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211206072337.9517-4-jgross@suse.com \
--to=jgross@suse.com \
--cc=minios-devel@lists.xenproject.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.