Reworked fix to make it cleaner
@@ -345,22 +345,15 @@ closure_function(3, 3, boolean, mincore_fill_vec,
u64 pgoff, i;
if (pt_entry_is_present(e)) {
- if (pt_entry_is_fat(level, e)) {
- /* have to handle starting in the middle of fat page */
- u64 off, coff;
- off = (addr & PAGEMASK_2M) >> PAGELOG;
- if (addr > bound(base)) {
- pgoff = (addr - bound(base)) >> PAGELOG;
- coff = 0;
- } else {
+ if (addr < bound(base))
pgoff = 0;
- coff = off;
- }
- for (i = 0; (i + coff < 512) && (pgoff + off + i < bound(nr_pgs)); i++) {
- bound(vec)[pgoff + off + i] = 1;
- }
+ else
+ pgoff = ((addr - bound(base)) >> PAGELOG);
+ if (pt_entry_is_fat(level, e)) {
+ u64 foff = (addr & PAGEMASK_2M) >> PAGELOG;
+ for (i = 0; (i < 512 - (pgoff ? 0 : foff)) && (pgoff + i < bound(nr_pgs)); i++)
+ bound(vec)[pgoff + i] = 1;
} else if (pt_entry_is_pte(level, e)) {
- pgoff = (addr - bound(base)) >> PAGELOG;
bound(vec)[pgoff] = 1;
}
}
