kernel/vm: Check the area's cache_type, not the cache's, in cut_area.

It seems this is the type of the innermost source cache, not the
topmost cache (which well may be "RAM" if this is an anonymous cache
on top of a Vnode cache.)

Originally VMArea::cache_type was introduced 15 years ago
(commit 0c12332715, 2007)
merely to mirror the underlying cache's type. Somewhere along the way,
it acquired different values. As the VM has changed a lot since then,
perhaps its overall purpose should be re-evaluated?

Fixes #17556.
This commit is contained in:
Augustin Cavalier 2022-03-10 17:40:15 -05:00
parent 23840276a9
commit 3a81e9446d

View File

@ -676,7 +676,7 @@ cut_area(VMAddressSpace* addressSpace, VMArea* area, addr_t address,
// If no one else uses the area's cache and it's an anonymous cache, we can
// resize or split it, too.
bool onlyCacheUser = cache->areas == area && area->cache_next == NULL
&& cache->consumers.IsEmpty() && cache->type == CACHE_TYPE_RAM;
&& cache->consumers.IsEmpty() && area->cache_type == CACHE_TYPE_RAM;
// Cut the end only?
if (offset > 0 && size == area->Size() - offset) {