Skip to content
Snippets Groups Projects
Commit 8f0c38ff authored by Claudio Fontana's avatar Claudio Fontana
Browse files

aarch64: mmu: distinguish between device and normal memory


we need to do that because load/store instructions
behave differently with Device-nGnRnE memory.

Signed-off-by: default avatarClaudio Fontana <claudio.fontana@huawei.com>
parent abe38111
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
namespace mmu { namespace mmu {
constexpr int max_phys_addr_size = 48; constexpr int max_phys_addr_size = 48;
constexpr int device_range_start = 0x8000000;
constexpr int device_range_stop = 0x10000000;
class arch_pt_element { class arch_pt_element {
public: public:
......
#include <osv/mmu.hh> #include <osv/mmu.hh>
#include <osv/prio.hh> #include <osv/prio.hh>
#include <osv/debug.h>
namespace mmu { namespace mmu {
...@@ -42,10 +43,16 @@ pt_element make_pte(phys addr, bool large, ...@@ -42,10 +43,16 @@ pt_element make_pte(phys addr, bool large,
arch_pt_element::set_user(&pte, false); arch_pt_element::set_user(&pte, false);
arch_pt_element::set_accessed(&pte, true); arch_pt_element::set_accessed(&pte, true);
/* at the moment we hardcode memory attributes,
but the API would need to be adapted for device direct assignment */
arch_pt_element::set_share(&pte, true); arch_pt_element::set_share(&pte, true);
arch_pt_element::set_attridx(&pte, 4);
if (addr >= mmu::device_range_start && addr < mmu::device_range_stop) {
/* we need to mark device memory as such, because the
semantics of the load/store instructions change */
debug_early_u64("make_pte: device memory at ", (u64)addr);
arch_pt_element::set_attridx(&pte, 0);
} else {
arch_pt_element::set_attridx(&pte, 4);
}
return pte; return pte;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment