Re: [PATCH v3.1 10/12] x86/mtrr: use new cache_map in mtrr_type_lookup()

From: Juergen Gross
Date: Mon Feb 27 2023 - 02:11:38 EST


On 26.02.23 18:00, Michael Kelley (LINUX) wrote:
From: Juergen Gross <jgross@xxxxxxxx> Sent: Thursday, February 23, 2023 10:37 PM

Instead of crawling through the MTRR register state, use the new
cache_map for looking up the cache type(s) of a memory region.

This allows now to set the uniform parameter according to the
uniformity of the cache mode of the region, instead of setting it
only if the complete region is mapped by a single MTRR. This now
includes even the region covered by the fixed MTRR registers.

Make sure uniform is always set.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
V3:
- new patch
V3.1:
- fix type_merge() (Michael Kelley)

Thanks. This version fixes the problem I previously reported with a normal
VM.

However, I'm seeing a different problem in a Confidential VM where
mtrr_overwrite_state() is used. In this case, we have no MTRRs, and when
mtrr_copy_map() is called, the copy is not done, and cache_map is set
to NULL. Subsequently when mtrr_type_lookup() is called, the check
for a NULL cache_map causes MTRR_TYPE_UNCACHABLE to be returned.
Then we're back to the original problem where pat_x_mtrr_type()
returns UC- instead of WB.

Sigh. Just removing the test for cache_map being NULL in mtrr_type_lookup()
should do the job.

Will send V4 soon.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature