arch/x86/include/asm/set_memory.h | 2 -- arch/x86/include/asm/smp.h | 2 +- arch/x86/mm/pat/set_memory.c | 13 ------------- drivers/virt/coco/sev-guest/sev-guest.c | 1 + 4 files changed, 2 insertions(+), 16 deletions(-)
The need for this series arose from a completely unrelated series [1].
Long story short, that series causes <linux/mm.h> to include
<linux/set_memory.h>, which doesn't feel too unreasonable.
That works fine on arm64 and probably most other architectures, but not
on x86 [2]: <asm/set_memory.h> itself includes <linux/mm.h>, creating a
circular dependency.
set_memory.h doesn't really need <linux/mm.h>, so removing that include
seems like the right thing to do. That turned out to be a little more
involved than expected, hence this series:
* Patch 1-2 ensure that code doesn't rely on <asm/set_memory.h>
including <linux/mm.h>. The errors that these patches fix are included
at the end of this email.
* Patch 3 removes an unused function whose declaration relied on
<linux/mm.h> being included.
* Patch 4 actually remove the include.
I've build-tested this series with x86_64_defconfig and allyesconfig.
- Kevin
[1] https://lore.kernel.org/linux-hardening/20241206101110.1646108-1-kevin.brodsky@arm.com/
[2] https://lore.kernel.org/oe-kbuild-all/202412062006.C23V9ESs-lkp@intel.com/
Cc: bp@alien8.de
Cc: dan.j.williams@intel.com
Cc: dave.hansen@linux.intel.com
Cc: david@redhat.com
Cc: jane.chu@oracle.com
Cc: osalvador@suse.de
Cc: tglx@linutronix.de
---
Build errors caused by patch 4 and fixed by patch 1-2:
CC drivers/gpu/drm/i915/gt/intel_ggtt.o
In file included from arch/x86/include/asm/smp.h:9,
from drivers/gpu/drm/i915/gt/intel_ggtt.c:7:
arch/x86/include/asm/thread_info.h: In function 'arch_within_stack_frames':
arch/x86/include/asm/thread_info.h:212:16: error: 'NOT_STACK' undeclared (first use in this function)
212 | return NOT_STACK;
| ^~~~~~~~~
arch/x86/include/asm/thread_info.h:212:16: note: each undeclared identifier is reported only once for each function it appears in
CC drivers/virt/coco/sev-guest/sev-guest.o
drivers/virt/coco/sev-guest/sev-guest.c: In function 'free_shared_pages':
drivers/virt/coco/sev-guest/sev-guest.c:621:31: error: implicit declaration of function 'PAGE_ALIGN'; did you mean 'PFN_ALIGN'? [-Wimplicit-function-declaration]
621 | unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
| ^~~~~~~~~~
| PFN_ALIGN
CC drivers/infiniband/hw/mlx5/ib_rep.o
drivers/virt/coco/sev-guest/sev-guest.c: In function 'alloc_shared_pages':
drivers/virt/coco/sev-guest/sev-guest.c:646:51: error: implicit declaration of function 'page_address'; did you mean 'pbe_address'? [-Wimplicit-function-declaration]
646 | ret = set_memory_decrypted((unsigned long)page_address(page), npages);
| ^~~~~~~~~~~~
| pbe_address
drivers/virt/coco/sev-guest/sev-guest.c:653:16: error: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion]
653 | return page_address(page);
| ^~~~~~~~~~~~~~~~~~
---
Kevin Brodsky (4):
x86/smp: Explicitly include <linux/thread_info.h>
x86/sev: Explicitly include <linux/mm.h>
x86/mm: Remove unused __set_memory_prot()
x86/mm: Remove unnecessary include in set_memory.h
arch/x86/include/asm/set_memory.h | 2 --
arch/x86/include/asm/smp.h | 2 +-
arch/x86/mm/pat/set_memory.c | 13 -------------
drivers/virt/coco/sev-guest/sev-guest.c | 1 +
4 files changed, 2 insertions(+), 16 deletions(-)
base-commit: fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
--
2.47.0
On Tue, Dec 10, 2024 at 06:46:06PM +0000, Kevin Brodsky wrote: > The need for this series arose from a completely unrelated series [1]. > Long story short, that series causes <linux/mm.h> to include > <linux/set_memory.h>, which doesn't feel too unreasonable. It is entirely unreasoable. <linux/mm.h> is inclued just about everywhere and should not grow more fringe includes. That btw doesn't invalidate any reason to not also reduce the amount of crap included in <asm/set_memory.h>, as reducing include hell is always good.
On 11/12/2024 06:04, Christoph Hellwig wrote:
> On Tue, Dec 10, 2024 at 06:46:06PM +0000, Kevin Brodsky wrote:
>> The need for this series arose from a completely unrelated series [1].
>> Long story short, that series causes <linux/mm.h> to include
>> <linux/set_memory.h>, which doesn't feel too unreasonable.
> It is entirely unreasoable. <linux/mm.h> is inclued just about
> everywhere and should not grow more fringe includes.
Understood, I did wonder about that. Then I suppose the best course of
action for the problematic patch in that other series [3] is to move
pagetable_{alloc,free} out of linux/mm.h.
- Kevin
[3]
https://lore.kernel.org/linux-hardening/20241206101110.1646108-11-kevin.brodsky@arm.com/
On Wed, Dec 11, 2024 at 09:14:07AM +0100, Kevin Brodsky wrote:
> On 11/12/2024 06:04, Christoph Hellwig wrote:
> > On Tue, Dec 10, 2024 at 06:46:06PM +0000, Kevin Brodsky wrote:
> >> The need for this series arose from a completely unrelated series [1].
> >> Long story short, that series causes <linux/mm.h> to include
> >> <linux/set_memory.h>, which doesn't feel too unreasonable.
> > It is entirely unreasoable. <linux/mm.h> is inclued just about
> > everywhere and should not grow more fringe includes.
>
> Understood, I did wonder about that. Then I suppose the best course of
> action for the problematic patch in that other series [3] is to move
> pagetable_{alloc,free} out of linux/mm.h.
Yes, adding a new header for the page table helpers only used by arch
code is probably a good idea. Or maybe they can actually fit into
asm-generic/pgalloc.h?
On 10.12.24 19:46, Kevin Brodsky wrote: > The need for this series arose from a completely unrelated series [1]. > Long story short, that series causes <linux/mm.h> to include > <linux/set_memory.h>, which doesn't feel too unreasonable. > > That works fine on arm64 and probably most other architectures, but not > on x86 [2]: <asm/set_memory.h> itself includes <linux/mm.h>, creating a > circular dependency. > > set_memory.h doesn't really need <linux/mm.h>, so removing that include > seems like the right thing to do. That turned out to be a little more > involved than expected, hence this series: > > * Patch 1-2 ensure that code doesn't rely on <asm/set_memory.h> > including <linux/mm.h>. The errors that these patches fix are included > at the end of this email. > > * Patch 3 removes an unused function whose declaration relied on > <linux/mm.h> being included. > > * Patch 4 actually remove the include. > > I've build-tested this series with x86_64_defconfig and allyesconfig. > > - Kevin > > [1] https://lore.kernel.org/linux-hardening/20241206101110.1646108-1-kevin.brodsky@arm.com/ > [2] https://lore.kernel.org/oe-kbuild-all/202412062006.C23V9ESs-lkp@intel.com/ > > Cc: bp@alien8.de > Cc: dan.j.williams@intel.com > Cc: dave.hansen@linux.intel.com > Cc: david@redhat.com > Cc: jane.chu@oracle.com > Cc: osalvador@suse.de > Cc: tglx@linutronix.de > --- LGTM Acked-by: David Hildenbrand <david@redhat.com> -- Cheers, David / dhildenb
© 2016 - 2025 Red Hat, Inc.