From b310b99bdc15eff6409b892cc9307040441068ac Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 29 Sep 2022 20:20:57 +0100 Subject: [PATCH] Handle unmapped ranges in TranslateRange --- app/src/main/cpp/skyline/common/address_space.h | 3 +++ app/src/main/cpp/skyline/common/address_space.inc | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/skyline/common/address_space.h b/app/src/main/cpp/skyline/common/address_space.h index e87d5b39..140ff904 100644 --- a/app/src/main/cpp/skyline/common/address_space.h +++ b/app/src/main/cpp/skyline/common/address_space.h @@ -113,6 +113,9 @@ namespace skyline { std::pair, size_t> LookupBlockLocked(VaType virt, std::function)> cpuAccessCallback = {}) { const auto &blockEntry{this->blockSegmentTable[virt]}; + if (blockEntry.phys == nullptr) + return {span{}, 0}; + VaType segmentOffset{virt - blockEntry.virt}; span blockSpan{blockEntry.phys, blockEntry.extent}; if (cpuAccessCallback) diff --git a/app/src/main/cpp/skyline/common/address_space.inc b/app/src/main/cpp/skyline/common/address_space.inc index 56179554..3b161f10 100644 --- a/app/src/main/cpp/skyline/common/address_space.inc +++ b/app/src/main/cpp/skyline/common/address_space.inc @@ -248,11 +248,15 @@ namespace skyline { blockPhys = sparseMap; } - span cpuBlock{blockPhys, blockSize}; - if (cpuAccessCallback) - cpuAccessCallback(cpuBlock); + if (predecessor->phys) { + span cpuBlock{blockPhys, blockSize}; + if (cpuAccessCallback) + cpuAccessCallback(cpuBlock); - ranges.push_back(cpuBlock); + ranges.push_back(cpuBlock); + } else { + ranges.push_back(span{static_cast(nullptr), blockSize}); + } size -= blockSize;