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 8DC54C88CB6 for ; Tue, 13 Jun 2023 07:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239738AbjFMHpg (ORCPT ); Tue, 13 Jun 2023 03:45:36 -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> Precedence: bulk List-ID: X-Mailing-List: linux-api@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.