Re: [PATCH] x86/kaslr: simplify the code in mem_avoid_memmap()

From: Qian Cai
Date: Thu Sep 05 2019 - 08:26:12 EST


Ping. Please take a look at this trivial patch.

On Thu, 2019-08-22 at 10:26 -0400, Qian Cai wrote:
> If "i >= MAX_MEMMAP_REGIONS" already when entering mem_avoid_memmap(),
> even without the return statement the loop will not run anyway. The only
> time it needs to set "memmap_too_large = true" in this situation is
> "memmap_too_large" is "false" currently. Hence, the code could be
> simplified.
>
> Signed-off-by: Qian Cai <cai@xxxxxx>
> ---
> Âarch/x86/boot/compressed/kaslr.c | 5 +----
> Â1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/kaslr.c
> b/arch/x86/boot/compressed/kaslr.c
> index 2e53c056ba20..35c6942fb95b 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;
> @@ -206,7 +203,7 @@ static void mem_avoid_memmap(char *str)
> Â }
> Â
> Â /* More than 4 memmaps, fail kaslr */
> - if ((i >= MAX_MEMMAP_REGIONS) && str)
> + if (i >= MAX_MEMMAP_REGIONS && !memmap_too_large)
> Â memmap_too_large = true;
> Â}
> Â