[kernel][vm] Cleanup lock annotations
Adds some missing lock annotations and cleans up some redundant
asserts.
Change-Id: I7b115d8e497f29c6829eb3a1d5b3694a10dcda39
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/514683
Reviewed-by: Rasha Eqbal <rashaeqbal@google.com>
Commit-Queue: Adrian Danis <adanis@google.com>
diff --git a/zircon/kernel/vm/include/vm/vm_address_region.h b/zircon/kernel/vm/include/vm/vm_address_region.h
index cfc8325..f90660b 100644
--- a/zircon/kernel/vm/include/vm/vm_address_region.h
+++ b/zircon/kernel/vm/include/vm/vm_address_region.h
@@ -574,11 +574,12 @@
// and if so populates pva with the base address to use.
bool CheckGapLocked(VmAddressRegionOrMapping* prev, VmAddressRegionOrMapping* next, vaddr_t* pva,
vaddr_t search_base, vaddr_t align, size_t region_size, size_t min_gap,
- uint arch_mmu_flags);
+ uint arch_mmu_flags) TA_REQ(lock());
// search for a spot to allocate for a region of a given size
zx_status_t AllocSpotLocked(size_t size, uint8_t align_pow2, uint arch_mmu_flags, vaddr_t* spot,
- vaddr_t upper_limit = ktl::numeric_limits<vaddr_t>::max());
+ vaddr_t upper_limit = ktl::numeric_limits<vaddr_t>::max())
+ TA_REQ(lock());
template <typename ON_VMAR, typename ON_MAPPING>
bool EnumerateChildrenInternalLocked(vaddr_t min_addr, vaddr_t max_addr, ON_VMAR on_vmar,
diff --git a/zircon/kernel/vm/vm_address_region.cc b/zircon/kernel/vm/vm_address_region.cc
index 1c4804d..33bd4ba 100644
--- a/zircon/kernel/vm/vm_address_region.cc
+++ b/zircon/kernel/vm/vm_address_region.cc
@@ -392,9 +392,6 @@
bool VmAddressRegion::CheckGapLocked(VmAddressRegionOrMapping* prev, VmAddressRegionOrMapping* next,
vaddr_t* pva, vaddr_t search_base, vaddr_t align,
size_t region_size, size_t min_gap, uint arch_mmu_flags) {
- // TODO: Add annotations to remove this.
- AssertHeld(lock_ref());
-
vaddr_t gap_beg; // first byte of a gap
vaddr_t gap_end; // last byte of a gap
@@ -586,7 +583,6 @@
void VmAddressRegion::Activate() {
DEBUG_ASSERT(state_ == LifeCycleState::NOT_READY);
- DEBUG_ASSERT(aspace_->lock()->lock().IsHeld());
state_ = LifeCycleState::ALIVE;
parent_->subregions_.InsertRegion(fbl::RefPtr<VmAddressRegionOrMapping>(this));
@@ -973,7 +969,6 @@
vaddr_t* spot, vaddr_t upper_limit) {
canary_.Assert();
DEBUG_ASSERT(size > 0 && IS_PAGE_ALIGNED(size));
- DEBUG_ASSERT(aspace_->lock()->lock().IsHeld());
DEBUG_ASSERT(spot);
LTRACEF_LEVEL(2, "aspace %p size 0x%zx align %hhu upper_limit 0x%lx\n", this, size, align_pow2,