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 32E08C77B7A for ; Tue, 13 Jun 2023 12:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241265AbjFMM3k (ORCPT ); Tue, 13 Jun 2023 08:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242474AbjFMM3O (ORCPT ); Tue, 13 Jun 2023 08:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 291D7173E for ; Tue, 13 Jun 2023 05:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686659298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5APAgmZrGjFJ9+U0RvJUaGvdr2gWc6sxi+r6310cnNs=; b=NpemX1ocFWDM1Jmyz+nrK9ZpYU08wE6iscEdj7w6KetAsPrCRPOR33uj2YzQ+NGDI9xFxG ofMbFgb7TFJdjLQXR1lYykQMCz2ht40lWsGpbzukhJ1tg5tLu5Plik83oCOioTshUpSdnP ahg0K99Jrlx1aaB+llVMNNOx/TmtlU0= 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_256_GCM_SHA384) id us-mta-515-O614FytmNMmlZX5Pk76c_w-1; Tue, 13 Jun 2023 08:28:17 -0400 X-MC-Unique: O614FytmNMmlZX5Pk76c_w-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-30fc9cfe82eso580173f8f.1 for ; Tue, 13 Jun 2023 05:28:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686659296; x=1689251296; h=content-transfer-encoding:in-reply-to:organization:from:references :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=5APAgmZrGjFJ9+U0RvJUaGvdr2gWc6sxi+r6310cnNs=; b=dEJ9s+qVflN8YRcZ8kjGvnVRahA01NK/l67pjK2PId8aUM/gyE0nmiN2z+z4MohVtG Uqm+TbI55aH9w5GxBApdRE1qZEe/1SXDC1Jkf5bQsxRIN71tghC74KLmP3G2x2HBcSvw QB9y3Z1jncnQtodl6U9JCJ2ygxZXJCePLIFsxruxkOtWI7iwi5UfX28vrxZ0PVdweHzj gqFM0gNz4LRlCdkR8jCjwNgTCYmbn/6MCChygXpUpp3m++FKsOzgbUKSL70nU3hPk2xA cF54SxcJwrZ47uEU203hvBA5XzRp7WMW6YnG1yAxFm69BBil3OmP6OMU36bUtnJBFqpG 8gpg== X-Gm-Message-State: AC+VfDwUeLXbspLoGlTZbxiNdKJUth0qzrp05G1zOyQ2Dm9Zkve4bmRo Rr4uo+vLL/LqqWUkazI2ZUWO7i0mB1Rd4tzlfh/lF5IWIcNDtT/yy+r4e3+BkZgpRHNuT8GEhuK /F7pJ6q3+RJX/r5wXyAywrUi1 X-Received: by 2002:a05:6000:10c7:b0:30a:eae0:106c with SMTP id b7-20020a05600010c700b0030aeae0106cmr7102033wrx.10.1686659296206; Tue, 13 Jun 2023 05:28:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61EMABfB7hkEtd8rE3feiAmwo8GaJnsqM5qFYcE5rkOiMq3BqizYRb/VE1CFB4BKMLKA5RWQ== X-Received: by 2002:a05:6000:10c7:b0:30a:eae0:106c with SMTP id b7-20020a05600010c700b0030aeae0106cmr7101998wrx.10.1686659295754; Tue, 13 Jun 2023 05:28:15 -0700 (PDT) Received: from ?IPV6:2003:cb:c710:ff00:1a06:80f:733a:e8c6? (p200300cbc710ff001a06080f733ae8c6.dip0.t-ipconnect.de. [2003:cb:c710:ff00:1a06:80f:733a:e8c6]) by smtp.gmail.com with ESMTPSA id u2-20020a5d4342000000b0030e5c8d55f2sm15258101wrr.6.2023.06.13.05.28.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 05:28:15 -0700 (PDT) Message-ID: <65805965-c6a2-ce0c-fb11-5277e5976120@redhat.com> Date: Tue, 13 Jun 2023 14:28:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v9 03/42] mm: Make pte_mkwrite() take a VMA Content-Language: en-US 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, szabolcs.nagy@arm.com, torvalds@linux-foundation.org, broonie@kernel.org References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-4-rick.p.edgecombe@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230613001108.3040476-4-rick.p.edgecombe@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13.06.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 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. > > In a previous patches, pte_mkwrite() was renamed pte_mkwrite_novma() and > callers that don't have a VMA were changed to use pte_mkwrite_novma(). So > now change pte_mkwrite() to take a VMA and change the remaining callers to > pass a VMA. Apply the same changes for pmd_mkwrite(). > > No functional change. > > Suggested-by: David Hildenbrand > Signed-off-by: Rick Edgecombe > --- Acked-by: David Hildenbrand Hopefully we'll get this landed soon :) -- Cheers, David / dhildenb