mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
vm: removed c_page_size, it cannot be used by globals
This commit is contained in:
parent
57e7cee84e
commit
2ebf257f84
6 changed files with 24 additions and 27 deletions
|
@ -776,7 +776,7 @@ bool jit_compiler::add(const std::string& path)
|
|||
if (!cache)
|
||||
{
|
||||
jit_log.error("ObjectCache: Failed to read file. (path='%s', error=%s)", path, fs::g_tls_error);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto object_file = llvm::object::ObjectFile::createObjectFile(*cache))
|
||||
|
@ -857,11 +857,11 @@ const char * fallback_cpu_detection()
|
|||
// Return zen4 as a workaround until the next LLVM upgrade.
|
||||
return "znver4";
|
||||
default:
|
||||
// Safest guesses
|
||||
// Safest guesses
|
||||
return utils::has_avx512() ? "znver4" :
|
||||
utils::has_avx2() ? "znver1" :
|
||||
utils::has_avx() ? "bdver1" :
|
||||
"nehalem";
|
||||
"nehalem";
|
||||
}
|
||||
}
|
||||
else if (brand.find("Intel") != std::string::npos)
|
||||
|
|
|
@ -15,12 +15,12 @@ namespace utils
|
|||
*/
|
||||
static inline u32 page_start(u32 addr)
|
||||
{
|
||||
return addr & ~(c_page_size - 1);
|
||||
return addr & ~(get_page_size() - 1);
|
||||
}
|
||||
|
||||
static inline u32 next_page(u32 addr)
|
||||
{
|
||||
return page_start(addr) + c_page_size;
|
||||
return page_start(addr) + get_page_size();
|
||||
}
|
||||
|
||||
static inline u32 page_end(u32 addr)
|
||||
|
@ -30,7 +30,7 @@ namespace utils
|
|||
|
||||
static inline u32 is_page_aligned(u32 val)
|
||||
{
|
||||
return (val & (c_page_size - 1)) == 0;
|
||||
return (val & (get_page_size() - 1)) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -746,7 +746,7 @@ namespace vm
|
|||
}
|
||||
|
||||
// If native page size exceeds 4096, don't map native pages (expected to be always mapped in this case)
|
||||
const bool is_noop = bflags & page_size_4k && utils::c_page_size > 4096;
|
||||
const bool is_noop = bflags & page_size_4k && utils::get_page_size() > 4096;
|
||||
|
||||
// Lock range being mapped
|
||||
auto range_lock = _lock_main_range_lock(range_allocation, addr, size);
|
||||
|
@ -958,7 +958,7 @@ namespace vm
|
|||
}
|
||||
|
||||
// If native page size exceeds 4096, don't unmap native pages (always mapped)
|
||||
const bool is_noop = bflags & page_size_4k && utils::c_page_size > 4096;
|
||||
const bool is_noop = bflags & page_size_4k && utils::get_page_size() > 4096;
|
||||
|
||||
// Determine deallocation size
|
||||
u32 size = 0;
|
||||
|
@ -1305,7 +1305,7 @@ namespace vm
|
|||
// Special path for whole-allocated areas allowing 4k granularity
|
||||
m_common = std::make_shared<utils::shm>(size, fmt::format("_block_x%08x", addr));
|
||||
|
||||
if (!map_critical(vm::_ptr<u8>(addr), this->flags & page_size_4k && utils::c_page_size > 4096 ? utils::protection::rw : utils::protection::no) || !map_critical(vm::get_super_ptr(addr), utils::protection::rw))
|
||||
if (!map_critical(vm::_ptr<u8>(addr), this->flags & page_size_4k && utils::get_page_size() > 4096 ? utils::protection::rw : utils::protection::no) || !map_critical(vm::get_super_ptr(addr), utils::protection::rw))
|
||||
{
|
||||
fmt::throw_exception("Memory mapping failed (addr=0x%x, size=0x%x, flags=0x%x): %s", addr, size, flags, map_error);
|
||||
}
|
||||
|
@ -1778,7 +1778,7 @@ namespace vm
|
|||
if (flags & preallocated)
|
||||
{
|
||||
m_common = std::make_shared<utils::shm>(size, fmt::format("_block_x%08x", addr));
|
||||
m_common->map_critical(vm::base(addr), this->flags & page_size_4k && utils::c_page_size > 4096 ? utils::protection::rw : utils::protection::no);
|
||||
m_common->map_critical(vm::base(addr), this->flags & page_size_4k && utils::get_page_size() > 4096 ? utils::protection::rw : utils::protection::no);
|
||||
m_common->map_critical(vm::get_super_ptr(addr));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace rsx
|
|||
{
|
||||
if (p.second.prot != utils::protection::rw)
|
||||
{
|
||||
utils::memory_protect(vm::base(p.first), utils::c_page_size, utils::protection::rw);
|
||||
utils::memory_protect(vm::base(p.first), utils::get_page_size(), utils::protection::rw);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ namespace rsx
|
|||
|
||||
if (page.prot == utils::protection::rw)
|
||||
{
|
||||
utils::memory_protect(vm::base(page_address), utils::c_page_size, utils::protection::no);
|
||||
utils::memory_protect(vm::base(page_address), utils::get_page_size(), utils::protection::no);
|
||||
page.prot = utils::protection::no;
|
||||
}
|
||||
}
|
||||
|
@ -865,7 +865,7 @@ namespace rsx
|
|||
|
||||
if (page.prot != utils::protection::rw)
|
||||
{
|
||||
utils::memory_protect(vm::base(this_address), utils::c_page_size, utils::protection::rw);
|
||||
utils::memory_protect(vm::base(this_address), utils::get_page_size(), utils::protection::rw);
|
||||
page.prot = utils::protection::rw;
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ namespace rsx
|
|||
else
|
||||
{
|
||||
// R/W to stale block, unload it and move on
|
||||
utils::memory_protect(vm::base(page_address), utils::c_page_size, utils::protection::rw);
|
||||
utils::memory_protect(vm::base(page_address), utils::get_page_size(), utils::protection::rw);
|
||||
m_locked_pages[location].erase(page_address);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -16,9 +16,6 @@ namespace utils
|
|||
// Obtain system page size
|
||||
long get_page_size();
|
||||
|
||||
// System page size
|
||||
inline const long c_page_size = get_page_size();
|
||||
|
||||
// Memory protection type
|
||||
enum class protection
|
||||
{
|
||||
|
|
|
@ -318,15 +318,15 @@ namespace utils
|
|||
ensure(::VirtualAlloc(pointer, size, MEM_COMMIT, +prot));
|
||||
#else
|
||||
const u64 ptr64 = reinterpret_cast<u64>(pointer);
|
||||
ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), +prot) != -1);
|
||||
ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), +prot) != -1);
|
||||
|
||||
if constexpr (c_madv_dump != 0)
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), c_madv_dump) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), c_madv_dump) != -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), MADV_WILLNEED) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), MADV_WILLNEED) != -1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -355,11 +355,11 @@ namespace utils
|
|||
|
||||
if constexpr (c_madv_no_dump != 0)
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), c_madv_no_dump) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), c_madv_no_dump) != -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), c_madv_free) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), c_madv_free) != -1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -387,17 +387,17 @@ namespace utils
|
|||
{
|
||||
if (size % 0x200000 == 0)
|
||||
{
|
||||
::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), c_madv_hugepage);
|
||||
::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), c_madv_hugepage);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (c_madv_dump != 0)
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), c_madv_dump) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), c_madv_dump) != -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), MADV_WILLNEED) != -1);
|
||||
ensure(::madvise(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), MADV_WILLNEED) != -1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ namespace utils
|
|||
}
|
||||
#else
|
||||
const u64 ptr64 = reinterpret_cast<u64>(pointer);
|
||||
ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -c_page_size), size + (ptr64 & (c_page_size - 1)), +prot) != -1);
|
||||
ensure(::mprotect(reinterpret_cast<void*>(ptr64 & -get_page_size()), size + (ptr64 & (get_page_size() - 1)), +prot) != -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1055,4 +1055,4 @@ namespace utils
|
|||
this->unmap(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
|
|
Loading…
Add table
Reference in a new issue