IRC channel logs
2024-12-24.log
back to list of logs
<damo22>i instrumented rump and found that bus_space_map() is failing <damo22>pci_device_map_range(pci_devices[i], addr, len, 1, &ret); is setting ret to 0 <damo22>printf("success devmem 0x%p\n", *dest); <damo22>that prints nonzero in pciaccess <damo22>something is getting called twice <damo22>libpciaccess is calling pci_device_map_range twice somehow before returning <damo22>youpi: theres a bug with pci_device_hurd_map_range <damo22>io_map() calls into x86 map range and that seems to work <damo22>but when it calls vm_map that fails <damo22>maybe the size being mapped is not a whole number of pages <damo22>i fixed the rounding to page size <solid_black>that should not be an issue, mach does the rounding itself <damo22>now that we are using io_map() why do we need an offset <damo22>and i have logs for inside x86 version of map_range <solid_black>is this the thing using vm_region memobj proxy thing? <damo22>no, its further down in the file you showed me <solid_black>but the memobj we try to map, where does it come from? <solid_black>yes, but io_map is just the call to get from pci-arbiter <solid_black>why are we passing VM_PROT_ALL for max protection with copy=0 <solid_black>let me check if getting that wrong will result in KERNL_INVALID_ARGUMENT, I'd expect KERN_PROTECTION_FAILUREor something <solid_black>if you got returned a wobj, you can pass VM_PROT_WRITE for max_prot even if writing is not being requested at the moment <solid_black>file_name_lookup_under -> openat, io_map+vm_map -> mmap <damo22>the port from file_name_lookup_under? <solid_black>you can replace the file_name_lookup_under call with openat() <solid_black>but I'm not necesarily saying you should change it like that <solid_black>just wondering why it wasn't written like that in the first palce <solid_black>yes, mmap in glibc is smart to notice if robj == wobj, and add the other protection to max_prot in both branches <damo22>so is pci_sys_hurd->root equivalent to a dirfd? <solid_black>mapping outside of the allowed range of the proxy would, too (!) <damo22>i dont understand why there is an offset <damo22>isnt the io_map mapping the exact file <solid_black>io_map retrieves the memory object (aka pager) that can be used to map the file <solid_black>offset = map->base - region->base_addr; <- does that make sense? <damo22>offset = 0 would make more sense <solid_black>looking at pci_device_freebsd_map_range, they map /dev/mem with offset=map->base <solid_black>whereas map->base is already factored in by us opening a specific pci-arbiter file in my understanding <solid_black>off_t offset = map->base - dev->regions[map->region].base_addr; <damo22>if we are opening a specific pci-arbiter file, surely the offset is zero? <solid_black>(I don't understand what pci is, exactly, or what kind of offset we want and why) <damo22>pci region is a MMIO at a physical address <solid_black>is it always MMIO? so it could be reachable via /dev/mem, as the freebsd version does it? <solid_black>so is map->base the start of the whole PCI region, or the speciic part we want? <solid_black>also what is it that you're doing overall again? haven't pci-arbiter and libpciaccess been working great this far? <damo22>[start, start + size] is a pci region <damo22>when i hexdump -C /servers/bus/pci/0000/.../regionX it dumps the region <damo22>so if i mmap the region, it should let me use it <damo22>but something is wrong in libpciaccess <damo22>the hurdish map_range breaks on vm_map() call <damo22>maybe it just needs to be map->base ? <damo22>if io_map is giving a proxy to dev/mem @ 0 <damo22> vm_region_create_proxy (mach_task_self (), <damo22> (vm_address_t) node->nn->ln->region_maps[reg_num], <damo22> max_prot, region->size, &proxy); <damo22>which works in qemu but fails on hw <damo22>ok i think i know what is wrong.... the size is 0x800 of the whole region <damo22>but as thats smaller than a page, mach rounds it up to a whole page but cant map it because the underlying region is truncated? <damo22>so the original mapping should round up to a whole page first? <solid_black>ok, so it's creating a proxy for the *region*, of the region->size <damo22>it needs to create a proxy for the region rounded up to a whole number of pages right? <damo22>why do we need to care in userspace <p4r4D0xum>hey, do you guys use uppermem on real machines? <solid_black>indeed, so Mach doesn't round the size when creating the proxy <solid_black>but it would be wise for pci-arbiter to do that in userland <solid_black>like if what foolows is a different device, won't we expose a part of its space to a task who's not supposed to have access? <p4r4D0xum>damo22: it's in the faq - probably outdated. uppermem 786432 should limit mem on systems with more RAM <damo22>solid_black: can we test that the length fits exactly in mach when creating the proxy, but round up the proxy? <solid_black>at the end of the day, you're still either mapping the last page, or not <solid_black>yes, if everything is root:root rw-rw----, it should be fine <solid_black>so pci-arbiter should round up the size when creating the proxy <youpi>one of the goals was to make the thing possibly exposed to non-root, such as non-trusted driver and such <youpi>if hardware exposes pieces that are non-pages, that's really a concern for that goal... <youpi>I wonder though if by construction BARs are limited to some rounding of their base <youpi>in which case there cannot be anything else in the same page <youpi>p4r4D0xum: that comment is not really outdated, it's saying "If you have an older version" <youpi>that older version would still have issues, sure <p4r4D0xum>youpi: btw. do you still run hurd on dell latitude e6420? <youpi>it's been a long time I didn't try <p4r4D0xum>question, the one I found at work e6440 has an original sata 80GB and crashes in AHCI mode on kmem <p4r4D0xum>and in IDE boots with hd0 and then rumpdisk looks for wd0 <youpi> 91346000-913467ff : 0000:00:17.0 <youpi> 91347000-913470ff : 0000:00:17.0 <youpi>that's what happens on my machine <youpi>the area is 2k, but the next is 4k away <damo22>we are fixing a long standing bug shortly that will fix ahci <youpi> 91347000-913470ff : 0000:00:17.0 <youpi> 91348000-91348fff : 0000:00:16.0 <p4r4D0xum>damo22: good to know, I have loads of old machines at home <p4r4D0xum>On one medion MT it works - slow but boots just fine <solid_black>I'm trying to get a better understanding of how copying objects works in mach vm <solid_black>it evidently does work, but a bunch of the things about the code are suprising and seemingly wrong <damo22>fixed, and it probes the controller now, but somehow wont probe the disk <damo22>maybe we should compile for single threaded locking in rump <damo22>all PCI bases are 16 byte aligned <damo22>the _CRS is empty for the IRQ _PRT setting though <damo22>meaning, it doesnt know the interrupt number <solid_black>either "Cannot share irq" or "You can't have this interrupt" should've been printed for D_ALREADY_OPEN <damo22> Enter evaluation : _SB.PCI0.PBR5._ADR (Integeirq handler [-1]: new delivery port f67fda58 entry f54a1ee0 You rcan't have this )interrupt <damo22>its difficult to read these logs when they are interleaved between acpi and rumpdisk <solid_black>ok, so something in the kernel already handles this irq <damo22>irq handler [-1]: new delivery port f67fda58 entry f54a1ee0 <damo22>i think the acpi server can return -1 for some get_irq rpc <damo22>what do we do if the ACPI table does not have the information?? <damo22>maybe we are not parsing it 100% correctly <damo22>*irq = acpi_get_irq_number(bus, dev, func); <damo22>so either we make it bulletproof or we need to allow it to return a failure state and handle the case where we dont get a value <damo22> // TODO: may need to compare prt_func <damo22> // prt_func = entry->address & 0xffff; <damo22>(10:14:42 PM) jmcneill: damo22: _CRS will have irq resources for the pci root port, and if they are missing, it means "use MSI" <damo22>i think we are not matching on the function number <damo22>The PCI function number in the Address field of the _PRT packages must be 0xFFFF, indicating “any” function number or “all functions”. <damo22>hmm so not matching on function number is the same thing <damo22>i added better error handling to acpi server and now i get: <damo22>irqhelp: tried acpi to get pci gsi and failed for 00:11.0