Skip to content

Commit becb4df

Browse files
SciresMWinterMute
authored andcommitted
use actual lowest/highest priorities, ignoring field names
1 parent 70d270d commit becb4df

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/elf2kip.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,17 @@ int ParseKipConfiguration(const char *json, KipHeader *kip_hdr) {
341341
status = 0;
342342
goto PARSE_CAPS_END;
343343
}
344+
345+
u8 real_highest_prio = (lowest_prio < highest_prio) ? lowest_prio : highest_prio;
346+
u8 real_lowest_prio = (lowest_prio > highest_prio) ? lowest_prio : highest_prio;
347+
344348
desc = highest_cpu;
345349
desc <<= 8;
346350
desc |= lowest_cpu;
347351
desc <<= 6;
348-
desc |= (lowest_prio & 0x3F);
352+
desc |= (real_highest_prio & 0x3F);
349353
desc <<= 6;
350-
desc |= (highest_prio & 0x3F);
354+
desc |= (real_lowest_prio & 0x3F);
351355
kip_hdr->Capabilities[cur_cap++] = (u32)((desc << 4) | (0x0007));
352356
} else if (!strcmp(type_str, "syscalls")) {
353357
if (!cJSON_IsObject(value)) {

src/npdmtool.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,17 @@ int CreateNpdm(const char *json, void **dst, u32 *dst_size) {
646646
status = 0;
647647
goto NPDM_BUILD_END;
648648
}
649+
650+
u8 real_highest_prio = (lowest_prio < highest_prio) ? lowest_prio : highest_prio;
651+
u8 real_lowest_prio = (lowest_prio > highest_prio) ? lowest_prio : highest_prio;
652+
649653
desc = highest_cpu;
650654
desc <<= 8;
651655
desc |= lowest_cpu;
652656
desc <<= 6;
653-
desc |= (lowest_prio & 0x3F);
657+
desc |= (real_highest_prio & 0x3F);
654658
desc <<= 6;
655-
desc |= (highest_prio & 0x3F);
659+
desc |= (real_lowest_prio & 0x3F);
656660
caps[cur_cap++] = (u32)((desc << 4) | (0x0007));
657661
} else if (!strcmp(type_str, "syscalls")) {
658662
if (!cJSON_IsObject(value)) {

0 commit comments

Comments
 (0)