Skip to contentSkip to conversation

x86/boot: Use __ALIGN_KERNEL_MASK() instead of open coded analogue

PATCH Applied Andy Shevchenko 2 participants 2 messages Apr 4, 2025 – Apr 6, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Use __ALIGN_KERNEL_MASK() instead of open coded analogue

LOAD_PHYSICAL_ADDR is calculated as an aligned (up) CONFIG_PHYSICAL_START with the respective alignment value CONFIG_PHYSICAL_ALIGN. However, the code is written openly while we have __ALIGN_KERNEL_MASK() macro that does the same. This macro has nothing special, that's why it may be used in assembler code or linker scripts (on the contrary __ALIGN_KERNEL() may not). Do it so.

---
 arch/x86/include/asm/page_types.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/include/asm/page_types.h +1 -3
index 974688973cf6..1f749eb5c3cb 100644
@@ -29,9 +29,7 @@
 #define VM_DATA_DEFAULT_FLAGS	VM_DATA_FLAGS_TSK_EXEC
 
 /* Physical address where kernel should be loaded. */
-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
-				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
-				& ~(CONFIG_PHYSICAL_ALIGN - 1))
+#define LOAD_PHYSICAL_ADDR	__ALIGN_KERNEL_MASK(CONFIG_PHYSICAL_START, CONFIG_PHYSICAL_ALIGN - 1)
 
 #define __START_KERNEL		(__START_KERNEL_map + LOAD_PHYSICAL_ADDR)
 
Signature · 1 line
2.47.2
#1 lore raw
The following commit has been merged into the x86/boot branch of tip:

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     0ee07a07920285d519152974872ca6e43f8742e8
Gitweb:        https://git.kernel.org/tip/0ee07a07920285d519152974872ca6e43f8742e8
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 04 Apr 2025 19:53:03 +03:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Sun, 06 Apr 2025 20:06:36 +02:00

x86/boot: Use __ALIGN_KERNEL_MASK() instead of open coded analogue

LOAD_PHYSICAL_ADDR is calculated as an aligned (up) CONFIG_PHYSICAL_START with the respective alignment value CONFIG_PHYSICAL_ALIGN. However, the code is written openly while we have __ALIGN_KERNEL_MASK() macro that does the same. This macro has nothing special, that's why it may be used in assembler code or linker scripts (on the contrary __ALIGN_KERNEL() may not). Do it so.

---
 arch/x86/include/asm/page_types.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/include/asm/page_types.h +1 -3
index 9f77bf0..018a8d9 100644
@@ -29,9 +29,7 @@
 #define VM_DATA_DEFAULT_FLAGS	VM_DATA_FLAGS_TSK_EXEC
 
 /* Physical address where kernel should be loaded. */
-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
-				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
-				& ~(CONFIG_PHYSICAL_ALIGN - 1))
+#define LOAD_PHYSICAL_ADDR	__ALIGN_KERNEL_MASK(CONFIG_PHYSICAL_START, CONFIG_PHYSICAL_ALIGN - 1)
 
 #define __START_KERNEL		(__START_KERNEL_map + LOAD_PHYSICAL_ADDR)