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 7ABDCC64ED6 for ; Wed, 1 Mar 2023 08:16:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED5046B0073; Wed, 1 Mar 2023 03:16:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E85AE6B0074; Wed, 1 Mar 2023 03:16:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D00096B0075; Wed, 1 Mar 2023 03:16:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BE9296B0073 for ; Wed, 1 Mar 2023 03:16:15 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7C726A1420 for ; Wed, 1 Mar 2023 08:16:15 +0000 (UTC) X-FDA: 80519621910.11.7EFEBBE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id A3623100012 for ; Wed, 1 Mar 2023 08:16:12 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lgx4494K; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1677658573; 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=qQIo0hNE1IdmdTJeAfVSWSJHdp/A2L81MbqwgQGi7/s=; b=Jv/KbeYtSKhFM0rDexk3ThAVcOyFl3Y3RlJpCi/rWVUjJv+EwSJq+Y+4VLLUs8PMIyJ0EH 0FcLMYkdV0np6FTRwo4EM+kIzgnaRWJp2BQNJSAbfxqK1zOVxt4179MMQypPdqP24mE6WY MeFxNt6DvJKfvJAtw1TGarIPaFjve/k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lgx4494K; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1677658573; a=rsa-sha256; cv=none; b=YTrYiJdokR9MdhnyVnWPp2d6WB/3oEkY6IW7lHJ8AsJS5S3DExLikxsNk5oWtjf4vcMViz hQUeO6kOjHZpV+e0TdLW/gmbhA1ahaafU8bena6vje7VC+WY0CmIk8dVhtka3XS/l0SHiZ jsyrKlWK8F51sf5j5vKVUcJsi5Q2U0U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677658571; 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=qQIo0hNE1IdmdTJeAfVSWSJHdp/A2L81MbqwgQGi7/s=; b=Lgx4494Ki92A8P7KBec9GZ+oniD/so9S6s376pXCBfwIZbpFryYzm7VuUbDCudOmPpuazJ BZlYjiR+awKb7+/obJJdaVaNJPlnbEr8EXFHhRoDxhAjgvdnre76/wb2aZFcUicW5ld7qE AjRVQKfqtaApCJ9VvbYhapBkNy2Iiis= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-106-YocJeo_rNS668ypp63WbSA-1; Wed, 01 Mar 2023 03:16:10 -0500 X-MC-Unique: YocJeo_rNS668ypp63WbSA-1 Received: by mail-wm1-f70.google.com with SMTP id t1-20020a7bc3c1000000b003dfe223de49so7990012wmj.5 for ; Wed, 01 Mar 2023 00:16:10 -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:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qQIo0hNE1IdmdTJeAfVSWSJHdp/A2L81MbqwgQGi7/s=; b=8HJ+dPeuHdBXeka58pPDZpKeAho1Emm40cAw0eHTwCEDp+vJqWOAht5nqBibBPFp52 EAuvRuy7QnwB5WUkMj+VbpVcKvunjbU/kWE+NHobT+dxsXHfUgOC6kcmVGoC0r1S5XyE H2dpSPbG8ePL6VJAOf/bVxTs6grr5wugaxgpVzmxU5xLJ9uGnofOLtmCeAmo/eRGnF1a 8uq0xzMxYV9AzJHpDJSFU82MQzB2/rmpdYu9PoIAyXRXn8tFUXyI4jafBte3RxFOFCL6 MNbp2h7mnckF0rqaejVavq8CUXR+f8FiUJBlNEf0suxW9h3ZmYohgbMfdWOsWM3YhxXa ch1Q== X-Gm-Message-State: AO0yUKUipRYwE/ZdpRAthoa4pL+WWlAVZKcB27ghIxGoDco8+DQJ7Jl8 av99e8rerAf+VgOcX1vn3VIUt+AU4tgxSMGoEqzo3Se4LKsOLXM5Wv1cdwW5B93o8IIsNr5nJ// 0+3k7127wcRY= X-Received: by 2002:adf:fa42:0:b0:2c8:9cfe:9e29 with SMTP id y2-20020adffa42000000b002c89cfe9e29mr3673950wrr.38.1677658569273; Wed, 01 Mar 2023 00:16:09 -0800 (PST) X-Google-Smtp-Source: AK7set/Zcp0KDYd3P+ttMa1nxfZFskB2aS7FMY5A6AFDn91vWMJGTRwO0n5U4FI/yi5+QKrlOm4zVQ== X-Received: by 2002:adf:fa42:0:b0:2c8:9cfe:9e29 with SMTP id y2-20020adffa42000000b002c89cfe9e29mr3673883wrr.38.1677658568881; Wed, 01 Mar 2023 00:16:08 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id m15-20020a5d6a0f000000b002c707785da4sm11739026wru.107.2023.03.01.00.16.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Mar 2023 00:16:08 -0800 (PST) Message-ID: <550c6035-6dd0-d215-226b-1a82dafa05d6@redhat.com> Date: Wed, 1 Mar 2023 09:16:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 To: Christophe Leroy , 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" , "linux-openrisc@vger.kernel.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: <20230227222957.24501-1-rick.p.edgecombe@intel.com> <20230227222957.24501-14-rick.p.edgecombe@intel.com> <1f8b78b6-9f34-b646-68f2-eac62136b9f4@csgroup.eu> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 13/41] mm: Make pte_mkwrite() take a VMA In-Reply-To: <1f8b78b6-9f34-b646-68f2-eac62136b9f4@csgroup.eu> 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-Stat-Signature: uexb9pxwfsb8nfwkyu41h89oq5qt3zka X-Rspam-User: X-Rspamd-Queue-Id: A3623100012 X-Rspamd-Server: rspam06 X-HE-Tag: 1677658572-114854 X-HE-Meta: U2FsdGVkX185KM4rGvsz6wn5D5T5fIXNZLjz/EdzJModMYtrIjI/cykfwWCSLfnTq8eausmKBDdEzvVUEKuQBHIVr7ehcu6p9jFjR2quS/tR9956ko/PPLZZN9Uw9IfNbkTYb5vjHZFEdMkCJb7xeLJdjaQyTygA69NtO/KKTzYHb8z2SS4WS3V9GM4eZYvjNy6g9g60sQCXh1UYMZVzplfV1zdv0Wt+soNLrlbMTMg0lbp3tuwKaeD6qRIm9BBNBCeWzJPOU2KIrs6eS1DjM4zGkUU/9+cNCIpqirzCnhEtAa4bPwOzS/cSylWtOsTFLVN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cTNUIBvnZnQ9zF7SH1PuEeqFgcYl4v/CSIu6pX7wTSILlT7UxxOj/DKWlp5H5CF/R2M9QmMgy1T0vcog== 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 01.03.23 08:03, Christophe Leroy wrote: > > > Le 27/02/2023 à 23:29, Rick Edgecombe a écrit : >> 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(). > > I'm not sure it is a good idea to add a second argument to > pte_mkwrite(). All pte_mkxxxx() only take a pte and nothing else. We touched on this in previous revisions and so far there was no strong push back. This turned out to be cleaner and easier than the alternatives we evaluated. pte_modify(), for example, takes another argument. Sure, we could try thinking about passing something else than a VMA to identify the writability type, but I am not convinced that will look particularly better. > > I think you should do the same as commit d9ed9faac283 ("mm: add new > arch_make_huge_pte() method for tile support") > We already have 3 architectures intending to support shadow stacks in one way or the other. Replacing all pte_mkwrite() with arch_pte_mkwrite() doesn't sound particularly appealing to me. -- Thanks, David / dhildenb