public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap
@ 2019-08-22 12:32 Qian Cai
  2019-08-22 13:26 ` Baoquan He
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2019-08-22 12:32 UTC (permalink / raw)
  To: tglx, mingo, hpa; +Cc: bhe, x86, linux-kernel, Qian Cai

MAX_MEMMAP_REGIONS is a macro that equal to 4. "i" is static local
variable that default to 0. The comparison "i >= MAX_MEMMAP_REGIONS"
will always be false.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/x86/boot/compressed/kaslr.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 2e53c056ba20..a4a5a88edb94 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -176,9 +176,6 @@ static void mem_avoid_memmap(char *str)
 {
 	static int i;
 
-	if (i >= MAX_MEMMAP_REGIONS)
-		return;
-
 	while (str && (i < MAX_MEMMAP_REGIONS)) {
 		int rc;
 		unsigned long long start, size;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap
  2019-08-22 12:32 [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap Qian Cai
@ 2019-08-22 13:26 ` Baoquan He
  2019-08-22 13:43   ` Qian Cai
  0 siblings, 1 reply; 3+ messages in thread
From: Baoquan He @ 2019-08-22 13:26 UTC (permalink / raw)
  To: Qian Cai; +Cc: tglx, mingo, hpa, x86, linux-kernel

On 08/22/19 at 08:32am, Qian Cai wrote:
> MAX_MEMMAP_REGIONS is a macro that equal to 4. "i" is static local
> variable that default to 0. The comparison "i >= MAX_MEMMAP_REGIONS"
> will always be false.

Seems not true. mem_avoid_memmap() could be invoked many times if
multiple memmap= added. It will carry the value accumulated from
the past.

> 
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/x86/boot/compressed/kaslr.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index 2e53c056ba20..a4a5a88edb94 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -176,9 +176,6 @@ static void mem_avoid_memmap(char *str)
>  {
>  	static int i;
>  
> -	if (i >= MAX_MEMMAP_REGIONS)
> -		return;
> -
>  	while (str && (i < MAX_MEMMAP_REGIONS)) {
>  		int rc;
>  		unsigned long long start, size;
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap
  2019-08-22 13:26 ` Baoquan He
@ 2019-08-22 13:43   ` Qian Cai
  0 siblings, 0 replies; 3+ messages in thread
From: Qian Cai @ 2019-08-22 13:43 UTC (permalink / raw)
  To: Baoquan He; +Cc: tglx, mingo, hpa, x86, linux-kernel

On Thu, 2019-08-22 at 21:26 +0800, Baoquan He wrote:
> On 08/22/19 at 08:32am, Qian Cai wrote:
> > MAX_MEMMAP_REGIONS is a macro that equal to 4. "i" is static local
> > variable that default to 0. The comparison "i >= MAX_MEMMAP_REGIONS"
> > will always be false.
> 
> Seems not true. mem_avoid_memmap() could be invoked many times if
> multiple memmap= added. It will carry the value accumulated from
> the past.

Ah, I am still a newbie in C after all those years. Sorry for the noise.

> 
> > 
> > Signed-off-by: Qian Cai <cai@lca.pw>
> > ---
> >  arch/x86/boot/compressed/kaslr.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/arch/x86/boot/compressed/kaslr.c
> > b/arch/x86/boot/compressed/kaslr.c
> > index 2e53c056ba20..a4a5a88edb94 100644
> > --- a/arch/x86/boot/compressed/kaslr.c
> > +++ b/arch/x86/boot/compressed/kaslr.c
> > @@ -176,9 +176,6 @@ static void mem_avoid_memmap(char *str)
> >  {
> >  	static int i;
> >  
> > -	if (i >= MAX_MEMMAP_REGIONS)
> > -		return;
> > -
> >  	while (str && (i < MAX_MEMMAP_REGIONS)) {
> >  		int rc;
> >  		unsigned long long start, size;
> > -- 
> > 1.8.3.1
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-22 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-22 12:32 [PATCH] x86/kaslr: remove useless code in mem_avoid_memmap Qian Cai
2019-08-22 13:26 ` Baoquan He
2019-08-22 13:43   ` Qian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox