Skip to content

Commit

Permalink
[sanitizer] Transition to new _zx_vmar_... calls
Browse files Browse the repository at this point in the history
Now that all _zx_vmar_... calls have been updated, we can undo the
change made in r337801 and switch over to the new calls.

Differential Revision: https://reviews.llvm.org/D51468

llvm-svn: 341011
  • Loading branch information
petrhosek committed Aug 30, 2018
1 parent 88599bf commit 6518929
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ class TracePcGuardController final {
// indices, but we'll never move the mapping address so we don't have
// any multi-thread synchronization issues with that.
uintptr_t mapping;
status = _zx_vmar_map_old(_zx_vmar_root_self(), 0, vmo_, 0, MappingSize,
ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE,
&mapping);
status =
_zx_vmar_map(_zx_vmar_root_self(), ZX_VM_PERM_READ | ZX_VM_PERM_WRITE,
0, vmo_, 0, MappingSize, &mapping);
CHECK_EQ(status, ZX_OK);

// Hereafter other threads are free to start storing into
Expand Down
28 changes: 13 additions & 15 deletions compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ static void *DoAnonymousMmapOrDie(uptr size, const char *mem_type,
// TODO(mcgrathr): Maybe allocate a VMAR for all sanitizer heap and use that?
uintptr_t addr;
status =
_zx_vmar_map_old(_zx_vmar_root_self(), 0, vmo, 0, size,
ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, &addr);
_zx_vmar_map(_zx_vmar_root_self(), ZX_VM_PERM_READ | ZX_VM_PERM_WRITE, 0,
vmo, 0, size, &addr);
_zx_handle_close(vmo);

if (status != ZX_OK) {
Expand Down Expand Up @@ -236,10 +236,9 @@ static uptr DoMmapFixedOrDie(zx_handle_t vmar, uptr fixed_addr, uptr map_size,
DCHECK_GE(base + size_, map_size + offset);
uintptr_t addr;

status = _zx_vmar_map_old(
vmar, offset, vmo, 0, map_size,
ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE | ZX_VM_FLAG_SPECIFIC,
&addr);
status =
_zx_vmar_map(vmar, ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_SPECIFIC,
offset, vmo, 0, map_size, &addr);
_zx_handle_close(vmo);
if (status != ZX_OK) {
if (status != ZX_ERR_NO_MEMORY || die_for_nomem) {
Expand Down Expand Up @@ -318,8 +317,8 @@ void *MmapAlignedOrDieOnFatalError(uptr size, uptr alignment,
size_t map_size = size + alignment;
uintptr_t addr;
status =
_zx_vmar_map_old(_zx_vmar_root_self(), 0, vmo, 0, map_size,
ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, &addr);
_zx_vmar_map(_zx_vmar_root_self(), ZX_VM_PERM_READ | ZX_VM_PERM_WRITE, 0,
vmo, 0, map_size, &addr);
if (status == ZX_OK) {
uintptr_t map_addr = addr;
uintptr_t map_end = map_addr + map_size;
Expand All @@ -331,11 +330,10 @@ void *MmapAlignedOrDieOnFatalError(uptr size, uptr alignment,
sizeof(info), NULL, NULL);
if (status == ZX_OK) {
uintptr_t new_addr;
status = _zx_vmar_map_old(_zx_vmar_root_self(), addr - info.base, vmo,
0, size,
ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE |
ZX_VM_FLAG_SPECIFIC_OVERWRITE,
&new_addr);
status = _zx_vmar_map(
_zx_vmar_root_self(),
ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_SPECIFIC_OVERWRITE,
addr - info.base, vmo, 0, size, &new_addr);
if (status == ZX_OK) CHECK_EQ(new_addr, addr);
}
}
Expand Down Expand Up @@ -395,8 +393,8 @@ bool ReadFileToBuffer(const char *file_name, char **buff, uptr *buff_size,
if (vmo_size < max_len) max_len = vmo_size;
size_t map_size = RoundUpTo(max_len, PAGE_SIZE);
uintptr_t addr;
status = _zx_vmar_map_old(_zx_vmar_root_self(), 0, vmo, 0, map_size,
ZX_VM_FLAG_PERM_READ, &addr);
status = _zx_vmar_map(_zx_vmar_root_self(), ZX_VM_PERM_READ, 0, vmo, 0,
map_size, &addr);
if (status == ZX_OK) {
*buff = reinterpret_cast<char *>(addr);
*buff_size = map_size;
Expand Down

0 comments on commit 6518929

Please sign in to comment.