mirror of
https://github.com/AngelAuraMC/angelauramc-openjdk-build.git
synced 2025-09-16 15:47:40 -04:00
Fix[JDK21]: fix patch, add breakpoint codepath for TXM devices
This commit is contained in:
parent
a8ca6a4c1c
commit
89b325ac14
@ -88,6 +88,7 @@ ln -s -f $CUPS_DIR/cups $ANDROID_INCLUDE/
|
|||||||
cd openjdk-${TARGET_VERSION}
|
cd openjdk-${TARGET_VERSION}
|
||||||
|
|
||||||
# Apply patches
|
# Apply patches
|
||||||
|
git add .
|
||||||
git reset --hard
|
git reset --hard
|
||||||
if [[ "$BUILD_IOS" != "1" ]]; then
|
if [[ "$BUILD_IOS" != "1" ]]; then
|
||||||
find ../patches/jre_${TARGET_VERSION}/android -name "*.diff" -print0 | xargs -0 -I {} sh -c 'echo "Applying {}" && git apply --reject --whitespace=fix {} || (echo "git apply failed (Android patch set)" && exit 1)'
|
find ../patches/jre_${TARGET_VERSION}/android -name "*.diff" -print0 | xargs -0 -I {} sh -c 'echo "Applying {}" && git apply --reject --whitespace=fix {} || (echo "git apply failed (Android patch set)" && exit 1)'
|
||||||
|
@ -117,37 +117,60 @@ index c895ff5cc..d864c9d8a 100644
|
|||||||
if (s == nullptr) {
|
if (s == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp
|
diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp
|
||||||
index faf9d9f64..9c2adc2e4 100644
|
index faf9d9f64..8828e855b 100644
|
||||||
--- a/src/hotspot/os/bsd/os_bsd.cpp
|
--- a/src/hotspot/os/bsd/os_bsd.cpp
|
||||||
+++ b/src/hotspot/os/bsd/os_bsd.cpp
|
+++ b/src/hotspot/os/bsd/os_bsd.cpp
|
||||||
@@ -136,6 +136,106 @@ static volatile int processor_id_map[processor_id_map_size];
|
@@ -136,6 +136,129 @@ static volatile int processor_id_map[processor_id_map_size];
|
||||||
static volatile int processor_id_next = 0;
|
static volatile int processor_id_next = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+#ifdef __APPLE__
|
+#ifdef __APPLE__
|
||||||
+address os::Bsd::debug_jit_mapping_mirrored = NULL;
|
+address os::Bsd::debug_jit_mapping_mirrored = NULL;
|
||||||
+
|
+
|
||||||
+__attribute__((noinline,optnone))
|
+__attribute__((naked,noinline,optnone))
|
||||||
+void BreakGetJITMapping(char **map, size_t bytes) {
|
+char* BreakGetJITMapping(char *map, size_t bytes) {
|
||||||
|
+ asm("brk #0x69 \n"
|
||||||
|
+ "ret");
|
||||||
|
+}
|
||||||
+
|
+
|
||||||
|
+bool DeviceRequiresTXMWorkaround() {
|
||||||
|
+ if(__builtin_available(iOS 19.0, *)) {
|
||||||
|
+ DIR *d = opendir("/private/preboot");
|
||||||
|
+ struct dirent *dir;
|
||||||
|
+ char txmPath[PATH_MAX];
|
||||||
|
+ while ((dir = readdir(d)) != NULL) {
|
||||||
|
+ if(strlen(dir->d_name) == 96) {
|
||||||
|
+ snprintf(txmPath, sizeof(txmPath), "/private/preboot/%s/usr/standalone/firmware/FUD/Ap,TrustedExecutionMonitor.img4", dir->d_name);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ closedir(d);
|
||||||
|
+ return access(txmPath, F_OK) == 0;
|
||||||
|
+ } else {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+char* get_debug_jit_mapping(size_t bytes) {
|
+char* get_debug_jit_mapping(size_t bytes) {
|
||||||
+ // the map we got has debuggable flag, r-x, setup mirrored map
|
+ // the map we got has debuggable flag, r-x, setup mirrored map
|
||||||
+ vm_address_t buf_rx = 0;
|
+ vm_address_t buf_rx = 0;
|
||||||
+ if(MirrorMappedCodeCache) {
|
+ if(MirrorMappedCodeCache) {
|
||||||
|
+ if(DeviceRequiresTXMWorkaround()) {
|
||||||
+ printf("[JIT26] Requesting %zu MB for JIT mapping\n", bytes/ (1024 * 1024));
|
+ printf("[JIT26] Requesting %zu MB for JIT mapping\n", bytes/ (1024 * 1024));
|
||||||
+ BreakGetJITMapping((char**)&buf_rx, bytes);
|
+ buf_rx = (vm_address_t)BreakGetJITMapping(NULL, bytes);
|
||||||
|
+ }
|
||||||
+ if(buf_rx) {
|
+ if(buf_rx) {
|
||||||
+ printf("[JIT26] Got JIT mapping %p from debugger\n", (void*)buf_rx);
|
+ printf("[JIT26] Got JIT mapping %p from debugger\n", (void*)buf_rx);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ buf_rx = (vm_address_t)mmap(NULL, bytes, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
+ buf_rx = (vm_address_t)mmap(NULL, bytes, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
|
||||||
+ if(!buf_rx) {
|
+ if(!buf_rx) {
|
||||||
+ printf("[JIT26] Failed to allocate RX region\n");
|
+ printf("[JIT26] Failed to allocate RX region\n");
|
||||||
+ return NULL;
|
+ return NULL;
|
||||||
+ }
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
+ vm_address_t buf_rw = 0;
|
+ vm_address_t buf_rw = 0;
|
||||||
+
|
+
|
||||||
+ vm_prot_t cur_prot, max_prot;
|
+ vm_prot_t cur_prot, max_prot;
|
||||||
@ -227,15 +250,34 @@ index faf9d9f64..9c2adc2e4 100644
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// utility functions
|
// utility functions
|
||||||
|
|
||||||
@@ -757,6 +857,7 @@ void os::Bsd::clock_init() {
|
@@ -757,26 +880,6 @@ void os::Bsd::clock_init() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+
|
-#ifdef __APPLE__
|
||||||
|
-static bool rwxChecked, rwxAvailable;
|
||||||
|
-#endif
|
||||||
|
-bool os::Bsd::isRWXJITAvailable() {
|
||||||
|
-#ifdef __APPLE__
|
||||||
|
- if (!rwxChecked) {
|
||||||
|
- rwxChecked = true;
|
||||||
|
- const int flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS | MAP_JIT;
|
||||||
|
- char* addr = (char*)::mmap(0, getpagesize(), PROT_NONE, flags, -1, 0);
|
||||||
|
- rwxAvailable = addr != MAP_FAILED;
|
||||||
|
- if (rwxAvailable) {
|
||||||
|
- ::munmap(addr, getpagesize());
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- return rwxAvailable;
|
||||||
|
-#else
|
||||||
|
- return true;
|
||||||
|
-#endif
|
||||||
|
-}
|
||||||
|
-
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static bool rwxChecked, rwxAvailable;
|
|
||||||
#endif
|
jlong os::javaTimeNanos() {
|
||||||
@@ -1576,7 +1677,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
|
@@ -1576,7 +1679,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
if (exec) {
|
if (exec) {
|
||||||
// Do not replace MAP_JIT mappings, see JDK-8234930
|
// Do not replace MAP_JIT mappings, see JDK-8234930
|
||||||
@ -244,7 +286,7 @@ index faf9d9f64..9c2adc2e4 100644
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1726,6 +1827,14 @@ static int anon_munmap(char * addr, size_t size) {
|
@@ -1726,6 +1829,14 @@ static int anon_munmap(char * addr, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::pd_reserve_memory(size_t bytes, bool exec) {
|
char* os::pd_reserve_memory(size_t bytes, bool exec) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user