All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, keescook@chromium.org,
	matt@codeblueprint.co.uk, tglx@linutronix.de, hpa@zytor.com,
	izumi.taku@jp.fujitsu.com, fanc.fnst@cn.fujitsu.com,
	thgarnie@google.com, n-horiguchi@ah.jp.nec.com,
	dyoung@redhat.com
Subject: Re: [PATCH v7] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions
Date: Fri, 28 Jul 2017 16:33:29 +0800	[thread overview]
Message-ID: <20170728083329.GL24304@x1> (raw)
In-Reply-To: <20170728064614.lcntuaovomcqwxx4@gmail.com>

Hi Ingo,

On 07/28/17 at 08:46am, Ingo Molnar wrote:
> 
> > +	pmap =  e->efi_memmap;
> > +#else
> > +	pmap = (e->efi_memmap | ((__u64)e->efi_memmap_hi << 32));
> > +#endif
> > +
> > +	nr_desc = e->efi_memmap_size / e->efi_memdesc_size;
> > +	for (i = 0; i < nr_desc; i++) {
> > +		md = (efi_memory_desc_t *)(pmap + (i * e->efi_memdesc_size));
> > +		if (md->attribute & EFI_MEMORY_MORE_RELIABLE) {
> > +			region.start = md->phys_addr;
> > +			region.size = md->num_pages << EFI_PAGE_SHIFT;
> > +			process_mem_region(&region, minimum, image_size);
> > +			efi_mirror_found = true;
> > +
> > +			if (slot_area_index == MAX_SLOT_AREA) {
> > +				debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> > +				break;
> > +			}
> > +		}
> > +	}
> 
> So I suggested this before: if you treat 'md' as an array of elements (which it 
> is), then the type cast can be moved to a more natural point, where we do address 
> calculations anyway:
> 
> 	md = (efi_memory_desc_t *)(e->efi_memmap | ((__u64)e->efi_memmap_hi << 32)));
> 
> The 'pmap' variable can be eliminated and all places in the loop that use 'md->' 
> can use 'md[i].'.

Thanks for reviewing this patch. Before when I read EFI code and found
almost all EFI codes take step of e->efi_memdesc_size long to forward to
get each EFI memmap, that's why I use it the same way here. I guess EFI
may not guarantee that each EFI memory map entry of 'efi_memory_desc_t'
occupy the whole space of e->efi_memdesc_size. In v6 post, you
questioned this, and Matt helped to confirm that EFI spec is suggesting
that way. Sorry, I trimmed the unrelated code in v6 reply, that could
make Matt's reply ignored.

Thanks
Baoquan

      reply	other threads:[~2017-07-28  8:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26  4:00 [PATCH v7] x86/boot/KASLR: Restrict kernel to be randomized in mirror regions Baoquan He
2017-07-28  6:46 ` Ingo Molnar
2017-07-28  8:33   ` Baoquan He [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=20170728083329.GL24304@x1 \
    --to=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=fanc.fnst@cn.fujitsu.com \
    --cc=hpa@zytor.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mingo@kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    /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.