ACK: [PATCH 2/3] bios: mtrr: fix cache type corner case at end of mtrr range

Alex Hung alex.hung at canonical.com
Fri Apr 29 07:57:31 UTC 2016


On 2016-04-28 04:11 AM, Ricardo Neri wrote:
> An entry in the mtrr list is set as entry->end = entry->start +
> entry->size. Thus, it follows that in order to assign a cache type, we
> must test whether any part of the memory range under test is in the
> range [entry->start, entry->end); this is, inclusive of entry->start
> but exclusive of entry->end.
>
> A DEFAULT type is assigned to a memory range if it is not covered by
> any entry of the mtrr list. This check begins verifying whether the
> end of the memory range under test ,e, lies inside any of the ranges
> described in the mtrr list. This is:
>
>                       entry.start < e <= entry.end                   (1)
>
> However, consider an hypothetical mtrr entry [0x1000, 0x3000) and a
> test range [0x2000, 0x3000]. Clearly, the memory location 0x3000 is
> not covered by the mtrr entry. However, the condition (1) is met and
> the function incorrectly determines that memory range under test is
> fully covered by the mtrr entry. Thus, the correct test should be
>
>                       entry.start < e < entry.end                    (1)
>
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon at linux.intel.com>
> ---
>   src/bios/mtrr/mtrr.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
> index 698a96c..8176803 100644
> --- a/src/bios/mtrr/mtrr.c
> +++ b/src/bios/mtrr/mtrr.c
> @@ -186,7 +186,7 @@ restart:
>   	fwts_list_foreach(item, mtrr_list) {
>   		entry = fwts_list_data(struct mtrr_entry*, item);
>
> -		if (entry->end >= end && entry->start < end) {
> +		if (entry->end > end && entry->start < end) {
>   			end = entry->start;
>   			if (end < start)
>   				end = start;
>

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list