Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2216134pxu; Fri, 9 Oct 2020 10:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+zF/ACbjOVHSZ7zymorRuEV9oB3WL+wbM28ViaXPtE0i4+RZadt5mJrf6GBj7bYJm+zxO X-Received: by 2002:a05:6402:890:: with SMTP id e16mr326225edy.272.1602265296642; Fri, 09 Oct 2020 10:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602265296; cv=none; d=google.com; s=arc-20160816; b=cBe0Yu9fjtZAnoFymK6ooXejITZzN8QLD8VnzMpld/R1aFh4/u33Xv0MP2zN1qk0wv wl6HnZmBjhHoxcxCdMbL0HbBbQosGB3iFPacnn9QIqxNo1eNrssB97G7e+saytorVkUy iTYAsg5vgJnj+hEL2mlV9OWmFQ+HGh8BOP7qmbhoyJreRwM/gQyRLQ0Tt2k4hLS/Q/bX RrJSEaDl787r81PVsxfcpumS5KIV+S0e/XMDjaot9YNxqa/hJk9PgMjHMYsznAw5j4hz YbKGk4gHFB6DgT6wMHA2bCXGbqXwWdzxP1jty32gwgCDas5Q7vHD+HPJMj9KQeG3MBPQ R4pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:date:message-id:from:references:cc:to :subject:dkim-signature; bh=iO7iieAE97VWREkueb1YYE1lfRocN/epUOpy+ZHHzLU=; b=HLWlr52SrFt3ObcEjxW0XIGyxXO6UV3MtmZ5M3GP3oroW3FoLlawc5ZeEV5HZrIew6 qJuSQ+kRNPZUCgXl8byqK9zFORV1ktqaAsQ2Vj40uyH/cB4lppU5UKRYJXbysK0jHWfz nfqN+BJYQUzlkC7e8d5Ru0e0bdYqQ5atEmj3LkPOoaPhF1R+358QGDLtz4deBsWT/KiJ Kd1KVqfF6rvRRID3fdgF1IW0eJAOryqL2siSG1AvZNb6wKIozb52ISHHlaB9Z+pqD/iL HnLQ8MLnAuGKqRuSNAINx+NySpoZii7m0WfmpDeqWjL1Yt3jkqHHBieNl2/yEhxa3rI7 KakQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="lm/RRwEN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si6404950edb.152.2020.10.09.10.41.13; Fri, 09 Oct 2020 10:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="lm/RRwEN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732067AbgJIK34 (ORCPT + 99 others); Fri, 9 Oct 2020 06:29:56 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33382 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgJIK3z (ORCPT ); Fri, 9 Oct 2020 06:29:55 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 099AKk5E081439; Fri, 9 Oct 2020 10:28:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=iO7iieAE97VWREkueb1YYE1lfRocN/epUOpy+ZHHzLU=; b=lm/RRwEN7aMfPBGuu1y8+/4adW66cEn+DgLonp2Cdor0mppzl8uvoXGxADkJGXzaahLt 08zSAgiY+fuMh6tp5BIn3HO/xI9FiGXYGAvEsnjUVQICwqzoX437nzYz7/eJbZmaJrke sE9v5SNvFFNfgL1dH20+B051p/OgMi7bOPKQmkhCo6gfGayoRqV+hCsxvEdpAwA27BmR KWmf6KPdEd3FhRWsN26JIB7pcqKANL7eF+hkIaaigun95lhrqk8ADLMcyIxYUUUQDVZG rL7P3chD49VMIw9nGsp2r4BOSof7u6vPob3e/gcg+9ROOAjIT/mraIkajbyHC1ipo2SC xA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 3429juts2b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 09 Oct 2020 10:28:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 099AQH6t142717; Fri, 9 Oct 2020 10:28:38 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 3429k0x68n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Oct 2020 10:28:38 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 099ASa86025600; Fri, 9 Oct 2020 10:28:36 GMT Received: from [10.175.178.74] (/10.175.178.74) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Oct 2020 03:28:36 -0700 Subject: Re: [PATCH 22/35] kvm, x86: Distinguish dmemfs page from mmio page To: Sean Christopherson , yulei.kernel@gmail.com Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Chen Zhuo References: <20201009005823.GA11151@linux.intel.com> From: Joao Martins Message-ID: Date: Fri, 9 Oct 2020 11:28:31 +0100 MIME-Version: 1.0 In-Reply-To: <20201009005823.GA11151@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9768 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=1 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010090073 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9768 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=1 lowpriorityscore=0 spamscore=0 clxscore=1011 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010090072 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/9/20 1:58 AM, Sean Christopherson wrote: > On Thu, Oct 08, 2020 at 03:54:12PM +0800, yulei.kernel@gmail.com wrote: >> From: Yulei Zhang >> >> Dmem page is pfn invalid but not mmio. Support cacheable >> dmem page for kvm. >> >> Signed-off-by: Chen Zhuo >> Signed-off-by: Yulei Zhang >> --- >> arch/x86/kvm/mmu/mmu.c | 5 +++-- >> include/linux/dmem.h | 7 +++++++ >> mm/dmem.c | 7 +++++++ >> 3 files changed, 17 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c >> index 71aa3da2a0b7..0115c1767063 100644 >> --- a/arch/x86/kvm/mmu/mmu.c >> +++ b/arch/x86/kvm/mmu/mmu.c >> @@ -41,6 +41,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -2962,9 +2963,9 @@ static bool kvm_is_mmio_pfn(kvm_pfn_t pfn) >> */ >> (!pat_enabled() || pat_pfn_immune_to_uc_mtrr(pfn)); >> >> - return !e820__mapped_raw_any(pfn_to_hpa(pfn), >> + return (!e820__mapped_raw_any(pfn_to_hpa(pfn), >> pfn_to_hpa(pfn + 1) - 1, >> - E820_TYPE_RAM); >> + E820_TYPE_RAM)) || (!is_dmem_pfn(pfn)); > > This is wrong. As is, the logic reads "A PFN is MMIO if it is INVALID && > (!RAM || !DMEM)". The obvious fix would be to change it to "INVALID && > !RAM && !DMEM", but that begs the question of whether or DMEM is reported > as RAM. I don't see any e820 related changes in the series, i.e. no evidence > that dmem yanks its memory out of the e820 tables, which makes me think this > change is unnecessary. > Even if there would exist e820 changes, e820__mapped_raw_any() checks against hardware-provided e820 that we are given before any changes happen i.e. not the one kernel has changed (e820_table_firmware). So unless you're having that memory carved from an MMIO range (which would be wrong), or the BIOS is misrepresenting its memory map... the e820__mapped_raw_any(E820_TYPE_RAM) ought to be enough to cover RAM. Or at least that has been my experience with similar work. Joao