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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2C2CC7EE29 for ; Tue, 13 Jun 2023 07:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239948AbjFMHn3 (ORCPT ); Tue, 13 Jun 2023 03:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239060AbjFMHn2 (ORCPT ); Tue, 13 Jun 2023 03:43:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2485D1B3; Tue, 13 Jun 2023 00:43:26 -0700 (PDT) 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 ABBAA61A7E; Tue, 13 Jun 2023 07:43:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3123C433D2; Tue, 13 Jun 2023 07:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686642205; bh=rQ3t6NfGFNVjHV4alVdkayNOjig6+FetCPJVDvnXdVc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EmgFk7vr3nHxTez4jl8DokEm1PYRmgvE7snzzuTVuCLvmQTe+waWvzsrNg2YyG2t2 dkrmMDVIr2A31ldRN7QSWK101Moy9a8TbIiySC8Q3yVlslcYtUZi5f1jfqLZnEaKvW b516jUoG37yToBvhzp/x728l6UTI7G+StXPAYCCNUlZbNV/K/A/Xg3RhMcFygsteZz W+HGrlT8JEWjdyCwUufHmlB2EhKbecTEbfAo0CW+uhzY26gxJq6lNj+PVWZa7M41L0 ZvvaRRO+LXQPCGXiDbfCWeVy4lmwb33+qWxNDe+qju3u1P6F0GqzVBHpSdCTqGpG9J 6ZJOk0KXi5+aw== Date: Tue, 13 Jun 2023 10:42:45 +0300 From: Mike Rapoport To: Rick Edgecombe Cc: 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 , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com, szabolcs.nagy@arm.com, torvalds@linux-foundation.org, broonie@kernel.org Subject: Re: [PATCH v9 03/42] mm: Make pte_mkwrite() take a VMA Message-ID: <20230613074245.GQ52412@kernel.org> References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-4-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613001108.3040476-4-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Mon, Jun 12, 2023 at 05:10:29PM -0700, Rick Edgecombe wrote: > The x86 Shadow stack feature includes a new type of memory called shadow > stack. This shadow stack memory has some unusual properties, which requires > some core mm changes to function properly. > > One of these unusual properties is that shadow stack memory is writable, > but only in limited ways. These limits are applied via a specific PTE > bit combination. Nevertheless, the memory is writable, and core mm code > will need to apply the writable permissions in the typical paths that > call pte_mkwrite(). Future patches will make pte_mkwrite() take a VMA, so > that the x86 implementation of it can know whether to create regular > writable memory or shadow stack memory. Nit: ^ mappings? > But there are a couple of challenges to this. Modifying the signatures of > each arch pte_mkwrite() implementation would be error prone because some > are generated with macros and would need to be re-implemented. Also, some > pte_mkwrite() callers operate on kernel memory without a VMA. > > So this can be done in a three step process. First pte_mkwrite() can be > renamed to pte_mkwrite_novma() in each arch, with a generic pte_mkwrite() > added that just calls pte_mkwrite_novma(). Next callers without a VMA can > be moved to pte_mkwrite_novma(). And lastly, pte_mkwrite() and all callers > can be changed to take/pass a VMA. > > In a previous patches, pte_mkwrite() was renamed pte_mkwrite_novma() and > callers that don't have a VMA were changed to use pte_mkwrite_novma(). So Maybe This is the third step so pte_mkwrite() was renamed to pte_mkwrite_novma() and ... > now change pte_mkwrite() to take a VMA and change the remaining callers to > pass a VMA. Apply the same changes for pmd_mkwrite(). > > No functional change. > > Suggested-by: David Hildenbrand > Signed-off-by: Rick Edgecombe Reviewed-by: Mike Rapoport (IBM)