kern: KSupervisorPageTable now checks wxn instead of setting it

This commit is contained in:
Michael Scire 2023-10-11 08:41:36 -07:00
parent c82d363682
commit b8b04d1bf3
3 changed files with 7 additions and 10 deletions

View file

@ -372,6 +372,10 @@ namespace ams::kern::arch::arm64::cpu {
this->SetBit(19, en); this->SetBit(19, en);
return *this; return *this;
} }
constexpr ALWAYS_INLINE bool GetWxn() const {
return this->GetBits(19, 1) != 0;
}
}; };
/* Accessors for timer registers. */ /* Accessors for timer registers. */

View file

@ -23,9 +23,8 @@ namespace ams::kern::arch::arm64 {
class KSupervisorPageTable { class KSupervisorPageTable {
private: private:
KPageTable m_page_table; KPageTable m_page_table;
u64 m_ttbr0_identity[cpu::NumCores];
public: public:
constexpr KSupervisorPageTable() : m_page_table(util::ConstantInitialize), m_ttbr0_identity() { /* ... */ } constexpr KSupervisorPageTable() : m_page_table(util::ConstantInitialize) { /* ... */ }
NOINLINE void Initialize(s32 core_id); NOINLINE void Initialize(s32 core_id);
@ -61,8 +60,6 @@ namespace ams::kern::arch::arm64 {
return m_page_table.GetPhysicalAddress(out, address); return m_page_table.GetPhysicalAddress(out, address);
} }
constexpr u64 GetIdentityMapTtbr0(s32 core_id) const { return m_ttbr0_identity[core_id]; }
void DumpMemoryBlocks() const { void DumpMemoryBlocks() const {
return m_page_table.DumpMemoryBlocks(); return m_page_table.DumpMemoryBlocks();
} }

View file

@ -18,12 +18,8 @@
namespace ams::kern::arch::arm64 { namespace ams::kern::arch::arm64 {
void KSupervisorPageTable::Initialize(s32 core_id) { void KSupervisorPageTable::Initialize(s32 core_id) {
/* Get the identity mapping ttbr0. */ /* Verify that sctlr_el1 has the wxn bit set. */
m_ttbr0_identity[core_id] = cpu::GetTtbr0El1(); MESOSPHERE_ABORT_UNLESS(cpu::SystemControlRegisterAccessor().GetWxn());
/* Set sctlr_el1 */
cpu::SystemControlRegisterAccessor().SetWxn(true).Store();
cpu::EnsureInstructionConsistency();
/* Invalidate the entire TLB. */ /* Invalidate the entire TLB. */
cpu::InvalidateEntireTlb(); cpu::InvalidateEntireTlb();