Re: [PATCH 22/35] kvm, x86: Distinguish dmemfs page from mmio page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 08, 2020 at 03:54:12PM +0800, yulei.kernel@xxxxxxxxx wrote:
> From: Yulei Zhang <yuleixzhang@xxxxxxxxxxx>
> 
> Dmem page is pfn invalid but not mmio. Support cacheable
> dmem page for kvm.
> 
> Signed-off-by: Chen Zhuo <sagazchen@xxxxxxxxxxx>
> Signed-off-by: Yulei Zhang <yuleixzhang@xxxxxxxxxxx>
> ---
>  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.

>  }
>  
>  /* Bits which may be returned by set_spte() */



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux