Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C2B5C64EC4 for ; Fri, 10 Mar 2023 14:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233392AbjCJOwT (ORCPT ); Fri, 10 Mar 2023 09:52:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbjCJOvl (ORCPT ); Fri, 10 Mar 2023 09:51:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A52E911F631; Fri, 10 Mar 2023 06:48:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 598FD6196F; Fri, 10 Mar 2023 14:48:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF365C433B3; Fri, 10 Mar 2023 14:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678459702; bh=MZZ+xz3G0vilznbAM1hCF+BZtVWTz2PltybcPZKNnL8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LtvAHCO4o5meyqPkBJtVpvSiemyQ2z8bYClzjwMOCq/5vzcTeCY8oTEGpfo8x9tid nWdLbH6iqLpUA8ExqOON8Vk2/AelJ2AbeoRL8nIFtm+VFzm2St/rFd6Yf4Ubg+2DBV zyirIAGgKjgWTFA8DmM4fvzD4mGYf3niLB4Ab828kbwhuZp2IKp15TYb5O69d+cJrK Hpz2v1Mf8VkVUCOEecNiSBzWEQbBGueKeBJ+uaLAD4hWXqbV6nFkAZkjyIfKXfnt+y 2DMMfsMnqW+VE/RGB5PtsfYqx8e0usUdtpN1was4RBvd2s82SwgEGbGR+9Pw0khygF KyMoDQT/9uc2A== Received: by mail-lj1-f180.google.com with SMTP id by8so5529218ljb.7; Fri, 10 Mar 2023 06:48:22 -0800 (PST) X-Gm-Message-State: AO0yUKWq+STV4wwV3e1OuOOqF5Zrsglq5LgZh9QMHjaEK/h2Yp/OOAAJ yF8+6p/iOL9bZgUp8zm7RZt/pvKVkguPuMb54Ws= X-Google-Smtp-Source: AK7set+0BQ0DMOVyXPC1WgLMQEUn+f1e8kQdc94gXG38KqQMt70pg+KRu5rYeqlTUHvA7UYzqFKOy5zXh8GA+CzToc8= X-Received: by 2002:a2e:595:0:b0:298:6d17:eaa7 with SMTP id 143-20020a2e0595000000b002986d17eaa7mr3310478ljf.2.1678459700862; Fri, 10 Mar 2023 06:48:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 10 Mar 2023 15:48:09 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 03/26] x86/boot: Set cr0 to known state in trampoline To: Evgeniy Baskov Cc: Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , "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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Dec 2022 at 13:38, Evgeniy Baskov wrote: > > Ensure WP bit to be set to prevent boot code from writing to > non-writable memory pages. > > Tested-by: Mario Limonciello > Tested-by: Peter Jones > Signed-off-by: Evgeniy Baskov Acked-by: Ard Biesheuvel > --- > 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 a75712991df3..9f2e8f50fc71 100644 > --- a/arch/x86/boot/compressed/head_64.S > +++ b/arch/x86/boot/compressed/head_64.S > @@ -660,9 +660,8 @@ SYM_CODE_START(trampoline_32bit_src) > pushl $__KERNEL_CS > pushl %eax > > - /* Enable paging again. */ > - movl %cr0, %eax > - btsl $X86_CR0_PG_BIT, %eax > + /* Enable paging and set CR0 to known state (this also sets WP flag) */ > + movl $CR0_STATE, %eax > movl %eax, %cr0 > > lret > -- > 2.37.4 >