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 DAC06C636CC for ; Mon, 20 Feb 2023 11:23:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E9146B0071; Mon, 20 Feb 2023 06:23:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 598EE6B0072; Mon, 20 Feb 2023 06:23:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439936B0073; Mon, 20 Feb 2023 06:23:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 350826B0071 for ; Mon, 20 Feb 2023 06:23:37 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F2E5CC0F58 for ; Mon, 20 Feb 2023 11:23:36 +0000 (UTC) X-FDA: 80487434832.03.7B91456 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id CCCEBA000A for ; Mon, 20 Feb 2023 11:23:34 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="LJ4z/ydl"; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676892214; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JGvEUYyDyInAU1qTOkUUwH1+5Pn5/FfAg09zLJh1EcU=; b=D1toWdk4i1uk4ThPsD7ybrm4RixdpQNnif5iLc2pHZ9+scG0UlIwIbWME4iufA27Uy88sm 4zatE9xfiQ4RFA6v4Aq1s+vwK4ORemBqQyga0vT3HCUp3oDe6o94So3taGBqYldu+e1BJN 1yUX4p04vFKe/oZxtvRquo239GSueUA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="LJ4z/ydl"; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676892214; a=rsa-sha256; cv=none; b=BRxgdIxDKBAH4fhgOahAfsXUS0uxSsB7WIARB1yHbGWumarFrjwhdjnxTQY3OvqCp/1LL8 ZBa9ble5v35kvb+kc/mKBCO5+liXSdZleQf+qsJVkBOsFHaQid8qPvGypnXdY/q6hKQ4ej Nt20xQ5oD+ATexFPowHI4LCIZK2mGJs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676892214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JGvEUYyDyInAU1qTOkUUwH1+5Pn5/FfAg09zLJh1EcU=; b=LJ4z/ydlreQO2yAtfBGq5VjJCLgp297eaAHVbIuZOwUBIi2Z0QExyTv6nd/ARNoqMqdjn1 /zMysMRY0+wYzE6vrOvE/OCyAU5zz2zZy4+k6HBeuFrxSJpfHYMdYB4k5d6NnCqUnBPAwg e5+N+BoK+DPErZpuJFnQdtZCGVRIc3E= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-659-638HvHafONy03eSutJCR4w-1; Mon, 20 Feb 2023 06:23:33 -0500 X-MC-Unique: 638HvHafONy03eSutJCR4w-1 Received: by mail-wr1-f70.google.com with SMTP id j9-20020a5d4529000000b002c5588d962fso273811wra.10 for ; Mon, 20 Feb 2023 03:23:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JGvEUYyDyInAU1qTOkUUwH1+5Pn5/FfAg09zLJh1EcU=; b=KUrvkBYM45dX5r9uIIrdUqJxYqLip281Ph2iQODFW6Lnqeq/Bv6a7eJuATroFESGbo fzsXbpmAnG77hLPVCgZAf3c/gkBHSHVaz9VZ0LeTNSW3Go3Ka/gPX4I68Gp9IpohanGu cKr6/io7snd2ZxDORlHJL7vRbgN2b0pPvTaMbGw4sHvVqESjyEvSVsatkjoKBq1PI0qc HyxF0yvONFfc1zubKq9aWO4rHZV/iJWH7t6+X8xYxoAGJ48ZGeL+l+gGCHXgvi/CT7fo HQDZgSx03weLCsB+on4cXzBtWfs0gYNSiEqkhacE32RSZc7FM9sI96O6xSJau6OCl3Zw mufw== X-Gm-Message-State: AO0yUKXds/AGaW/IlYmtU6lDc6qhVdPToaRNqu82lt72GRWeXR7IZkfA i0EviTANeAGrMi3U+bfEC/YNL0IwfqnVJA6qzRbgkjVkDWOLUmNxNPp4UdXsDZ5u3hOqxAFxk0c 8xl9LQE4VfQI= X-Received: by 2002:adf:e889:0:b0:2bf:ae19:d8e4 with SMTP id d9-20020adfe889000000b002bfae19d8e4mr1431230wrm.16.1676892211953; Mon, 20 Feb 2023 03:23:31 -0800 (PST) X-Google-Smtp-Source: AK7set8MwtYqrZBvXsoQ9yPZN/bwu32QfvZtBFBM6ley7E2vAkMmUmM+SZmaWRHMAwPacrP/Dgjyyg== X-Received: by 2002:adf:e889:0:b0:2bf:ae19:d8e4 with SMTP id d9-20020adfe889000000b002bfae19d8e4mr1431211wrm.16.1676892211619; Mon, 20 Feb 2023 03:23:31 -0800 (PST) Received: from ?IPV6:2003:cb:c705:8300:e519:4218:a8b5:5bec? (p200300cbc7058300e5194218a8b55bec.dip0.t-ipconnect.de. [2003:cb:c705:8300:e519:4218:a8b5:5bec]) by smtp.gmail.com with ESMTPSA id u13-20020a5d434d000000b002c55ec7f661sm154441wrr.5.2023.02.20.03.23.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 03:23:30 -0800 (PST) Message-ID: Date: Mon, 20 Feb 2023 12:23:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [PATCH v6 13/41] mm: Make pte_mkwrite() take a VMA 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 , 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, debug@rivosinc.com Cc: 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, xen-devel@lists.xenproject.org References: <20230218211433.26859-1-rick.p.edgecombe@intel.com> <20230218211433.26859-14-rick.p.edgecombe@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230218211433.26859-14-rick.p.edgecombe@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CCCEBA000A X-Stat-Signature: ya8omqyesmzbp1ayi1xbws436jarjkm7 X-HE-Tag: 1676892214-511716 X-HE-Meta: U2FsdGVkX1/bAMwhZ3j92h/X67Sa+dUKzMYI66S7wkhiCRzz0/cDGb5QlqQuAS/88eJuosrFpppzoPnncLGZygB6U4ZzLRn+PYCGfyzH1Nc4VUPvj8wyHpa7BJeQvJfpieoH4drxmkzqgSxqY32qlYEj6BM1Ns6S03qfohUKegxDKU6GWl4hWTW4j93VqhKEphcTIHq2ToIvxGeO0XiQYgkKeaAje1oDYmABatTSCcwRI1PLAyvJWr7pZp37u0Q35ruGxOpGtTuxLyjcd/JbmIQtSPBbW4MmhOGfM/XAqyHYGPKUpu1Xy2F1/IK9Reb0qjRZRtE9ue42KYRc7Bt0Gru1gODMZq/BwrW7c657hmJO8Fz/HgWZQY5xZHmaj09mfhr2uOlBjh9MWgVGIvkAeHsYJBIILB+kubS4RG8isgKqX0uXN5oleYnfri6OLMwnaQ08FGZGS/+PRtMW7OcHX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taVymlOXohyErKi3l9ysPeux1WOYFNn/ekwVECRglZIDv6pVEuXwD/eJykMZGh4OLGA1shDCISogOipPhHYDtfdkrEfOv1B0MPBdlhrSDiMEDTB9lhKQmx122owC+XKPepUWplKA0nCI/aeF6t4Aig3iKzX5YUGdwBrBJgHi5m8QIgt5fTZkItRIOmOvns05Q7NFVC+GxJapuoe5nbf0p21zPHJ4M2vKlRDymzKQFe4hmX7r1tnehN3eyQ2F4djilR16jUM0OTRpr+vb4x2PMpQz3az7XGWidJ/nPD6I6o4s+buYqY5w1wRfzEDimiCxPxl32T/XCz+aeiEJH7/CsHFneR9D6XFP5D9JqamAG+3NsraLBMUxf45yVCN0VZpRXsIy1sAspEHw== 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 18.02.23 22:14, Rick Edgecombe wrote: > The x86 Control-flow Enforcement Technology (CET) 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(). > > In addition to VM_WRITE, the shadow stack VMA's will have a flag denoting > that they are special shadow stack flavor of writable memory. So make > pte_mkwrite() take a VMA, so that the x86 implementation of it can know to > create regular writable memory or shadow stack memory. > > Apply the same changes for pmd_mkwrite() and huge_pte_mkwrite(). > > 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: xen-devel@lists.xenproject.org > Cc: linux-arch@vger.kernel.org > Cc: linux-mm@kvack.org > Tested-by: Pengfei Xu > Suggested-by: David Hildenbrand > Signed-off-by: Rick Edgecombe > > --- > Hi Non-x86 Arch’s, > > 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 stack > 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. > > 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 shadow stack memory details inside arch/x86. > > Testing was just 0-day build testing. > > Hopefully that is enough context. Thanks! > > [0] https://lore.kernel.org/lkml/0e29a2d0-08d8-bcd6-ff26-4bea0e4037b0@redhat.com/#t > > v6: > - New patch > --- > Documentation/mm/arch_pgtable_helpers.rst | 9 ++++++--- > arch/alpha/include/asm/pgtable.h | 6 +++++- > arch/arc/include/asm/hugepage.h | 2 +- > arch/arc/include/asm/pgtable-bits-arcv2.h | 7 ++++++- > arch/arm/include/asm/pgtable-3level.h | 7 ++++++- > arch/arm/include/asm/pgtable.h | 2 +- > arch/arm64/include/asm/pgtable.h | 4 ++-- > arch/csky/include/asm/pgtable.h | 2 +- > arch/hexagon/include/asm/pgtable.h | 2 +- > arch/ia64/include/asm/pgtable.h | 2 +- > arch/loongarch/include/asm/pgtable.h | 4 ++-- > arch/m68k/include/asm/mcf_pgtable.h | 2 +- > arch/m68k/include/asm/motorola_pgtable.h | 6 +++++- > arch/m68k/include/asm/sun3_pgtable.h | 6 +++++- > arch/microblaze/include/asm/pgtable.h | 2 +- > arch/mips/include/asm/pgtable.h | 6 +++--- > arch/nios2/include/asm/pgtable.h | 2 +- > arch/openrisc/include/asm/pgtable.h | 2 +- > arch/parisc/include/asm/pgtable.h | 6 +++++- > arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +- > arch/powerpc/include/asm/book3s/64/pgtable.h | 4 ++-- > arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +- > arch/powerpc/include/asm/nohash/32/pte-8xx.h | 2 +- > arch/powerpc/include/asm/nohash/64/pgtable.h | 2 +- > arch/riscv/include/asm/pgtable.h | 6 +++--- > arch/s390/include/asm/hugetlb.h | 4 ++-- > arch/s390/include/asm/pgtable.h | 4 ++-- > arch/sh/include/asm/pgtable_32.h | 10 ++++++++-- > arch/sparc/include/asm/pgtable_32.h | 2 +- > arch/sparc/include/asm/pgtable_64.h | 6 +++--- > arch/um/include/asm/pgtable.h | 2 +- > arch/x86/include/asm/pgtable.h | 6 ++++-- > arch/xtensa/include/asm/pgtable.h | 2 +- > include/asm-generic/hugetlb.h | 4 ++-- > include/linux/mm.h | 2 +- > mm/debug_vm_pgtable.c | 16 ++++++++-------- > mm/huge_memory.c | 6 +++--- > mm/hugetlb.c | 4 ++-- > mm/memory.c | 4 ++-- > mm/migrate_device.c | 2 +- > mm/mprotect.c | 2 +- > mm/userfaultfd.c | 2 +- > 42 files changed, 106 insertions(+), 69 deletions(-) That looks painful but IMHO worth it :) Acked-by: David Hildenbrand -- Thanks, David / dhildenb