kernel/vm: Drop methods used only by the old guarded heap.

They're not needed anymore. The VMTranslationMap method was confusingly
named anyway, as the other Debug* methods are for use in KDL, while
this one required the regular locks and flush mechanisms.

Change-Id: Ic1baf3d786071562d8beaeb768d996cd1d34f9b7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9706
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Augustin Cavalier
2025-10-31 02:36:19 +00:00
committed by waddlesplash
parent d36a3e286b
commit 5769051834
18 changed files with 0 additions and 474 deletions
@@ -39,9 +39,6 @@ public:
vm_page_reservation* reservation) = 0; vm_page_reservation* reservation) = 0;
virtual status_t Unmap(addr_t start, addr_t end) = 0; virtual status_t Unmap(addr_t start, addr_t end) = 0;
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
// map not locked // map not locked
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
-4
View File
@@ -84,10 +84,6 @@ const char* vm_cache_type_to_string(int32 type);
void vm_free_page_mapping(page_num_t page, vm_page_mapping* mapping, uint32 flags); void vm_free_page_mapping(page_num_t page, vm_page_mapping* mapping, uint32 flags);
status_t vm_prepare_kernel_area_debug_protection(area_id id, void** cookie);
status_t vm_set_kernel_area_debug_protection(void* cookie, void* _address,
size_t size, uint32 protection);
status_t vm_block_address_range(const char* name, void* address, addr_t size); status_t vm_block_address_range(const char* name, void* address, addr_t size);
status_t vm_unreserve_address_range(team_id team, void *address, addr_t size); status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
status_t vm_reserve_address_range(team_id team, void **_address, status_t vm_reserve_address_range(team_id team, void **_address,
@@ -279,62 +279,6 @@ ARMVMTranslationMap32Bit::Unmap(addr_t start, addr_t end)
} }
status_t
ARMVMTranslationMap32Bit::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
#if 0
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
page_directory_entry *pd = fPagingStructures->pgdir_virt;
do {
int index = VADDR_TO_PDENT(start);
if ((pd[index] & X86_PDE_PRESENT) == 0) {
// no page table here, move the start up to access the next page
// table
start = ROUNDUP(start + 1, kPageTableAlignment);
continue;
}
Thread* thread = thread_get_current_thread();
ThreadCPUPinner pinner(thread);
page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt(
pd[index] & X86_PDE_ADDRESS_MASK);
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
index++, start += B_PAGE_SIZE) {
if ((pt[index] & X86_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
X86PagingMethod32Bit::SetPageTableEntryFlags(&pt[index],
X86_PTE_PRESENT);
} else {
if (markPresent)
continue;
page_table_entry oldEntry
= X86PagingMethod32Bit::ClearPageTableEntryFlags(&pt[index],
X86_PTE_PRESENT);
if ((oldEntry & ARM_MMU_L2_FLAG_AP0) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
#endif
return B_OK;
}
status_t status_t
ARMVMTranslationMap32Bit::UnmapPage(VMArea* area, addr_t address, ARMVMTranslationMap32Bit::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -27,9 +27,6 @@ struct ARMVMTranslationMap32Bit : ARMVMTranslationMap {
vm_page_reservation* reservation); vm_page_reservation* reservation);
virtual status_t Unmap(addr_t start, addr_t end); virtual status_t Unmap(addr_t start, addr_t end);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -585,65 +585,6 @@ PPCVMTranslationMap460::RemapAddressRange(addr_t *_virtualAddress,
} }
status_t
PPCVMTranslationMap460::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
panic("%s: UNIMPLEMENTED", __FUNCTION__);
return B_ERROR;
#if 0//X86
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
page_directory_entry *pd = fPagingStructures->pgdir_virt;
do {
int index = VADDR_TO_PDENT(start);
if ((pd[index] & PPC_PDE_PRESENT) == 0) {
// no page table here, move the start up to access the next page
// table
start = ROUNDUP(start + 1, kPageTableAlignment);
continue;
}
Thread* thread = thread_get_current_thread();
ThreadCPUPinner pinner(thread);
page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt(
pd[index] & PPC_PDE_ADDRESS_MASK);
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
index++, start += B_PAGE_SIZE) {
if ((pt[index] & PPC_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
PPCPagingMethod460::SetPageTableEntryFlags(&pt[index],
PPC_PTE_PRESENT);
} else {
if (markPresent)
continue;
page_table_entry oldEntry
= PPCPagingMethod460::ClearPageTableEntryFlags(&pt[index],
PPC_PTE_PRESENT);
if ((oldEntry & PPC_PTE_ACCESSED) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
return B_OK;
#endif
}
status_t status_t
PPCVMTranslationMap460::UnmapPage(VMArea* area, addr_t address, PPCVMTranslationMap460::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -38,9 +38,6 @@ struct PPCVMTranslationMap460 : PPCVMTranslationMap {
virtual status_t RemapAddressRange(addr_t *_virtualAddress, virtual status_t RemapAddressRange(addr_t *_virtualAddress,
size_t size, bool unmap); size_t size, bool unmap);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -585,65 +585,6 @@ PPCVMTranslationMapClassic::RemapAddressRange(addr_t *_virtualAddress,
} }
status_t
PPCVMTranslationMapClassic::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
panic("%s: UNIMPLEMENTED", __FUNCTION__);
return B_ERROR;
#if 0//X86
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
page_directory_entry *pd = fPagingStructures->pgdir_virt;
do {
int index = VADDR_TO_PDENT(start);
if ((pd[index] & PPC_PDE_PRESENT) == 0) {
// no page table here, move the start up to access the next page
// table
start = ROUNDUP(start + 1, kPageTableAlignment);
continue;
}
Thread* thread = thread_get_current_thread();
ThreadCPUPinner pinner(thread);
page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt(
pd[index] & PPC_PDE_ADDRESS_MASK);
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
index++, start += B_PAGE_SIZE) {
if ((pt[index] & PPC_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
PPCPagingMethodClassic::SetPageTableEntryFlags(&pt[index],
PPC_PTE_PRESENT);
} else {
if (markPresent)
continue;
page_table_entry oldEntry
= PPCPagingMethodClassic::ClearPageTableEntryFlags(&pt[index],
PPC_PTE_PRESENT);
if ((oldEntry & PPC_PTE_ACCESSED) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
return B_OK;
#endif
}
status_t status_t
PPCVMTranslationMapClassic::UnmapPage(VMArea* area, addr_t address, PPCVMTranslationMapClassic::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -38,9 +38,6 @@ struct PPCVMTranslationMapClassic : PPCVMTranslationMap {
virtual status_t RemapAddressRange(addr_t *_virtualAddress, virtual status_t RemapAddressRange(addr_t *_virtualAddress,
size_t size, bool unmap); size_t size, bool unmap);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -311,15 +311,6 @@ RISCV64VMTranslationMap::Unmap(addr_t start, addr_t end)
} }
status_t
RISCV64VMTranslationMap::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
NOT_IMPLEMENTED_PANIC();
return B_NOT_SUPPORTED;
}
status_t status_t
RISCV64VMTranslationMap::UnmapPage(VMArea* area, addr_t address, RISCV64VMTranslationMap::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -39,9 +39,6 @@ struct RISCV64VMTranslationMap: public VMTranslationMap {
vm_page_reservation* reservation); vm_page_reservation* reservation);
virtual status_t Unmap(addr_t start, addr_t end); virtual status_t Unmap(addr_t start, addr_t end);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -263,61 +263,6 @@ X86VMTranslationMap32Bit::Unmap(addr_t start, addr_t end)
} }
status_t
X86VMTranslationMap32Bit::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
page_directory_entry *pd = fPagingStructures->pgdir_virt;
do {
int index = VADDR_TO_PDENT(start);
if ((pd[index] & X86_PDE_PRESENT) == 0) {
// no page table here, move the start up to access the next page
// table
start = ROUNDUP(start + 1, kPageTableAlignment);
continue;
}
Thread* thread = thread_get_current_thread();
ThreadCPUPinner pinner(thread);
page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt(
pd[index] & X86_PDE_ADDRESS_MASK);
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
index++, start += B_PAGE_SIZE) {
if ((pt[index] & X86_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
X86PagingMethod32Bit::SetPageTableEntryFlags(&pt[index],
X86_PTE_PRESENT);
} else {
if (markPresent)
continue;
page_table_entry oldEntry
= X86PagingMethod32Bit::ClearPageTableEntryFlags(&pt[index],
X86_PTE_PRESENT);
if ((oldEntry & X86_PTE_ACCESSED) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
return B_OK;
}
status_t status_t
X86VMTranslationMap32Bit::UnmapPage(VMArea* area, addr_t address, X86VMTranslationMap32Bit::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -27,9 +27,6 @@ struct X86VMTranslationMap32Bit final : X86VMTranslationMap {
vm_page_reservation* reservation); vm_page_reservation* reservation);
virtual status_t Unmap(addr_t start, addr_t end); virtual status_t Unmap(addr_t start, addr_t end);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -316,59 +316,6 @@ X86VMTranslationMap64Bit::Unmap(addr_t start, addr_t end)
} }
status_t
X86VMTranslationMap64Bit::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
TRACE("X86VMTranslationMap64Bit::DebugMarkRangePresent(%#" B_PRIxADDR
", %#" B_PRIxADDR ")\n", start, end);
ThreadCPUPinner pinner(thread_get_current_thread());
do {
uint64* pageTable = X86PagingMethod64Bit::PageTableForAddress(
fPagingStructures->VirtualPMLTop(), start, fIsKernelMap, false,
NULL, fPageMapper, fMapCount);
if (pageTable == NULL) {
// Move on to the next page table.
start = ROUNDUP(start + 1, k64BitPageTableRange);
continue;
}
for (uint32 index = start / B_PAGE_SIZE % k64BitTableEntryCount;
index < k64BitTableEntryCount && start < end;
index++, start += B_PAGE_SIZE) {
if ((pageTable[index] & X86_64_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
X86PagingMethod64Bit::SetTableEntryFlags(&pageTable[index],
X86_64_PTE_PRESENT);
} else {
if (markPresent)
continue;
uint64 oldEntry = X86PagingMethod64Bit::ClearTableEntryFlags(
&pageTable[index], X86_64_PTE_PRESENT);
if ((oldEntry & X86_64_PTE_ACCESSED) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
return B_OK;
}
status_t status_t
X86VMTranslationMap64Bit::UnmapPage(VMArea* area, addr_t address, X86VMTranslationMap64Bit::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -28,9 +28,6 @@ struct X86VMTranslationMap64Bit final : X86VMTranslationMap {
vm_page_reservation* reservation); vm_page_reservation* reservation);
virtual status_t Unmap(addr_t start, addr_t end); virtual status_t Unmap(addr_t start, addr_t end);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -499,64 +499,6 @@ X86VMTranslationMapPAE::Unmap(addr_t start, addr_t end)
} }
status_t
X86VMTranslationMapPAE::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
start = ROUNDDOWN(start, B_PAGE_SIZE);
if (start >= end)
return B_OK;
do {
pae_page_directory_entry* pageDirEntry
= X86PagingMethodPAE::PageDirEntryForAddress(
fPagingStructures->VirtualPageDirs(), start);
if ((*pageDirEntry & X86_PAE_PDE_PRESENT) == 0) {
// no page table here, move the start up to access the next page
// table
start = ROUNDUP(start + 1, kPAEPageTableRange);
continue;
}
Thread* thread = thread_get_current_thread();
ThreadCPUPinner pinner(thread);
pae_page_table_entry* pageTable
= (pae_page_table_entry*)fPageMapper->GetPageTableAt(
*pageDirEntry & X86_PAE_PDE_ADDRESS_MASK);
uint32 index = start / B_PAGE_SIZE % kPAEPageTableEntryCount;
for (; index < kPAEPageTableEntryCount && start < end;
index++, start += B_PAGE_SIZE) {
if ((pageTable[index] & X86_PAE_PTE_PRESENT) == 0) {
if (!markPresent)
continue;
X86PagingMethodPAE::SetTableEntryFlags(
&pageTable[index], X86_PAE_PTE_PRESENT);
} else {
if (markPresent)
continue;
pae_page_table_entry oldEntry
= X86PagingMethodPAE::ClearTableEntryFlags(
&pageTable[index], X86_PAE_PTE_PRESENT);
if ((oldEntry & X86_PAE_PTE_ACCESSED) != 0) {
// Note, that we only need to invalidate the address, if the
// accessed flags was set, since only then the entry could
// have been in any TLB.
InvalidatePage(start);
}
}
}
} while (start != 0 && start < end);
return B_OK;
}
status_t status_t
X86VMTranslationMapPAE::UnmapPage(VMArea* area, addr_t address, X86VMTranslationMapPAE::UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool deletingAddressSpace, uint32* _flags) bool updatePageQueue, bool deletingAddressSpace, uint32* _flags)
@@ -30,9 +30,6 @@ struct X86VMTranslationMapPAE final : X86VMTranslationMap {
vm_page_reservation* reservation); vm_page_reservation* reservation);
virtual status_t Unmap(addr_t start, addr_t end); virtual status_t Unmap(addr_t start, addr_t end);
virtual status_t DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent);
virtual status_t UnmapPage(VMArea* area, addr_t address, virtual status_t UnmapPage(VMArea* area, addr_t address,
bool updatePageQueue, bool updatePageQueue,
bool deletingAddressSpace, uint32* _flags); bool deletingAddressSpace, uint32* _flags);
@@ -31,14 +31,6 @@ VMTranslationMap::~VMTranslationMap()
} }
status_t
VMTranslationMap::DebugMarkRangePresent(addr_t start, addr_t end,
bool markPresent)
{
return B_NOT_SUPPORTED;
}
/*! Unmaps a range of pages of an area. /*! Unmaps a range of pages of an area.
The default implementation just iterates over all virtual pages of the The default implementation just iterates over all virtual pages of the
-89
View File
@@ -1452,95 +1452,6 @@ wait_if_address_range_is_wired(VMAddressSpace* addressSpace, addr_t base,
} }
/*! Prepares an area to be used for vm_set_kernel_area_debug_protection().
It must be called in a situation where the kernel address space may be
locked.
*/
status_t
vm_prepare_kernel_area_debug_protection(area_id id, void** cookie)
{
AddressSpaceReadLocker locker;
VMArea* area;
status_t status = locker.SetFromArea(id, area);
if (status != B_OK)
return status;
if (area->page_protections == NULL) {
status = allocate_area_page_protections(area);
if (status != B_OK)
return status;
}
*cookie = (void*)area;
return B_OK;
}
/*! This is a debug helper function that can only be used with very specific
use cases.
Sets protection for the given address range to the protection specified.
If \a protection is 0 then the involved pages will be marked non-present
in the translation map to cause a fault on access. The pages aren't
actually unmapped however so that they can be marked present again with
additional calls to this function. For this to work the area must be
fully locked in memory so that the pages aren't otherwise touched.
This function does not lock the kernel address space and needs to be
supplied with a \a cookie retrieved from a successful call to
vm_prepare_kernel_area_debug_protection().
*/
status_t
vm_set_kernel_area_debug_protection(void* cookie, void* _address, size_t size,
uint32 protection)
{
// check address range
addr_t address = (addr_t)_address;
size = PAGE_ALIGN(size);
if ((address % B_PAGE_SIZE) != 0
|| (addr_t)address + size < (addr_t)address
|| !IS_KERNEL_ADDRESS(address)
|| !IS_KERNEL_ADDRESS((addr_t)address + size)) {
return B_BAD_VALUE;
}
// Translate the kernel protection to user protection as we only store that.
if ((protection & B_KERNEL_READ_AREA) != 0)
protection |= B_READ_AREA;
if ((protection & B_KERNEL_WRITE_AREA) != 0)
protection |= B_WRITE_AREA;
VMAddressSpace* addressSpace = VMAddressSpace::GetKernel();
VMTranslationMap* map = addressSpace->TranslationMap();
VMArea* area = (VMArea*)cookie;
addr_t offset = address - area->Base();
if (area->Size() - offset < size) {
panic("protect range not fully within supplied area");
return B_BAD_VALUE;
}
if (area->page_protections == NULL) {
panic("area has no page protections");
return B_BAD_VALUE;
}
// Invalidate the mapping entries so any access to them will fault or
// restore the mapping entries unchanged so that lookup will success again.
map->Lock();
map->DebugMarkRangePresent(address, address + size, protection != 0);
map->Unlock();
// And set the proper page protections so that the fault case will actually
// fail and not simply try to map a new page.
for (addr_t pageAddress = address; pageAddress < address + size;
pageAddress += B_PAGE_SIZE) {
set_area_page_protection(area, pageAddress, protection);
}
return B_OK;
}
status_t status_t
vm_block_address_range(const char* name, void* address, addr_t size) vm_block_address_range(const char* name, void* address, addr_t size)
{ {