About JVM in aarch64

49 views
Skip to first unread message

sig ox

unread,
Sep 2, 2022, 12:44:36 AM9/2/22
to OSv Development
Hi, I have a ongoing project about integrating OSV and JVM applications with aarch64.

However, as you addressed, I encountered same issue when executing Java applications on osv.

https://github.com/cloudius-systems/osv/issues/1196

I am not quite getting a detail but you mentioned that changing phys_mem worked for these issues.

After I saw your thread, I changed  phys_mem value
 from:0xffff800000000000 -> to:0x0000800000000000 

  in get_mem_area_base at include/osv/mmu-defs.hh, but osv did not print any message in boot process  :/

I will be appreciated if you offer the patch or commit  you did.

Thank you in advance.

Waldek Kozaczuk

unread,
Sep 2, 2022, 1:26:42 PM9/2/22
to OSv Development
Yeah, this is not as trivial as changing this single line (that is why it is not done yet :-)). But it may not be that difficult.

I will try to take a stab at it and see what can be done.

Waldek

PS. It would be nice to get Java run on ARM.

Waldek Kozaczuk

unread,
Oct 11, 2022, 10:38:26 PM10/11/22
to OSv Development
Hi,

I am not sure if you are still interested in it but I have just finally found some time to work on it and it seems I got it work. I will be sending a proper patch soon but here is an inlined one you can apply
manually to the current master:

diff --git a/arch/aarch64/arch-setup.cc b/arch/aarch64/arch-setup.cc
index 24e007c4..89dceae9 100644
--- a/arch/aarch64/arch-setup.cc
+++ b/arch/aarch64/arch-setup.cc
@@ -36,12 +36,11 @@
 
 void setup_temporary_phys_map()
 {
-    // duplicate 1:1 mapping into phys_mem
+    // duplicate 1:1 mapping into the lower part of phys_mem
     u64 *pt_ttbr0 = reinterpret_cast<u64*>(processor::read_ttbr0());
-    u64 *pt_ttbr1 = reinterpret_cast<u64*>(processor::read_ttbr1());
     for (auto&& area : mmu::identity_mapped_areas) {
         auto base = reinterpret_cast<void*>(get_mem_area_base(area));
-        pt_ttbr1[mmu::pt_index(base, 3)] = pt_ttbr0[0];
+        pt_ttbr0[mmu::pt_index(base, 3)] = pt_ttbr0[0];
     }
     mmu::flush_tlb_all();
 }
diff --git a/core/mmu.cc b/core/mmu.cc
index 007d4331..33ae8407 100644
--- a/core/mmu.cc
+++ b/core/mmu.cc
@@ -78,7 +78,7 @@ public:
 };
 
 constexpr uintptr_t lower_vma_limit = 0x0;
-constexpr uintptr_t upper_vma_limit = 0x800000000000;
+constexpr uintptr_t upper_vma_limit = 0x400000000000;
 
 typedef boost::intrusive::set<vma,
                               bi::compare<vma_compare>,
diff --git a/include/osv/mmu-defs.hh b/include/osv/mmu-defs.hh
index 18edf441..fd6a85a6 100644
--- a/include/osv/mmu-defs.hh
+++ b/include/osv/mmu-defs.hh
@@ -46,12 +46,12 @@ constexpr uintptr_t mem_area_size = uintptr_t(1) << 44;
 
 constexpr uintptr_t get_mem_area_base(mem_area area)
 {
-    return 0xffff800000000000 | uintptr_t(area) << 44;
+    return 0x400000000000 | uintptr_t(area) << 44;
 }
 
 static inline mem_area get_mem_area(void* addr)
 {
-    return mem_area(reinterpret_cast<uintptr_t>(addr) >> 44 & 7);
+    return mem_area(reinterpret_cast<uintptr_t>(addr) >> 44 & 3);
 }
 
 constexpr void* translate_mem_area(mem_area from, mem_area to, void* addr)
diff --git a/scripts/loader.py b/scripts/loader.py
index 6878a7a3..0ce782d0 100755
--- a/scripts/loader.py
+++ b/scripts/loader.py
@@ -27,7 +27,7 @@ class status_enum_class(object):
     pass
 status_enum = status_enum_class()
 
-phys_mem = 0xffff800000000000
+phys_mem = 0x400000000000
 
 def pt_index(addr, level):
     return (addr >> (12 + 9 * level)) & 511

Best regards,
Waldek

Reply all
Reply to author
Forward
0 new messages