Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp876345rwd; Tue, 13 Jun 2023 01:21:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zkT3Bcw0aRfqg0aozjXUOoKq8eVKUiUm1cXTugBI9On0N4+zOvbd+hTmS/YHQFh00jL7c X-Received: by 2002:a17:907:2d29:b0:969:e993:6ff0 with SMTP id gs41-20020a1709072d2900b00969e9936ff0mr12297122ejc.25.1686644466477; Tue, 13 Jun 2023 01:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686644466; cv=none; d=google.com; s=arc-20160816; b=ZWEGS2rPdj9I4Krv08ejd+dpBGeQHzvVZYxIsHuT+moApyDA8X8LFHUlPi8oxPzc4J 4jRhBKdn4GBUP+1uNm1KWOj0WUkfd9+lBDyasvdUI4SPBIbQh6M7oKorZOzzZ03Zx5v+ TFHGgAIGB54rnbAWyqyMvY5VqVEf1BOkqABZGHpoXDZIO6ePNpDEyDL3D2FpawMLYDxY /lbYal2Fd6H3LBYvtdmuCxLRzjdXQFSwApJ1F1tAnaO/2KVCDtNHA44ZyAs1JJMYcQcG ArLufWPXoVRGZREz1HB7tQCA6ck8OXDcxL7Q1gfaD1FeUtK4P4ddSmQWF3Kgl000Qd8o ymKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ecmtu4ADdOVyaAVZou3H3TdMRu/+J1Pqv9ca9be8EvI=; b=uubX79QLNN5C9aQXTR1z+mqgfS9Fzb/ZM51t9b6Y9SXAzHoEQq+YSn3rIYDn4cQCNE Nl6s1/mwiYhbH7s7kzBD/p2ETm92xFkLfQaoG5FLNN+DfH5hLCypso0Iv6pfhNDMSErp cwP2ON0xxvl6N7ux/m/NX+8M5K5lsiwSCnFnE37MfywrLW+i4TsIVvxtQHDdrP1g67D4 BvbhgVZ/S6hm3dBc82o1kqJ/7c7tSG/azLtvLyIz+ztZbUkdD8nTY2iZJGoSLkXJGFhq eVTe4rzdBp9ifdpw5/PlA+9K7O4fHiwlO7KVrXsOHgqUxxbVtAcQg0+XJvfoSS5YEhMX c6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DAQB2Nbi; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a1709064ccf00b009766824ec85si6230333ejt.20.2023.06.13.01.20.29; Tue, 13 Jun 2023 01:21:06 -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=@kernel.org header.s=k20201202 header.b=DAQB2Nbi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238470AbjFMHpk (ORCPT + 99 others); Tue, 13 Jun 2023 03:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240544AbjFMHpJ (ORCPT ); Tue, 13 Jun 2023 03:45:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEDD2AA; Tue, 13 Jun 2023 00:45:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5A9D8624B9; Tue, 13 Jun 2023 07:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 089C9C433D2; Tue, 13 Jun 2023 07:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686642307; bh=f4w4+2Npq1dkMitUJV0S3ITs/vGEti03A0AefRWYLBE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DAQB2NbikRdiWHwMApaPAIzaTY/w5HN4Xf7lKIGhQ1CWk0NWLGkjAYZnVQ2Z/26E5 Gj6fP0pEbtlpdHh+jAjgE6Pt3fChamJqEF8aVQsamsvQWLvQ+me4hgKoCdbO2U9n0H sLhdxmmB9s+aWXDyuT2lGzl1ZVFe+wKqtDoS4hK67cKlfHnfx6dLaBFlaN8NreyThe AbwFvqwokH5jRmekfEWGpgdCqyPUEmoq/Gm4fiWKIVNatWddBhbTkdXtpDdl7j7Ve/ HOLkc/hxxqb1vXEgvy7sHCTE8mCUAdXBvfqxYV+N5P2bD908YKbA9glKAU7xQzQvwR geNzoGQaAeXIA== Date: Tue, 13 Jun 2023 10:44:28 +0300 From: Mike Rapoport To: Rick Edgecombe Cc: 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, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com, szabolcs.nagy@arm.com, torvalds@linux-foundation.org, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH v9 02/42] mm: Move pte/pmd_mkwrite() callers with no VMA to _novma() Message-ID: <20230613074428.GS52412@kernel.org> References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-3-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613001108.3040476-3-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Mon, Jun 12, 2023 at 05:10:28PM -0700, 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. Nit: ^ mappings? > 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. > > Previous patches have done the first step, so next move the callers that > don't have a VMA to pte_mkwrite_novma(). Also do the same for I hear x86 maintainers asking to drop "previous patches" ;-) Maybe This is the second step of the conversion that moves the callers ... > pmd_mkwrite(). This will be ok for the shadow stack feature, as these > callers are on kernel memory which will not need to be made shadow stack, > and the other architectures only currently support one type of memory > in pte_mkwrite() > > Cc: linux-doc@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-s390@vger.kernel.org > Cc: xen-devel@lists.xenproject.org > Cc: linux-arch@vger.kernel.org > Cc: linux-mm@kvack.org > Signed-off-by: Rick Edgecombe Reviewed-by: Mike Rapoport (IBM) -- Sincerely yours, Mike.