Skip to content

Update module names for T2 MacBook profiles - #275

Open
simiscoool-afk wants to merge 2 commits into
CachyOS:masterfrom
simiscoool-afk:patch-1
Open

simiscoool-afk wants to merge 2 commits into
CachyOS:masterfrom
simiscoool-afk:patch-1

Conversation

@simiscoool-afk

Copy link
Copy Markdown

No description provided.

@Revival8697 Revival8697 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simiscoool-afk

Copy link
Copy Markdown
Author

Thanks, i am quite new to this but trying to learn.

i have gotten some help from a user on the discord called several people, this should work i think, if there are any problems or anything i am happy to fix and learn.

@Revival8697

Copy link
Copy Markdown
Contributor

Resolves CachyOS/linux-cachyos#1004.

CC: @vnepogodin.

mkinitcpio -P

echo apple-bce > /etc/modules-load.d/t2.conf
echo t2bce_core >> /etc/modules-load.d/t2.conf

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to create proper module alias configuration instead of force loading any modules.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias pci:v0000106Bd00001801sv*sd*bc*sc*i* t2bce_core
alias pci:v0000106Bd00001801sv*sd*bc*sc*i* t2bce_dma
alias pci:v0000106Bd00001801sv*sd*bc*sc*i* t2bce_vhci
alias pci:v0000106Bd00001801sv*sd*bc*sc*i* t2bce_audio
alias pci:v0000106Bd00001802sv*sd*bc*sc*i* t2bce_core
alias pci:v0000106Bd00001802sv*sd*bc*sc*i* t2bce_dma
alias pci:v0000106Bd00001802sv*sd*bc*sc*i* t2bce_vhci
alias pci:v0000106Bd00001802sv*sd*bc*sc*i* t2bce_audio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to create proper module alias configuration instead of force loading any modules.

Those already exist for the new t2bce modules. I think the issue to solve now is how to fix the old file for existing installs once 6.18 also gets t2bce.

@PandaWood PandaWood Sep 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue to solve now is how to fix the old file for existing installs once 6.18 also gets t2bce.

Happy to leave this with you - I'm just a user who hit the break after 7.2 kernel upgrade...

But for what it's worth after following this, my AI suggested this for me:

a one-shot pacman hook in the chwd package that rewrites 11-chwd.conf on upgrade if it still references apple-bce. That way existing installs get fixed without users needing to do anything

If it's useful to have someone to test against, I'm on an iMac Pro

@ventureoo
ventureoo requested a review from vnepogodin August 29, 2026 14:07
cat <<EOF >/etc/mkinitcpio.conf.d/11-chwd.conf
# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT.
MODULES+=(apple-bce)
MODULES+=(t2bce_core t2bce_dma t2bce_vhci t2bce_audio)

@yiminyuan yiminyuan Aug 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't fix the issue. The installer also installs the LTS kernel, which does not ship the t2bce modules. As a result, this fix would still cause mkinitcpio to fail for the LTS kernel, potentially aborting the installation.

I think MODULES needs to be an empty array as long as LTS and mainline kernels ship different bce modules. After installation, we need to do cachy-chroot, remove one incompatible kernel, and manually do mkinitcpio before reboot.

The best way of fixing this issue is having an option to choose the kernel variants.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the installer is the LTS kernel it should install then?
the installer is requesting Apple-BCE but cant find is which is suggesting that its not the LTS kernel or its newer than 7.1.x

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, just add t2bce to LTS then, no need to complicate this.

CC: @1Naim.

@yiminyuan yiminyuan Aug 30, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the installer installs both linux-cachyos (which migrated to t2bce in 7.2) and linux-cachyos-lts (which still uses apple-bce in 6.18) by default.

Therefore, changing to MODULES+=(t2bce_core t2bce_dma t2bce_vhci t2bce_audio) would probably cause mkinitcpio to fail for the linux-cachyos-lts kernel, potentially aborting the installation—similar to what is currently happening with linux-cachyos.

@PandaWood

PandaWood commented Sep 8, 2026

Copy link
Copy Markdown

OK I admit a lot of help from Claude/Opus on this one, but here we go...

Data point from a T2 machine that isn't a MacBook — iMacPro1,1, chwd 1.24.1-1, with both linux-cachyos 7.2.3-1 and linux-cachyos-lts 6.18.48-1 installed.

@yiminyuan's concern about LTS is correct — here it is actually happening. I applied exactly the MODULES= list from this PR as a drop-in and ran mkinitcpio -P:

==> Starting build: '6.18.48-1-cachyos-lts'
==> ERROR: module not found: 't2bce_core'
==> ERROR: module not found: 't2bce_dma'
==> ERROR: module not found: 't2bce_vhci'
==> ERROR: module not found: 't2bce_audio'
==> WARNING: errors were encountered during the build. The image may not be complete.

==> Starting build: '7.2.3-1-cachyos'
==> Initcpio image generation successful

The error moves from mainline to LTS rather than going away, because mkinitcpio -P builds every preset from one shared config.

There is a middle option between "empty array" and "add t2bce to LTS", though: $KERNELVERSION is in scope when mkinitcpio sources the config, so the generated drop-in can pick per kernel and both presets build clean:

# /etc/mkinitcpio.conf.d/11-chwd.conf
_t2dir="/usr/lib/modules/${KERNELVERSION}/kernel/drivers/staging"
if [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/t2bce" ]; then
    MODULES+=(t2bce_vhci)
elif [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/apple-bce" ]; then
    MODULES+=(apple-bce)
fi
unset _t2dir

That keeps working through the transition without requiring anyone to remove a kernel or chroot after install.

On @ventureoo's alias suggestion — the aliases are already compiled into the modules, and the proposed IDs don't match them. From the 7.2.3 tree:

=== t2bce_core ===
softdep:  post: t2bce_vhci
depends:  t2bce_dma
alias:    pci:v0000106Bd00001801sv*sd*bc*sc*i*

=== t2bce_dma ===
depends:

=== t2bce_vhci ===
softdep:  pre: t2bce_core
depends:  t2bce_core

=== t2bce_audio ===
softdep:  pre: t2bce_core
depends:  snd,snd-pcm,t2bce_core
alias:    pci:v0000106Bd00001803sv*sd*bc*sc*i*

against the actual devices:

02:00.1 Apple Inc. T2 Bridge Controller [106b:1801]
02:00.2 Apple Inc. T2 Secure Enclave Processor [106b:1802]
02:00.3 Apple Inc. Apple Audio Device [106b:1803]

So t2bce_core autoloads from 1801 and pulls t2bce_dma (depends) and t2bce_vhci (softdep post); t2bce_audio autoloads separately from 1803. Nothing binds 1802. The block in the review comment maps all four modules onto 1801 and 1802, which would attach t2bce_audio to the wrong device and add aliases for two modules that are meant to arrive via depends/softdep.

The whole stack comes up with no configuration at all. On this machine /etc/modules-load.d/t2.conf has contained the stale apple-bce for months —

systemd-modules-load[394]: Failed to find module 'apple_bce'

— and until today there were no t2bce modules in the initramfs either, yet all four load correctly every boot:

t2bce_audio            77824  0
t2bce_vhci            106496  0
t2bce_core             53248  2 t2bce_audio,t2bce_vhci
t2bce_dma              36864  1 t2bce_core

That suggests the modules-load.d line can simply be dropped rather than renamed or replaced with aliases, leaving MODULES+= (for the initramfs) as the only part that actually needs deciding.

Caveat: this is an iMac Pro, where the keyboard is external and the T2 modules aren't needed to reach a LUKS prompt, so I can't confirm the initramfs side from here. Someone on a T2 MacBook that depends on the internal keyboard at unlock should check t2bce_vhci really lands in the image before the MODULES+= line is trimmed.

Separately, the current master still writes apple-bce in both places, so until this lands every T2 Mac gets a failed mkinitcpio hook on each kernel update and a Failed to find module on each boot.

@InsideTheVoid

Copy link
Copy Markdown

I have a T2 macbook with LUKS and need to manually set the module otherwise i can't use the internal keyboard or unlock my drive.

I'm running this workaround:

if [[ "$KERNELVERSION" =~ ^(6\.|7\.[01]) ]]; then
    MODULES+=(apple-bce)
else
    MODULES+=(t2bce_dma t2bce_core t2bce_vhci t2bce_audio)
fi

@PandaWood

Copy link
Copy Markdown

@InsideTheVoid thanks, that closes the gap in my comment.

A LUKS T2 MacBook that can't type without the modules in the image means the
MODULES+= line has to stay, so "empty array" isn't a general fix, and my "this
can probably be dropped" only applies to /etc/modules-load.d/t2.conf, not the
initramfs entry.

Also good to have $KERNELVERSION confirmed on a second machine.

One thing I'd change in the workaround: ^(6\.|7\.[01]) hardcodes where the
rename happened, so an LTS line moving to 7.x while still shipping apple-bce
(or a backport the other way) would silently pick the wrong name. Testing what
the kernel tree actually contains is self-correcting:

_t2dir="/usr/lib/modules/${KERNELVERSION}/kernel/drivers/staging"
if [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/t2bce" ]; then
    MODULES+=(t2bce_core t2bce_dma t2bce_vhci t2bce_audio)
elif [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/apple-bce" ]; then
    MODULES+=(apple-bce)
fi
unset _t2dir

Checked against mkinitcpio itself: KERNELVERSION is resolved before the main
config and the conf.d drop-ins are concatenated and sourced, so this works for
every preset in mkinitcpio -P and in the installer chroot, not just for the
running kernel.

@simiscoool-afk if you want to fold this into the PR, one gotcha: the profile
writes 11-chwd.conf through cat <<EOF, which expands variables when chwd
runs post_install, not when mkinitcpio later reads the file. It needs
cat <<'EOF' for the block above to survive intact. With that, both kernels
build clean and no chroot step is needed. Suggested diff against master:

 post_install = """
-    cat <<EOF >/etc/mkinitcpio.conf.d/11-chwd.conf
+    cat <<'EOF' >/etc/mkinitcpio.conf.d/11-chwd.conf
 # This file is automatically generated by chwd. PLEASE DO NOT EDIT IT.
-MODULES+=(apple-bce)
+# linux-cachyos >= 7.2 ships t2bce_*, linux-cachyos-lts still ships apple-bce.
+# Pick whichever exists for the kernel being built so `mkinitcpio -P` succeeds
+# for every installed preset.
+_t2dir="/usr/lib/modules/${KERNELVERSION}/kernel/drivers/staging"
+if [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/t2bce" ]; then
+    MODULES+=(t2bce_core t2bce_dma t2bce_vhci t2bce_audio)
+elif [ -n "${KERNELVERSION}" ] && [ -d "${_t2dir}/apple-bce" ]; then
+    MODULES+=(apple-bce)
+fi
+unset _t2dir
 EOF
     mkinitcpio -P

-    echo apple-bce > /etc/modules-load.d/t2.conf
+    # Both drivers autoload from their PCI aliases (106b:1801 / 106b:1803);
+    # remove the stale entry that fails systemd-modules-load on every boot.
+    rm -f /etc/modules-load.d/t2.conf
     kernelparams="intel_iommu=on iommu=pt pcie_ports=compat"

post_remove already deletes t2.conf, so nothing else needs to change there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants