Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp837544rwd; Tue, 13 Jun 2023 00:39:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wzlPBj0NbntlOt0ZZCAiefZgXm4NutxmIYU+p5zun4M7XtoUqqlmeZTwfs4dviE7BeebO X-Received: by 2002:aca:f0d:0:b0:39a:aba9:bcbd with SMTP id 13-20020aca0f0d000000b0039aaba9bcbdmr5398267oip.51.1686641988792; Tue, 13 Jun 2023 00:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686641988; cv=none; d=google.com; s=arc-20160816; b=vKNu29S1TXxSQORoZnqxYjIC2rQmYtPbIah0cZuZ6biIGjaz9K4W/rs1Ai2coAQ/sB 9oaACicoQGrWAOisxmsGMbfPHj7JZy9M1K1BOP441Zv2NVt7ggO8rXtSI0PrC7IhVoA8 NI2DblISppntDLP4IWtymlXT6Gwnb4kAxeh/4U3NqVYbaqJRtggIHjB9fhz1xTFKb7v/ q2kX6usQ4oB4WS93qg+DQS5Af14PA4/8sBm2A/N2Kum3vjBkjSLpX+3Sghc4iQQF+vGX Xp9rO+PXP3KRKfOpQO07u3Ag5X5RcKaUYDqhe++UtouAMLoM+AzZXVRp6gsZBW7pyg5m kdew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=ITQxRRVvGqeadcPmREQwIKcrCF11bOcCffnNhxRvWPA=; b=zKF6wnOadVrGEVkzBh/+79uDYDAr8ZVhM4/otK5YFCzP/4HGbF+Y259Z/QneUr2G5q zsjzO8NqGf2ivR+XmJzh6BDNoLhgj0EnX9x26+vTa0D/8xwQ/RPBuhiulNE5bXP0mQ// tV6tq0B5pjGcD0L8cdW7/dsR+I8J5vF3TnjnrqDkBZpwM0Usy8ya9wQ6ZapTx6P254nP qJ8YnjqnIFNaICqaJ4OgqvcW1BQBi4v5Pbk2hRHgl4S4csU8bWGzbOOnztyJpMkecuvU DJFryJlmL9oZdyfcTmOhTQK4s37lzVeRjnLFfx6kOF3A9Cf4+v3mov/L5MMF27E2sxY9 YyTg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a656a83000000b0053059dfafe4si8008843pgu.86.2023.06.13.00.39.36; Tue, 13 Jun 2023 00:39:48 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240233AbjFMHTw convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Jun 2023 03:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235104AbjFMHTt (ORCPT ); Tue, 13 Jun 2023 03:19:49 -0400 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F8EC0; Tue, 13 Jun 2023 00:19:46 -0700 (PDT) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-56cf34a3c72so33023487b3.1; Tue, 13 Jun 2023 00:19:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686640786; x=1689232786; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fbl6hTPLrmpSWav/3sGvPZAOIrvUN7WR7CUdowhVquE=; b=CYPa0D7+jbBvJ3cOitY0gXvuYT37NfuNauO6N64whHzy8+kHEUavVCUZhK3cW+ni/c Kbw/9y4IoE0Lo5/pyatskPihHopjAMWX8QNFLj0yFSXRwZQXUIQIrVWifFw04Xuld1mV UBA2cqyGkuxJur9O4TaAVTEBTuIZ+Z5S7/Vy+Ycx4gbM36sY6W7yY/Kp3BDjOh6bli94 aFyHKaBSJUdJCSbHH5DUYZSfAnid4BrEt6jS05swqMHIYnrDHp6H5UywlKpbqIdtKfpP 4UZLischxJbL2jcC3CiKSRnPeRLTE4cH7zMgWoZ9a5W0Bmjw8HpAZDKipK18BsYNLMDU iaIQ== X-Gm-Message-State: AC+VfDwybvyycEfyP2j8Z9EcnsCu64s3CVfkkN+5Y5NOSDng74Mg/EEx gFOgGxnSdJ9nwrPq53hBkxB4TVgx2SewNWrw X-Received: by 2002:a25:c084:0:b0:b9e:7ec8:5d45 with SMTP id c126-20020a25c084000000b00b9e7ec85d45mr677625ybf.55.1686640785780; Tue, 13 Jun 2023 00:19:45 -0700 (PDT) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com. [209.85.128.172]) by smtp.gmail.com with ESMTPSA id d17-20020a258891000000b00b99768e3b83sm2876576ybl.25.2023.06.13.00.19.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 00:19:45 -0700 (PDT) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-56cf34a3c72so33023347b3.1; Tue, 13 Jun 2023 00:19:44 -0700 (PDT) X-Received: by 2002:a25:b191:0:b0:ba8:3bc0:4d19 with SMTP id h17-20020a25b191000000b00ba83bc04d19mr680890ybj.28.1686640784641; Tue, 13 Jun 2023 00:19:44 -0700 (PDT) MIME-Version: 1.0 References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-2-rick.p.edgecombe@intel.com> In-Reply-To: <20230613001108.3040476-2-rick.p.edgecombe@intel.com> From: Geert Uytterhoeven Date: Tue, 13 Jun 2023 09:19:32 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 01/42] mm: Rename arch pte_mkwrite()'s to pte_mkwrite_novma() 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, rppt@kernel.org, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Jun 13, 2023 at 2:13 AM 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. > > 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/ > arch/m68k/include/asm/mcf_pgtable.h | 2 +- > arch/m68k/include/asm/motorola_pgtable.h | 2 +- > arch/m68k/include/asm/sun3_pgtable.h | 2 +- Acked-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds