Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4167250rwb; Tue, 6 Sep 2022 03:43:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Fn6lWb9pszWmjkdqzveuftlVIgcmYNzxAQDyzPfr2hW2w5Qzx0Q2aczdpOZR8U0g7AR6r X-Received: by 2002:a62:2584:0:b0:537:d4f9:385d with SMTP id l126-20020a622584000000b00537d4f9385dmr51759508pfl.55.1662461001948; Tue, 06 Sep 2022 03:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662461001; cv=none; d=google.com; s=arc-20160816; b=mA97i78fVLYhFIqdb8H6j0EazoZJDgFoVPKN2vdGCi1Hw3jOh/t3FM70cDuOhsu7T0 3PGHK2TtW8FU1OYO7E8/Zub8B3SoTanh/ZV4zP5rqPkZInyjDSio+fvY4J88+q367URR ID7Z/xsXH0XKk04QR5kFcg6fdl7cuHr/aHdnYhxkVfx5iuKgGhIpgWZtiP5UF54aBxfk 7fbA8Dwh2uLtPG8ORgAkACNLFfAB4x82+JWjnN4ee/AM8A19b4qxLoKQkpNdo1vS3aJz 8IdbshFSfj0kOgfIFT+L6oqfcATEGVdB3b208mKMUbuCxxXg1O8kyeqHlQk2Cxastqrd O7Fw== 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; bh=EYqCjBNGfpXryXdGLpMJPnTOJ04Y5Ux806QDSrInYRE=; b=pxk1phe328qqMacOo7W9dTkKbT4ytpxsXgoekN1cB/CEbXVFeLkLdsiR/QXhm/XDc4 1j7bXuZjOu8PgjtDRJE3jQSsHau+41oEf6Dc8F2abKcItijMd2DIpF75NrP0XapvvSRI MIlyA0kaPIq2AKUtuPXpxjHfqSae7kzPFtvBrKPTNy2zge1bSY6/wqaATP8FDZcpdqR/ MdyKUcFwY23kalJb8fISeIdd38j0R8Z1P2h9sc7Am5eSCRyA1ufpU3QabyAzqWjnRx1t TMm5P77m9bBis25zO4ZzKWqIAH7p6L0XhcJSA9bk46Bpl66b/FS2/CzxP3DyK6Y4/axQ GEmA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a17090adc1500b00200a9235f48si592296pjv.44.2022.09.06.03.43.10; Tue, 06 Sep 2022 03:43:21 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239577AbiIFKmL (ORCPT + 99 others); Tue, 6 Sep 2022 06:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234105AbiIFKlp (ORCPT ); Tue, 6 Sep 2022 06:41:45 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1285F9B9; Tue, 6 Sep 2022 03:41:43 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id 784744076251; Tue, 6 Sep 2022 10:41:38 +0000 (UTC) From: Evgeniy Baskov To: Ard Biesheuvel Cc: Evgeniy Baskov , Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 03/16] x86/boot: Set cr0 to known state in trampoline Date: Tue, 6 Sep 2022 13:41:07 +0300 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Ensure WP bit to be set to prevent boot code from writing to non-writable memory pages. Signed-off-by: Evgeniy Baskov --- arch/x86/boot/compressed/head_64.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index d33f060900d2..5273367283b7 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -619,9 +619,8 @@ SYM_CODE_START(trampoline_32bit_src) /* Set up new stack */ leal TRAMPOLINE_32BIT_STACK_END(%ecx), %esp - /* Disable paging */ - movl %cr0, %eax - btrl $X86_CR0_PG_BIT, %eax + /* Disable paging and setup CR0 */ + movl $(CR0_STATE & ~X86_CR0_PG), %eax movl %eax, %cr0 /* Check what paging mode we want to be in after the trampoline */ -- 2.35.1