Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2634212lqp; Mon, 25 Mar 2024 05:13:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKPoVVLvEFemZf7eLzb6xhzwzltJzAgn627oMxUQpxnh4z01N0ftTvHMIPTrVXuu4syRjirwb/zFB3l1g19qT6gDuKmyVgNdN2QNW4hw== X-Google-Smtp-Source: AGHT+IEBPtimtJ8HdyOCImN/oXIR+0mWFHStHL3RVjP2beav+hKINPVzdpbwoz2RkuIJP5LXmXFB X-Received: by 2002:a17:90a:420b:b0:2a0:4df6:e4e3 with SMTP id o11-20020a17090a420b00b002a04df6e4e3mr9344716pjg.7.1711368795977; Mon, 25 Mar 2024 05:13:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711368795; cv=pass; d=google.com; s=arc-20160816; b=OkVezn/EQqMsS0uykFmnJIKpfQRWp2/loqljNfZxMT3fUz+/6t9d/hjEC/O52cwW+H HKEK4aPtGBTJ7CHV8eHwlLh1iNwKS9dt274S8xW8TQXDF7q89Ts5xycex2CXaDx5gGLf AoyYkOW3mXMS18NJ/ILkZLIz8PyQUl1YcPEcUlLL6JMO8Q6uP4TqBGQWFWa8m8Z1NljX V9ykL1w1mSNcu8yQ8qMqLsCgJ7VU+C1xvSeK8xNFGKBOlT94qPcGMO37Pd4bTzoLCplG nTMXyc924AA89/W/dpnwQs2rwaCszqBZIRgf3Bqqt3gk2TEmFfKlRhdqZQoZqcrLrTRN VY3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=vOdE5GK9frTqnGBcDfKLPMdOy0vqMIYuDdIMspn+B1Q=; fh=+TWiG88hadBsYPhiZ7Rz4v7MyhtjlBoh9eIDunDOLsU=; b=afGzFULX7/xeUKl3YfBxITE+olFet/eABbrlxF/rOMk/r/bgs6CXiLsyPd9C+7Uacw HGWxQn0Pr6JZIBA/7Xnf2KhJn5u5P6LyFVbXuIfR/Pxo2M8wLFqYgmRvZRUmkUnFap9v oVY26ItVFrb1zDZweC84Y5/hsdjgnllmiIJHvg50AXCdx9+2ZObfQxsjxQEo42AzzbWy sLlK6rNvOVljKI7c9Fv0ilhFenRXBEHMTzA+ZrguV0Ir6SwEa5KWHH79T5W+hcghSWMl BSOE2sHom/m2YqOOVaVKxpdmSRBqfccYDUN6JjUzIIW2gRlBcjg0YuH2hvHu96n1CAZt Szsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-116425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b9-20020a17090a9bc900b002a02da1cad9si8179344pjw.116.2024.03.25.05.13.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-116425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D9ACEB61F69 for ; Mon, 25 Mar 2024 11:10:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0ACB815664D; Mon, 25 Mar 2024 06:24:39 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B32FE25D03F for ; Mon, 25 Mar 2024 02:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335463; cv=none; b=Wllg/EuwPncAcM2rJMXcDyQhF7mRni4Dm7eGn6Nrh6V5xgvOQSyri8/AAkGuy5CsNaV+mUQZ5f5x59/TMrBVNuCqBcglUZiu7h/8cWcXWdd80B9j1uXecRL0AC5h1iVXftLIovCjdlH6y4qxdn3Rz+pIC6UJFdL0V7Y+UviOBww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335463; c=relaxed/simple; bh=Iq0l8d+smzcyIUy4k+N1v6VVd/r/I7UzeUZkGu16rqM=; h=Message-ID:Date:MIME-Version:CC:Subject:To:References:From: In-Reply-To:Content-Type; b=dNIWLCc1WK3ZyR6y78o3I6/g82nM+3wKWzVNSYfeJRcfTElMbvw4L6Gn5FIeFouHfsb5KMy7nMN6gtlAQSwDMdC9lmFdEHv0R/Pt+kwriqFuii0uYeAyoWKuSaN/S+fXbetkt+TiKFqqVlEY6nxxm+TXp3DkrN2cmN/MHgh7NmI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V2yG6219Jz2BhYF; Mon, 25 Mar 2024 10:54:54 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id C5BE81A016F; Mon, 25 Mar 2024 10:57:31 +0800 (CST) Received: from [10.174.178.120] (10.174.178.120) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 25 Mar 2024 10:57:30 +0800 Message-ID: Date: Mon, 25 Mar 2024 10:57:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , , , , , , Subject: Re: [PATCH v1] x86/mm/pat: fix VM_PAT handling in COW mappings Content-Language: en-US To: , References: <20240312181118.318701-1-david@redhat.com> <5bc9de2f-c3ba-46e7-a234-3d3a46e53ba1@redhat.com> <1f2a8ed4-aaff-4be7-b3b6-63d2841a2908@redhat.com> From: mawupeng In-Reply-To: <1f2a8ed4-aaff-4be7-b3b6-63d2841a2908@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemd200001.china.huawei.com (7.185.36.224) On 2024/3/15 0:42, David Hildenbrand wrote: > On 12.03.24 20:38, David Hildenbrand wrote: >> On 12.03.24 20:22, Matthew Wilcox wrote: >>> On Tue, Mar 12, 2024 at 07:11:18PM +0100, David Hildenbrand wrote: >>>> PAT handling won't do the right thing in COW mappings: the first PTE >>>> (or, in fact, all PTEs) can be replaced during write faults to point at >>>> anon folios. Reliably recovering the correct PFN and cachemode using >>>> follow_phys() from PTEs will not work in COW mappings. >>> >>> I guess the first question is: Why do we want to support COW mappings >>> of VM_PAT areas?  What breaks if we just disallow it? >> >> Well, that was my first approach. Then I decided to be less radical (IOW >> make my life easier by breaking less user space) and "fix it" with >> minimal effort. >> >> Chances of breaking some weird user space is possible, although I >> believe for most such mappings MAP_PRIVATE doesn't make too much sense >> sense. >> >> Nasty COW support for VM_PFNMAP mappings dates back forever. So does PAT >> support. >> >> I can try finding digging through some possible user space users tomorrow. > > As discussed, MAP_PRIVATE doesn't make too much sense for most PFNMAP mappings. > > However, /dev/mem and /proc/vmcore are still used with MAP_PRIVATE in some cases. > > Side note: /proc/vmcore is a bit weird: mmap_vmcore() sets VM_MIXEDMAP, and then we might call remap_pfn_range(), which sets VM_PFNMAP. I'm not so sure if that's what we want to happen ... > > As far as I can see, makedumpfile always mmap's memory to be dumped (/dev/mem, /proc/vmcore) using PROT_READ+MAP_PRIVATE, resulting in a COW mapping. > > > In my opinion, we should use this fairly simple fix to keep it working for now and look into disabling any MAP_PRIVATE of VM_PFNMAP separately, for all architectures. > > But I'll leave the decision to x86 maintainers. Hi, x86 maintainers: kindle ping. >