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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4867C7EE23 for ; Wed, 1 Mar 2023 08:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229481AbjCAIUK (ORCPT ); Wed, 1 Mar 2023 03:20:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjCAIUI (ORCPT ); Wed, 1 Mar 2023 03:20:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E582718 for ; Wed, 1 Mar 2023 00:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677658752; 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=Z8Cmz8kGuZ7dpEHwad+20UUQP/FcXAolknIt56sF66Uwky1y7RH85Ey819E6ASN3nlh1zG YoKv08jmHjVNBUCVZiZCO/mMzuhcqA80jLVoVMFrDo8d37VCclrFrtpCxtgil1MY011NYU xxeNw4zD8gkpY7/Y5abqyKFiKAHTb0c= 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_256_GCM_SHA384) id us-mta-64-Q7AjpIVjMPCWehMibPldNw-1; Wed, 01 Mar 2023 03:16:10 -0500 X-MC-Unique: Q7AjpIVjMPCWehMibPldNw-1 Received: by mail-wm1-f70.google.com with SMTP id k36-20020a05600c1ca400b003eac86e4387so7988120wms.8 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=L5FvIrTU8dyBG8lNKDav0+//+JPBS02A9llxqNVLPOltuXrhv9P03eVrRJ0W5R9iKf NAjtKht5gg39OVF6Hn5k6qg+dzeM+r8zGxGxRrqRMXsyKy9Lp5kDGlJIxapPSZdZEf6d tPRkGPsuyi4sVxr0Zxo9zE8XEztwUFqy5BDEUobLyBHZcEpB/v/qqwOmdpwg/oeUwlo0 7JZWn13HcdK1xomsvNAlyLKwbH8jDxnVe1UsgiwCG3+k81JdX2SCxsv7beF9sCOfdRuH PLSYUNnlbHi7VdlAvIT3R1e38+A6ldPS+7XFC/gs2uzpCRmH6F/m6M5zzM2Eq/V4jMQn MrDg== X-Gm-Message-State: AO0yUKUUfMgU5xlZ7mN5JLEirvx1c63aVvFSS/pV16kWzlljV6KQyr3v enGVe7xWxY3WGBNXcb5iXWuDRSD+fy2o3C0RlJwr+9nZQZgW3O3tOiu/N3ZZkLApaszcKoXqgvA lBfxInvYhlYElcEtPU7g0iw== X-Received: by 2002:adf:fa42:0:b0:2c8:9cfe:9e29 with SMTP id y2-20020adffa42000000b002c89cfe9e29mr3673911wrr.38.1677658569263; 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> Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org 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