A Linux-on-M1 update
source link: https://lwn.net/Articles/924557/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A Linux-on-M1 update
We are continuously upstreaming kernel features, and 6.2 notably adds device trees and basic boot support for M1 Pro/Max/Ultra machines. However, there is still a long road before upstream kernels are usable on laptops. There is no trackpad/keyboard support upstream yet.While you can boot an upstream 6.2 kernel on desktops (M1 Mac Mini, M1 Max/Ultra Mac Studio) and do useful things with it, that is only the case for 16K page size kernel builds.
No generic ARM64 distro ships 16K kernels today, to our knowledge.
(Log in to post comments)
A Linux-on-M1 update
Posted Feb 27, 2023 18:20 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]
Thank you!
A Linux-on-M1 update
Posted Feb 27, 2023 20:51 UTC (Mon) by proski (subscriber, #104) [Link]
Twitter removed that annoyance recently. Still, it's good that Asahi Linux has switched to a site more appropriate for free software announcements.
Twtitter (was A Linux-on-M1 update)
Posted Feb 28, 2023 0:42 UTC (Tue) by dskoll (subscriber, #1630) [Link]
Pretty OT, but someone told be about nitter.net. In any Twitter URL, replace twitter.com with nitter.net and you can read the thread in peace without actually going to the twitter.com site.
Twtitter (was A Linux-on-M1 update)
Posted Feb 28, 2023 2:17 UTC (Tue) by mathstuf (subscriber, #69389) [Link]
A Linux-on-M1 update
Posted Feb 27, 2023 19:25 UTC (Mon) by mfuzzey (subscriber, #57966) [Link]
I know userspace can use sysconf to obtain the kernel page size but it wouldn't surprise me if some code just hardcodes 4k.
Though it sounds like the 16k page size is temporary and they are planning on supporting 4k in the future?
A Linux-on-M1 update
Posted Feb 27, 2023 19:47 UTC (Mon) by Shawnl (guest, #163686) [Link]
A Linux-on-M1 update
Posted Feb 27, 2023 19:54 UTC (Mon) by josh (subscriber, #17465) [Link]
A Linux-on-M1 update
Posted Feb 27, 2023 20:12 UTC (Mon) by Paf (subscriber, #91811) [Link]
A Linux-on-M1 update
Posted Feb 27, 2023 20:35 UTC (Mon) by ballombe (subscriber, #9523) [Link]
mmap always returns an address that is aligned on a page boundary, so it can be passed to mprotect as is.
However if you want to mprotect only a subset of what mmap returned, you have to make sure
that subset is aligned on page boundary.
A Linux-on-M1 update
Posted Feb 27, 2023 20:43 UTC (Mon) by chris_se (subscriber, #99706) [Link]
From the manpage:
> offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).
Also, if you use MAP_FIXED (or MAP_FIXED_NOREPLACE), you have
> addr must be suitably aligned: for most architectures a multiple of the page size is sufficient; however, some architectures may impose additional restrictions.
Furthermore, while this isn't relevant to this specific thread, but if you want to write portable code and also support Windows, it uses a page size of 4kiB of x86_64, but requires all virtual memory mappings to be aligned to 64kiB. (But don't hard-code those numbers, it's possible to query this at runtime.)
I've written quite a bit of code that makes use of mmap() (especially for shared memory IPC) and I made sure to always follow the best practices here and dynamically query the OS for the correct alignments when needed. But I've also stumbled upon a lot of other code on the internet that just hard-codes these values. (Or worse, tries to be clever, and uses per-arch/os #ifdefs instead of querying them at runtime.)
Now obviously not everyone uses offset/fixed addresses, and if you just want to map an entire file (or at least a region that starts at offset 0), you don't have to care about the page size, and you'll never need to query it. (Not even on Windows.) But as soon as your use case gets a bit more complicated, you'll need to take this into account.
A Linux-on-M1 update
Posted Feb 28, 2023 2:51 UTC (Tue) by NYKevin (subscriber, #129325) [Link]
* Shockingly, POSIX doesn't say that the return value of mmap needs to be aligned at all, unlike malloc(3), so a conforming implementation could give you an odd address! But I would like to believe that no modern implementation is quite that ridiculous.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK