+u64
+svm_get_global_region_base_va ()
+{
+#if __aarch64__
+ /* On AArch64 VA space can have different size, from 36 to 48 bits.
+ Here we are trying to detect VA bits by parsing /proc/self/maps
+ address ranges */
+ int fd;
+ unformat_input_t input;
+ u64 start, end = 0;
+ u8 bits = 0;
+
+ if ((fd = open ("/proc/self/maps", 0)) < 0)
+ clib_unix_error ("open '/proc/self/maps'");
+
+ unformat_init_clib_file (&input, fd);
+ while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (&input, "%llx-%llx", &start, &end))
+ end--;
+ unformat_skip_line (&input);
+ }
+ unformat_free (&input);
+ close (fd);
+
+ bits = count_leading_zeros (end);
+ bits = 64 - bits;
+ if (bits >= 36 && bits <= 48)
+ return ((1ul << bits) / 4) - (2 * SVM_GLOBAL_REGION_SIZE);
+ else
+ clib_unix_error ("unexpected va bits '%u'", bits);
+#endif
+
+ /* default value */
+ return 0x30000000;
+}
+