All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: rob@landley.net, tglx@linutronix.de,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	bhelgaas@google.com, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 2/2] x86: reimplement mem boot option
Date: Thu, 28 Jun 2012 09:29:27 +0800	[thread overview]
Message-ID: <4FEBB377.2080309@cn.fujitsu.com> (raw)
In-Reply-To: <4FD99CFA.6060801@cn.fujitsu.com>

Pin......

At 06/14/2012 04:12 PM, Wen Congyang Wrote:
> Current mem boot option only can work for non efi environment. If the user
> specifies add_efi_memmap, it cannot work for efi environment. In
> the efi environment, we call e820_add_region() to add the memory map. So
> we can modify __e820_add_region() and the mem boot option can work for
> efi environment.
> 
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  arch/x86/kernel/e820.c |   29 +++++++++++++++++++++++++----
>  1 files changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index 4185797..20bc467 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
>  #ifdef CONFIG_PCI
>  EXPORT_SYMBOL(pci_mem_start);
>  #endif
> +static u64 mem_limit = ~0ULL;
>  
>  /*
>   * This function checks if any part of the range <start,end> is mapped
> @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
>  		return;
>  	}
>  
> +	if (start >= mem_limit) {
> +		printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
> +		       (unsigned long long)start,
> +		       (unsigned long long)(start + size - 1));
> +		return;
> +	}
> +
> +	if (mem_limit - start < size) {
> +		printk(KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n",
> +		       (unsigned long long)mem_limit,
> +		       (unsigned long long)(start + size - 1));
> +		size = mem_limit - start;
> +	}
> +
>  	e820x->map[x].addr = start;
>  	e820x->map[x].size = size;
>  	e820x->map[x].type = type;
> @@ -809,7 +824,7 @@ static int userdef __initdata;
>  /* "mem=nopentium" disables the 4MB page tables. */
>  static int __init parse_memopt(char *p)
>  {
> -	u64 mem_size;
> +	char *oldp;
>  
>  	if (!p)
>  		return -EINVAL;
> @@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
>  	}
>  
>  	userdef = 1;
> -	mem_size = memparse(p, &p);
> +	oldp = p;
> +	mem_limit = memparse(p, &p);
>  	/* don't remove all of memory when handling "mem={invalid}" param */
> -	if (mem_size == 0)
> +	if (mem_limit == 0 || p == oldp)
>  		return -EINVAL;
> -	e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
>  
>  	return 0;
>  }
> @@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
>  
>  void __init finish_e820_parsing(void)
>  {
> +	if (mem_limit != ~0ULL) {
> +		userdef = 1;
> +		e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
> +				  E820_RAM, 1);
> +	}
> +
>  	if (userdef) {
>  		u32 nr = e820.nr_map;
>  


  reply	other threads:[~2012-06-28  1:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  8:10 [PATCH 1/2] doc: update mem= option's spec Wen Congyang
2012-06-14  8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
2012-06-28  1:29   ` Wen Congyang [this message]
2012-07-17  5:22     ` Wen Congyang
2012-07-18  9:16       ` Ingo Molnar
2012-08-21  8:11   ` [PATCH v2 " Wen Congyang
2012-09-05  9:28     ` Wen Congyang
2012-06-14 20:22 ` [PATCH 1/2] doc: update mem= option's spec Rob Landley
  -- strict thread matches above, loose matches on Subject: below --
2012-05-22  7:02 [PATCH 1/2] x86: add max_addr boot option Wen Congyang
2012-05-22  7:05 ` [PATCH 2/2] x86: reimplement mem " Wen Congyang

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=4FEBB377.2080309@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=bhelgaas@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rob@landley.net \
    --cc=tglx@linutronix.de \
    --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.