mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 11:34:55 +00:00
Sync page manager protections
This commit is contained in:
parent
4c279f64c7
commit
71d5d27ab2
@ -57,12 +57,6 @@ struct PageManager::Impl {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateProtectRange {
|
|
||||||
VAddr addr;
|
|
||||||
u64 size;
|
|
||||||
Core::MemoryPermission perms;
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr size_t ADDRESS_BITS = 40;
|
static constexpr size_t ADDRESS_BITS = 40;
|
||||||
static constexpr size_t NUM_ADDRESS_PAGES = 1ULL << (40 - PAGE_BITS);
|
static constexpr size_t NUM_ADDRESS_PAGES = 1ULL << (40 - PAGE_BITS);
|
||||||
inline static Vulkan::Rasterizer* rasterizer;
|
inline static Vulkan::Rasterizer* rasterizer;
|
||||||
@ -195,9 +189,6 @@ struct PageManager::Impl {
|
|||||||
template <bool track>
|
template <bool track>
|
||||||
void UpdatePageWatchers(VAddr addr, u64 size) {
|
void UpdatePageWatchers(VAddr addr, u64 size) {
|
||||||
RENDERER_TRACE;
|
RENDERER_TRACE;
|
||||||
boost::container::small_vector<UpdateProtectRange, 16> update_ranges;
|
|
||||||
{
|
|
||||||
std::scoped_lock lk(lock);
|
|
||||||
|
|
||||||
size_t page = addr >> PAGE_BITS;
|
size_t page = addr >> PAGE_BITS;
|
||||||
auto perms = cached_pages[page].Perm();
|
auto perms = cached_pages[page].Perm();
|
||||||
@ -207,12 +198,14 @@ struct PageManager::Impl {
|
|||||||
const auto release_pending = [&] {
|
const auto release_pending = [&] {
|
||||||
if (range_bytes > 0) {
|
if (range_bytes > 0) {
|
||||||
RENDERER_TRACE;
|
RENDERER_TRACE;
|
||||||
// Add pending (un)protect action
|
// Perform pending (un)protect action
|
||||||
update_ranges.push_back({range_begin << PAGE_BITS, range_bytes, perms});
|
Protect(range_begin << PAGE_BITS, range_bytes, perms);
|
||||||
range_bytes = 0;
|
range_bytes = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::scoped_lock lk(lock);
|
||||||
|
|
||||||
// Iterate requested pages
|
// Iterate requested pages
|
||||||
const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE);
|
const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE);
|
||||||
const u64 aligned_addr = page << PAGE_BITS;
|
const u64 aligned_addr = page << PAGE_BITS;
|
||||||
@ -247,17 +240,9 @@ struct PageManager::Impl {
|
|||||||
release_pending();
|
release_pending();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush deferred protects
|
|
||||||
for (const auto& range : update_ranges) {
|
|
||||||
Protect(range.addr, range.size, range.perms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <bool track>
|
template <bool track>
|
||||||
void UpdatePageWatchersMasked(VAddr base_addr, RegionBits& mask) {
|
void UpdatePageWatchersMasked(VAddr base_addr, RegionBits& mask) {
|
||||||
RENDERER_TRACE;
|
RENDERER_TRACE;
|
||||||
boost::container::small_vector<UpdateProtectRange, 16> update_ranges;
|
|
||||||
|
|
||||||
auto start_range = mask.FirstRange();
|
auto start_range = mask.FirstRange();
|
||||||
auto end_range = mask.LastRange();
|
auto end_range = mask.LastRange();
|
||||||
|
|
||||||
@ -270,9 +255,6 @@ struct PageManager::Impl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
std::scoped_lock lk(lock);
|
|
||||||
|
|
||||||
size_t base_page = (base_addr >> PAGE_BITS);
|
size_t base_page = (base_addr >> PAGE_BITS);
|
||||||
auto perms = cached_pages[base_page + start_range.first].Perm();
|
auto perms = cached_pages[base_page + start_range.first].Perm();
|
||||||
u64 range_begin = 0;
|
u64 range_begin = 0;
|
||||||
@ -281,12 +263,15 @@ struct PageManager::Impl {
|
|||||||
const auto release_pending = [&] {
|
const auto release_pending = [&] {
|
||||||
if (range_bytes > 0) {
|
if (range_bytes > 0) {
|
||||||
RENDERER_TRACE;
|
RENDERER_TRACE;
|
||||||
// Add pending (un)protect action
|
// Perform pending (un)protect action
|
||||||
update_ranges.push_back({range_begin << PAGE_BITS, range_bytes, perms});
|
Protect((range_begin << PAGE_BITS), range_bytes, perms);
|
||||||
range_bytes = 0;
|
range_bytes = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::scoped_lock lk(lock);
|
||||||
|
|
||||||
|
// Iterate pages
|
||||||
for (size_t page = start_range.first; page < end_range.second; ++page) {
|
for (size_t page = start_range.first; page < end_range.second; ++page) {
|
||||||
PageState& state = cached_pages[base_page + page];
|
PageState& state = cached_pages[base_page + page];
|
||||||
const bool update = mask.Get(page);
|
const bool update = mask.Get(page);
|
||||||
@ -320,12 +305,6 @@ struct PageManager::Impl {
|
|||||||
release_pending();
|
release_pending();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush deferred protects
|
|
||||||
for (const auto& range : update_ranges) {
|
|
||||||
Protect(range.addr, range.size, range.perms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<PageState, NUM_ADDRESS_PAGES> cached_pages{};
|
std::array<PageState, NUM_ADDRESS_PAGES> cached_pages{};
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
Common::AdaptiveMutex lock;
|
Common::AdaptiveMutex lock;
|
||||||
|
Loading…
Reference in New Issue
Block a user