Message ID | 159597c484778da5e59c3a5728669f131f800b5a.1678785672.git.baskov@ispras.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1672572wrd; Tue, 14 Mar 2023 03:23:04 -0700 (PDT) X-Google-Smtp-Source: AK7set9RZ1/1I4/ZGF77aYWC9VX9tV55DUF9b2hJMjdbf8efGuGi+VjMb9J21v5hatb7Otmp1uIr X-Received: by 2002:a62:79cb:0:b0:623:1402:4550 with SMTP id u194-20020a6279cb000000b0062314024550mr9024779pfc.12.1678789384179; Tue, 14 Mar 2023 03:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678789384; cv=none; d=google.com; s=arc-20160816; b=mcmGuOAKUGYJJ/G/sbE0FYQ9DvgRx9Ek4S0dXcm4skmJpdvCyWokn6m5AGzbmIb7jA cb/6JOt0+D/JD3ZrKSYMkGuWDsto5Tjx2CsccRyxkludLOaTKUvEH7bKWdViWvfuD12o 2A3rAXA116ArKHXHBucfMYhJxCYFJEQyU1PfgGElvocl+dLczi8By9iZlkR2kmA0uPUG wXnvESpLVZeJXjhFsr+TARF/I3DnTTEHSe/itpNKNNO38ctJACky62yOUDjbrYNcTjOJ LkUOsCD/lWg2jvKp20rkr8gOFl/s/RvV+h7ZDUkMhA54j2ULGTrtpn3YkTOTbkN4D31/ VUrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=J5zJSuuCzj+1C39z27zh+o9bfA57PDh8/CXoZdGgyyU=; b=znk3UxSXIuzvQeCmxzuGv9zRBe0n/8t4AVD+uaf5Rz9/0kzRoV+2kIxW4Tc709Egt9 H67xAk812dpifEb3K3/UYjrJXwM+wDBCC8SOBygEhXML3RwoIZBgLQ/HGr9kT8WEhoJl maePoDx2fRVxqj7UL9gSciBvXTza3YH5AmGQMtoUVji24UrdBv7jKOkl5NBGnEyRi9DY BhfBSlO7+STFefFJgm57E+/pxg6/bdqx2+cLSaynAt1BCSGi/NbiVp8UOG9qUtcPn3+E k0P0IxffFG0tGvJVimCoDa4bnlWvGrH6Uii1MbgYlVeTFyQAA3s2KclbyHc3awFfEIt7 JQig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=bZQowxWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020aa79af5000000b00577c17000dasi1953971pfp.166.2023.03.14.03.22.49; Tue, 14 Mar 2023 03:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=bZQowxWT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjCNKP4 (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Tue, 14 Mar 2023 06:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbjCNKPx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Mar 2023 06:15:53 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74C639AFE6; Tue, 14 Mar 2023 03:15:14 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id 9A36740755C6; Tue, 14 Mar 2023 10:14:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 9A36740755C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1678788840; bh=J5zJSuuCzj+1C39z27zh+o9bfA57PDh8/CXoZdGgyyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZQowxWT7U+/gNyV66AeYgrHbuevv0qUoJikCUi0iBw2hO3m3mzHYKRw4xrYZhOn3 yYznLBK481C3v9vNbtgGhKz46WcBd2mJdRi+4kQMkebhtK/Kb7ogwR061COdNJqPWY HCkDJkjGMp0phuVuhYI146H/uvO+ZQ0fpejPM9eU= From: Evgeniy Baskov <baskov@ispras.ru> To: Ard Biesheuvel <ardb@kernel.org> Cc: Evgeniy Baskov <baskov@ispras.ru>, Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Alexey Khoroshilov <khoroshilov@ispras.ru>, Peter Jones <pjones@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Limonciello, Mario" <mario.limonciello@amd.com>, joeyli <jlee@suse.com>, lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v5 01/27] x86/boot: Align vmlinuz sections on page size Date: Tue, 14 Mar 2023 13:13:28 +0300 Message-Id: <159597c484778da5e59c3a5728669f131f800b5a.1678785672.git.baskov@ispras.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <cover.1678785672.git.baskov@ispras.ru> References: <cover.1678785672.git.baskov@ispras.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760338257095600584?= X-GMAIL-MSGID: =?utf-8?q?1760338257095600584?= |
Series |
x86_64: Improvements at compressed kernel stage
|
|
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
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.
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 --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 = . ;