Re: [PATCH v4 7/7] mtrr, mm, x86: Enhance MTRR checks for KVA huge page mapping

From: Toshi Kani
Date: Tue May 12 2015 - 10:49:50 EST


On Tue, 2015-05-12 at 09:28 +0200, Borislav Petkov wrote:
> On Mon, May 11, 2015 at 04:09:39PM -0600, Toshi Kani wrote:
> > There may not be any type conflict with MTRR_TYPE_INVALID.
>
> Because...?

Because you cannot have a memory type conflict with MTRRs when MTRRs are
disabled. mtrr_type_lookup() returns MTRR_TYPE_INVALID when MTRRs are
disabled. This is stated in the comments of mtrr_type_lookup() and the
MTRR_TYPE_INVALID definition itself.

BIOS can disable MTRRs, or VM may choose not to implement MTRRs. The OS
needs to handle this case as a valid config, and this is not an error
case.

> Let me guess: you cannot change this function to return a signed value
> which is the type when positive and an error when negative?

No, that is not the reason.

> > I will change the caller to check MTRR_TYPE_INVALID, and treat it as a
> > uniform case.
>
> That would be, of course, also wrong.

I am confused... In your previous comments, you mentioned that:

| If you want to be able to state that a type is uniform even if MTRRs
| are disabled, you need to define another retval which means exactly
| that.

There may not be type conflict when MTRRs are disabled. There is no
point of defining a new return value.

| Or add an inline function called mtrr_enabled() and call it in the
| mtrr_type_lookup() callers.

MTRR_TYPE_INVALID means MTRRs disabled. So, the caller checking with
this value is the same as checking with mtrr_enabled() you suggested.

Thanks,
-Toshi


--
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/