[PATCH 0/4] Remove problematic include in <asm/set_memory.h>
From: Kevin Brodsky
Date: Tue Dec 10 2024 - 13:46:56 EST
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@xxxxxxx/
[2] https://lore.kernel.org/oe-kbuild-all/202412062006.C23V9ESs-lkp@xxxxxxxxx/
Cc: bp@xxxxxxxxx
Cc: dan.j.williams@xxxxxxxxx
Cc: dave.hansen@xxxxxxxxxxxxxxx
Cc: david@xxxxxxxxxx
Cc: jane.chu@xxxxxxxxxx
Cc: osalvador@xxxxxxx
Cc: tglx@xxxxxxxxxxxxx
---
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