lkml.org 
[lkml]   [2020]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 6/8] x86/kaslr: Simplify process_gb_huge_pages
On Mon, Jul 27, 2020 at 07:07:59PM -0400, Arvind Sankar wrote:
> Short-circuit the whole function on 32-bit.
>
> Replace the loop to determine the number of 1Gb pages with arithmetic.
>
> Fix one minor bug: if the end of the region is aligned on a 1Gb
> boundary, the current code will not use the last available 1Gb page due
> to an off-by-one error.
>
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Can you add some KUnit tests could be written to do validation of the
refactorings? Touching this code is so painful. :)

-Kees

> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -546,49 +546,43 @@ static void store_slot_info(struct mem_vector *region, unsigned long image_size)
> static void
> process_gb_huge_pages(struct mem_vector *region, unsigned long image_size)
> {
> - unsigned long addr, size = 0;
> + unsigned long pud_start, pud_end, gb_huge_pages;
> struct mem_vector tmp;
> - int i = 0;
>
> - if (!max_gb_huge_pages) {
> + if (IS_ENABLED(CONFIG_X86_32) || !max_gb_huge_pages) {
> store_slot_info(region, image_size);
> return;
> }

Won't max_gb_huge_pages always be false for 32-bit?

--
Kees Cook

\
 
 \ /
  Last update: 2020-07-28 21:28    [W:0.333 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site