Skip to content

Commit abbc148

Browse files
committed
fix: 26.0 compilation errors
- 00_setup_coreentitlements.sh – staged the exact V2 headers from the 26.0 KDK and generated the missing CoreEntitlements/V2/Kernel.h plus os/ firehose_buffer_private.h stubs, eliminating the type/ header gaps that stopped the build. - add_iboot_header.patch – dropped in the minimal EXTERNAL_HEADERS/iBoot/boot_args_abi.h stub that 26.0 now requires. - link_kdk.patch (26.0 refresh) – extended the force-load logic so the linker pulls in libVMAPPLE.os.RELEASE.a, resolving the new set of low-level ARM64 symbols Apple keeps binary-only in this release. - remove_applefeatures_include.patch – trimmed the stray <AppleFeatures.h> include from vm_resident.c, since that header still isn’t published in the 26.0 drop. - remove_tightbeam.patch – updated for the renamed config/libTightbeam.exports, clearing the export list and preventing linker lookups for Tightbeam’s private _tb_* symbols.
1 parent e1b9670 commit abbc148

11 files changed

Lines changed: 561 additions & 6 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
| macOS 15.4 || [DB](https://github.com/blacktop/darwin-xnu-build/releases/download/v15.4/xnu-codeql.zip) | ❔ / ❔ |
3636
| macOS 15.5 || [DB](https://github.com/blacktop/darwin-xnu-build/releases/download/v15.5/xnu-codeql.zip) | ❔ / ❔ |
3737
| macOS 15.6 || [DB](https://github.com/blacktop/darwin-xnu-build/releases/download/v15.6/xnu-codeql.zip) | ✅ / ❔ |
38-
| macOS 26.0 | | [DB](https://github.com/blacktop/darwin-xnu-build/releases/download/v26.0/xnu-codeql.zip) | ❔ / ❔ |
38+
| macOS 26.0 | | [DB](https://github.com/blacktop/darwin-xnu-build/releases/download/v26.0/xnu-codeql.zip) | ❔ / ❔ |
3939

4040
> [!NOTE]
4141
> CodeQL DBs built with `MACHINE_CONFIG=VMAPPLE`

build.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,24 @@ patches() {
333333
'14.4' | '14.5')
334334
PATCH_DIR="${WORK_DIR}/patches/14.4"
335335
;;
336-
'14.6' | '15.0' | '15.1' | '15.2' | '15.3' | '15.4' | '15.5' | '15.6' | '26.0')
336+
'14.6' | '15.0' | '15.1' | '15.2' | '15.3' | '15.4' | '15.5' | '15.6')
337337
PATCH_DIR="${WORK_DIR}/patches/15.0"
338338
;;
339+
'26.'*)
340+
PATCH_DIR="${WORK_DIR}/patches/26.0"
341+
;;
339342
*)
340343
error "Invalid xnu version"
341344
exit 1
342345
;;
343346
esac
344347
cd "${WORK_DIR}/xnu"
345-
for SCRIPT in "${PATCH_DIR}"/*.sh; do
346-
running "Running script: ${SCRIPT}"
347-
bash "${SCRIPT}"
348-
done
348+
if compgen -G "${PATCH_DIR}"'/*.sh' > /dev/null; then
349+
for SCRIPT in "${PATCH_DIR}"/*.sh; do
350+
running "Running script: ${SCRIPT}"
351+
bash "${SCRIPT}"
352+
done
353+
fi
349354
for PATCH in "${PATCH_DIR}"/*.patch; do
350355
if git apply --check "$PATCH" 2> /dev/null; then
351356
running "Applying patch: ${PATCH}"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/bin/bash
2+
3+
# Setup CoreEntitlements V2 headers from KDK
4+
# This script creates the necessary directory structure and copies KDK headers
5+
6+
EXTERNAL_HEADERS="./EXTERNAL_HEADERS"
7+
KDK_CE_PATH="/Library/Developer/KDKs/KDK_26.0_25A353.kdk/System/Library/Frameworks/Kernel.framework/Versions/A/PrivateHeaders/platform/CoreEntitlements"
8+
9+
echo "Setting up CoreEntitlements V2 headers..."
10+
11+
# Create V2 directory if it doesn't exist
12+
mkdir -p "${EXTERNAL_HEADERS}/CoreEntitlements/V2"
13+
14+
# Copy Context.h and API.h from KDK (these exist in KDK)
15+
if [ -f "${KDK_CE_PATH}/V2/Context.h" ]; then
16+
echo " Copying Context.h from KDK..."
17+
cp "${KDK_CE_PATH}/V2/Context.h" "${EXTERNAL_HEADERS}/CoreEntitlements/V2/"
18+
fi
19+
20+
if [ -f "${KDK_CE_PATH}/V2/API.h" ]; then
21+
echo " Copying API.h from KDK..."
22+
cp "${KDK_CE_PATH}/V2/API.h" "${EXTERNAL_HEADERS}/CoreEntitlements/V2/"
23+
fi
24+
25+
if [ -f "${KDK_CE_PATH}/V2/Return.h" ]; then
26+
echo " Copying Return.h from KDK..."
27+
cp "${KDK_CE_PATH}/V2/Return.h" "${EXTERNAL_HEADERS}/CoreEntitlements/V2/"
28+
fi
29+
30+
# Create minimal Kernel.h stub (not in KDK, needed by amfi.h)
31+
echo " Creating Kernel.h stub..."
32+
cat > "${EXTERNAL_HEADERS}/CoreEntitlements/V2/Kernel.h" <<'EOF'
33+
#ifndef CORE_ENTITLEMENTS_V2_KERNEL_H
34+
#define CORE_ENTITLEMENTS_V2_KERNEL_H
35+
36+
#include <stdbool.h>
37+
#include <stdint.h>
38+
#include <CoreEntitlements/CoreEntitlements.h>
39+
#include <CoreEntitlements/der_vm.h>
40+
41+
struct CEQueryContext;
42+
43+
#ifdef __cplusplus
44+
extern "C" {
45+
#endif
46+
47+
typedef struct coreentitlements_kernel_api {
48+
uint32_t version;
49+
CEError_t kNoError;
50+
CEError_t kMalformedEntitlements;
51+
CEError_t kNotEligibleForAcceleration;
52+
53+
const char *(*GetErrorString)(CEError_t error);
54+
55+
CEError_t (*ContextQuery)(CEQueryContext_t ctx,
56+
const CEQueryOperation_t *__counted_by(queryLength) query,
57+
size_t queryLength);
58+
59+
CEError_t (*Validate)(const CERuntime_t rt,
60+
CEValidationResult *result,
61+
const uint8_t *__ended_by(blob_end) blob,
62+
const uint8_t *blob_end);
63+
64+
CEError_t (*AcquireUnmanagedContext)(const CERuntime_t rt,
65+
CEValidationResult validationResult,
66+
struct CEQueryContext *ctx);
67+
68+
der_vm_context_t (*der_vm_context_create)(const CERuntime_t rt,
69+
ccder_tag dictionary_tag,
70+
bool sorted_keys,
71+
const uint8_t *__ended_by(der_end) der,
72+
const uint8_t *der_end);
73+
74+
der_vm_context_t (*der_vm_execute)(der_vm_context_t context,
75+
CEQueryOperation_t op);
76+
77+
der_vm_context_t (*der_vm_execute_seq)(der_vm_context_t context,
78+
const CEQueryOperation_t *__counted_by(queryLength) query,
79+
size_t queryLength);
80+
81+
bool (*der_vm_context_is_valid)(der_vm_context_t context);
82+
bool (*der_vm_bool_from_context)(der_vm_context_t context);
83+
84+
CEError_t (*IndexSizeForContext)(CEQueryContext_t ctx, size_t *size);
85+
CEError_t (*BuildIndexForContext)(CEQueryContext_t ctx);
86+
bool (*ContextIsAccelerated)(CEQueryContext_t ctx);
87+
} coreentitlements_kernel_api;
88+
89+
typedef struct coreentitlements_kernel_api CEKernelAPI_t;
90+
91+
#ifdef __cplusplus
92+
}
93+
#endif
94+
95+
#endif /* CORE_ENTITLEMENTS_V2_KERNEL_H */
96+
EOF
97+
98+
# Create os directory for firehose header if needed
99+
mkdir -p "${EXTERNAL_HEADERS}/os"
100+
101+
# Create firehose_buffer_private.h stub
102+
echo " Creating firehose_buffer_private.h stub..."
103+
cat > "${EXTERNAL_HEADERS}/os/firehose_buffer_private.h" <<'EOF'
104+
#ifndef _OS_FIREHOSE_BUFFER_PRIVATE_H_
105+
#define _OS_FIREHOSE_BUFFER_PRIVATE_H_
106+
107+
#include <stdbool.h>
108+
#include <stdint.h>
109+
#include <mach/vm_types.h>
110+
#include <firehose/firehose_types_private.h>
111+
112+
struct firehose_buffer_range_s {
113+
uint16_t fbr_offset;
114+
uint16_t fbr_length;
115+
};
116+
117+
#define FIREHOSE_BUFFER_KERNEL_CHUNK_COUNT 1
118+
#define FIREHOSE_BUFFER_KERNEL_DEFAULT_CHUNK_COUNT 64
119+
#define FIREHOSE_BUFFER_KERNEL_DEFAULT_IO_PAGES 0
120+
121+
__BEGIN_DECLS
122+
123+
firehose_tracepoint_t __firehose_buffer_tracepoint_reserve(uint64_t timestamp,
124+
firehose_stream_t stream,
125+
uint16_t pub_size,
126+
uint16_t priv_size,
127+
uint8_t **priv_data_out);
128+
129+
void __firehose_buffer_tracepoint_flush(firehose_tracepoint_t ft,
130+
firehose_tracepoint_id_u ftid);
131+
132+
void __firehose_buffer_push_to_logd(firehose_buffer_t fb, bool for_io);
133+
void __firehose_allocate(vm_offset_t *addr, vm_size_t size);
134+
void __firehose_critical_region_enter(void);
135+
void __firehose_critical_region_leave(void);
136+
137+
bool __firehose_kernel_configuration_valid(uint32_t chunk_count, uint32_t io_pages);
138+
firehose_buffer_t __firehose_buffer_create(size_t *size);
139+
bool __firehose_merge_updates(firehose_push_reply_t reply);
140+
141+
__END_DECLS
142+
143+
#endif /* _OS_FIREHOSE_BUFFER_PRIVATE_H */
144+
EOF
145+
146+
echo "CoreEntitlements V2 setup complete."
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/EXTERNAL_HEADERS/iBoot/boot_args_abi.h b/EXTERNAL_HEADERS/iBoot/boot_args_abi.h
2+
new file mode 100644
3+
index 0000000..cc3b984
4+
--- /dev/null
5+
+++ b/EXTERNAL_HEADERS/iBoot/boot_args_abi.h
6+
@@ -0,0 +1,11 @@
7+
+#ifndef _IBOOT_BOOT_ARGS_ABI_H_
8+
+#define _IBOOT_BOOT_ARGS_ABI_H_
9+
+
10+
+/*
11+
+ * Minimal stub of the iBoot boot arguments ABI definitions needed by the
12+
+ * open-source XNU kernel build. Only the maximum environment variable data
13+
+ * size constant is required for sizing the command line buffer.
14+
+ */
15+
+#define IBOOT_MAX_ENV_VAR_DATA_SIZE 4096
16+
+
17+
+#endif /* _IBOOT_BOOT_ARGS_ABI_H_ */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff --git a/pexpert/pexpert/arm64/VMAPPLE.h b/pexpert/pexpert/arm64/VMAPPLE.h
2+
index 45b0c9d26..b0a48d0ab 100644
3+
--- a/pexpert/pexpert/arm64/VMAPPLE.h
4+
+++ b/pexpert/pexpert/arm64/VMAPPLE.h
5+
@@
6+
#include <pexpert/arm64/apple_arm64_common.h>
7+
+#undef BTI_ENFORCED
8+
+#define BTI_ENFORCED 0
9+
#undef __ARM64_PMAP_SUBPAGE_L1__
10+
#undef __ARM64_PMAP_KERN_SUBPAGE_L1__

patches/26.0/iokit.patch

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
diff --git a/iokit/DriverKit/IORPC.h b/iokit/DriverKit/IORPC.h
2+
index 7ffc6b73..5d49f179 100644
3+
--- a/iokit/DriverKit/IORPC.h
4+
+++ b/iokit/DriverKit/IORPC.h
5+
@@ -267,4 +267,6 @@ struct OSClassDescription {
6+
char metaMethodNames[0];
7+
};
8+
9+
+IORPCMessage *IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
10+
+
11+
#endif /* _IORPC_H */
12+
diff --git a/iokit/DriverKit/IOReturn.h b/iokit/DriverKit/IOReturn.h
13+
index e36d37b3..71f6b40f 100644
14+
--- a/iokit/DriverKit/IOReturn.h
15+
+++ b/iokit/DriverKit/IOReturn.h
16+
@@ -36,6 +36,10 @@
17+
#ifndef __IOKIT_IORETURN_H
18+
#define __IOKIT_IORETURN_H
19+
20+
+#include <IOKit/IORPC.h>
21+
+IORPCMessage *
22+
+IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
23+
+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
diff --git a/iokit/IOKit/IORPC.h b/iokit/IOKit/IORPC.h
28+
index 7ffc6b73..5d49f179 100644
29+
--- a/iokit/IOKit/IORPC.h
30+
+++ b/iokit/IOKit/IORPC.h
31+
@@ -267,4 +267,6 @@ struct OSClassDescription {
32+
char metaMethodNames[0];
33+
};
34+
35+
+IORPCMessage *IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
36+
+
37+
#endif /* _IORPC_H */
38+
diff --git a/iokit/Kernel/IOUserServer.cpp b/iokit/Kernel/IOUserServer.cpp
39+
index d61ffd1f..9100d9f1 100644
40+
--- a/iokit/Kernel/IOUserServer.cpp
41+
+++ b/iokit/Kernel/IOUserServer.cpp
42+
@@ -2404,7 +2404,7 @@ OSMetaClassBase::Invoke(IORPC rpc)
43+
IORPCMessage * message;
44+
45+
assert(rpc.sendSize >= (sizeof(IORPCMessageMach) + sizeof(IORPCMessage)));
46+
- message = rpc.kernelContent;
47+
+ message = IORPCMessageFromMach(rpc.message, false);
48+
if (!message) {
49+
return kIOReturnIPCError;
50+
}
51+
@@ -3630,6 +3630,45 @@ IORPCMessageFromMachReply(IORPCMessageMach * msg)
52+
return (IORPCMessage *)(uintptr_t) desc;
53+
}
54+
55+
+IORPCMessage *
56+
+IORPCMessageFromMach(IORPCMessageMach * msg, bool reply)
57+
+{
58+
+ mach_msg_size_t idx, count;
59+
+ mach_msg_port_descriptor_t * desc;
60+
+ mach_msg_port_descriptor_t * maxDesc;
61+
+ size_t size, msgsize;
62+
+ bool upgrade;
63+
+
64+
+ msgsize = msg->msgh.msgh_size;
65+
+ count = msg->msgh_body.msgh_descriptor_count;
66+
+ desc = &msg->objects[0];
67+
+ maxDesc = (typeof(maxDesc))(((uintptr_t) msg) + msgsize);
68+
+ upgrade = (msg->msgh.msgh_id != (reply ? kIORPCVersionCurrentReply : kIORPCVersionCurrent));
69+
+
70+
+ if (upgrade) {
71+
+ OSReportWithBacktrace("obsolete message");
72+
+ return NULL;
73+
+ }
74+
+
75+
+ for (idx = 0; idx < count; idx++) {
76+
+ if (desc >= maxDesc) {
77+
+ return NULL;
78+
+ }
79+
+ switch (desc->type) {
80+
+ case MACH_MSG_PORT_DESCRIPTOR:
81+
+ size = sizeof(mach_msg_port_descriptor_t);
82+
+ break;
83+
+ case MACH_MSG_OOL_DESCRIPTOR:
84+
+ size = sizeof(mach_msg_ool_descriptor_t);
85+
+ break;
86+
+ default:
87+
+ return NULL;
88+
+ }
89+
+ desc = (typeof(desc))(((uintptr_t) desc) + size);
90+
+ }
91+
+ return (IORPCMessage *)(uintptr_t) desc;
92+
+}
93+
+
94+
ipc_port_t
95+
IOUserServer::copySendRightForObject(OSObject * object, ipc_kobject_type_t type)
96+
{

patches/26.0/link_kdk.patch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/makedefs/MakeInc.def b/makedefs/MakeInc.def
2+
index 3468fbff8..87bb7e540 100644
3+
--- a/makedefs/MakeInc.def
4+
+++ b/makedefs/MakeInc.def
5+
@@ -1095,6 +1095,10 @@ LDFILES_KERNEL_ONLY = $(TARGET)/all-kpi.exp $(TARGET)/all-alias.exp $(TARGET)/sy
6+
#
7+
LD_KERNEL_LIBS = -lcc_kext
8+
LD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel
9+
+# Link opensource binary library for VMAPPLE and specific SoCs
10+
+ifneq ($(filter T6000 T6020 T8101 T8103 T8112 VMAPPLE,$(CURRENT_MACHINE_CONFIG)),)
11+
+ LDFLAGS_KERNEL_ONLY += -rdynamic -Wl,-force_load,$(KDKROOT)/System/Library/KernelSupport/lib$(CURRENT_MACHINE_CONFIG).os.$(CURRENT_KERNEL_CONFIG).a
12+
+endif
13+
14+
#
15+
# Derive SPTM/TXM and Exclaves enablement from the EDM properties.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/osfmk/vm/vm_resident.c b/osfmk/vm/vm_resident.c
2+
index 6bf2c39..1f43374 100644
3+
--- a/osfmk/vm/vm_resident.c
4+
+++ b/osfmk/vm/vm_resident.c
5+
@@ -61,7 +61,6 @@
6+
*
7+
* Resident memory management module.
8+
*/
9+
-#include <AppleFeatures.h>
10+
#include <debug.h>
11+
#include <libkern/OSDebug.h>
12+
13+
@@ -11363,4 +11362,3 @@ vm_retire_boot_pages(void)
14+
* SMC will store it in PMU SRAM under the 'sECC' key.
15+
*/
16+
uint64_t ecc_panic_physical_address = 0;
17+
-

0 commit comments

Comments
 (0)