From patchwork Tue Oct 25 14:12:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeniy Baskov X-Patchwork-Id: 10812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1032150wru; Tue, 25 Oct 2022 07:13:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rGwITxwIQUjIvz6/0YriMXtLRFvMV/gAjKsf9wV7xZ0wQ8f4gqWVS/epwAHerMJbpH9V1 X-Received: by 2002:a05:6a02:192:b0:43c:a0cb:44d3 with SMTP id bj18-20020a056a02019200b0043ca0cb44d3mr34175753pgb.139.1666707229550; Tue, 25 Oct 2022 07:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666707229; cv=none; d=google.com; s=arc-20160816; b=WhuGngPsvyvhdgg8mU0LQD0S6dH5xx8cb3U2pTFU+0609oAzknKb19GN1Hzv9HYwIR QKWX0ztycJWb9064qOthRffW7kUOvCGQts498mKr72++m9QNhnaxtfMxpYcNZkydQaVi MApzyG0wLb8bMAbEer35IHuEYxLUjpmH/XF07Ymr9cq5bzvRAXDA9M5xdxOuEYGWv3Hc LYvn0SpWf2HCalRmYxjPxYoEC7NPbcHH7BJTY/u9jfZTxAyuNKUKEdnspww3KVWWMc1v eR1GcRnMfHYB3sIY/HuVG1d+fYg3VEqwTlil5ydDxvG71mx5fnO5u94DTjBGFtVCLqwW tF6w== 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=Q9fnWgrDqNAEfbyyDhr1NF2k/eQWdzIJiBg8GZcJcfM=; b=QI2FeQ1lg2upOwwwiOFQtIuQ15TAaBCPvm8WUnq/ipJSXF6ViSeKyxUr6F3N5lPzHJ wVQuIDXkFV2wZGATuVxUFdvdYeQ1agRmyBeh8q5z9dUs7CHh3wj8jVeDZXgt0eQkbnvW 0xrICxQoA+9Cxpvcf20eF2m7U6N+es2O+FF9n/ODVoTHAMq+Bd9jJlDfFnN/1RLi5hcB I0/FqnccEIEqSvOuxsv4B0b7IuO3XjWPAhJQFyj+CZsMfqcOSdf4OCvrNWNNBFqjVRcz WP6taZSSI07yOEgoiuue5pUruImNnO4thu9MmUR2vvXnRENqYFTFsv9U+K1AgyMn1uO/ Z7MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=YQzgIw4H; 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 b3-20020a639303000000b004612e8df649si449684pge.784.2022.10.25.07.13.35; Tue, 25 Oct 2022 07:13:49 -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=YQzgIw4H; 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 S232964AbiJYONY (ORCPT + 99 others); Tue, 25 Oct 2022 10:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbiJYONU (ORCPT ); Tue, 25 Oct 2022 10:13:20 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 664F79C2EE; Tue, 25 Oct 2022 07:13:19 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id DF7AD419E9C1; Tue, 25 Oct 2022 14:13:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru DF7AD419E9C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1666707196; bh=Q9fnWgrDqNAEfbyyDhr1NF2k/eQWdzIJiBg8GZcJcfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YQzgIw4H4258IJy13u2s453qRvWd3gEaFSmUfhIfBnTcPR02DI6f4rRjsryOmM992 bcEZElVn4CDB4tHTuSGZ2yjgnk32eHiZDlNZ37tmt0Y/qZ9ZouwvnnBAupdnDxiumv vEgb/WsHxuTS6TtCOpexu8QvN95m+L1RsHO4mbOM= 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 , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 01/23] x86/boot: Align vmlinuz sections on page size Date: Tue, 25 Oct 2022 17:12:39 +0300 Message-Id: X-Mailer: git-send-email 2.37.4 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?1747669200071855860?= X-GMAIL-MSGID: =?utf-8?q?1747669200071855860?= To protect sections on page table level each section needs to be aligned on page size (4KB). Set sections alignment in linker script. Add _compressed/_ecompressed symbols to access '.rodata..compressed' section content in the same way other sections are accessed. This is useful when applying memory attributes of the section. Signed-off-by: Evgeniy Baskov --- arch/x86/boot/compressed/vmlinux.lds.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 112b2375d021..6be90f1a1198 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -27,21 +27,27 @@ SECTIONS HEAD_TEXT _ehead = . ; } + . = ALIGN(PAGE_SIZE); .rodata..compressed : { + _compressed = .; *(.rodata..compressed) + _ecompressed = .; } + . = ALIGN(PAGE_SIZE); .text : { _text = .; /* Text */ *(.text) *(.text.*) _etext = . ; } + . = ALIGN(PAGE_SIZE); .rodata : { _rodata = . ; *(.rodata) /* read-only data */ *(.rodata.*) _erodata = . ; } + . = ALIGN(PAGE_SIZE); .data : { _data = . ; *(.data)