Browse Source

[core] don't adjust for nce on non-nce (obviously)

remotes/1785372757367212240/tmp_refs/heads/variable-page-size
Exverge 4 weeks ago
parent
commit
70a59b1188
No known key found for this signature in database GPG Key ID: DAD399BCC5FB77E4
  1. 34
      src/common/host_memory.cpp
  2. 2
      src/core/arm/nce/guest_context.h

34
src/common/host_memory.cpp

@ -223,7 +223,11 @@ public:
} }
void Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perms) { void Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perms) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are direct mapping, intersect the range with our address space.
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
std::unique_lock lock{placeholder_mutex}; std::unique_lock lock{placeholder_mutex};
if (!IsNiechePlaceholder(virtual_offset, length)) { if (!IsNiechePlaceholder(virtual_offset, length)) {
Split(virtual_offset, length); Split(virtual_offset, length);
@ -235,7 +239,10 @@ public:
} }
void Unmap(size_t virtual_offset, size_t length) { void Unmap(size_t virtual_offset, size_t length) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are direct mapping, intersect the range with our address space.
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
std::scoped_lock lock{placeholder_mutex}; std::scoped_lock lock{placeholder_mutex};
// Unmap until there are no more placeholders // Unmap until there are no more placeholders
@ -244,7 +251,10 @@ public:
} }
void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) { void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are direct mapping, intersect this region with
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
DWORD new_flags{}; DWORD new_flags{};
if (read && write && execute) { if (read && write && execute) {
@ -682,8 +692,10 @@ public:
} }
void Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perms) { void Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perms) {
// Intersect the range with our address space.
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are direct mapping, intersect the range with our address space.
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
// We are removing a placeholder. // We are removing a placeholder.
free_manager.AllocateBlock(virtual_base + virtual_offset, length); free_manager.AllocateBlock(virtual_base + virtual_offset, length);
@ -707,8 +719,10 @@ public:
// The method name is wrong. We're still talking about the virtual range. // The method name is wrong. We're still talking about the virtual range.
// We don't want to unmap, we want to reserve this memory. // We don't want to unmap, we want to reserve this memory.
// Intersect the range with our address space.
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are using direct mapping, intersect the range with our address space.
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
// Merge with any adjacent placeholder mappings. // Merge with any adjacent placeholder mappings.
auto [merged_pointer, merged_size] = auto [merged_pointer, merged_size] =
@ -719,8 +733,10 @@ public:
} }
void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) { void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) {
// Intersect the range with our address space.
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
// If we are using direct mapping, intersect the range with our address space.
if (virtual_base == nullptr) {
AdjustMap(virtual_map_base, virtual_size, &virtual_offset, &length);
}
int flags = PROT_NONE; int flags = PROT_NONE;
if (read) { if (read) {

2
src/core/arm/nce/guest_context.h

@ -87,7 +87,7 @@ public:
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)
KernelContext(void* ptr) : ptr(static_cast<ucontext_t>(ptr).uc_mcontext) {}
KernelContext(void* ptr) : ptr(static_cast<ucontext_t*>(ptr)->uc_mcontext) {}
u64* pc() { u64* pc() {
return &ptr->__ss.__pc; return &ptr->__ss.__pc;

Loading…
Cancel
Save