aboutsummaryrefslogtreecommitdiff
path: root/i386
Commit message (Collapse)AuthorAgeFilesLines
* Update kdb_kintr according to new interrupt stack layoutSamuel Thibault2022-11-272-4/+12
| | | | | | | | e2fcf261076b ("interrupt: Fix saving irq/ipl when linux drivers are disabled") changed the stack layout for interrupt handlers, but missed updating kdb_kintr's code that tries to mangle it. This restores the control-alt-d shortcut.
* Update mach_debug interfaces to use struct.Flavio Cruz2022-11-252-0/+16
| | | | | | | | | | | | | | | | | | | | | | The new interfaces will be compatible both with a 64 bits kernel and userland and 64 bits kernel and 32 bit userland. Also removed many of the uses of natural_t where an unsigned int suffices. Ideally we should replace natural_t with something more portable such as uintptr_t or a basic int type for counters since for the most part we don't need counters to have the same width as the pointer type. * i386/include/mach/i386/vm_types.h: Define rpc_unsigned_long. * include/mach/mach_types.defs: Define type rpc_vm_offset_t. * include/mach_debug/hash_info.h: Use unsigned int instead of natural_t. * include/mach_debug/mach_debug_types.defs: Update cache_info_t, hash_info_bucket_t, vm_region_info_t, vm_object_info_t and vm_page_info_t to use struct. * include/mach_debug/slab_info.h: Use rpc_vm_size_t and rpc_unsigned_long for compatibility with 32 bits userland. * include/mach_debug/vm_info.h: Update struct fields to use the correct types and avoid natural_t whenever we just want to keep a count of something. Message-Id: <Y32lp1SuV01ImCx9@viriathus>
* interrupt: Fix passing parameter to splx_cli and ioapic_irq_eoiSamuel Thibault2022-11-101-2/+2
| | | | | | | e2fcf261076b (""interrupt: Fix saving irq/ipl when linux drivers are disabled") broke booting under some conditions, because the parameters were erroneously written 4 bytes too far for splx_cli and ioapic_irq_eoi to read them.
* i386/pit: Tune delaysDamien Zammit2022-10-262-4/+22
| | | | | | | - Add half a clock tick for more accuracy - Start the pit countdown during pit_sleep - Add pit_mdelay and pit_udelay functions Message-Id: <20221025105502.222708-8-damien@zamaudio.com>
* acpi: Add lapic_addrDamien Zammit2022-10-252-0/+3
| | | | | | Message-Id: <20221025105502.222708-5-damien@zamaudio.com> Co-authored-by: Almudena Garcia <liberamenso10000@gmail.com>
* proc_reg: Fix pushf/popfSamuel Thibault2022-10-251-6/+6
|
* kdb: Fix TODO for multiprocessorDamien Zammit2022-10-251-1/+3
| | | | Message-Id: <20221025105502.222708-2-damien@zamaudio.com>
* Fix when enabling APIC without SMPEtienne Brateau2022-09-262-10/+10
| | | | | | When we want to enable APIC, we must initialize the structure or otherwise, it will try to access to a not initialized memory addresses. Message-Id: <20220924163145.39894-1-etienne.brateau@gmail.com>
* x86_64: ignore warningSamuel Thibault2022-09-181-0/+1
|
* interrupt: Fix saving irq/ipl when linux drivers are disabledSamuel Thibault2022-09-171-14/+37
| | | | | | | | | | | | | | When Linux drivers are disabled, in hardclock() the linux_timer_intr() call is dropped, and gcc can tail-recursion-optimize the call to clock_interrupt(). To do so, it overwrites the hardclock() parameters to suit the clock_interrupt parameters layout. This however means it thrashes the backups that the interrupt() function had made of irq/ipl, leading to mayhem. interrupt should thus really properly separate its irq/ipl backups from the interrupt function parameters. Thanks a lot to Etienne Brateau for the tricky investigation!
* kd_mouse: Fix warningSamuel Thibault2022-09-172-4/+5
|
* x86_64: fix warningSamuel Thibault2022-09-171-2/+2
|
* copyinmsg: Set msgh_size inside copyinmsg rather than the callerSamuel Thibault2022-08-282-0/+6
| | | | | In the 32/64 conversion case it is copyinmsg that will know the eventual size.
* Fix inclusability of <mach/mach_types.h>Samuel Thibault2022-08-283-8/+64
| | | | | Now that mach/machine/vm_types.h uses stdint types, we have to ship a header that defines them.
* add rpc_versions for vm typesLuca Dariz2022-08-271-4/+33
| | | | | | | | | | | | | | | * vm_types.h: add new types and conversion functions * mach_types.defs: adapt vm types depending on kernel user/server * vm_info.h: adapt rpc structure to have uniformly-sized members also on 64-bit * x86_64/configfrag.c: add new option to select the user-space variant. Note that with this change the user-space interface is somehow fixed, i.e. it can't support 32-bit and 64-bit tasks at the same time. If this would be needed at some point, this change needs to be reworked. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403145955.120742-3-luca@orpolo.org>
* fix warnings for 32 bit buildsLuca Dariz2022-08-273-1/+3
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-13-luca@orpolo.org>
* x86_64: fix exception stack alignmentLuca Dariz2022-08-273-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * i386/i386/pcb.c: - increase alignment of pcb cache to 16 - ensure the stack is properly aligned when switching ktss * i386/i386/thread.h: - add padding tomake iss field end aligned to 16 bytes * i386/i386/trap.c: - ensure the state we get after the trap points to the correct place in the pcb structure When handling exceptions from IA-32e compatibility mode in user space, on a 64-bit kernel, the exception stack where error info is pushed needs to be aligned to 16 bytes (see Intel System Programming guide, $6.14.2) The exception stack frame is set in the middle of pcb->iss, but it's not always 16-byte aligned; to make sure it is, we increase the alignment of the pcb cache and add a padding field in the pcb structure. This issue resulted in a general protection failure due to CS being corrupted after a page fault. The corruption was happening when the exception stack frame was not properly aligned and a page fault happened; the error info was then pushed after re-aligning the stack, so the value of eflags was actually written in CS place and other fields were shifted too. It also makes sense to ensure this by adding two assertions, although these were primarly useful during debug. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-10-luca@orpolo.org>
* fix Task State Segment layout for 64 bitLuca Dariz2022-08-274-3/+36
| | | | | Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-7-luca@orpolo.org>
* enable user accessLuca Dariz2022-08-271-2/+2
| | | | | | | | The pmap module is a bit limited on 64 bit paging, so this should be refined when we'll be able to use addresses over 4G. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-6-luca@orpolo.org>
* fix console setting from cmdlineLuca Dariz2022-08-271-0/+5
| | | | | | | | The leading space prevents it working if console=comX is the only argument, so handle this case separately. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-5-luca@orpolo.org>
* cleanup multibootLuca Dariz2022-08-272-119/+14
| | | | | | | | | * use _raw_ structs where we refer to the bootloader-provided data * remove unused structures * fix 64 bit boot Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-3-luca@orpolo.org>
* add support for booting from grub with x86_64Luca Dariz2022-08-275-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | * configure: compile for native x86_64 by default instead of xen * x86_64/Makefrag.am: introduce KERNEL_MAP_BASE to reuse the constant in both code and linker script * x86_64/ldscript: use a .boot section for the very first operations, until we reach long mode. This section is not really allocated, so it doesn't need to be freed later. The vm system is later initialized starting from .text and not including .boot * link kernel at 0x4000000 as the xen version, higher values causes linker errors * we can't use full segmentation in long mode, so we need to create a temporary mapping during early boot to be able to jump to high addresses * build direct map for first 4G in boothdr, it seems required by Linux drivers * add INTEL_PTE_PS bit definition to enable 2MB pages during bootstrap * ensure write bit is set in PDP entry access rights. This only applies to PAE-enabled kernels, mandatory for x86_64. On xen platform it seems to be handled differently Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220205175129.309469-2-luca@orpolo.org>
* gnumach: Remove PCI_CFG2_* as a reserved ioport rangeDamien Zammit2022-08-231-4/+1
| | | | | | | | | | | | | PCI CONF2 access method was deprecated in PCI v2.0 Also, the conf2 ioport range is only activated for use as pci configuration space when conf1 registers are accessed in a particular sequence. Since the pci-arbiter does not access the conf1 forwarding register, we are safe to remove this completely from gnumach to allow normal I/O use of the conf2 range as modern hardware expects. Message-Id: <20220823032638.292813-1-damien@zamaudio.com>
* convert K&R into ansiGuy-Fleury Iteriteka2022-05-2711-64/+35
| | | | Message-Id: <Yo+lzS7RtW5ZjQHN@debian>
* pmap: Make sure we do not allocate page tables beyond 4GiBSamuel Thibault2022-02-171-1/+4
| | | | vm_page_insert would not be able to store the offset.
* xen: Fix storing physical addressesSamuel Thibault2022-02-161-2/+2
|
* io_map: Fix using physical addressesSamuel Thibault2022-02-161-5/+5
|
* db: Fix db_user_to_phys_address returning physical addressesSamuel Thibault2022-02-161-7/+7
| | | | It shall return a phys_addr_t, not vm_offset_t.
* vm_object: Fix vm_object_page_map map function prototypeSamuel Thibault2022-02-161-1/+1
| | | | The map function is supposed to return physical addresses, thus phys_addr_t.
* biosmem: Narrow e820 regions as requiredDamien Zammit2022-02-151-0/+28
| | | | Message-Id: <20220215064133.68593-1-damien@zamaudio.com>
* Makefrag.am: Move architecture condition inside architecture Makefrag.amSamuel Thibault2022-02-061-17/+14
| | | | | Otherwise we cannot use _DIST there and have them all taken into account. As a consequence, we can drop duplicate _DIST between i386 and x86_64.
* Convert from K&R to ANSIEtienne Brateau2022-01-215-49/+29
| | | | | | | | * hardclock.c: convert to ANSI * com.c: ditto * lpr.c: ditto * mem.c: ditto Message-Id: <20220120170004.21722-1-etienne.brateau@gmail.com>
* mach_i386: include MACH_I386_IMPORTSSamuel Thibault2022-01-011-0/+4
| | | | Like other defs header do, to allow e.g. including libports/ports.h
* ddb: Fix updating sp while progressing through framesSamuel Thibault2021-12-291-1/+6
| | | | Notably trap/interrupt/syscall provide an exact SP value.
* ddb: Unwind over RETSamuel Thibault2021-12-292-6/+30
| | | | | When we don't have a frame but PC points to a RET instruction (e.g. in the userland system call assembly code), we can trivially unwind it.
* ddb: Fix accessing high memorySamuel Thibault2021-12-282-20/+61
| | | | | User processes loaded in high memory are not visible to ddb through the direct mapping. We can however read/write data through copy_from/to_phys.
* rtc: drop message on setting RTC timeSamuel Thibault2021-12-161-8/+0
| | | | | We haven't seen the 2032 bug for a long time, f040677be3c0 ("kd: Do not read the CMOS ram") probably fixed it at last.
* memmmap: Use biosmem_addr_available rather than vm_page_lookup_paSamuel Thibault2021-11-283-17/+25
| | | | | | | The segment code actually has vm_page entries for reserved pages, and thus memmmap would reject mapping ACPI pages. Taking the information from biosmem is much more precise, and indeed knows all hardware quirks which can now be dropped from memmmap.
* memory_object_create_proxy: Make len parameter vm_size_array_tSamuel Thibault2021-10-171-0/+1
| | | | | | | | | | | This is a no-op on i386. * i386/include/mach/i386/vm_types.h (vm_size_array_t): New type. * include/mach/mach4.defs (vm_size_array_t): New type. (memory_object_create_proxy): Turn len parameter from vm_offset_array_t to vm_size_array_t. * vm/memory_object_proxy.c (memory_object_create_proxy): Turn len parameter from const vm_offset_t * to const vm_size_t *.
* i386/i386/fpu.h: Fix xrstor and xrstors macrosSamuel Thibault2021-09-231-2/+6
| | | | | | | | | | xrstor and xrstors also take the xsave support bitmask. We were otherwise not necessarily properly reloading all the FPU state, thus leading to various subtle bugs, notably with glibc 2.33's ifunc-optimized memcpy etc. * i386/i386/fpu.h (xrstor, xrstors): Pass fp_xsave_support in EDX:EAX.
* i386/i386/fpu.h: Drop spurious backslashesSamuel Thibault2021-09-231-4/+4
|
* vm_page_grab: allow allocating in high memorySamuel Thibault2021-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_page_grab was systematically using the VM_PAGE_SEL_DIRECTMAP selector to play safe with existing code. This adds a flags parameter to let callers of vm_page_grab specify their constraints. Linux drivers need 32bit dmas, Xen drivers use kvtophys to clear some data. Callers of kmem_pagealloc_physmem and vm_page_grab_phys_addr also use kvtophys. Otherwise allocations can go to highmem. This fixes the allocation jam in the directmap segment. * vm/vm_page.h (VM_PAGE_DMA, VM_PAGE_DMA32, VM_PAGE_DIRECTMAP, VM_PAGE_HIGHMEM): New macros. (vm_page_grab): Add flags parameter. * vm/vm_resident.c (vm_page_grab): Choose allocation selector according to flags parameter. (vm_page_convert, vm_page_alloc): Pass VM_PAGE_HIGHMEM to vm_page_grab. (vm_page_grab_phys_addr): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * vm/vm_fault.c (vm_fault_page): Pass VM_PAGE_HIGHMEM to vm_page_grab. * vm/vm_map.c (vm_map_copy_steal_pages): Pass VM_PAGE_HIGHMEM to vm_page_grab. * kern/slab.c (kmem_pagealloc_physmem): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * i386/intel/pmap.c (pmap_page_table_page_alloc): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * xen/block.c (device_read): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * linux/dev/glue/block.c (alloc_buffer): Pass VM_PAGE_DMA32 to vm_page_grab.
* rtc: Add read/write messagesSamuel Thibault2021-04-051-1/+16
| | | | | | | | | | | We are still having issues with bogus dates. This adds prints at boot and time set, to make sure what we actually read and write. * i386/i386at/rtc.c: Include <kern/printf.h> (readtodc): Warning about reaching CENTURY_START. Print the time read from RTC. (writetodc): Record in RTC remainder of division of year by 100 rather than subtracting 1900. Print the time written to RTC.
* kd: Do not read the CMOS ramSamuel Thibault2021-04-052-3/+10
| | | | | | | This could conflict with read/writing the RTC. * i386/i386at/kd.c (kd_xga_init): Do not read the CRAM. We were always assuming VGA anyway.
* apic: Also unmask irq 3 and 4 earlySamuel Thibault2021-04-051-0/+7
| | | | | | | We unmasked by hand kd's irq 1, but com0/1 also need unmasking. More generally we should unmask irqs as appropriate. * i386/i386at/model_dep.c (machine_init): Unmask irq 3 and 4.
* ioapic: Fix arg passing of redirection entryDamien Zammit2021-04-051-6/+7
| | | | Message-Id: <20210405115921.184572-3-damien@zamaudio.com>
* ioapic: Refactor EOIDamien Zammit2021-04-053-2/+2
| | | | Message-Id: <20210405115921.184572-2-damien@zamaudio.com>
* ioapic: Use irq specific EOI properly when detectedDamien Zammit2021-04-052-8/+26
| | | | Message-Id: <20210405052916.174771-5-damien@zamaudio.com>
* Don't call EOI on spurious interruptsDamien Zammit2021-04-051-6/+3
| | | | Message-Id: <20210405052916.174771-4-damien@zamaudio.com>
* ioapic: target first processor for interruptsDamien Zammit2021-04-051-1/+2
| | | | Message-Id: <20210405052916.174771-3-damien@zamaudio.com>