From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42933C433F5 for ; Tue, 8 Feb 2022 00:13:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B775D6B0073; Mon, 7 Feb 2022 19:13:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B26426B0075; Mon, 7 Feb 2022 19:13:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EE516B0078; Mon, 7 Feb 2022 19:13:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 8C36B6B0073 for ; Mon, 7 Feb 2022 19:13:52 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 47F329879D for ; Tue, 8 Feb 2022 00:13:52 +0000 (UTC) X-FDA: 79117689504.09.9B4D0F2 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf11.hostedemail.com (Postfix) with ESMTP id E7BBD40002 for ; Tue, 8 Feb 2022 00:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644279231; x=1675815231; h=message-id:date:mime-version:to:cc:references:from: subject:in-reply-to:content-transfer-encoding; bh=BPhMCShSVCOniHzYsoSxv9XqF3MkYnnOdHCV78VWtYE=; b=WoUOH0XueyPf6viG/SvNCzthgcBzOXDApLFisYC5ny5vXAcSqYlCTzUY MWg57ImYiaTSm4bnYeJjVaiG6ej90jV4hUuRogP0+LAdgAwB/zTdo+02I oxzrGZVDcyaQmYlHrc0/kyIlRkXe4SScCA2oXcGKs1GOXcghBxFv8aMXS Pp25DJ33kDdvEKwthR19EGC7zF8TJvK/ZVi+jJZMpgg/8uWq+y56JuGty LDI+UmF6bbZCrUxPiswXn29mRbkt/qfWqGxAeIPxqLzdolV0GoKdoesNZ jyCu+7ngti/x3fFuLLCRNJxBHhUrOsbZWEbqUG0Bzq1Gf8ZI6+cPdZAak Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10251"; a="229484636" X-IronPort-AV: E=Sophos;i="5.88,351,1635231600"; d="scan'208";a="229484636" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2022 16:13:49 -0800 X-IronPort-AV: E=Sophos;i="5.88,351,1635231600"; d="scan'208";a="525332786" Received: from hgrunes-mobl1.amr.corp.intel.com (HELO [10.251.3.57]) ([10.251.3.57]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2022 16:13:48 -0800 Message-ID: <672fa390-c88c-4e2a-aa42-52d171acfd62@intel.com> Date: Mon, 7 Feb 2022 16:13:45 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: Rick Edgecombe , x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Dave Martin , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com Cc: Yu-cheng Yu , Christoph Hellwig References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <20220130211838.8382-8-rick.p.edgecombe@intel.com> From: Dave Hansen Subject: Re: [PATCH 07/35] x86/mm: Remove _PAGE_DIRTY from kernel RO pages In-Reply-To: <20220130211838.8382-8-rick.p.edgecombe@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E7BBD40002 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WoUOH0Xu; spf=none (imf11.hostedemail.com: domain of dave.hansen@intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=dave.hansen@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: 4jodozt8snugurzun7x4oaf3ne5nuzkt X-Rspamd-Server: rspam04 X-HE-Tag: 1644279230-542313 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 1/30/22 13:18, Rick Edgecombe wrote: > The x86 family of processors do not directly create read-only and Dirty > PTEs. These PTEs are created by software. That's not strictly correct. There's nothing in the architecture today to prevent the CPU from creating Write=0,Dirty=1 PTEs. In fact, some CPUs do this in weird situations. It wouldn't be wrong to say: Processors sometimes directly create read-only and Dirty PTEs. which is the opposite of what is written above. This is why the CET spec has the blurb about shadow-stack-supporting CPUs promise not to do this any more. > One such case is that kernel > read-only pages are historically setup as Dirty. ^ set up > New processors that support Shadow Stack regard read-only and Dirty PTEs as > shadow stack pages. This also isn't *quite* correct. It's not just having a new processor, it includes enabling shadow stacks. > This results in ambiguity between shadow stack and kernel read-only > pages. To resolve this, removed Dirty from kernel read- only pages. One thing that's not clear from the spec: does this cause an *actual* problem? For instance, does setting: IA32_U_CET.SH_STK_EN=1 but IA32_S_CET.SH_STK_EN=0 means that shadow stacks are enforced in user *MODE* or on user-paging-permission (U=0) PTEs? I think it's modes, but it would be nice to be clear. *BUT*, if this is accurate, doesn't it also mean that this patch is not strictly necessary? Don't get me wrong, the patch is probably still a good idea, but let's make sure we get the exact reasoning clear.