[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACZOiM2W_8P_S6EypD3XfX1RuU+Do69w9qEMk7nDH2BxtK2E1g@mail.gmail.com>
Date: Fri, 9 Oct 2020 19:42:17 +0800
From: yulei zhang <yulei.kernel@...il.com>
To: Joao Martins <joao.m.martins@...cle.com>
Cc: Sean Christopherson <sean.j.christopherson@...el.com>,
akpm@...ux-foundation.org, naoya.horiguchi@....com,
viro@...iv.linux.org.uk, Paolo Bonzini <pbonzini@...hat.com>,
linux-fsdevel@...r.kernel.org, kvm <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Xiao Guangrong <xiaoguangrong.eric@...il.com>,
Wanpeng Li <kernellwp@...il.com>,
Haiwei Li <lihaiwei.kernel@...il.com>,
Yulei Zhang <yuleixzhang@...cent.com>,
Chen Zhuo <sagazchen@...cent.com>
Subject: Re: [PATCH 22/35] kvm, x86: Distinguish dmemfs page from mmio page
Sean and Joao, thanks for the feedback. Probably we can drop this change.
On Fri, Oct 9, 2020 at 6:28 PM Joao Martins <joao.m.martins@...cle.com> wrote:
>
> On 10/9/20 1:58 AM, Sean Christopherson wrote:
> > On Thu, Oct 08, 2020 at 03:54:12PM +0800, yulei.kernel@...il.com wrote:
> >> From: Yulei Zhang <yuleixzhang@...cent.com>
> >>
> >> Dmem page is pfn invalid but not mmio. Support cacheable
> >> dmem page for kvm.
> >>
> >> Signed-off-by: Chen Zhuo <sagazchen@...cent.com>
> >> Signed-off-by: Yulei Zhang <yuleixzhang@...cent.com>
> >> ---
> >> 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 <linux/hash.h>
> >> #include <linux/kern_levels.h>
> >> #include <linux/kthread.h>
> >> +#include <linux/dmem.h>
> >>
> >> #include <asm/page.h>
> >> #include <asm/memtype.h>
> >> @@ -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
Powered by blists - more mailing lists