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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A374AC433ED for ; Fri, 9 Apr 2021 15:20:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38EB560FE8 for ; Fri, 9 Apr 2021 15:20:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38EB560FE8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C1CC76B006E; Fri, 9 Apr 2021 11:20:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBA2F6B0071; Fri, 9 Apr 2021 11:20:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0D2E6B0072; Fri, 9 Apr 2021 11:20:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 8863E6B006E for ; Fri, 9 Apr 2021 11:20:12 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 416441841FC9C for ; Fri, 9 Apr 2021 15:20:12 +0000 (UTC) X-FDA: 78013189464.29.C6AF7C8 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf19.hostedemail.com (Postfix) with ESMTP id 7884090009EC for ; Fri, 9 Apr 2021 15:20:01 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id x13so127583lfr.2 for ; Fri, 09 Apr 2021 08:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BdyCaKl/yFk8RKzHPOIXKxOU3yTB+9Fr3zs0DpkeLKM=; b=d1siBDnR6tbrwRIdnsNOlc6NmlCCox/2Jn4ypJ4KC81Y4bNAMgjMseR+/nK3e5VDbG ojFCJJRxN1mxXKbEGZsasX+fDSTeoQEYxDMWr46YxnysDD4NcxU+4OFO50nm+bM768nN FMyZWZ1hm/ZA3A2TvlUd0sx63vQnN+Z9j86KxWoKOTtHi7X6/dx8IYkx9RRGpCmlAZ+Z 2Ix6jFhc1cuRHLwW+INfVp1hpN+g5OzC3yVQxSg3bk+t7q0l7kckXYGg4nkDrAE90Yv0 yQ3EoPc/AqyVJuvCymv5CIaeZ8/5fKQXVzalMV2DSlXxNZGgxsfDnAcEbIvliAmXavWp KiJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BdyCaKl/yFk8RKzHPOIXKxOU3yTB+9Fr3zs0DpkeLKM=; b=Oys3Q9RBq3U11Xzl/T/icsSBZl+lA+VuK5hkxvG+o9rv3NkvGYj79L0ITTyoFG6Xg0 7/n3Slj+9WYJz3aruR74PrUGZH8mimtwi2JICsonvVEvHJiqy5g4Md9DtQyzohUWJ7md 5BzI5HFM7zHPnOMXcKvlEkt3sL2ck8zVEBWUBFFd3y/n1mBb6bbsUwLzmLOQ3/+qnqc7 kngKOsM4Jd/Orn7pjkSjsypnr3suF2oR1bxByRrr6MgwZJhYK1u7KUvJufcD11yYe2J0 Jt1aYTz8e6Bwy9m0bqXmJFXyoAWece7vDKmjVWEdUs0iWE00klyCz6FTMABUjcFKcoCc 4txQ== X-Gm-Message-State: AOAM531SUWIsKRjIeSLUdILfW6ZIH71uCPLCI+7AsehIAD/xhUlLRnoA /mUs6QEaaAJETBKyPe3/fOILuA== X-Google-Smtp-Source: ABdhPJyeY3SOcNghbUnFtmBYutviMO6rEuJWu8D3EaniZ1hk2GrTHZuB3RQ8/DjT6S0hr71xS0x82A== X-Received: by 2002:a19:c46:: with SMTP id 67mr10560336lfm.369.1617981610479; Fri, 09 Apr 2021 08:20:10 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id s2sm306117ljj.36.2021.04.09.08.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 08:20:10 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 740FE102498; Fri, 9 Apr 2021 18:20:09 +0300 (+03) Date: Fri, 9 Apr 2021 18:20:09 +0300 From: "Kirill A. Shutemov" To: Yu-cheng Yu 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 , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , "Kirill A . Shutemov" Subject: Re: [PATCH v24 16/30] mm: Fixup places that call pte_mkwrite() directly Message-ID: <20210409152009.xyewe3eefxce2dqq@box.shutemov.name> References: <20210401221104.31584-1-yu-cheng.yu@intel.com> <20210401221104.31584-17-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210401221104.31584-17-yu-cheng.yu@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7884090009EC X-Stat-Signature: 9dp8r4f14o75g6cpgjpzzz5ya3tnufe6 Received-SPF: none (shutemov.name>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail-lf1-f53.google.com; client-ip=209.85.167.53 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617981601-558562 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 Thu, Apr 01, 2021 at 03:10:50PM -0700, Yu-cheng Yu wrote: > When serving a page fault, maybe_mkwrite() makes a PTE writable if it is in > a writable vma. A shadow stack vma is writable, but its PTEs need > _PAGE_DIRTY to be set to become writable. For this reason, maybe_mkwrite() > has been updated. > > There are a few places that call pte_mkwrite() directly, but have the > same result as from maybe_mkwrite(). These sites need to be updated for > shadow stack as well. Thus, change them to maybe_mkwrite(): > > - do_anonymous_page() and migrate_vma_insert_page() check VM_WRITE directly > and call pte_mkwrite(), which is the same as maybe_mkwrite(). Change > them to maybe_mkwrite(). > > - In do_numa_page(), if the numa entry was writable, then pte_mkwrite() > is called directly. Fix it by doing maybe_mkwrite(). > > - In change_pte_range(), pte_mkwrite() is called directly. Replace it with > maybe_mkwrite(). > > A shadow stack vma is writable but has different vma > flags, and handled accordingly in maybe_mkwrite(). > Have you checked THP side? Looks like at least do_huge_pmd_numa_page() needs adjustment, no? -- Kirill A. Shutemov