[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bk1x42vk.fsf@nvdebian.thelocal>
Date: Tue, 13 Aug 2024 11:33:24 +1000
From: Alistair Popple <apopple@...dia.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Dan Williams <dan.j.williams@...el.com>, dave.hansen@...ux.intel.com,
luto@...nel.org, peterz@...radead.org, max8rr8@...il.com,
linux-kernel@...r.kernel.org, x86@...nel.org, jhubbard@...dia.com, Kees
Cook <keescook@...omium.org>
Subject: Re: [PATCH 1/1] x86/ioremap: Use is_vmalloc_addr in iounmap
Thomas Gleixner <tglx@...utronix.de> writes:
> On Mon, Aug 12 2024 at 12:03, Thomas Gleixner wrote:
>> On Mon, Aug 12 2024 at 17:41, Alistair Popple wrote:
>>> The same applies to the rest of the DIRECT_MAP_END users here. Perhaps
>>> it would be better to define this as DIRECT_MAP_SIZE and calculate this
>>> based off PAGE_OFFSET instead?
>>
>> Duh, yes. I shouldn't try to write patches at 30C :)
>
> We can avoid the calculation and expose the end of the physical address
> space for memory. This time I actually built and ran it :)
To be fair the previous version did actually build and run fine, it just
didn't fix the issue. However this version does so feel free to add:
Tested-by: Alistair Popple <apopple@...dia.com>
[...]
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -97,6 +97,10 @@ extern const int mmap_rnd_compat_bits_ma
> extern int mmap_rnd_compat_bits __read_mostly;
> #endif
>
> +#ifndef PHYSMEM_END
> +# define PHYSMEM_END (1UL << (MAX_PHYSMEM_BITS-PAGE_SHIFT))
However I think this should be:
# define PHYSMEM_END ((1UL << MAX_PHYSMEM_BITS) - 1)
- Alistair
> +#endif
> +
> #include <asm/page.h>
> #include <asm/processor.h>
>
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1826,8 +1826,7 @@ static resource_size_t gfr_start(struct
> if (flags & GFR_DESCENDING) {
> resource_size_t end;
>
> - end = min_t(resource_size_t, base->end,
> - (1ULL << MAX_PHYSMEM_BITS) - 1);
> + end = min_t(resource_size_t, base->end, PHYSMEM_END);
> return end - size + 1;
> }
>
> @@ -1844,8 +1843,7 @@ static bool gfr_continue(struct resource
> * @size did not wrap 0.
> */
> return addr > addr - size &&
> - addr <= min_t(resource_size_t, base->end,
> - (1ULL << MAX_PHYSMEM_BITS) - 1);
> + addr <= min_t(resource_size_t, base->end, PHYSMEM_END);
> }
>
> static resource_size_t gfr_next(resource_size_t addr, resource_size_t size,
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1681,7 +1681,7 @@ struct range __weak arch_get_mappable_ra
>
> struct range mhp_get_pluggable_range(bool need_mapping)
> {
> - const u64 max_phys = (1ULL << MAX_PHYSMEM_BITS) - 1;
> + const u64 max_phys = PHYSMEM_END;
> struct range mhp_range;
>
> if (need_mapping) {
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -129,7 +129,7 @@ static inline int sparse_early_nid(struc
> static void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn,
> unsigned long *end_pfn)
> {
> - unsigned long max_sparsemem_pfn = 1UL << (MAX_PHYSMEM_BITS-PAGE_SHIFT);
> + unsigned long max_sparsemem_pfn = (PHYSMEM_END + 1) >> PAGE_SHIFT;
>
> /*
> * Sanity checks - do not allow an architecture to pass
Powered by blists - more mailing lists