diff mbox series

[v5,01/27] x86/boot: Align vmlinuz sections on page size

Message ID 159597c484778da5e59c3a5728669f131f800b5a.1678785672.git.baskov@ispras.ru (mailing list archive)
State Handled Elsewhere
Headers show
Series x86_64: Improvements at compressed kernel stage | expand

Commit Message

Evgeniy Baskov March 14, 2023, 10:13 a.m. UTC
To protect sections on page table level each section needs to be
aligned on page size (4KB).

Set sections alignment in linker script for the kernel decompressor
(boot/compressed/vmlinux.lds.S).

Also introduce symbols that can be used to reference compressed
kernel blob section later in the later patches.

Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
---
 arch/x86/boot/compressed/vmlinux.lds.S | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Borislav Petkov April 5, 2023, 5:13 p.m. UTC | #1
On Tue, Mar 14, 2023 at 01:13:28PM +0300, Evgeniy Baskov wrote:
> To protect sections on page table level each section needs to be
> aligned on page size (4KB).

Protect against what?

> Set sections alignment in linker script for the kernel decompressor
> (boot/compressed/vmlinux.lds.S).

Do not talk about *what* the patch is doing in the commit message - that
should be obvious from the diff itself. Rather, concentrate on the *why*
it needs to be done.

> Also introduce symbols that can be used to reference compressed
> kernel blob section later in the later patches.

Introduce those with the respective patch that uses them. This one is
adding section alignment only and that's all that it should do.

Thx.
Evgeniy Baskov April 8, 2023, 3:03 p.m. UTC | #2
On 2023-04-05 20:13, Borislav Petkov wrote:

Sorry for delayed reply.

> On Tue, Mar 14, 2023 at 01:13:28PM +0300, Evgeniy Baskov wrote:
>> To protect sections on page table level each section needs to be
>> aligned on page size (4KB).
> 
> Protect against what?

Protect against invalid memory accesses, mainly caused by bugs, I guess.
I meant just applying tight memory attributes, sorry for the
bad wording. I will change it in the next version.

> 
>> Set sections alignment in linker script for the kernel decompressor
>> (boot/compressed/vmlinux.lds.S).
> 
> Do not talk about *what* the patch is doing in the commit message - 
> that
> should be obvious from the diff itself. Rather, concentrate on the 
> *why*
> it needs to be done.

Makes sense. I'll try to improve it before resubmitting.

> 
>> Also introduce symbols that can be used to reference compressed
>> kernel blob section later in the later patches.
> 
> Introduce those with the respective patch that uses them. This one is
> adding section alignment only and that's all that it should do.

Oh, good point, will do.

> 
> Thx.

Thanks,
Evgeniy Baskov
diff mbox series

Patch

diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
index b22f34b8684a..a5015b958085 100644
--- a/arch/x86/boot/compressed/vmlinux.lds.S
+++ b/arch/x86/boot/compressed/vmlinux.lds.S
@@ -27,31 +27,32 @@  SECTIONS
 		HEAD_TEXT
 		_ehead = . ;
 	}
-	.rodata..compressed : {
+	.rodata..compressed : ALIGN(PAGE_SIZE) {
+		_compressed = .;
 		*(.rodata..compressed)
+		_ecompressed = .;
 	}
-	.text :	{
+	.text :	ALIGN(PAGE_SIZE) {
 		_text = .; 	/* Text */
 		*(.text)
 		*(.text.*)
 		*(.noinstr.text)
 		_etext = . ;
 	}
-	.rodata : {
+	.rodata : ALIGN(PAGE_SIZE) {
 		_rodata = . ;
 		*(.rodata)	 /* read-only data */
 		*(.rodata.*)
 		_erodata = . ;
 	}
-	.data :	{
+	.data :	ALIGN(PAGE_SIZE) {
 		_data = . ;
 		*(.data)
 		*(.data.*)
 		*(.bss.efistub)
 		_edata = . ;
 	}
-	. = ALIGN(L1_CACHE_BYTES);
-	.bss : {
+	.bss : ALIGN(L1_CACHE_BYTES) {
 		_bss = . ;
 		*(.bss)
 		*(.bss.*)
@@ -60,8 +61,7 @@  SECTIONS
 		_ebss = .;
 	}
 #ifdef CONFIG_X86_64
-       . = ALIGN(PAGE_SIZE);
-       .pgtable : {
+       .pgtable : ALIGN(PAGE_SIZE) {
 		_pgtable = . ;
 		*(.pgtable)
 		_epgtable = . ;