Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1732176pxu; Thu, 8 Oct 2020 20:46:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNngsxQnYBZ2QXlKsa0Bxg1NMmxB5IuAZHxwGI8GrNbB7/stlY5PkPPydg0OEtQB7V5zaR X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr12062708edb.129.1602215218851; Thu, 08 Oct 2020 20:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602215218; cv=none; d=google.com; s=arc-20160816; b=pwiFxtuBjfzxQWDGgjuveqfo1bYHf08pv7UFaBq7zSq6mzR3yzgcNCV2QS7cvMQOb8 JEvWpObEdXhiQC80zvxN0iCuq3filxx9ZobfdCBoGt/ZEgR8PJ5+FLkizEt9W5OkRC4t /0C0omTM53PF3HaT3NkUIjlZyDoIHrux+i9wUmpXw8bKsTmu5Dq4F0+XNdofgF98WLc4 et/V8l8biDVNc8Rq3klEvxSOxnm7aHIjeYvB8jHBDJDP3MlUCkRuEoKMt6QKONBbQGKP 0RiVgrk7q07tpRTyumCFD4vtCJw26RwiVCHlKn8TNUsam65ca2dmMF0xzDzhFtRpgxG0 K6Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=q0tEP/AQ6PTZQquaruRefy0pR//rErDD+C668McVlMI=; b=IzKSiwKXsxzTwCen+yZj/PfobBmzf6yK2PdtUA6Oq9bEPpjMDL91nLTJM9CYiiXLU5 intPeDtsygCHX7zRQgg//zhZjy9OGu2M1A4sQf0R36iriTX/E+FEmFzxLlMIqcwWozmU ssPjIBqignaAc67Wa/A+2HxQN2hdbTM3bZvXjZ+gfWinJiJvvDhpQuo/9W11AAq8kXeu ek+jwsDAlooRuk/1GMBV3bqZaqNJI33GkKKZSe0uQgljaQ+BYjSXX4rFV2St3RmN2oux 4Y2b0wD4R0JxqzjMNCIwYnxr08KuQQP6JEVYVPa9mfB8e68f7FvZEwmZFXkoMqZDP1YE eVyQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si5222167eja.274.2020.10.08.20.46.23; Thu, 08 Oct 2020 20:46:58 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730270AbgJIA60 (ORCPT + 99 others); Thu, 8 Oct 2020 20:58:26 -0400 Received: from mga04.intel.com ([192.55.52.120]:23450 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgJIA6Z (ORCPT ); Thu, 8 Oct 2020 20:58:25 -0400 IronPort-SDR: mNat5ftlMF+/aWBh96+2/dYhPUUD6sngEFY7KAD/UadEp78eRPxpHSN4M8HwjPhjBUGjHDTAkF MIKXSBnc74wQ== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="162789248" X-IronPort-AV: E=Sophos;i="5.77,353,1596524400"; d="scan'208";a="162789248" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2020 17:58:24 -0700 IronPort-SDR: GltQmS+4InnTbci6lMsS7uuuC/Au3gBVh1CnYduQ9e/hpEY/YA5KVKJ92y8dtUlTQcMasbgIaH +DhCc/+CdoIA== X-IronPort-AV: E=Sophos;i="5.77,353,1596524400"; d="scan'208";a="328742638" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.160]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2020 17:58:24 -0700 Date: Thu, 8 Oct 2020 17:58:23 -0700 From: Sean Christopherson To: 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 Subject: Re: [PATCH 22/35] kvm, x86: Distinguish dmemfs page from mmio page Message-ID: <20201009005823.GA11151@linux.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > } > > /* Bits which may be returned by set_spte() */