Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

ipa: fix the receive-ring priming off-by-one -- a GSI ring holds at most slots-1 outstanding (the doorbell is the write pointer; level with the read pointer at the ring base it reads as empty, not full), so priming all 'slots' TREs left the hardware seeing no receive buffers; now prime slots-1, and the TX and command rings keep one slot free too; receive and transmit completions tracked in order through ch->done, fixing a spurious slot-mismatch warning; prebuilt kernel

shimoku74c38086816af2
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMS
index 0178142..6f14ad4 100644
--- a/prebuilt/SHA256SUMS
+++ b/prebuilt/SHA256SUMS
@@ -1,6 +1,6 @@
-Built 2026-10-25 20:30 from this tree.
+Built 2026-10-25 21:08 from this tree.
-e6051a7ba5f2869417307b7ac5307080b72bef977ac94111dfde5722d864b5a4 prebuilt/mach.development.bcm2837
+a39443ca2ec27977f7b30a8adf765819db04e832c21f6ec3d5423062fcea4df6 prebuilt/mach.development.bcm2837
3de0d8b2095989a9a8f9f9679b8bec01d80bad38eee535d934d29b7b76fee984 prebuilt/loader.efi
932c856c04e87611b16c872da37c461d572c6258da0202ecd875d91c29886e03 prebuilt/userland/HakiosAudio
45bffe2da6b2484836bd29074b39bd5cc67b4cdaa253c2aa39561ce5188d6ddc prebuilt/userland/child
diff --git a/prebuilt/mach.development.bcm2837 b/prebuilt/mach.development.bcm2837
index 21224ae..13dc85b 100755
Binary files a/prebuilt/mach.development.bcm2837 and b/prebuilt/mach.development.bcm2837 differ
diff --git a/xnu/files/bsd/dev/hakios.ipa.c b/xnu/files/bsd/dev/hakios.ipa.c
index 6fd6af7..e2d9bf9 100644
--- a/xnu/files/bsd/dev/hakios.ipa.c
+++ b/xnu/files/bsd/dev/hakios.ipa.c
@@ -533,7 +533,7 @@ ipa_command(const char *what, uint8_t opcode, const void *payload, size_t size)
uint32_t slot = command.next % command.slots;
struct command_done waiting = { .tre = command.tre_ring.phys + slot * ELEMENT_SIZE };
- if (size > command.buffer_size || command.next - command.done >= command.slots) {
+ if (size > command.buffer_size || command.next - command.done >= command.slots - 1) {
return false;
}
memcpy((void *)slot_virt(&command, slot), payload, size);
@@ -651,11 +651,13 @@ receive_event(struct channel *ch, const struct event *e, void *context)
}
return;
}
- if (slot != ch->next % ch->slots) {
+ /* receives complete in order; ch->done is the next expected slot, ch->next the next to post (slots-1 ahead) */
+ if (slot != ch->done % ch->slots) {
if (ch->errors++ < 4) {
- printf("ipa: %s: slot %u finished while slot %u was expected\n", ch->name, slot, ch->next % ch->slots);
+ printf("ipa: %s: slot %u finished while slot %u was expected\n", ch->name, slot, ch->done % ch->slots);
}
}
+ ch->done++;
buffer = (const uint8_t *)slot_virt(ch, slot);
if (length > ch->buffer_size) {
length = ch->buffer_size;
@@ -716,7 +718,7 @@ hakios_ipa_transmit(uint8_t mux, const void *packet, size_t length)
}
lck_mtx_lock(&ipa_lock);
channel_events(ch, transmit_event, NULL);
- if (ch->next - ch->done >= ch->slots) {
+ if (ch->next - ch->done >= ch->slots - 1) { /* one slot always left free: write==read means empty */
ch->dropped++;
lck_mtx_unlock(&ipa_lock);
return false;
@@ -852,7 +854,9 @@ hakios_ipa_data_setup(void)
}
ch->started = true;
if (!ch->to_ipa) {
- for (uint32_t slot = 0; slot < ch->slots; slot++) {
+ /* one short of the ring: the doorbell is the write pointer, and writing it level with
+ * the read pointer (base) would mean "empty", not "full" */
+ for (uint32_t slot = 0; slot + 1 < ch->slots; slot++) {
receive_post(ch, slot);
}
channel_doorbell(ch);