[PATCH v2 2/2] x86/mm: Remove unnecessary include in set_memory.h

From: Kevin Brodsky
Date: Thu Dec 12 2024 - 03:09:44 EST


Commit 03b122da74b2 ("x86/sgx: Hook arch_memory_failure() into
mainline code") included <linux/mm.h> in asm/set_memory.h to provide
some helper. However commit b3fdf9398a16 ("x86/mce: relocate
set{clear}_mce_nospec() functions") moved the inline definitions
someplace else, and now set_memory.h just declares a bunch of
functions.

No need for the whole linux/mm.h for declaring functions; just
remove that include. This helps avoid circular dependency headaches
(e.g. if linux/mm.h ends up including <linux/set_memory.h>).

This change requires a couple of include fixups not to break the
build:

* asm/smp.h: including <asm/thread_info.h> directly relies on
<linux/thread_info.h> having already been included, because the
former needs the BAD_STACK/NOT_STACK constants defined in the
latter. This is no longer the case when asm/smp.h is included from
some driver file - just include <linux/thread_info.h> to stay out
of trouble.

* sev-guest.c relies on <asm/set_memory.h> including <linux/mm.h>,
so we just need to make that include explicit.

Signed-off-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
---
arch/x86/include/asm/set_memory.h | 1 -
arch/x86/include/asm/smp.h | 2 +-
drivers/virt/coco/sev-guest/sev-guest.c | 1 +
3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h
index 6586d533fe3a..8d9f1c9aaa4c 100644
--- a/arch/x86/include/asm/set_memory.h
+++ b/arch/x86/include/asm/set_memory.h
@@ -2,7 +2,6 @@
#ifndef _ASM_X86_SET_MEMORY_H
#define _ASM_X86_SET_MEMORY_H

-#include <linux/mm.h>
#include <asm/page.h>
#include <asm-generic/set_memory.h>

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index ca073f40698f..2ca1da5f16d9 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -3,10 +3,10 @@
#define _ASM_X86_SMP_H
#ifndef __ASSEMBLY__
#include <linux/cpumask.h>
+#include <linux/thread_info.h>

#include <asm/cpumask.h>
#include <asm/current.h>
-#include <asm/thread_info.h>

DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index b699771be029..e134bee818fa 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -23,6 +23,7 @@
#include <linux/cleanup.h>
#include <linux/uuid.h>
#include <linux/configfs.h>
+#include <linux/mm.h>
#include <uapi/linux/sev-guest.h>
#include <uapi/linux/psp-sev.h>

--
2.47.0