Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions build-hnp/qemu-vroot/0007-fix-jit-on-OHOS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From fc2deebbb54669dba84557523d654dae0b99dbdd Mon Sep 17 00:00:00 2001
From: hackeris <hackeris@qq.com>
Date: Tue, 12 Aug 2025 23:54:40 +0800
Subject: [PATCH 7/7] fix jit on OHOS

---
include/qemu/osdep.h | 2 ++
tcg/region.c | 2 --
util/osdep.c | 11 ++++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 96fe51bc390..29c032280f5 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -166,6 +166,8 @@ QEMU_EXTERN_C int daemon(int, int);

#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
#include "system/os-posix.h"
+#include <sys/prctl.h>
+#define PRCTL_SET_JITFORT 0x6a6974
#endif

#if defined(EMSCRIPTEN)
diff --git a/tcg/region.c b/tcg/region.c
index 718447044c2..4c63893e7d7 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -572,8 +572,6 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot,
#ifndef CONFIG_TCG_INTERPRETER
#ifdef CONFIG_POSIX
#include "qemu/memfd.h"
-#include <sys/prctl.h>
-#define PRCTL_SET_JITFORT 0x6a6974

static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
{
diff --git a/util/osdep.c b/util/osdep.c
index 770369831bc..56bf1036d4d 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -84,7 +84,16 @@ static int qemu_mprotect__osdep(void *addr, size_t size, int prot)
}
return 0;
#else
- if (mprotect(addr, size, prot)) {
+ if (prot & PROT_EXEC) {
+ // required by OHOS
+ prctl(PRCTL_SET_JITFORT, 0, 0);
+ }
+ int ret = mprotect(addr, size, prot);
+ if (prot & PROT_EXEC) {
+ // required by OHOS
+ prctl(PRCTL_SET_JITFORT, 0, 1);
+ }
+ if (ret) {
error_report("%s: mprotect failed: %s", __func__, strerror(errno));
return -1;
}
--
2.43.0

1 change: 1 addition & 0 deletions build-hnp/qemu-vroot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ all: download/qemu-10
cd temp/qemu-10 && git apply ../../0004-enable-jit-on-OHOS.patch
cd temp/qemu-10 && git apply ../../0005-fix-argv-for-geust-on-OHOS.patch
cd temp/qemu-10 && git apply ../../0006-support-redirecting-file-access-to-specified-root-fi.patch
cd temp/qemu-10 && git apply ../../0007-fix-jit-on-OHOS.patch
cd temp/qemu-10 && \
PKG_CONFIG=$(shell which pkg-config) \
PKG_CONFIG_PATH= \
Expand Down
62 changes: 62 additions & 0 deletions build-hnp/qemu/0006-fix-jit-on-OHOS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From fc2deebbb54669dba84557523d654dae0b99dbdd Mon Sep 17 00:00:00 2001
From: hackeris <hackeris@qq.com>
Date: Tue, 12 Aug 2025 23:54:40 +0800
Subject: [PATCH 6/6] fix jit on OHOS

---
include/qemu/osdep.h | 2 ++
tcg/region.c | 2 --
util/osdep.c | 11 ++++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 96fe51bc390..29c032280f5 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -166,6 +166,8 @@ QEMU_EXTERN_C int daemon(int, int);

#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
#include "system/os-posix.h"
+#include <sys/prctl.h>
+#define PRCTL_SET_JITFORT 0x6a6974
#endif

#if defined(EMSCRIPTEN)
diff --git a/tcg/region.c b/tcg/region.c
index 718447044c2..4c63893e7d7 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -572,8 +572,6 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot,
#ifndef CONFIG_TCG_INTERPRETER
#ifdef CONFIG_POSIX
#include "qemu/memfd.h"
-#include <sys/prctl.h>
-#define PRCTL_SET_JITFORT 0x6a6974

static int alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp)
{
diff --git a/util/osdep.c b/util/osdep.c
index 770369831bc..56bf1036d4d 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -84,7 +84,16 @@ static int qemu_mprotect__osdep(void *addr, size_t size, int prot)
}
return 0;
#else
- if (mprotect(addr, size, prot)) {
+ if (prot & PROT_EXEC) {
+ // required by OHOS
+ prctl(PRCTL_SET_JITFORT, 0, 0);
+ }
+ int ret = mprotect(addr, size, prot);
+ if (prot & PROT_EXEC) {
+ // required by OHOS
+ prctl(PRCTL_SET_JITFORT, 0, 1);
+ }
+ if (ret) {
error_report("%s: mprotect failed: %s", __func__, strerror(errno));
return -1;
}
--
2.43.0

1 change: 1 addition & 0 deletions build-hnp/qemu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ all: download/qemu-10
cd temp/qemu-10 && git apply ../../0003-update-gitignore.patch
cd temp/qemu-10 && git apply ../../0004-enable-jit-on-OHOS.patch
cd temp/qemu-10 && git apply ../../0005-fix-argv-for-geust-on-OHOS.patch
cd temp/qemu-10 && git apply ../../0006-fix-jit-on-OHOS.patch
cd temp/qemu-10 && \
PKG_CONFIG=$(shell which pkg-config) \
PKG_CONFIG_PATH= \
Expand Down