From 7cb6c665ac4a9891c5ec5d0f58e91f35caa0d311 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Wed, 14 Jun 2023 13:14:11 -0700 Subject: Remove HWASanUntag The pointer passed to it was never tagged in the first place. Add DCHECK to codify this assumption. Test: art/tools/run-gtests.sh Change-Id: Ib8ebc242d44b0599dccb80758198d1255426a7c6 --- compiler/exception_test.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'compiler/exception_test.cc') diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc index 82c4998217..75ade55799 100644 --- a/compiler/exception_test.cc +++ b/compiler/exception_test.cc @@ -69,9 +69,10 @@ class ExceptionTest : public CommonRuntimeTest { dex_ = my_klass_->GetDexCache()->GetDexFile(); + std::vector fake_code; uint32_t code_size = 12; for (size_t i = 0 ; i < code_size; i++) { - fake_code_.push_back(0x70 | i); + fake_code.push_back(0x70 | i); } const uint32_t native_pc_offset = 4u; @@ -96,16 +97,23 @@ class ExceptionTest : public CommonRuntimeTest { const size_t header_size = sizeof(OatQuickMethodHeader); const size_t code_alignment = GetInstructionSetCodeAlignment(kRuntimeISA); - fake_header_code_and_maps_.resize(stack_maps_size + header_size + code_size + code_alignment); - // NB: The start of the vector might not have been allocated the desired alignment. + fake_header_code_and_maps_size_ = stack_maps_size + header_size + code_size + code_alignment; + // Use mmap to make sure we get untagged memory here. Real code gets allocated using + // mspace_memalign which is never tagged. + fake_header_code_and_maps_ = static_cast(mmap(nullptr, + fake_header_code_and_maps_size_, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, + 0)); uint8_t* code_ptr = AlignUp(&fake_header_code_and_maps_[stack_maps_size + header_size], code_alignment); memcpy(&fake_header_code_and_maps_[0], stack_map.data(), stack_maps_size); - OatQuickMethodHeader method_header(code_ptr - fake_header_code_and_maps_.data()); + OatQuickMethodHeader method_header(code_ptr - fake_header_code_and_maps_); static_assert(std::is_trivially_copyable::value, "Cannot use memcpy"); memcpy(code_ptr - header_size, &method_header, header_size); - memcpy(code_ptr, fake_code_.data(), fake_code_.size()); + memcpy(code_ptr, fake_code.data(), fake_code.size()); if (kRuntimeISA == InstructionSet::kArm) { // Check that the Thumb2 adjustment will be a NOP, see EntryPointToCodePointer(). @@ -123,10 +131,12 @@ class ExceptionTest : public CommonRuntimeTest { method_g_->SetEntryPointFromQuickCompiledCode(code_ptr); } + void TearDown() override { munmap(fake_header_code_and_maps_, fake_header_code_and_maps_size_); } + const DexFile* dex_; - std::vector fake_code_; - std::vector fake_header_code_and_maps_; + size_t fake_header_code_and_maps_size_; + uint8_t* fake_header_code_and_maps_; ArtMethod* method_f_; ArtMethod* method_g_; -- cgit v1.2.3-59-g8ed1b