Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5918026rwd; Sun, 18 Jun 2023 22:40:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40kQHvE/ye7h99jtmfz2l8dOY3mBStuZRsYxAPKnyhr6QJz5cFyx5p4I13t0kQEyDWlMx9 X-Received: by 2002:a17:902:6e01:b0:1b5:1b8:479d with SMTP id u1-20020a1709026e0100b001b501b8479dmr9271197plk.48.1687153223502; Sun, 18 Jun 2023 22:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687153223; cv=none; d=google.com; s=arc-20160816; b=TIripoVfNrvYHoMpeCQi5QT3KSdAf/xCuHaNGtlLVSEyYC7WvdnR1uTNsS3uTZhp5V yzTLfcWMvc4aFl9HeQ3RncrJHn4QJ94nk9DwoLZ+pzsBAmdc9VIZ4N9klaTeCWUd2qEQ nNuGyzbOs0X81r1F/FHP3tDfy+QQhBbXhTemN4wKl2xUSwOAZCAnfSQUhB3tQUtCG/4V e6aUNDwwqTAXYFjjevAYiY2w/ThblU4ImKj453nXKGOkCP6SjTeEq74LugS8Bnv2lQrg 3ZbbZ/Ot8HyABDolmETE8Ct3G07BP4xjKeCqtIxwDdRpJiezck2X1MIjZrXi29xX1QaK Vi/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=p3ciugZYEwxL6zC8wU3pZhU5AoPobxIL/VqtKabdjNk=; b=Otld7sy8BPqkpxJ+WShtl47GOa4nQvIxLkBvjr95kHP5FEpc2ELH7m96wToOh7Ojo6 rG5jc58dUxdG7dzsnbcVrzy8tIRTME7S1FQYTS68VwhDCr4tu5VZDyodwziZMYVqHtQ6 9DZBbUiEasW5lNa58biGIX2qUl2zcw40dRVAegY6POXiHfx0bxjjSC/ysO2jXle+NCU/ pv5d54Q33XTlFej6wm4MmFqUoKONQxHsblLnZVV5ZH7G6X5vi2byN5FxbSlGP+LqjxMg FGbG3QbpnuajNu/FqePYrUPoQ6jYsr6P1fMMO81AicuBticZI1ry6FKok7mwIfMr/kRN UGzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=LSI+CVQn; 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=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170902ea0400b001ab06251f98si16630463plg.429.2023.06.18.22.40.06; Sun, 18 Jun 2023 22:40:23 -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=@gmx.de header.s=s31663417 header.b=LSI+CVQn; 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=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjFSE2I (ORCPT + 99 others); Mon, 19 Jun 2023 00:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbjFSE2H (ORCPT ); Mon, 19 Jun 2023 00:28:07 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C2B1BB; Sun, 18 Jun 2023 21:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1687148863; x=1687753663; i=deller@gmx.de; bh=cgufvUEgcntUumfnkvWsXTVY4o9BX5y3Q1d3nNiorMc=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=LSI+CVQnaUd6ZMiX61A8dHxL5FB33EKK2GfA8HS/KbhLK/gAFDgOGYBQTIc7UA0YxZlgc11 Wm2tEkM7QMjReqt934JW1mqCbztCGIRi1x7tg0Sdth0/z7xNmWMnz8L7ZIPyATtzjKkEoWNCP fBFdWPt9qUeokkdcFxNR1orDek2op/PmIQEcYknBJG0v6dTYwpaSLzspj871C8X2NHNlJKe2x U/aF8CjiInrPwgYJUJSmH4U4nMaqaXQ3+3foc+pfVzMKCyF6bbJZypa6vGubrPDK3FnEYXwEO 5evbNYgm7wAX4gyEArY4q6R7yBFLwwoYjIczqnAdEy8naOmr87lQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.20.60] ([94.134.148.114]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MGhuU-1qNlvQ3mle-00Dmh3; Mon, 19 Jun 2023 06:27:42 +0200 Message-ID: <79b816e7-c331-49f9-058c-02828623ad94@gmx.de> Date: Mon, 19 Jun 2023 06:27:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v9 01/42] mm: Rename arch pte_mkwrite()'s to pte_mkwrite_novma() Content-Language: en-US To: Rick Edgecombe , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org Cc: linux-parisc@vger.kernel.org References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-2-rick.p.edgecombe@intel.com> From: Helge Deller In-Reply-To: <20230613001108.3040476-2-rick.p.edgecombe@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Q4zXbl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EvDyg i3vakQcp7veDUSIy1BJiflPhJ/EXg8sie0bOkCfzXKFLv5KoVZRGINt6P3myqQ158Z+YenJeJ Q+NUuyUeS3Cp3oW8chby1NEsMma7WNMKN5AojipQZu5J2CQlvJVhuWGXO8nXDMjES8PmlKJQd Ju/N+L9TBexz2jkHcF3qUwbzK/o= X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 6/13/23 02:10, 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 requi= res > 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, s= o > 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 o= f > each arch pte_mkwrite() implementation would be error prone because some > are generated with macros and would need to be re-implemented. Also, som= e > 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 ca= n > be moved to pte_mkwrite_novma(). And lastly, pte_mkwrite() and all calle= rs > 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 t= he > 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-=3DwiZjSu7c9sFYZb3q04108stgHff2w= fbokGCCgW7riz+8Q@mail.gmail.com/ > --- > Hi Non-x86 Arch=E2=80=99s, > > x86 has a feature that allows for the creation of a special type of > writable memory (shadow stack) that is only writable in limited specific > ways. Previously, changes were proposed to core MM code to teach it to > decide when to create normally writable memory or the special shadow sta= ck > writable memory, but David Hildenbrand suggested[0] to change > pXX_mkwrite() to take a VMA, so awareness of shadow stack memory can be > moved into x86 code. Later Linus suggested a less error-prone way[1] to = go > about this after the first attempt had a bug. > > Since pXX_mkwrite() is defined in every arch, it requires some tree-wide > changes. So that is why you are seeing some patches out of a big x86 > series pop up in your arch mailing list. There is no functional change. > After this refactor, the shadow stack series goes on to use the arch > helpers to push arch memory details inside arch/x86 and other arch's > with upcoming shadow stack features. > > Testing was just 0-day build testing. > > Hopefully that is enough context. Thanks! > > [0] https://lore.kernel.org/lkml/0e29a2d0-08d8-bcd6-ff26-4bea0e4037b0@re= dhat.com/ > [1] https://lore.kernel.org/lkml/CAHk-=3DwiZjSu7c9sFYZb3q04108stgHff2wfb= okGCCgW7riz+8Q@mail.gmail.com/ > --- > arch/parisc/include/asm/pgtable.h | 2 +- Acked-by: Helge Deller # parisc Helge