All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>,
	Sean Christopherson <seanjc@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Joerg Roedel <jroedel@suse.de>, Ard Biesheuvel <ardb@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Kuppuswamy Sathyanarayanan
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	David Rientjes <rientjes@google.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Varad Gautam <varad.gautam@suse.com>,
	Dario Faggioli <dfaggioli@suse.com>,
	x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev,
	linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 5/7] x86/mm: Reserve unaccepted memory bitmap
Date: Sat, 15 Jan 2022 20:46:57 +0200	[thread overview]
Message-ID: <YeMWoTpHoJRRhnoN@kernel.org> (raw)
In-Reply-To: <a4b5707f-0f0b-57a8-ccdb-d89f66210b52@intel.com>

On Wed, Jan 12, 2022 at 11:53:42AM -0800, Dave Hansen wrote:
> On 1/12/22 11:43 AM, Kirill A. Shutemov wrote:
> > On Tue, Jan 11, 2022 at 11:10:40AM -0800, Dave Hansen wrote:
> >> On 1/11/22 03:33, Kirill A. Shutemov wrote:
> >>
> >>> +	/* Mark unaccepted memory bitmap reserved */
> >>> +	if (boot_params.unaccepted_memory) {
> >>> +		unsigned long size;
> >>> +
> >>> +		/* One bit per 2MB */
> >>> +		size = DIV_ROUND_UP(e820__end_of_ram_pfn() * PAGE_SIZE,
> >>> +				    PMD_SIZE * BITS_PER_BYTE);
> >>> +		memblock_reserve(boot_params.unaccepted_memory, size);
> >>> +	}
> >>
> >> Is it OK that the size of the bitmap is inferred from
> >> e820__end_of_ram_pfn()?  Is this OK in the presence of mem= and other things
> >> that muck with the e820?
> > 
> > Good question. I think we are fine. If kernel is not able to allocate
> > memory from a part of physical address space we don't need the bitmap for
> > it either.
> 
> That's a good point.  If the e820 range does a one-way shrink it's
> probably fine.  The only problem would be if the bitmap had space for
> for stuff past e820__end_of_ram_pfn() *and* it later needed to be accepted.

It's unlikely, but e820 can grow because of EFI and because of memmap=.
To be completely on the safe side, the unaccepted bitmap should be reserved
after parse_early_param() and efi_memblock_x86_reserve_range().

Since we anyway do not have memblock allocations before
e820__memblock_setup(), the simplest thing would be to put the reservation
first thing in e820__memblock_setup().

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2022-01-15 18:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 11:33 [PATCHv2 0/7] Implement support for unaccepted memory Kirill A. Shutemov
2022-01-11 11:33 ` [PATCHv2 1/7] mm: Add " Kirill A. Shutemov
2022-01-11 19:46   ` Dave Hansen
2022-01-12 11:31     ` David Hildenbrand
2022-01-12 19:15       ` Kirill A. Shutemov
2022-01-14 13:22         ` David Hildenbrand
2022-01-12 18:30     ` Kirill A. Shutemov
2022-01-12 18:40       ` Dave Hansen
2022-01-13  7:42         ` Mike Rapoport
2022-01-11 11:33 ` [PATCHv2 2/7] efi/x86: Get full memory map in allocate_e820() Kirill A. Shutemov
2022-01-11 11:33 ` [PATCHv2 3/7] efi/x86: Implement support for unaccepted memory Kirill A. Shutemov
2022-01-11 17:17   ` Dave Hansen
2022-01-12 19:29     ` Kirill A. Shutemov
2022-01-12 19:35       ` Dave Hansen
2022-01-11 11:33 ` [PATCHv2 4/7] x86/boot/compressed: Handle " Kirill A. Shutemov
2022-01-11 11:33 ` [PATCHv2 5/7] x86/mm: Reserve unaccepted memory bitmap Kirill A. Shutemov
2022-01-11 19:10   ` Dave Hansen
2022-01-12 19:43     ` Kirill A. Shutemov
2022-01-12 19:53       ` Dave Hansen
2022-01-15 18:46         ` Mike Rapoport [this message]
2022-01-11 11:33 ` [PATCHv2 6/7] x86/mm: Provide helpers for unaccepted memory Kirill A. Shutemov
2022-01-11 20:01   ` Dave Hansen
2022-01-12 19:43     ` Kirill A. Shutemov
2022-01-11 11:33 ` [PATCHv2 7/7] x86/tdx: Unaccepted memory support Kirill A. Shutemov
2022-01-18 21:05 ` [PATCHv2 0/7] Implement support for unaccepted memory Brijesh Singh

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=YeMWoTpHoJRRhnoN@kernel.org \
    --to=rppt@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dfaggioli@suse.com \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rientjes@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=varad.gautam@suse.com \
    --cc=vbabka@suse.cz \
    --cc=x86@kernel.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.