From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
minios-devel@lists.xenproject.org,
xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 3/3] mini-os: fix number of pages for PVH
Date: Sun, 19 Jun 2022 07:51:53 +0200 [thread overview]
Message-ID: <09d88287-a957-b89a-939a-7d39282e7d94@suse.com> (raw)
In-Reply-To: <20220618155654.kcvodnjcd7khwspl@begin>
[-- Attachment #1.1.1: Type: text/plain, Size: 2144 bytes --]
On 18.06.22 17:56, Samuel Thibault wrote:
> Juergen Gross, le sam. 18 juin 2022 16:07:07 +0200, a ecrit:
>> On 18.06.22 14:13, Samuel Thibault wrote:
>>> Hello,
>>>
>>> Juergen Gross, le sam. 18 juin 2022 12:48:16 +0200, a ecrit:
>>>> @@ -124,7 +126,7 @@ void arch_mm_preinit(void *p)
>>>> do_exit();
>>>> }
>>>> - last_free_pfn = e820_get_maxpfn(ret);
>>>> + last_free_pfn = e820_get_maxpfn(ret - e820_initial_reserved_pfns);
>>>
>>> Mmm, but the reserved pfn could be in the middle of the e820 address
>>> space.
>>
>> That doesn't matter.
>>
>> e820_get_maxpfn(n) will just return the pfn of the n-th RAM pfn it is
>> finding in the E820 map.
>
> Yes, but subtracting at this point looks a bit hacky to me.
>
> It seems to me that it'd be better to make e820_get_maxpfn count by
> itself the reserved pages (but never return its pfn of course), rather
> than having to make e820_sanitize look at the reserved pages, store
> it somewhere, and hope that other code will remember to subtract that
> before calling e820_get_maxpfn.
>
> I mean something like:
>
> unsigned long e820_get_maxpfn(unsigned long pages)
> {
> int i;
> unsigned long pfns = 0, start = 0;
>
> if ( !e820_entries )
> e820_get_memmap();
>
> for ( i = 0; i < e820_entries; i++ )
> {
> pfns = e820_map[i].size >> PAGE_SHIFT;
>
> if ( e820_map[i].type == E820_RESERVED )
> {
> /* This counts in the memory reservation, but is not usable */
> pages -= pfns;
> continue;
> }
> if ( e820_map[i].type != E820_RAM )
> continue;
>
> start = e820_map[i].addr >> PAGE_SHIFT;
> if ( pages <= pfns )
> return start + pages;
> pages -= pfns;
> }
>
> return start + pfns;
> }
This would lead to wrong values of nr_mem_pages. I think the best solution
would be to have functions returning the number of available and max RAM
pages to e820.c. This would address your valid concern, while not leading
to wrong values at the callers side.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
prev parent reply other threads:[~2022-06-19 5:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-18 10:48 [PATCH 0/3] mini-os: some memory map updates for PVH Juergen Gross
2022-06-18 10:48 ` [PATCH 1/3] mini-os: take newest version of arch-x86/hvm/start_info.h Juergen Gross
2022-06-18 12:13 ` Samuel Thibault
2022-06-18 10:48 ` [PATCH 2/3] mini-os: prefer memory map via start_info for PVH Juergen Gross
2022-06-18 12:14 ` Samuel Thibault
2022-06-18 10:48 ` [PATCH 3/3] mini-os: fix number of pages " Juergen Gross
2022-06-18 12:13 ` Samuel Thibault
2022-06-18 14:07 ` Juergen Gross
2022-06-18 15:56 ` Samuel Thibault
2022-06-19 5:51 ` Juergen Gross [this message]
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=09d88287-a957-b89a-939a-7d39282e7d94@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.