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 0995AC4361B for ; Tue, 8 Dec 2020 19:24:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7748623B8A for ; Tue, 8 Dec 2020 19:24:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7748623B8A 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 977B36B005D; Tue, 8 Dec 2020 14:24:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 900D36B0068; Tue, 8 Dec 2020 14:24:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C9576B006C; Tue, 8 Dec 2020 14:24:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 63A6F6B005D for ; Tue, 8 Dec 2020 14:24:21 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1B962180AD81A for ; Tue, 8 Dec 2020 19:24:21 +0000 (UTC) X-FDA: 77571091122.05.top75_2508545273e9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 00B011801BB79 for ; Tue, 8 Dec 2020 19:24:20 +0000 (UTC) X-HE-Tag: top75_2508545273e9 X-Filterd-Recvd-Size: 4436 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 19:24:19 +0000 (UTC) IronPort-SDR: eD9V3VG5jucU9ZrwE9IOchGWTKgafjmsBFIm1IVnd4j2q8fh7O2cYlRhXGBSB2q8wQNlWnviCh qH995KB95+Bw== X-IronPort-AV: E=McAfee;i="6000,8403,9829"; a="173195789" X-IronPort-AV: E=Sophos;i="5.78,403,1599548400"; d="scan'208";a="173195789" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2020 11:24:17 -0800 IronPort-SDR: uTi/Mmkl/xKuBC/AXfiazJdiwWLlLG6xSH3fWQdFdTUbXRcuwFtEp5b5pUVtQ+yM50I5q+Vvf8 X9TzX8nXSQNQ== X-IronPort-AV: E=Sophos;i="5.78,403,1599548400"; d="scan'208";a="317940844" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.139.184]) ([10.209.139.184]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2020 11:24:16 -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> From: "Yu, Yu-cheng" Message-ID: Date: Tue, 8 Dec 2020 11:24:16 -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: <20201208184727.GF27920@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/8/2020 10:47 AM, Borislav Petkov wrote: > On Tue, Dec 08, 2020 at 10:25:15AM -0800, Yu, Yu-cheng wrote: >>> Both are "R/O + _PAGE_COW". Where's the difference? The dirty bit? >> >> The PTEs are the same for both (a) and (b), but come from different routes. > > Do not be afraid to go into detail and explain to me what those routes > are please. Case (a) is a normal writable data page that has gone through fork(). So it has W=0, D=1. But here, the software chooses not to use the D bit, and instead, W=0, COW=1. 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. >>>> (e) A page where the processor observed a Write=1 PTE, started a write, set >>>> Dirty=1, but then observed a Write=0 PTE. >>> >>> How does that happen? Something changed the PTE's W bit to 0 in-between? >> >> Yes. > > Also do not scare from going into detail and explaining what you mean > here. Example? 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. >>> Does _PAGE_COW mean dirty too? >> >> Yes. Basically [read-only & dirty] is created by software. Now the >> software uses a different bit. > > That convention: > > "[read-only & dirty] is created by software." > > needs some prominent writeup somewhere explaining what it is. > > Thx. > I will put these into the comments. -- Yu-cheng