Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp849208rwd; Tue, 13 Jun 2023 00:53:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7fcrYRGdgXUEf0lKx1uKK0ISec8lHwLRVNhZr+ehTKOPtwEwxQDEzItyYKqeZIF7etsoln X-Received: by 2002:a05:6808:1153:b0:39c:93e7:d5b0 with SMTP id u19-20020a056808115300b0039c93e7d5b0mr6604143oiu.21.1686642804609; Tue, 13 Jun 2023 00:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686642804; cv=none; d=google.com; s=arc-20160816; b=0c6ee4r8ncM/TgVapFIP6L4HdqhmlFf2tL3zbDod1UzOKefvdTMvnt8TbBAfGtGuMv Q42PXRk0rhjgHbG257JMANtxDiLo6BKdQGfN3AZkN/Ru30tf5yQN12rUbSns8b3oF2hg NE+2FidVVVCZ1StEgKYC4jWk+STgEN0FVX/WSKcAnAJKOEmb0kKmcqqsEbaTjYmchpHn wMee14rI3NN63OVpzKMQcmQ/5ndfSax8meaA2/YhqmvHXcqRtdvhKnVQP/mdit4AxwxZ poSDmiW4WdWD/wW59OUQPak/ffVfgBNoL5wxJcPdB3fOWebUtdejSQyH45KMVrR5drrx KyZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b50gttmnfug6Q46kgDgbEmrsmsrAcNKzGE2z07rUaKA=; b=0lrnpAjh1TpDQFQiSD5m2z1euQ+ietp9D6IbTgtuuN7JPDObW4J+i2oIZf94OXI80a NXEISIEsVh3ar9lgcDLgrxAUPx1xl1habHK0cXVwdyxyPdSmOoQQ0lm5aWwAp49Tz/Bm CjS2TkmCsNHx0D7Yzlj4I/xidujZAtBHWHujZZ4ORxUlDGeO5aHH+5W5+FE2HwI6Mqn2 +5VuvO/IIXyV+TKekXMRpEUzhwsMEOCXTjuGQcxWND8Cfi4mPWAzVrXMBsaug62i9HUn Ya0BEMJInaDPr35lnALq1HBX6CsJajYRy0DFr6UUHloOtmuxEei+RuqTHyhfWgeJ8bS9 V7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HyA2VS9k; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j62-20020a638041000000b00542c0357ee3si5304097pgd.714.2023.06.13.00.53.10; Tue, 13 Jun 2023 00:53:24 -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=@kernel.org header.s=k20201202 header.b=HyA2VS9k; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239848AbjFMHpG (ORCPT + 99 others); Tue, 13 Jun 2023 03:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240285AbjFMHoo (ORCPT ); Tue, 13 Jun 2023 03:44:44 -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 BBBA219B1; Tue, 13 Jun 2023 00:44:31 -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 532C561333; Tue, 13 Jun 2023 07:44:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E078FC433D2; Tue, 13 Jun 2023 07:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686642270; bh=ez0I+RKRhMdZt82NML91fPb7fzRC4/NkCFA3IdK3cEg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HyA2VS9kwVTQsYOWOuof1Z4qJ92ct0+rpQ0B5SIAzOL2Mz6wp6NoYwA7DcLYOqzj9 Q8Z9RGOQt5lsRA8Nc33tC8G7SiwN9ipBSdD03bBdhpX4MycI3Vh7vOT7ypJVtsouWv 8Bsg5dlRSFLhnsq+PWCSJc5VolYLva+SeDgrT92N096TEl0/uLmsJvVPLGz9OK3/dz OYm6tEkeVT/cDyaIgk5UyxE5b/W7hyDcldGwNesOYI9EZOqwD7xGIveZKNt/lp9izm uoBjmwxoGZjGvj7XWF9lQv7iNjjhyG9sIxFni/WcE8h+xW9r48P7ifrawWGz2rEEWN FKciDs53eQHeQ== Date: Tue, 13 Jun 2023 10:43:47 +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, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, Linus Torvalds Subject: Re: [PATCH v9 01/42] mm: Rename arch pte_mkwrite()'s to pte_mkwrite_novma() Message-ID: <20230613074347.GR52412@kernel.org> References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-2-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613001108.3040476-2-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Mon, Jun 12, 2023 at 05:10:27PM -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: ^ mapping? > 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. > > Start the process by renaming pte_mkwrite() to pte_mkwrite_novma() and > adding the pte_mkwrite() wrapper in linux/pgtable.h. Apply the same > pattern for pmd_mkwrite(). Since not all archs have a pmd_mkwrite_novma(), > create a new arch config HAS_HUGE_PAGE that can be used to tell if > pmd_mkwrite() should be defined. Otherwise in the !HAS_HUGE_PAGE cases the > compiler would not be able to find pmd_mkwrite_novma(). > > No functional change. > > Cc: linux-doc@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-alpha@vger.kernel.org > Cc: linux-snps-arc@lists.infradead.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-csky@vger.kernel.org > Cc: linux-hexagon@vger.kernel.org > Cc: linux-ia64@vger.kernel.org > Cc: loongarch@lists.linux.dev > Cc: linux-m68k@lists.linux-m68k.org > Cc: Michal Simek > Cc: Dinh Nguyen > Cc: linux-mips@vger.kernel.org > Cc: openrisc@lists.librecores.org > Cc: linux-parisc@vger.kernel.org > Cc: linuxppc-dev@lists.ozlabs.org > Cc: linux-riscv@lists.infradead.org > Cc: linux-s390@vger.kernel.org > Cc: linux-sh@vger.kernel.org > Cc: sparclinux@vger.kernel.org > Cc: linux-um@lists.infradead.org > Cc: linux-arch@vger.kernel.org > Cc: linux-mm@kvack.org > Suggested-by: Linus Torvalds > Signed-off-by: Rick Edgecombe > Link: https://lore.kernel.org/lkml/CAHk-=wiZjSu7c9sFYZb3q04108stgHff2wfbokGCCgW7riz+8Q@mail.gmail.com/ Reviewed-by: Mike Rapoport (IBM) -- Sincerely yours, Mike.