diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/page_table.cpp | 34 | ||||
| -rw-r--r-- | src/common/settings_common.cpp | 2 | ||||
| -rw-r--r-- | src/common/settings_common.h | 2 |
3 files changed, 12 insertions, 26 deletions
diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp index 166dc3dce..85dc18c11 100644 --- a/src/common/page_table.cpp +++ b/src/common/page_table.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/page_table.h" | 4 | #include "common/page_table.h" |
| 5 | #include "common/scope_exit.h" | ||
| 5 | 6 | ||
| 6 | namespace Common { | 7 | namespace Common { |
| 7 | 8 | ||
| @@ -11,29 +12,10 @@ PageTable::~PageTable() noexcept = default; | |||
| 11 | 12 | ||
| 12 | bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, | 13 | bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, |
| 13 | Common::ProcessAddress address) const { | 14 | Common::ProcessAddress address) const { |
| 14 | // Setup invalid defaults. | 15 | out_context->next_offset = GetInteger(address); |
| 15 | out_entry->phys_addr = 0; | 16 | out_context->next_page = address / page_size; |
| 16 | out_entry->block_size = page_size; | ||
| 17 | out_context->next_page = 0; | ||
| 18 | |||
| 19 | // Validate that we can read the actual entry. | ||
| 20 | const auto page = address / page_size; | ||
| 21 | if (page >= backing_addr.size()) { | ||
| 22 | return false; | ||
| 23 | } | ||
| 24 | |||
| 25 | // Validate that the entry is mapped. | ||
| 26 | const auto phys_addr = backing_addr[page]; | ||
| 27 | if (phys_addr == 0) { | ||
| 28 | return false; | ||
| 29 | } | ||
| 30 | 17 | ||
| 31 | // Populate the results. | 18 | return this->ContinueTraversal(out_entry, out_context); |
| 32 | out_entry->phys_addr = phys_addr + GetInteger(address); | ||
| 33 | out_context->next_page = page + 1; | ||
| 34 | out_context->next_offset = GetInteger(address) + page_size; | ||
| 35 | |||
| 36 | return true; | ||
| 37 | } | 19 | } |
| 38 | 20 | ||
| 39 | bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const { | 21 | bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const { |
| @@ -41,6 +23,12 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c | |||
| 41 | out_entry->phys_addr = 0; | 23 | out_entry->phys_addr = 0; |
| 42 | out_entry->block_size = page_size; | 24 | out_entry->block_size = page_size; |
| 43 | 25 | ||
| 26 | // Regardless of whether the page was mapped, advance on exit. | ||
| 27 | SCOPE_EXIT({ | ||
| 28 | context->next_page += 1; | ||
| 29 | context->next_offset += page_size; | ||
| 30 | }); | ||
| 31 | |||
| 44 | // Validate that we can read the actual entry. | 32 | // Validate that we can read the actual entry. |
| 45 | const auto page = context->next_page; | 33 | const auto page = context->next_page; |
| 46 | if (page >= backing_addr.size()) { | 34 | if (page >= backing_addr.size()) { |
| @@ -55,8 +43,6 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c | |||
| 55 | 43 | ||
| 56 | // Populate the results. | 44 | // Populate the results. |
| 57 | out_entry->phys_addr = phys_addr + context->next_offset; | 45 | out_entry->phys_addr = phys_addr + context->next_offset; |
| 58 | context->next_page = page + 1; | ||
| 59 | context->next_offset += page_size; | ||
| 60 | 46 | ||
| 61 | return true; | 47 | return true; |
| 62 | } | 48 | } |
diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 5960b78aa..b90e3509c 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp | |||
| @@ -35,7 +35,7 @@ bool BasicSetting::Save() const { | |||
| 35 | return save; | 35 | return save; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | bool BasicSetting::RuntimeModfiable() const { | 38 | bool BasicSetting::RuntimeModifiable() const { |
| 39 | return runtime_modifiable; | 39 | return runtime_modifiable; |
| 40 | } | 40 | } |
| 41 | 41 | ||
diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 1a290ad77..987489e8a 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h | |||
| @@ -186,7 +186,7 @@ public: | |||
| 186 | /** | 186 | /** |
| 187 | * @returns true if the current setting can be changed while the guest is running. | 187 | * @returns true if the current setting can be changed while the guest is running. |
| 188 | */ | 188 | */ |
| 189 | [[nodiscard]] bool RuntimeModfiable() const; | 189 | [[nodiscard]] bool RuntimeModifiable() const; |
| 190 | 190 | ||
| 191 | /** | 191 | /** |
| 192 | * @returns A unique number corresponding to the setting. | 192 | * @returns A unique number corresponding to the setting. |