Message ID | 1461787914-13902-2-git-send-email-ricardo.neri-calderon@linux.intel.com |
---|---|
State | Accepted |
Headers | show |
On 27/04/16 21:11, Ricardo Neri wrote: > To assign a cache type to a memory range, we determine if _any_ part of > it is covered by one or more of the mtrr list entries. > > If only the last location of the memory range under test lies inside > the range described by the mttr entry, we will fail to identify it. As an > example, consider that the mttr range is from [0x2000, 0x3000) - inclusive > of 0x1000 but exclusive of 0x2000. If the range under test is [0x1000, > 0x2000], the second test of the condition will not be met. Thus, it is > necessary to check whether the end of the memory range under test is less > _or_ equal to the start of the range given by the mtrr entry. > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@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 0a98465..698a96c 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -174,7 +174,7 @@ static int cache_types(uint64_t start, uint64_t end) > fwts_list_foreach(item, mtrr_list) { > entry = fwts_list_data(struct mtrr_entry*, item); > > - if (entry->end > start && entry->start < end) > + if (entry->end > start && entry->start <= end) > type |= entry->type; > } > > Nice catch, thanks Ricardo. Acked-by: Colin Ian Jing <colin.king@canonical.com>
On 2016-04-28 04:11 AM, Ricardo Neri wrote: > To assign a cache type to a memory range, we determine if _any_ part of > it is covered by one or more of the mtrr list entries. > > If only the last location of the memory range under test lies inside > the range described by the mttr entry, we will fail to identify it. As an > example, consider that the mttr range is from [0x2000, 0x3000) - inclusive > of 0x1000 but exclusive of 0x2000. If the range under test is [0x1000, > 0x2000], the second test of the condition will not be met. Thus, it is > necessary to check whether the end of the memory range under test is less > _or_ equal to the start of the range given by the mtrr entry. > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@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 0a98465..698a96c 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -174,7 +174,7 @@ static int cache_types(uint64_t start, uint64_t end) > fwts_list_foreach(item, mtrr_list) { > entry = fwts_list_data(struct mtrr_entry*, item); > > - if (entry->end > start && entry->start < end) > + if (entry->end > start && entry->start <= end) > type |= entry->type; > } > > Acked-by: Alex Hung <alex.hung@canonical.com>
diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index 0a98465..698a96c 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -174,7 +174,7 @@ static int cache_types(uint64_t start, uint64_t end) fwts_list_foreach(item, mtrr_list) { entry = fwts_list_data(struct mtrr_entry*, item); - if (entry->end > start && entry->start < end) + if (entry->end > start && entry->start <= end) type |= entry->type; }
To assign a cache type to a memory range, we determine if _any_ part of it is covered by one or more of the mtrr list entries. If only the last location of the memory range under test lies inside the range described by the mttr entry, we will fail to identify it. As an example, consider that the mttr range is from [0x2000, 0x3000) - inclusive of 0x1000 but exclusive of 0x2000. If the range under test is [0x1000, 0x2000], the second test of the condition will not be met. Thus, it is necessary to check whether the end of the memory range under test is less _or_ equal to the start of the range given by the mtrr entry. Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> --- src/bios/mtrr/mtrr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)