goto fail;
 
        /*
-        * Enforce minimum alignment that EFI requires when requesting
-        * a specific address.  We are doing page-based allocations,
-        * so we must be aligned to a page.
+        * Enforce minimum alignment that EFI or Linux requires when
+        * requesting a specific address.  We are doing page-based (or
+        * larger) allocations, and both the address and size must meet
+        * alignment constraints.
         */
        if (align < EFI_ALLOC_ALIGN)
                align = EFI_ALLOC_ALIGN;
 
-       nr_pages = round_up(size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE;
+       size = round_up(size, EFI_ALLOC_ALIGN);
+       nr_pages = size / EFI_PAGE_SIZE;
 again:
        for (i = 0; i < map_size / desc_size; i++) {
                efi_memory_desc_t *desc;
                        continue;
 
                start = desc->phys_addr;
-               end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT);
+               end = start + desc->num_pages * EFI_PAGE_SIZE;
 
                if (end > max)
                        end = max;
                goto fail;
 
        /*
-        * Enforce minimum alignment that EFI requires when requesting
-        * a specific address.  We are doing page-based allocations,
-        * so we must be aligned to a page.
+        * Enforce minimum alignment that EFI or Linux requires when
+        * requesting a specific address.  We are doing page-based (or
+        * larger) allocations, and both the address and size must meet
+        * alignment constraints.
         */
        if (align < EFI_ALLOC_ALIGN)
                align = EFI_ALLOC_ALIGN;
 
-       nr_pages = round_up(size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE;
+       size = round_up(size, EFI_ALLOC_ALIGN);
+       nr_pages = size / EFI_PAGE_SIZE;
        for (i = 0; i < map_size / desc_size; i++) {
                efi_memory_desc_t *desc;
                unsigned long m = (unsigned long)map;
                        continue;
 
                start = desc->phys_addr;
-               end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT);
+               end = start + desc->num_pages * EFI_PAGE_SIZE;
 
                /*
                 * Don't allocate at 0x0. It will confuse code that