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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 5F878C4361B for ; Thu, 10 Dec 2020 18:11:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9525023C44 for ; Thu, 10 Dec 2020 18:11:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9525023C44 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A1BB26B005D; Thu, 10 Dec 2020 13:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CB306B006C; Thu, 10 Dec 2020 13:11:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E21A6B006E; Thu, 10 Dec 2020 13:11:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 787C26B005D for ; Thu, 10 Dec 2020 13:11:03 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 401113621 for ; Thu, 10 Dec 2020 18:11:03 +0000 (UTC) X-FDA: 77578164006.03.bomb85_43140e0273fa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 1500F28A4EC for ; Thu, 10 Dec 2020 18:11:03 +0000 (UTC) X-HE-Tag: bomb85_43140e0273fa X-Filterd-Recvd-Size: 4122 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 18:11:01 +0000 (UTC) IronPort-SDR: kVgD90J3jwNb2PqIIB+iesWXhJkxHKoLLV92mShfkdH5lSOGJyZA9Rbf6JjwA1MwX9ruHpAjhD UxPYMzfrSK2w== X-IronPort-AV: E=McAfee;i="6000,8403,9831"; a="192630846" X-IronPort-AV: E=Sophos;i="5.78,409,1599548400"; d="scan'208";a="192630846" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2020 10:11:00 -0800 IronPort-SDR: Di/9GtzhnlMyvHk9Tbj4VdG3pvc+2+9r5Kol8VEIrCJbCHfuinQBHCqC6rUIi0EFWr2uGFAbgY PRCKHV9MbYzw== X-IronPort-AV: E=Sophos;i="5.78,409,1599548400"; d="scan'208";a="364822613" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.212.137.62]) ([10.212.137.62]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2020 10:10:58 -0800 Subject: Re: [PATCH v15 08/26] x86/mm: Introduce _PAGE_COW To: Borislav Petkov 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 , 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 References: <20201110162211.9207-1-yu-cheng.yu@intel.com> <20201110162211.9207-9-yu-cheng.yu@intel.com> <20201208175014.GD27920@zn.tnic> <218503f6-eec1-94b0-8404-6f92c55799e3@intel.com> <20201208184727.GF27920@zn.tnic> <20201210174155.GD26529@zn.tnic> From: "Yu, Yu-cheng" Message-ID: <2f9a0203-63eb-c808-d67f-11ad0c105531@intel.com> Date: Thu, 10 Dec 2020 10:10:58 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20201210174155.GD26529@zn.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 12/10/2020 9:41 AM, Borislav Petkov wrote: > On Tue, Dec 08, 2020 at 11:24:16AM -0800, Yu, Yu-cheng wrote: >> Case (a) is a normal writable data page that has gone through fork(). So it > > Writable > >> has W=0, D=1. But here, the software chooses not to use the D bit, and > > But it has W=0. So not writable? Maybe I will change to: A page in a writable vma, has been modified and gone through fork(). >> instead, W=0, COW=1. > > So the "new" way of denoting that the page is modified is COW=1 > *when* on CET hw. The D=1 bit is still used on the rest thus the two > _PAGE_DIRTY_BITS. > > Am I close? COW=1 is only used in copy-on-write situation (when CET is enabled). If W=1, D bit is used. >> Case (b) is a normal read-only data page. Since it is read-only, fork() >> won't affect it. In __get_user_pages(), a copy of the read-only page is >> needed, and the page is duplicated. The software sets COW=1 for the new >> copy. > > That makes more sense. > >> Thread-A is writing to a writable page, and the page's PTE is becoming W=1, >> D=1. In the middle of it, Thread-B is changing the PTE to W=0. > > Yah, add that to the explanation pls. > Sure.