From patchwork Tue Mar 14 10:13:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeniy Baskov X-Patchwork-Id: 69431 Return-Path: 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 + 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 ); 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 To: Ard Biesheuvel Cc: Evgeniy Baskov , Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , "Limonciello, Mario" , joeyli , 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: References: MIME-Version: 1.0 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: 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?= 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 Signed-off-by: Evgeniy Baskov --- arch/x86/boot/compressed/vmlinux.lds.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 = . ;