Re: [PATCH v4 7/7] mtrr, mm, x86: Enhance MTRR checks for KVA huge page mapping
From: Toshi Kani
Date: Mon May 11 2015 - 16:58:08 EST
On Mon, 2015-05-11 at 22:18 +0200, Borislav Petkov wrote:
> On Mon, May 11, 2015 at 01:25:16PM -0600, Toshi Kani wrote:
> > > > @@ -235,13 +240,19 @@ static u8 mtrr_type_lookup_variable(u64 start, u64 end, u64 *partial_end,
> > > > * Return Values:
> > > > * MTRR_TYPE_(type) - The effective MTRR type for the region
> > > > * MTRR_TYPE_INVALID - MTRR is disabled
> > > > + *
> > > > + * Output Argument:
> > > > + * uniform - Set to 1 when MTRR covers the region uniformly, i.e. the region
> > > > + * is fully covered by a single MTRR entry or the default type.
> > >
> > > I'd call this "single_mtrr". "uniform" could also mean that the resulting
> > > type is uniform, i.e. of the same type but spanning multiple MTRRs.
> > Actually, that is the intend of "uniform" and the same type but spanning
> > multiple MTRRs should set "uniform" to 1. The patch does not check such
> So why does it say "is fully covered by a single MTRR entry or the
> default type." - the stress being on *single*
> You need to make up your mind.
I will clarify the comment as follows.
uniform - Set to 1 when the region is not covered with multiple memory
types by MTRRs. It is set for any return value.
NOTE: The current code sets 'uniform' to 1 when the region is fully
covered by a single MTRR entry or fully uncovered. However, it does not
detect a uniform case that the region is covered by the same type but
spanning multiple MTRR entries for simplicity.
> > We need to set "uniform" to 1 when MTRRs are disabled since there is no
> > type conflict with MTRRs.
> No, this is wrong.
> When we return an *error*, "uniform" should be *undefined* because MTRRs
> are disabled and callers should be checking whether it returned an error
> first and only *then* look at uniform.
MTRRs disabled is not an error case as it could be a normal
configuration on some platforms / BIOS setups. I clarified it in the
above comment that uniform is set for any return value.
> > The warning was suggested by reviewers in the previous review so that
> > driver writers will notice the issue.
> No, we don't flood dmesg so that driver writers notice stuff. We better
> fix the callers.
> > Returning 0 here will lead
> > ioremap() to use 4KB mappings, but does not cause ioremap() to fail.
> I guess a pr_warn_once() should be better then. Flooding dmesg with
> error messages for which the user can't really do anything about doesn't
> bring us anything.
OK, I will change it to pr_warn_once().
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/