2021-06-07
00:20jevinskie[m] has joined #asahi
00:22al3xtjames has quit [Read error: Connection reset by peer]
00:23al3xtjames has joined #asahi
01:37bgb_ has joined #asahi
01:40bps has quit [charon.oftc.net liquid.oftc.net]
01:40apetresc has quit [charon.oftc.net liquid.oftc.net]
01:40ave has quit [charon.oftc.net liquid.oftc.net]
01:40skipwich has quit [charon.oftc.net liquid.oftc.net]
01:42ave has joined #asahi
01:42skipwich has joined #asahi
01:48bps has joined #asahi
02:01inglor has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
02:14phiologe has joined #asahi
02:14inglor has joined #asahi
02:17PhilippvK has quit [Ping timeout: 480 seconds]
02:46klltkr has joined #asahi
03:12skipwich has quit [Ping timeout: 480 seconds]
04:01marvin24_ has joined #asahi
04:04marvin24 has quit [Ping timeout: 480 seconds]
04:13zopieux has quit [Ping timeout: 480 seconds]
04:37klltkr has quit [Ping timeout: 480 seconds]
05:14VinDuv has joined #asahi
06:25VinDuv has quit [Quit: Leaving.]
06:58bisko has joined #asahi
07:02bisko has quit []
07:06bisko has joined #asahi
07:06bisko has quit []
07:37Glanzmann has joined #asahi
07:43pitust[m] has joined #asahi
07:43kettenissome more OpenBSD developers are getting involved, so I have been working on the installer for folks to be able to install on NVMe without bricking their machines ;)
07:50bisko has joined #asahi
07:56kettenisall works although the ethernet gets the default address programmed in the controller which I suspect is the same for all M1 machines
07:57kettenissome incompatible device tree binding changes coming up though, which is why I'm not advertising M1 support in OpenBSD much yet
08:05bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:10apetresc has joined #asahi
08:14bisko has joined #asahi
08:16GreatGodvin has joined #asahi
08:24_jannau_kettenis: I haven't seen any during kernel compiles. booting linux directly from m1n1 with sven's dart/usb-c patches
08:28kettenisbut if an upstream kernel with sven's patches works fine, this must be an OpenBSD problem
08:30EER has joined #asahi
08:35kettenisand inserted loads of strong memory barriers in the kernel that didn't seem to make a significant difference
08:36choozy has joined #asahi
08:40GreatGodvin has quit [Quit: GreatGodvin]
09:14marcanWe do know that OSX configures some "interesting" nonstandard memory behavior, but I don"t *think* our chicken bits do. Also, that would probably break VMs unless they reset them in Hypervisor.framework
09:41pitust[m]i'm trying to shrink APFS partition according to the instructions at https://github.com/AsahiLinux/docs/wiki/Developer-Quickstart
10:04Glanzmannpitust[m]: If I remeber correctly, you sometimes have to wait for a long time. I have done it throught he GUI. Maybe give it an hour?
10:16GreatGodvin has joined #asahi
10:22GreatGodvin has quit [Quit: GreatGodvin]
10:32EER has quit [Ping timeout: 480 seconds]
10:41bgb has joined #asahi
10:41bgb_ has quit [Ping timeout: 480 seconds]
10:44choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
10:47zopieux has joined #asahi
11:01marcanpitust[m]: are you doing this from 1TR? it should work live too, but much more likely to hang
11:15GreatGodvin has joined #asahi
11:16GreatGodvin has quit []
11:24GreatGodvin has joined #asahi
11:29GreatGodvin has quit []
11:29GreatGodvin has joined #asahi
11:45malvo has quit [Ping timeout: 480 seconds]
12:02bisko has quit [Read error: Connection reset by peer]
12:17choozy has joined #asahi
12:30GreatGodvin has left #asahi [#asahi]
12:46choozy has quit [Ping timeout: 480 seconds]
12:54choozy has joined #asahi
13:19bgb has quit [Ping timeout: 480 seconds]
13:35svenyou'll also need https://lore.kernel.org/linux-usb/YL3ve%2FrxTlIzErlX@infradead.org/T/#m23583793ac437503588690662f3daffb0e01f9d2 if you run with a 4k kernel or want the iommu in bypass mode
13:45_jannau_sven: indeed. Did you remove the dts changes? if I'm not mistaken I was using the dtb from the kernel to boot last week (before friday).
14:07adamcstephens has quit [Quit: The Lounge - https://thelounge.chat]
14:08adamcstephens has joined #asahi
14:18bisko has joined #asahi
14:21arndsven: did you manage to enable bypass mode on all iommu instances in the end, or do you program a linear map into them?
14:23adamcstephens has quit [Quit: The Lounge - https://thelounge.chat]
14:26bisko has quit [Read error: Connection reset by peer]
14:26j_eyarnd: https://github.com/AsahiLinux/linux/commit/c502200195e78672a10b9a01b595eb605b15a0ef#diff-981ebe4a9626be1eac3d742dbca78b8bf3000c22834dfb4510ef71a975bc6802R522
14:26bisko has joined #asahi
14:30svenso for the pcie ones i have a dma-ranges on the pcie bridge that limits DMA to the first 4G
14:31svenand then i just program a static linear map and tell the iommu api that this iommu really needs a bypass domain
14:33marcanI still think we outright shouldn't support putting those in bypass mode, or at most do it only with a nondefault, scary parameter
14:33arndok. I suppose bypass mode on the thunderbolt wouldn't make much of a difference in practice, since that is too dangerous for practical use
14:36marcanthough really nobody should be using these things with 4K pages, given all this, except for like installers
14:36marcanbut the wifi attack surface is a couple orders of magnitude worse (and it's had a bunch of CVEs already)
14:39marcando we even know if the GPU MMU does 4K pages? because if it doesn't, lol no 3D for 4K kernels
14:39arndMost developer boards still have only Cortex-A53 or Cortex-A72, which don't support 16KB pages at all
14:40arndI expect distros to fight that very hard, as it adds a lot of extra validation work to have more than one
14:41marcanif we can't make the kernel somehow deal with a 16K IOMMU when built for 4k, there is no other good option
14:41sveni'd be happy with 4k without thunderbolt as a fallback. that way most people can at least use this
14:42svenand i'm sure there will be third party repos that will ship the distro kernels with 16k support then
14:42arndI still hope that opening up the discussion again will at least make some users understand just how bad 64K pages are for general-purpose workloads
14:43marcaninsmod dart.ko expose_me_to_broadcom_firmware_bugs=1 (or whatever module we put the gate in)
14:43arndthough a more likely outcome is that a lot of users run microbenchmarks that show 64K pages being faster because of lower TLB pressure
14:43svenit might be possible to make the kernel deal with 16k iommu when built for 4k but the dart driver itself is already >1k loc or so
14:44marcanpeople should be *aware* that running in this mode is crap for security for several reasons, but especially that one
14:44marcanif distros want to flip the flag instead of ship 16k, that has to be an explicit decision
14:46arndsven: right, that fixing the common iommu code to work with this should be possible by the time that distros actually want to ship installers to work on mac. That is still a going to be a while, and your solution is enough for an initial merge
14:48marcanand then we can be more specific about just breaking wifi by default if we want to in the future
14:49arndfor the streaming mappings, I think there is already a small security hole regardless of the iommu type and the page size, as dma_map_single() often gets passed small buffers that live in the same page as other (possibly sensitive) data
14:50svenj_ey: the point is that reviewing 1k lines of code is already quite a lot. adding the 16k/4k thing on top that makes it even worse
14:52svendart also supports subpage protection fwiw, but patching *that* into the iommu code would be more annoying
14:52arnddrivers using only the coherent interfaces (dma_alloc_coherent() etc), currently get full pages, so those are safe as long as the page size matches, or we change the common code to use io page size allocations
14:53arndsven: what are the parameters for sub-page protections? Can you e.g. map an arbitrary naturally aligned 64 byte range in a page?
14:54sveni think so. i haven't tested this in detail but from what i can tell you can limit access inside the page down to that level
14:54arndok, perfect. So the dart would actually end up being more secure than most others for the streaming API ;-)
15:00arnddo if we find a way change the iommu ->map() callback to pass the location within the page and do sub-page protection as well as fix the dma-iommu code to no longer assume iopagesize<=page_suze, I think that should allow safely using wireless and thunderbolt with 4KB pages, it would only prevent you from using device assignment into VM guests and user space like DPDK
15:02svenso i don't think the iommu_pagesize > cpu_pagesize fix is going to require a lot of changes, but it'll certainly require reviewing the entire code to be comfortable it doesn't break anything by accident
15:05arndsven: have you found out if dart can do both cache-coherent dma mappings and non-coherent ones? Is bypass mode still coherent?
15:05marcanarnd: by the way, "small buffers that live in the same page as other (possibly sensitive) data" isn't a "small" security hole
15:06brentr123[m]I wonder if the ps5 can get pwned the same way ;)
15:08arndmarcan: I wonder if it makes sense to address this as a general security issue then, and start by making the dma-iommu code use bounce buffers as an option, and make the sub-page protection as a way to make it faster
15:09arndbloom: mostly a waste of memory, e.g. when dealing with small files your page cache often blows up to 5x the memory usage
15:11svenarnd: afaik the iommu code already has the option to use bounce buffers for untrusted pci devices
15:11marcanarnd: certainly, if we can make it use bounce buffers easily for sub-page maps, it makes sense to start off with that
15:11arndbloom: it's extremely workload specific, and a number of other things also go wrong: anything that small bits of data but requires page alignment can explode. Other things I'm sure cause problems are swapspace handling, and network buffers
15:13arndbloom: ok the other hand, anything that is purely CPU bound and fits within a small working set tends to benefit from the lower TLB usage, so microbenchmarks almost always show 64KB pages come out winning
15:16arndWhen I tested kernel builds on Amazon EC2 comparing page sizes, I found that with 4GB RAM per core, 64KB pages were a few percent faster, but once I reduced the amount of RAM I found that 4KB pages still worked fine even after it started swapping, but as soon as the 64KB kernel went into swap space, it would start thrashing and never complete the kernel build
15:16arndor complete it after a day of wearing out the disks, instead of a few minutes of building in RMA
15:17sveni think iommu_dma_map_page uses __iommu_dma_map_swiotlb which uses bounce buffers. and from what i can tell dma_map_page is used for streaming dma
15:24arndit looks like that was added fairly recently (last November) based on code from the Intel iommu driver.
15:27arndsven: the dev_is_untrusted() logic in there looks like the exact thing to use for determining whether to set up a linear map or not
15:28arndfor the thunderbolt ports, it would be set using the "external-facing" property, for the wireless device I suppose the driver could set it
15:40svenyup, in iommu_get_def_domain_type there is a check before it calls to the iommu driver to get the default domain: if (dev_is_pci(dev) && to_pci_dev(dev)->untrusted) return IOMMU_DOMAIN_DMA;
15:41svenso if something is untrusted the dart driver will never see a IOMMU_DOMAIN_IDENTITY unless the user forces it
15:45arndThat sounds exactly like what we want, though I'm not sure it would work if the wireless driver sets the flag from the probe function, that is probably too late.
15:50malvo has joined #asahi
15:51svenhm, but i think we'll somehow need the wireless device in the dt anyway since it needs that special poweron sequence
15:52malvo has left #asahi [#asahi]
15:55arndsven: right, that would work, we could just put the "external-facing" property on the bridge node, but that feels wrong, as what we really want is to mark that whole class of broadcom wireless devices (or maybe any wireless network device?) as untrusted, regardless of what machine they are used in
16:07choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
16:30VinDuv has joined #asahi
16:49skipwich has joined #asahi
16:54pugguu has joined #asahi
17:01marvin24 has joined #asahi
17:04marvin24_ has quit [Ping timeout: 480 seconds]
17:25bisko has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
17:26EER has joined #asahi
18:23sveniirc the region was encoded in the top 24 or so bits of the PTE and you had to clear bit 0 or 1 to enable it
18:28Emantorsven: The pgsize calculation in the dart driver looks wrong, it's doing a 0x4 > PAGE_SIZE comparison for the USB darts. This way the force_bypass parameter will never work.
18:42EmantorGreat, now that the dart driver works by enabling bypass mode, gadget mode receives requests. Sorry for the noise.
18:44sventurns out you don't actually need a different phy init sequence for gadget/host mode (at least for usb2)
18:48sveni didn't try switching but the same phy init pokes i have work for either mode without an additional phy driver in linux
18:49svenoh, when you try to switch you'll run into the "using the same port twice isn't supported" issue :D
18:49pipcet[m]sven: we can just reset the port once every few seconds except when it's connected :-)
18:50svenso if you want to hack it just spawn a thread that polls and checks if it's connected and if not resets it once
18:52svenif i wanted to just get something somehow working we would have a kernel+distro hacked together a few months ago already ;)
18:56svenpeter[m]Nice!
18:57svenpeter[m]You’ve probably seen kettenis’ bindings haven’t you?
18:57svenpeter[m]I think they’ve already been reviewed by the maintainers
19:05Andalu30 has joined #asahi
19:06Emantorpipcet[m]: chainloading the generic 2nd dt image for barebox fails for me, HV works obviously. But the gadget still spews lots of errors.
19:09Emantorye, doesn't matter. Still get an apple logo screen chainloading m1n1 with a barebox payload.
19:10pipcet[m]the frame buffer is black on black unless you apply the patch or hack the DT to claim x8r8g8b8 layout.
19:18EmantorRunning under the hypervisor gives me nice simplefb output with debug apple logo. Where does that even come from?
19:19svenpeter[m]That’s an Easter egg inside mini 😅
19:21pipcet[m](...my excuse is I didn't get much sleep since I tried to get nvme to work in barebox)
19:26Erus_Iluvatar has quit [Quit: Erus_Iluvatar]
19:26Erus_Iluvatar has joined #asahi
19:33klltkr has joined #asahi
19:42erincandescent_ has quit [Remote host closed the connection]
19:43erincandescent has joined #asahi
19:47klltkr has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
19:48klltkr has joined #asahi
19:48klltkr has quit []
19:49Andalu30 has quit [Quit: Konversation terminated!]
19:49klltkr has joined #asahi
19:49klltkr has quit []
19:49klltkr has joined #asahi
19:49klltkr has quit []
19:50klltkr has joined #asahi
19:50klltkr has quit []
20:01pipcet[m]emantor: do you happen to know whether nvme support in barebox works on other machines? I got something to work but I had to touch the generic code...
20:03Emantorpipcet[m]: Yep, should work on boards with an nvme slot, which are the zii imx8mq boards AFAIK.
20:05VinDuv has quit [Quit: Leaving.]
20:06choozy has joined #asahi
20:06pugguu has quit [Ping timeout: 480 seconds]
20:49thunfisch has quit [Remote host closed the connection]
20:50thunfisch has joined #asahi
21:19kettenis_ has joined #asahi
21:20kettenis has quit [Ping timeout: 480 seconds]
21:49EER has quit [Remote host closed the connection]
22:16choozy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]