AsahiLinux / m1n1

A bootloader and experimentation playground for Apple Silicon
MIT License
3.61k stars 210 forks source link

T6030 (M3 Pro) changes #402

Open emxll opened 2 months ago

emxll commented 2 months ago

Hey, here are some changes I made in order to get m1n1 to work (better, not perfectly though) on my chip.

A couple of notes:

I don't know how much work has been done on AIC3, but as far as I can tell, the interface is identical to (or a superset of) that of AIC2, with only the initial CFG offset being different. I've written aic3_init to be more inline with what the official driver does (mainly pulling everything from the adt (edt?) instead of hardcoding it like m1n1 does) but aic2_init is able to initialize everything just fine.

CMDLINE_LENGTH is 1024 (not 608) on my system/version of macOS but I'm not quite sure what the plan is for addressing this issue which is why I'm not submitting a patch.

The RTBuddy/__OSLOG (causing illegal address panics in phystokv) fix for booting macOS isn't enough for my kernelcache. I'll investigate this more if I can find the time.

marcan commented 1 month ago

I think you'll want to look at the PRs by @dberlin (e.g. #364) since he did most of the M3 m1n1 bringup already, it's just not merged yet because we didn't get around to pushing forward with that since priorities shifted elsewhere.

emxll commented 1 month ago

Once those changes have been merged i'll rebase and see if I'm still missing anything.

flatz commented 1 month ago

@emxll @marcan I was able to fix __OSLOG panics by tweaking segment_names/segment_ranges cleaning code on Python's side:

adt.py:

def remove_os_log_segments(adt, name):
    key = f"/arm-io/{name}"
    if key in adt:
        entry = adt[key]
        try:
            segment_names = entry.segment_names.split(";")
            idx = segment_names.index("__OS_LOG")
            del segment_names[idx]
            entry.segment_names = ";".join(segment_names)
            entry.segment_ranges = entry.segment_ranges[:idx * 32] + entry.segment_ranges[(idx + 1) * 32:] # struct adt_segment_ranges
            return True
        except:
            pass
    return False

Change block within for name in ("mtp", "aop"):: init.py:

        for name in ("mtp", "aop", "dcp", "dcpext"):
            if name in self.adt["/arm-io"]:
                key = f"/arm-io/{name}"
                remove_os_log_segments(self.adt, name)
                remove_os_log_segments(self.adt, f"{name}/iop-{name}-nub")

chainload.py:

for name in ("mtp", "aop", "dcp", "dcpext"):
    if name in u.adt["/arm-io"]:
        key = f"/arm-io/{name}"
        remove_os_log_segments(u.adt, name)
        remove_os_log_segments(u.adt, f"{name}/iop-{name}-nub")

Also older cleaning code has a bug, OSLOG segment could be in the middle and not in the end as it may expect here: https://github.com/AsahiLinux/m1n1/blob/9d445d829170edbff6e703705b0c82210024fa6a/proxyclient/m1n1/hv/__init__.py#L1741

dberlin commented 1 month ago

Once those changes have been merged i'll rebase and see if I'm still missing anything.

FWIW: I'm around and don't have a lot of time to code (but will in a few months, actually).

At the point i uploaded all my PR's, i could boot and run osx under m1n1.

I still have notes on things if you run into any issues.

mildsunrise commented 2 weeks ago

although most of the patches here are no longer needed, some are still of value. @emxll could you add the missing sign offs when you have some time?