mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2024-11-23 15:10:44 +00:00
Init jitfort at app start.
Signed-off-by: luyifan<842825214@qq.com>
This commit is contained in:
parent
c85d3faad3
commit
9ab4a4743d
@ -195,9 +195,6 @@ static int SetXpmConfig(const AppSpawnMgr *content, const AppSpawningCtx *proper
|
|||||||
if (IsNWebSpawnMode(content)) {
|
if (IsNWebSpawnMode(content)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
AppSpawnMsgOwnerId *ownerInfo = (AppSpawnMsgOwnerId *)GetAppProperty(property, TLV_OWNER_INFO);
|
|
||||||
int ret = InitXpmRegion();
|
|
||||||
APPSPAWN_CHECK(ret == 0, return ret, "init xpm region failed: %{public}d", ret);
|
|
||||||
|
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
char *provisionType = GetAppPropertyExt(property, MSG_EXT_NAME_PROVISION_TYPE, &len);
|
char *provisionType = GetAppPropertyExt(property, MSG_EXT_NAME_PROVISION_TYPE, &len);
|
||||||
@ -206,13 +203,19 @@ static int SetXpmConfig(const AppSpawnMgr *content, const AppSpawningCtx *proper
|
|||||||
provisionType = PROVISION_TYPE_DEBUG;
|
provisionType = PROVISION_TYPE_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppSpawnMsgOwnerId *ownerInfo = (AppSpawnMsgOwnerId *)GetAppProperty(property, TLV_OWNER_INFO);
|
||||||
|
int jitfortEnable = IsJitFortModeOn(property) ? 1 : 0;
|
||||||
|
int idType = PROCESS_OWNERID_UNINIT;
|
||||||
|
const char *ownerId = NULL;
|
||||||
if (strcmp(provisionType, PROVISION_TYPE_DEBUG) == 0) {
|
if (strcmp(provisionType, PROVISION_TYPE_DEBUG) == 0) {
|
||||||
ret = SetXpmOwnerId(PROCESS_OWNERID_DEBUG, NULL);
|
idType = PROCESS_OWNERID_DEBUG;
|
||||||
} else if (ownerInfo == NULL) {
|
} else if (ownerInfo == NULL) {
|
||||||
ret = SetXpmOwnerId(PROCESS_OWNERID_COMPAT, NULL);
|
idType = PROCESS_OWNERID_COMPAT;
|
||||||
} else {
|
} else {
|
||||||
ret = SetXpmOwnerId(PROCESS_OWNERID_APP, ownerInfo->ownerId);
|
idType = PROCESS_OWNERID_APP;
|
||||||
|
ownerId = ownerInfo->ownerId;
|
||||||
}
|
}
|
||||||
|
int ret = InitXpm(jitfortEnable, idType, ownerId);
|
||||||
APPSPAWN_CHECK(ret == 0, return ret, "set xpm region failed: %{public}d", ret);
|
APPSPAWN_CHECK(ret == 0, return ret, "set xpm region failed: %{public}d", ret);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -459,15 +462,17 @@ static int SpawnGetSpawningFlag(AppSpawnMgr *content, AppSpawningCtx *property)
|
|||||||
// Start app from begetctl for debugging.
|
// Start app from begetctl for debugging.
|
||||||
property->client.flags |= APP_BEGETCTL_BOOT;
|
property->client.flags |= APP_BEGETCTL_BOOT;
|
||||||
APPSPAWN_LOGI("Spawning: prepare app %{public}s, start from begetctl", GetProcessName(property));
|
APPSPAWN_LOGI("Spawning: prepare app %{public}s, start from begetctl", GetProcessName(property));
|
||||||
}
|
}
|
||||||
// check developer mode
|
property->client.flags |= content->flags;
|
||||||
property->client.flags |= CheckEnabled("const.security.developermode.state", "true") ? APP_DEVELOPER_MODE : 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SpawnLoadConfig(AppSpawnMgr *content)
|
static int SpawnLoadConfig(AppSpawnMgr *content)
|
||||||
{
|
{
|
||||||
LoadSilkConfig();
|
LoadSilkConfig();
|
||||||
|
// init flags that will not change until next reboot
|
||||||
|
content->flags |= CheckEnabled("const.security.developermode.state", "true") ? APP_DEVELOPER_MODE : 0;
|
||||||
|
content->flags |= CheckEnabled("persist.security.jitfort.enabled", "true") ? APP_JITFORT_MODE : 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ typedef struct TagAppSpawnMgr {
|
|||||||
pid_t servicePid;
|
pid_t servicePid;
|
||||||
struct ListNode appQueue; // save app pid and name
|
struct ListNode appQueue; // save app pid and name
|
||||||
uint32_t diedAppCount;
|
uint32_t diedAppCount;
|
||||||
|
uint32_t flags;
|
||||||
struct ListNode diedQueue; // save app pid and name
|
struct ListNode diedQueue; // save app pid and name
|
||||||
struct ListNode appSpawnQueue; // save app pid and name
|
struct ListNode appSpawnQueue; // save app pid and name
|
||||||
struct timespec perLoadStart;
|
struct timespec perLoadStart;
|
||||||
@ -196,6 +197,11 @@ APPSPAWN_INLINE int IsDeveloperModeOn(const AppSpawningCtx *property)
|
|||||||
return (property != NULL && ((property->client.flags & APP_DEVELOPER_MODE) == APP_DEVELOPER_MODE));
|
return (property != NULL && ((property->client.flags & APP_DEVELOPER_MODE) == APP_DEVELOPER_MODE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APPSPAWN_INLINE int IsJitFortModeOn(const AppSpawningCtx *property)
|
||||||
|
{
|
||||||
|
return (property != NULL && ((property->client.flags & APP_JITFORT_MODE) == APP_JITFORT_MODE));
|
||||||
|
}
|
||||||
|
|
||||||
APPSPAWN_INLINE int GetAppSpawnMsgType(const AppSpawningCtx *appProperty)
|
APPSPAWN_INLINE int GetAppSpawnMsgType(const AppSpawningCtx *appProperty)
|
||||||
{
|
{
|
||||||
return (appProperty != NULL && appProperty->message != NULL) ?
|
return (appProperty != NULL && appProperty->message != NULL) ?
|
||||||
|
@ -865,6 +865,15 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawningCtx_Msg_001, TestSize.Level0)
|
|||||||
ret = IsDeveloperModeOn(nullptr);
|
ret = IsDeveloperModeOn(nullptr);
|
||||||
EXPECT_EQ(ret, 0);
|
EXPECT_EQ(ret, 0);
|
||||||
|
|
||||||
|
//IsJitFortModeOn
|
||||||
|
ret = IsJitFortModeOn(appCtx);
|
||||||
|
EXPECT_EQ(ret, 0);
|
||||||
|
appCtx->client.flags |= APP_JITFORT_MODE;
|
||||||
|
ret = IsJitFortModeOn(appCtx);
|
||||||
|
EXPECT_EQ(ret, 1);
|
||||||
|
ret = IsJitFortModeOn(nullptr);
|
||||||
|
EXPECT_EQ(ret, 0);
|
||||||
|
|
||||||
DeleteAppSpawningCtx(appCtx);
|
DeleteAppSpawningCtx(appCtx);
|
||||||
DeleteAppSpawnMgr(mgr);
|
DeleteAppSpawnMgr(mgr);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ extern "C" {
|
|||||||
#define APP_COLD_START 0x01
|
#define APP_COLD_START 0x01
|
||||||
#define APP_ASAN_DETECTOR 0x02
|
#define APP_ASAN_DETECTOR 0x02
|
||||||
#define APP_DEVELOPER_MODE 0x04
|
#define APP_DEVELOPER_MODE 0x04
|
||||||
|
#define APP_JITFORT_MODE 0x08
|
||||||
#define APP_BEGETCTL_BOOT 0x400
|
#define APP_BEGETCTL_BOOT 0x400
|
||||||
|
|
||||||
#define MAX_LEN_SHORT_NAME 16
|
#define MAX_LEN_SHORT_NAME 16
|
||||||
|
Loading…
Reference in New Issue
Block a user