[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240508161424.5bf4bdfc.alex.williamson@redhat.com>
Date: Wed, 8 May 2024 16:14:24 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Yan Zhao <yan.y.zhao@...el.com>
Cc: "Tian, Kevin" <kevin.tian@...el.com>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "x86@...nel.org" <x86@...nel.org>,
"jgg@...dia.com" <jgg@...dia.com>, "iommu@...ts.linux.dev"
<iommu@...ts.linux.dev>, "pbonzini@...hat.com" <pbonzini@...hat.com>,
"seanjc@...gle.com" <seanjc@...gle.com>, "dave.hansen@...ux.intel.com"
<dave.hansen@...ux.intel.com>, "luto@...nel.org" <luto@...nel.org>,
"peterz@...radead.org" <peterz@...radead.org>, "tglx@...utronix.de"
<tglx@...utronix.de>, "mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de"
<bp@...en8.de>, "hpa@...or.com" <hpa@...or.com>, "corbet@....net"
<corbet@....net>, "joro@...tes.org" <joro@...tes.org>, "will@...nel.org"
<will@...nel.org>, "robin.murphy@....com" <robin.murphy@....com>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>, "Liu, Yi L"
<yi.l.liu@...el.com>
Subject: Re: [PATCH 1/5] x86/pat: Let pat_pfn_immune_to_uc_mtrr() check MTRR
for untracked PAT range
On Tue, 7 May 2024 17:12:40 +0800
Yan Zhao <yan.y.zhao@...el.com> wrote:
> On Tue, May 07, 2024 at 04:26:37PM +0800, Tian, Kevin wrote:
> > > From: Zhao, Yan Y <yan.y.zhao@...el.com>
> > > Sent: Tuesday, May 7, 2024 2:19 PM
> > >
> > > However, lookup_memtype() defaults to returning WB for PFNs within the
> > > untracked PAT range, regardless of their actual MTRR type. This behavior
> > > could lead KVM to misclassify the PFN as non-MMIO, permitting cacheable
> > > guest access. Such access might result in MCE on certain platforms, (e.g.
> > > clflush on VGA range (0xA0000-0xBFFFF) triggers MCE on some platforms).
> >
> > the VGA range is not exposed to any guest today. So is it just trying to
> > fix a theoretical problem?
>
> Yes. Not sure if VGA range is allowed to be exposed to guest in future, given
> we have VFIO variant drivers.
include/uapi/linux/vfio.h:
/*
* Expose VGA regions defined for PCI base class 03, subclass 00.
* This includes I/O port ranges 0x3b0 to 0x3bb and 0x3c0 to 0x3df
* as well as the MMIO range 0xa0000 to 0xbffff. Each implemented
* range is found at it's identity mapped offset from the region
* offset, for example 0x3b0 is region_info.offset + 0x3b0. Areas
* between described ranges are unimplemented.
*/
VFIO_PCI_VGA_REGION_INDEX,
We don't currently support mmap for this region though, so I think we
still don't technically require this, but I guess an mmap through KVM
is theoretically possible. Thanks,
Alex
> > > @@ -705,7 +705,17 @@ static enum page_cache_mode
> > > lookup_memtype(u64 paddr)
> > > */
> > > bool pat_pfn_immune_to_uc_mtrr(unsigned long pfn)
> > > {
> > > - enum page_cache_mode cm = lookup_memtype(PFN_PHYS(pfn));
> > > + u64 paddr = PFN_PHYS(pfn);
> > > + enum page_cache_mode cm;
> > > +
> > > + /*
> > > + * Check MTRR type for untracked pat range since lookup_memtype()
> > > always
> > > + * returns WB for this range.
> > > + */
> > > + if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE))
> > > + cm = pat_x_mtrr_type(paddr, paddr + PAGE_SIZE,
> > > _PAGE_CACHE_MODE_WB);
> >
> > doing so violates the name of this function. The PAT of the untracked
> > range is still WB and not immune to UC MTRR.
> Right.
> Do you think we can rename this function to something like
> pfn_of_uncachable_effective_memory_type() and make it work under !pat_enabled()
> too?
>
> >
> > > + else
> > > + cm = lookup_memtype(paddr);
> > >
> > > return cm == _PAGE_CACHE_MODE_UC ||
> > > cm == _PAGE_CACHE_MODE_UC_MINUS ||
> >
>
Powered by blists - more mailing lists