Commit graph

1988 commits

Author SHA1 Message Date
cinap_lenrek 0cb4115b82 kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec() 2019-09-04 02:44:39 +02:00
cinap_lenrek 6aa7ebcf49 kernel: make exec clear errstr, stop side-channels and truncate on utf8 boundary
make exec() clear the per process error string
to avoid spurious errors and confusion.

the errstr() syscall used to always swap the
maximum buffer size with memmove(), which is
problematic as this gives access to the garbage
beyond the NUL byte. worse, newproc(), werrstr()
and rerrstr() only clear the first byte of the
input buffer. so random stack rubble could be
leaked across processes.

we change the errstr() syscall to not copy
beyond the NUL byte.

the manpage also documents that errstr() should
truncate on a utf8 boundary so we use utfecpy()
to ensure proper NUL termination.
2019-09-04 02:40:41 +02:00
cinap_lenrek e4a57c8b8a bcm64: enable devgpio in kernel configuration (thanks qeed) 2019-09-02 19:38:44 +02:00
cinap_lenrek 7bb1a9a185 pc64: map kernel text readonly and everything else no-execute
the idea is to catch bugs and make kernel exploitation
harder by mapping the kernel text section readonly
and everything else no-execute.

l.s maps the KZERO address space using 2MB pages so
to get the 4K granularity for the text section we use
the new ptesplit() function to split that mapping up.

we need to set EFER no-execute enable bit early
in apbootstrap so secondary application processors
will understand the NX bit in our shared kernel page
tables. also APBOOTSTRAP needs to be kept executable.

rebootjump() needs to mark REBOOTADDR page executable.
2019-08-29 07:35:22 +02:00
cinap_lenrek d9fec3c70a kernel: prohibit changing cache attributes (SG_CACHED|SG_DEVICE) in segattach(), set SG_RONLY in data2txt()
the user should not be able to change the cache
attributes for a segment in segattach() as this
can cause the same memory to be mapped with
conflicting attributes in the cache.

SG_TEXT should always be mapped with SG_RONLY
attribute. so fix data2txt() to follow the rules.
2019-08-27 06:16:20 +02:00
cinap_lenrek d25ca13ed8 kernel: make user stack segment non-executable 2019-08-27 04:04:46 +02:00
cinap_lenrek 1e773c97e7 pc64: implement NX bit discovery, map kernel mappings no-execute 2019-08-27 03:55:12 +02:00
cinap_lenrek 49411b2ca1 kernel: catch execution read fault on SG_NOEXEC segment (for mips) 2019-08-27 03:48:51 +02:00
cinap_lenrek 2149600d12 kernel: catch execution read fault on SG_NOEXEC segment
fault() now has an additional pc argument that is
used to detect fault on a non-executable segment.
that is, we check on read fault if the segment
has the SG_NOEXEC attribute and the program counter
is within faulting page.
2019-08-27 03:47:18 +02:00
cinap_lenrek 128ea44a89 kernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, add PTECACHED bits
a portable SG_NOEXEC segment attribute was added to allow
non-executable (physical) segments. which will set the
PTENOEXEC bits for putmmu().

in the future, this can be used to make non-executable
stack / bss segments.

the SG_DEVICE attribute was added to distinguish between
mmio regions and uncached memory. only matterns on arm64.

on arm, theres the issue that PTEUNCACHED would have
no bits set when using the hardware bit definitions.
this is the reason bcm, kw, teg2 and omap kernels use
arteficial PTE constants. on zynq, the XN bit was used
as a hack to give PTEUNCACHED a non-zero value and when
the bit is clear then cache attributes where added to
the pte.

to fix this, PTECACHED constant was added.

the portable mmu code in fault.c will now explicitely set
PTECACHED bits for cached memory and PTEUNCACHED for
uncached memory. that way the hardware bit definitions
can be used everywhere.
2019-08-26 22:34:38 +02:00
cinap_lenrek 51cfe763a4 emmc: 50MHz highspeed support (from richard miller) 2019-08-25 20:02:53 +02:00
cinap_lenrek a8c50a7943 bcm64: replace emmc2 driver with richard millers sdhc driver
the new driver supports 50MHz highspeed bus mode
and uses ADMA instead of SDMA.
2019-08-25 18:45:29 +02:00
cinap_lenrek bcf988aff1 bcm64: deal with discontinuous memory regions, avoid virtual memory aliasing, implement vmap() proper
on the 2GB and 4GB raspberry pi 4 variants, there are two
memory regions for ram:

[0x00000000..0x3e600000)
[0x40000000..0xfc000000)

the framebuffer is somewhere at the end of the first
GB of memory.

to handle these, we append the region base and limit
of the second region to *maxmem= like:

*maxmem=0x3e600000 0x40000000 0xfc000000

the mmu code has been changed to have non-existing
ram unmapped and mmukmap() now uses small 64K pages
instead of 512GB pages to avoid aliasing (framebuffer).

the VIRTPCI mapping has been removed as we now have
a proper vmap() implementation which assigns vritual
addresses automatically.
2019-08-23 21:39:20 +02:00
cinap_lenrek e6d22570a8 bcm: invalidate cache on Fbinfo after firmware completion 2019-08-22 02:54:06 +02:00
cinap_lenrek aca0293f0b bcm: flush out early boot messages on uart and screen initialization
make early boot messages available by writing out
kmesg.buf after uart and screen initialization.
2019-08-22 02:52:21 +02:00
cinap_lenrek b4cb19235e bcm: set XN bits for kernel device mappings 2019-08-21 18:28:01 +02:00
cinap_lenrek 6280c0f17b bcm64: do not use OTP_BOOTMODE_REG to determine OSC frequency (thanks richard miller)
the register does not seem to be accessible on the Rpi 3b.
so instead hardcode oscfreq in the Soc structure.
2019-08-19 16:42:20 +02:00
cinap_lenrek f35d5ee5b0 bcm64: add support for more than 1GB of ram (untested)
this adds a 4GB KMAP window into the kernel address space
so we can access all physical ram on raspberry pi 4 for
user pages.

note that kernel memory above KZERO is still limited
to 1GB because of DMA restrictions.
2019-08-18 21:16:30 +02:00
cinap_lenrek 3fc8d1bdae bcm64: add driver for emmc2 controller 2019-08-18 18:50:24 +02:00
cinap_lenrek bc8c31dbd5 bcm: fix typo in gpio.c on unused AFedge0 constant 2019-08-16 19:35:46 +02:00
cinap_lenrek 031f5756ab bcm64: poll gisb arbiter for asynchronous bus errors 2019-08-16 19:24:00 +02:00
cinap_lenrek 54becb8466 ethergenet: remove debugging
the hangs where caused by missing NX bits on the mmio mappings,
so the debug code is not needed anymore.
2019-08-16 19:22:28 +02:00
cinap_lenrek 3bf49f1814 bcm64: set XN bits for kernel device mappings 2019-08-16 19:05:04 +02:00
cinap_lenrek 05f9a66fd4 bcm, bcm64: add vcore support for raspberry pi 3 GPIO expander 2019-07-28 11:39:57 +02:00
cinap_lenrek 8630bd35a6 bcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup
according to the following linux change, BCM2711 uses a different
method for changing pullup/down mode:

abcfd09286 (diff-cf078559c38543ac72c5db99323e236d)

gpiomeminit() was broken, using virtual address for the gpio physseg
instead of the physical one.

cleanup the code, avoid repetition by declaring static u32int *regs
variable. make local variable names consistent.
2019-07-27 20:00:53 +02:00
cinap_lenrek ea2a5a33ca bcm64: fix wrong prescaler for generic timer on rpi4
the raspberry pi 4 uses 54 instead of 19.2 MHz crystal.
detect which frequency is used by reading OTP bootmode
register:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/otpbits.md

Bit 1: sets the oscillator frequency to 19.2MHz
2019-07-27 17:59:25 +02:00
cinap_lenrek 834f670349 ethergenet: fix flow control negotiation 2019-07-25 17:44:47 +02:00
cinap_lenrek 1717368f64 bcm, bcm64: clean dma destination buffer before issuing dma in case of non cache-line-size aligned buffer 2019-07-25 13:55:17 +02:00
cinap_lenrek 706926f818 bcm64: add config for raspberry pi 4 2019-07-25 09:12:40 +02:00
cinap_lenrek 3bc4e5a6d5 bcm64: work in progress genet ethernet driver for raspberry pi 4 2019-07-25 09:11:53 +02:00
cinap_lenrek 2a4c767c41 bcm64: reorganize virtual memory map for rapberry pi4 2019-07-25 09:10:07 +02:00
cinap_lenrek 4200778861 bcm64: update io.h for pci express and raspberry pi 4 2019-07-25 09:08:35 +02:00
cinap_lenrek 6d9edeeb67 bcm64: add pci express driver for raspberry pi 4 2019-07-25 09:04:50 +02:00
cinap_lenrek 676ef0ca0b bcm64: add gic interrupt controller driver for raspberry pi 4 2019-07-25 09:02:47 +02:00
cinap_lenrek 10b456ff44 bcm64: add gisb arbiter driver to catch bus timeouts 2019-07-25 09:01:44 +02:00
cinap_lenrek 811b80cae1 bcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()
the raspberry pi 4 has a new interrupt controller and
pci support, so get rid of intrenable() macro and
properly make intrenable function with tbdf argument.
2019-07-25 08:58:58 +02:00
cinap_lenrek dfea95b3c2 bcm64: strip debug symbols to make sure .img file is multiple of 4 bytes
the raspberry pi4 firmware refuses to enable the GIC interrup controller
for arm64 when the .img file is not a multiple of 4 bytes. yes, this
is insane and nowhere documented.
2019-07-25 08:52:46 +02:00
cinap_lenrek 5a0c2e2d17 bcm, bcm64: add dmaflush() function and make virtio size and virtual address configurable in Soc.virtio and Soc.iosize 2019-07-25 08:41:37 +02:00
cinap_lenrek 4983adfa2c bcm, bcm64: add support for device tree parameter passing
the new raspberry pi 4 firmware for arm64 seems to have
broken atag support. so we now parse the device tree
structure to get the bootargs and memory configuration.
2019-07-25 08:19:12 +02:00
cinap_lenrek a6a1806c17 usbxhci: implement portable dma flush operations and move to port/ 2019-07-17 10:30:06 +02:00
cinap_lenrek 19a883ce7a usbehci: introduce dmaflush() function to handle portable cache invalidation for device drivers 2019-07-17 10:24:50 +02:00
cinap_lenrek a1a6f26110 kernel: move common ethermii to port/ 2019-07-11 07:47:39 +02:00
cinap_lenrek 7111de631c devuart: make sure uart is enabled in uartkick() 2019-07-11 07:45:34 +02:00
cinap_lenrek 54f9b36720 usbxhci: fix mysterious ENABLESLOT failures (update to XHCI spec revision 1.2 (2019))
Ori Bernstein had Sunrise Point-H USB 3.0 xHCI Controller that would mysteriously
crash on the 5th ENABLESLOT command. This was reproducable by even just allocating
slots in a loop right after init.

It turns out, the 1.2 spec extended the Max Scratchpad Buffers in HCSPARAMS2 so our
driver would not allocate enougth scratchpad buffers and controller firmware would
crash once it went beyond our allocated scratchpad buffer array.

This change also fixes:

- ignore bits 16:31 in PAGESIZE register
- preserve bits 10:31 in the CONFIG register
- handle ADDESSDEV command failure (so it can be retried)
2019-07-02 05:34:13 +02:00
cinap_lenrek b2c7a8d84a pc64: preallocate mmupool page tables
preallocate 2% of user pages for page tables and MMU structures
and keep them mapped in the VMAP range. this leaves more space
in the KZERO window and avoids running out of kernel memory on
machines with large amounts of memory.
2019-06-28 18:12:13 +02:00
cinap_lenrek 4d96bacd35 bcm, kw, omap, teg2: implement setregisters() 2019-06-20 13:17:36 +02:00
cinap_lenrek 2d83ae8fb2 pc64: actually fix it, what was i THINKING 2019-06-20 00:36:51 +02:00
cinap_lenrek a40364218d pc64: fix compiler warning in rebootjump() entry calculation 2019-06-20 00:32:54 +02:00
cinap_lenrek 8d36cd8d8a devdtracy: make machlocks and dtktab static 2019-06-14 10:30:50 +02:00
cinap_lenrek f42e53655e bcm64: implement dtracy support 2019-06-14 10:28:30 +02:00
cinap_lenrek 197ff3ac2f devip: if the server does not support TCP ws option, disable window scaling (thanks joe9)
if the server responds without a window scale option in
its syn-ack, disable window scaling alltogether as both
sides need to understand the option.
2019-05-22 22:20:31 +02:00
cinap_lenrek c881e33e8e bcm, bcm64: fix cache operations for dma and emmc
always clean AND invalidate caches before dma read,
never just invalidate as the buffer might not be
aligned to cache lines...

we have to invalidate caches again *AFTER* the dma
read has completed. the processor can bring in data
speculatively into the cache while the dma in in
flight.
2019-05-19 16:54:50 +02:00
cinap_lenrek d5e4558078 bcm64: remove unneccesary tlb flush on mmuidmap() 2019-05-17 18:57:05 +02:00
cinap_lenrek 2235660f86 bcm64: no need to flush instruction cache when switching TTBR0 2019-05-17 18:56:34 +02:00
cinap_lenrek 5c5c1b6666 bcm64: switch to 64k page size 2019-05-17 18:35:14 +02:00
cinap_lenrek b24ed2bfac bcm64: generalize mmu code
make user page table list heads arrays so we can
index into the right level avoiding the special
cases for differen PTLEVELS.
2019-05-15 16:19:20 +02:00
cinap_lenrek 47d3e8fc63 bcm64: fix mmu0clear() mistake from previous commit 2019-05-15 13:24:34 +02:00
cinap_lenrek adf96a529e bcm: add cache invalidate before accessing prop buffer 2019-05-13 19:21:14 +02:00
cinap_lenrek a3b5e3994f bcm64: implement reboot support 2019-05-13 19:20:21 +02:00
cinap_lenrek 3b36daa2bb bcm, bcm64: preserve memsize across reboots, avoid trashing atags while parsing cmdline
we override atag memory on reboot, so preserve
the memsize learned from atag as *maxmem plan9
variable. the global memsize variable is not
needed anymore.

avoid trashing the following atag when zero
terminating the cmdline string.

zero memory after plan9.ini variables.
2019-05-13 19:12:41 +02:00
cinap_lenrek 157d7ebdbd devip: do not lock selftab in ipselftabread(), remove unused fields from Ipself
the Ipselftab is designed to not require locking on read
operation. locking the selftab in ipselftabread() risks
deadlock when accessing the user buffer creates a fault.

remove unused fields from the Ipself struct.
2019-05-12 01:20:21 +02:00
cinap_lenrek 333c320204 devip: reset speed and delay on bind, adjust burst on mtu change, ifc->m nil check, consistent error strings
initialize the rate limits when the device gets
bound, not when it is created. so that the
rate limtis get reset to default when the ifc
is reused.

adjust the burst delay when the mtu is changed.
this is to make sure that we allow at least one
full sized packet burst.

make a local copy of ifc->m before doing nil
check as it can change under us when we do
not have the ifc locked.

specify Ebound[] and Eunbound[] error strings
and use them consistently.
2019-05-11 17:22:33 +02:00
cinap_lenrek 7186be0424 devip: make sure ifc is bound in add6 ctl command 2019-05-11 14:54:10 +02:00
cinap_lenrek 3a0d5f41a8 devip: remove unused c->car qlock, avoid potential deadlock in ipifcregisterproxy()
remove references to the unused Conv.car qlock.

ipifcregisterproxy() is called with the proxy
ifc wlock'd, which means we cannot acquire the
rwlock of the interfaces that will proxy for us
because it is allowed to rlock() multiple ifc's
in any order. to get arround this, we use canrlock()
and skip the interface when we cannot acquire the
lock.

the ifc should get wlock'd only when we are about
to modify the ifc or its lifc chain. that is when
adding or removing addresses. wlock is not required
when we addresses to the selfcache, which has its
own qlock.
2019-05-11 14:01:26 +02:00
cinap_lenrek a25819c43a devip: avoid media bind/unbind kproc reader startup race, simplify etherbind
mark reader process pointers with (void*)-1 to mean
not started yet. this avoids the race condition when
media unbind happens before the kproc has set its
Proc* pointer. then we would not post the note and
the reader would continue running after unbind.

etherbind can be simplified by reading the #lX/addr
file to get the mac address, avoiding the temporary
buffer.
2019-05-11 07:22:34 +02:00
cinap_lenrek db3bf8271b bcm64: use exclusive monitor on nrdy to wake up idlehands()
when the exclusive monitor is cleared, a event is generated
which we can use to wake up idlehands. that way we do not
need to wait for the next timer interrupt until a cpu takes
work from the run queue.
2019-05-10 14:05:04 +02:00
cinap_lenrek 9d790238f2 bcm64: use MOVP instruction for saving and restoring registers 2019-05-09 11:11:45 +02:00
cinap_lenrek 1046d3e30b bcm64: map framebuffer write-through to allow unaligned access 2019-05-09 02:17:50 +02:00
cinap_lenrek f22b4ecc77 bootrc: fix $rootdir and $rootspec handling (thanks lucio)
we did not interpret the $rootdir and $rootspec environment
variables right. $rootdir is what gets bound to / (usually /root)
and $rootspec is the mountspec of /root.
2019-05-05 17:02:37 +02:00
cinap_lenrek 75d44bc306 bcm: make sure fiq is on enabled on cpu0 2019-05-05 14:04:27 +02:00
cinap_lenrek de7190ba6b bcm64: provide idlehands() function 2019-05-05 13:59:03 +02:00
cinap_lenrek b0c402dfa6 bcm64: get rid of usb workaround delay 2019-05-05 13:57:48 +02:00
cinap_lenrek 4d96c40a47 usbdwc: enable Slowbuilkin workarround, improve split transaction timing, handle erroring sleep(), debugging
i'v been seeing the error condition described above in the
Slowbulkin comment. so i'm enabling the work arround which
seems to fix the lockup.

in the split transaction case where we want to start the
transaction at frame start, acquire the ctlr lock *before*
checking if we are in the right frame number. so the start
will happen atomically. checking the software ctlr->sofchan
instead of checking the interrupt mask register seems to
be quicker.

setting the haint mask bit for the chan under ctlr lock
in chanio() instead of chanwait() avoids needing to acquire
the ctlr lock twice.

mask wakechan bits with busychan bitmap in interrupt handlers
so we will not try to wake up released chans by accident.

sleep() and tsleep() might get interrupted so we have to
release the split qlock in the split transaction case and
in all cases, make sure to halt the channel before release.

add some common debug functions to dump channel and controller
registers.
2019-05-05 13:34:02 +02:00
cinap_lenrek 70ea1310d1 pc kernel: remove countpagerefs() (thanks BurnZeZ)
forgot to commit this...
2019-05-03 23:52:49 +02:00
cinap_lenrek 0b5e782882 kernel: exec support for arm64 binaries 2019-05-03 23:15:42 +02:00
cinap_lenrek c6ad540af5 bcm64: add experimental work in progress arm64 kernel for raspberry pi 3 2019-05-03 23:14:57 +02:00
cinap_lenrek 1a7c224b3e bcm: don't call nil on PADDR() in dmaaddr(), return busdram dummy address 2019-05-03 22:53:09 +02:00
cinap_lenrek eb4bd4aa3e bcm: move fiq saved pc adjust into lexception.s so it can be shared with arm64 2019-05-03 22:02:07 +02:00
cinap_lenrek 3ca395a36c uartpl011: dont touch line control while uart is enabled 2019-05-03 21:34:20 +02:00
cinap_lenrek fe594760eb kernel: get rid of checkpagerefs() debugging
was only implemented by the pc kernel. does not
account pages used by the mount cache.
2019-05-01 12:40:27 +02:00
cinap_lenrek b452f8857f kernel: export freepages() function so it can be used in mmurelease() 2019-05-01 10:07:39 +02:00
cinap_lenrek a6ee23a739 kernel: include lock pointer in error report, stop spamming lockloop prints when we are panicing 2019-05-01 09:39:02 +02:00
cinap_lenrek 54562b6ac2 kernel: insert memory barrier in the scheduler before setting up->mach = nil
we have to ensure that all stores saving the process state
have completed before setting up->mach = nil in the scheduler.
otherwise, another cpu could observe up->mach == nil while
the stores such as the processes p->sched label have not finnished.
2019-05-01 09:35:51 +02:00
cinap_lenrek 2f884a5116 ether8169: fix thinkpad A485 ethernet (thanks mischief)
attached is a patch to fix receive in the 8169 chip on my thinkpad
A485. i'm not sure why, but the same thing was done in 3d56a0fc4645
for Macv45.

nick
2019-04-27 21:55:16 +02:00
cinap_lenrek a0da5b973f usbxhci: make stuck usb transactions interruptable.
some control transactions can confuse the xhci controller so
much that it even fails to respond to command abort or STOPEP
control command. with no way for us to abort the transaction
but a full controller reset.

we give the controller 5 seconds to abort our initial
transaction and if that fails we wake the recover process
to reset the controller.

thanks mischief for testing.
2019-04-19 23:39:47 +02:00
cinap_lenrek b44440bd16 devsd: fix sddelpart() AGAIN
the previous "fix" missed to advance pp so after
we hit a invalid partition all following partitions
would be ignored.
2019-04-16 16:25:33 +02:00
BurnZeZ 75ee3b3081 devsd: fix panic when using "delpart" to remove a partition that was already removed 2019-04-15 19:48:03 +00:00
mischief 82438139d6 pc: audiohda: recognize AMD Family 17h hd audio controller 2019-04-13 23:11:19 -07:00
mischief 79e24f5ee5 pc: devarch: recognize AMD Ryzen model 2019-04-13 23:08:26 -07:00
mischief 7accf11170 pc: pci: add AMD FCH LPC bridge to southbridges 2019-04-13 23:07:57 -07:00
cinap_lenrek 83c7a727e0 devip: reject bad numeric ports (such as 9fs -> 9) 2019-04-14 03:22:05 +02:00
cinap_lenrek 810aed76a5 bcm: move CONFADDR parsing into bootargs.c, simplify initcode start() args handling 2019-04-11 19:10:47 +02:00
cinap_lenrek 6aff58df75 bcm: don't use PADDR() to convert bus address to physical in vcore 2019-04-11 17:12:20 +02:00
cinap_lenrek 9ae99fb5ad kernel: get rid of KSTKSIZE alias for KSTACK 2019-04-11 14:05:23 +02:00
cinap_lenrek 37d36fdd7f kernel: get rid of PTR2UINT() and UINT2PTR() macros 2019-04-11 13:51:38 +02:00
cinap_lenrek 753fa51b77 bcm: dont assume PHYSDRAM 0 in dmaaddr(), fix dmaioaddr() 2019-04-11 13:49:41 +02:00
cinap_lenrek 6a3a3d69c6 bcm: add pl011 uart driver
the raspi has two uarts, the pl011 and the mini. only one
can be used at a time due to pin muxing. the bcm kernel
uses the mini by default.
2019-04-11 13:21:06 +02:00
cinap_lenrek fe34e52d19 bcm: move okay() from uartmini.c to devarch.c 2019-04-10 15:06:56 +02:00
cinap_lenrek f00aa6b92a bcm: add irq.c to mkfile 2019-04-10 15:06:24 +02:00
cinap_lenrek 55a3964517 bcm: move interrupt handling out of trap.c into irq.c 2019-04-10 15:04:59 +02:00
cinap_lenrek 3e65a15ae0 audiohda: add support for Gemini-Lake audio in Intel NUC nuc7pjyh (thanks sam-d) 2019-04-08 15:50:13 +02:00
cinap_lenrek 6540a9a21a sgi: remove obsolete TSTKTOP constant 2019-04-04 15:28:04 +02:00
cinap_lenrek b7105fe066 xen: remove obsolete TSTKTOP constant 2019-04-04 15:25:10 +02:00
cinap_lenrek 8b160d1ea1 bcm: remove obsolete TSTKTOP constant 2019-04-04 15:23:20 +02:00
cinap_lenrek 0132e7fed0 pc64: get rid of TSTKTOP, USTKTOP is the end of user address space
the temporary stack segment used to be at a fixed address above or
below the user stack. these days, the temp stack is mapped dynamically
by sysexec so TSTKTOP is obsolete.
2019-04-04 15:21:25 +02:00
BurnZeZ 3f1fefeafb bootrc: simplify if statement 2019-03-30 15:09:00 +00:00
cinap_lenrek 4f0bfe0fb8 dtracy: avoid dmachlock() race
between being commited to a machno and having acquired the lock, the
scheduler could come in an schedule us on a different processor. the
solution is to have dtmachlock() take a special -1 argument to mean
"current mach" and return the actual mach number after the lock has
been acquired and interrupts being disabled.
2019-03-30 09:17:46 +01:00
cinap_lenrek 2f5983ba02 bootrc: handle automatic ip configuration on gbe media 2019-03-27 14:17:51 +01:00
cinap_lenrek 8d9f3906fa plan9.ini: add nora6= option to disable automatic ipv6 configuration 2019-03-27 14:11:25 +01:00
cinap_lenrek 1e97adc86b nusbrc: detect "keyboardio model 01", appears as multifuction device with IAD csp(0102EF) (thanks sam-d) 2019-03-21 02:14:40 +01:00
cinap_lenrek 4b8f7a2110 devip: ignore the evil bit in fragment info field
using ~IP_DF mask to select offset and "more fragments" bits
includes the evil bit 15. so instead define a constant IP_FO
for the fragment offset bits and use (IP_MF|IP_FO). that way
the evil bit gets ignored and doesnt cause any useless calls
to ipreassemble().
2019-03-07 22:39:50 +01:00
cinap_lenrek 4885c75526 devip: ignore icmp advise about laggard fragments
icmp has to advise protocols about the first
fragment only. all other fragments should be
ignored.
2019-03-07 01:25:11 +01:00
qwx b7525d1ed8 igfx: add support for 915gm
tested on a t43 with igfx and a 1600x1200 t43p screen
what works: lvds, blanking
what doesn't: hwgc (not visible), snarfing edid
untested: vga

based on realemu traces.
2019-03-04 21:37:52 +01:00
cinap_lenrek 57284d07ca devip: ignore reserved fragment offset bits 2019-03-04 12:07:40 +01:00
cinap_lenrek e2d310e623 devip: handle packet too big advise for icmp6, remove fragment header 2019-03-04 03:13:29 +01:00
cinap_lenrek 2af6b08960 devip: use common code in icmp for handling advise 2019-03-04 03:09:39 +01:00
cinap_lenrek 827020f686 devip: zero fragment offset after reassembly, remove tos magic, cleanup 2019-03-04 03:08:27 +01:00
cinap_lenrek a1fceabd5b devip: fix fragment forwarding
unfraglen() had the side effect that it would always copy the
nexthdr field from the fragment header to the previous nexthdr
field. this is fine when we reassemble packets but breaks
fragments that we want to just forward unchanged.
2019-03-04 03:05:30 +01:00
cinap_lenrek fa97c3dd10 devip: simplify ip reassembly functions, getting rid of Ipfrag.hlen
given that we now keep the block size consistent with the
ip packet size, the variable header part of the ip packet
is just: BLEN(bp) - fp->flen == fp->hlen.

fix bug in ip6reassemble() in the non-fragmented case:
reload ih after ip header was moved before writing ih->ploadlen.

use concatbloc() instead of pullupblock().
2019-03-03 18:56:18 +01:00
cinap_lenrek a859f05837 devip: fix block list handling for icmp/icmp6, use proper MinAdvise for icmp6 2019-03-03 09:01:23 +01:00
cinap_lenrek a2c0e55e68 qio: handle common case in trimblock() 2019-03-03 05:26:09 +01:00
cinap_lenrek 5b972a9aea devip: fix ip fragmentation handling issues with header options
some protocols assume that Ip4hdr.length[] and Ip6hdr.ploadlen[]
are valid and not out of range within the block but this has
not been verified. also, the ipv4 and ipv6 headers can have variable
length options, which was not considered in the fragmentation and
reassembly code.

to make this sane, ipiput4() and ipiput6() now verify that everything
is in range and trims to block to the expected size before it does
any further processing. now blocklen() and Ip4hdr.length[] are conistent.

ipoput4() and ipoput6() are simpler now, as they can rely on
blocklen() only, not having a special routing case.

ip fragmentation reassembly has to consider that fragments could
arrive with different ip header options, so we store the header+option
size in new Ipfrag.hlen field.

unfraglen() has to make sure not to run past the buffer, and hadle
the case when it encounters multiple fragment headers.
2019-03-03 05:25:00 +01:00
cinap_lenrek 967b1248f8 libip: move optimized 386 assembly version of ptclbsum() from kernel to libip 2019-02-27 18:29:08 +01:00
cinap_lenrek 88ccea37f6 kernel: remove ptclbsum dependencies from configs 2019-02-27 08:47:17 +01:00
cinap_lenrek 242403d9f9 pi, pi2: remove ptclbsum dependency from config 2019-02-27 08:38:19 +01:00
cinap_lenrek 66ab4ac223 pc, pc64: fix %.*s format in multibootargs 2019-02-25 04:25:36 +01:00
cinap_lenrek 96d6f44335 wifi: fix %.*s format in wifictl 2019-02-25 04:22:03 +01:00
cinap_lenrek 06912e53e4 devip: remove unused eipconvtet.c and ptclbsum.c files 2019-02-13 17:42:20 +01:00
cinap_lenrek 57ed5cc3f0 devip: ipv6 loopback ::1 has link-local scope 2019-02-13 08:46:49 +01:00
cinap_lenrek 7102a23245 devip: use parseipandmask() for ipifc and route control message parsing 2019-02-11 23:43:14 +01:00
cinap_lenrek 31637404ba bcm: include sdmmc in pi kernel configuration 2019-02-01 23:31:44 +01:00
cinap_lenrek cefc849a95 devdraw: get rid of softscreen==0xa110c hack and make attachscreen() return Memdata*
all screen implementations use a Memimage* internally
for the framebuffer, so we can return a shared reference
to its Memdata structure in attachscreen() instead of
a framebuffer data pointer.

this eleminates the softscreen == 0xa110c hack as we
always use shared Memdata* now.
2019-01-30 18:22:52 +01:00
cinap_lenrek 8e1218aceb bcm: list devswap only once in devtab array 2019-01-30 18:05:04 +01:00
cinap_lenrek 5b5416aa05 devdraw: simplify drawgen() 2019-01-28 23:29:22 +01:00
cinap_lenrek 8152e9d075 devip: tcp: Don't respond to FIN-less ACKs during TIME-WAIT (thanks Barret Rhoden)
Under the normal close sequence, when we receive a FIN|ACK, we enter
TIME-WAIT and respond to that LAST-ACK with an ACK.  Our TCP stack would
send an ACK in response to *any* ACK, which included FIN|ACK but also
included regular ACKs.  (Or PSH|ACKs, which is what we were actually
getting/sending).

That was more ACKs than is necessary and results in an endless ACK storm
if we were under the simultaneous close sequence.  In that scenario,
both sides of a connection are in TIME-WAIT.  Both sides receive
FIN|ACK, and both respond with an ACK.  Then both sides receive *those*
ACKs, and respond again.  This continues until the TIME-WAIT wait period
elapses and each side's TCP timers (in the Plan 9 / Akaros case) shut
down.

The fix for this is to only respond to a FIN|ACK when we are in TIME-WAIT.
2019-01-27 22:12:50 +01:00
cinap_lenrek 058951bb80 devtls: remove static "already" flag in tlsinit(). this function is only run once. 2019-01-22 22:08:07 +01:00
cinap_lenrek 26d36c3ae2 devswap: simplify, don't panic when writing swapfile fails
always start the pager kproc in swapinit(), simplifying kickpager().

allow zero conf.nswap and conf.nswppo. avoid allocating the reference
map and iolist arrays in that case.

use ulong for ioptr and iolist indices.

don't panic when writing pages out to the swapfile fails. just
requeue the page in the io transaction list so we will try
again next time executeio() is run or just free the page when
the swap reference was dropped.

remove unused pagersummary() function.
2019-01-22 22:06:42 +01:00
cinap_lenrek 4b2f31131a pc64: properly handle faulterror in faultamd64()
replicate what faulterror() would have done with up->nerrlab == 0,
that is, terminate the process.
2019-01-22 21:55:20 +01:00
cinap_lenrek 83aa7ba709 ether82563: fix bugus FCA write and link detection for i217
the FCA registers 0x28, 0x2C have been reassigned to
to FEXTNVM on i217, i218 and i219 so add Fnofca flag
and avoid writing the registers.

make link detection more robust on i217 by delaying the
phy status read after link status change by 150ms. we'd
otherwise get a "phy wedged" (power saving state?) and
not update the link status until the next link change.
2019-01-13 17:17:11 +01:00
cinap_lenrek 998d478550 ether82563: work arround spurious jumbo packets on i217 (thanks k0ga)
i217 appears to receive spurious jumbo frame and then
stops receiving completely. reducing the mtu to 2k as
a work arround for now.
2019-01-12 21:07:12 +01:00
cinap_lenrek 0de56a9913 ether82563: use 9018 byte mtu from datasheet for i217, i218, i219 2019-01-12 19:37:37 +01:00
cinap_lenrek 53275c7045 ether82563, ether82598, etherx550: round rbsz to multiple of 1K
the max packet size is configured in 1K increments on these chips,
which can result in the card receiving a 10K packet but the
driver having only allocated 9.5K of buffer. this actually caued
pool corruption with i210, i217, i218, i219, i350.

for 82598 and x550, we explicitely round rbsz to avoid similar bugs
in the future, even tho the Rbsz constant was already a multiple of
1K and is not affected by the bug.
2019-01-12 15:34:23 +01:00
cinap_lenrek d0f824edc2 pc, pc64: properly track dependencies for mem.h on autogenerated apbootstrap.h and reboot.h targets 2019-01-04 02:51:29 +01:00
cinap_lenrek d843bc8e22 etherx550: add intel 10GB ethernet controlller x550 driver (thanks joe9) 2018-12-23 17:48:11 +01:00
cinap_lenrek 426c989317 ether82598: fix multicast filter (thanks aiju, joe9) 2018-12-23 17:41:47 +01:00
cinap_lenrek 9fe1377336 dtracy: avoid pointer to integer truncation warning on amd64 2018-12-15 20:39:32 +01:00
aiju c7304ea03c dtracy: get rid of DTName struct, support more than three parts in a probe name, wildcard matching 2018-12-13 10:42:49 +00:00
aiju a6517fb498 kernel: change peek to return number of characters left rather than 0/-1 2018-12-11 09:17:44 +00:00
aiju cc066d8130 dtracy: catch page faults 2018-12-11 09:09:08 +00:00
aiju 6f30420136 add dtracy support to mkdevc and enable dtracy with plan9.ini 2018-12-11 07:44:34 +00:00
aiju ca851bbb5e dtracy: call dtptrigger with a struct pointer rather than a list of arguments; put return value in arg9 2018-12-09 21:43:22 +00:00
aiju 58fa29447b dtracy: add support for aggregations 2018-12-08 15:07:53 +00:00
cinap_lenrek 6891093034 kernel: remove unused static variable "sofar" from timerintr() (thanks mischief) 2018-12-05 03:59:08 +01:00
cinap_lenrek d15aca0532 kernel: fix tprof on multiprocessor
segclock() has to be called from hzclock(), otherwise
only processes running on cpu0 would catche the interrupt
and the time delta would be wrong.

lock the segment when allocating Seg->profile as
profile ctl might be issued from multiple processes.
Proc->debug qlock is not sufficient.

Seg->profile can never be freed or reallocated once
set as the timer interrupt accesses it without any
locking.
2018-12-05 01:43:19 +01:00
cinap_lenrek c5393d612f bootrc: remove $ff references (was old parsed /boot/boot argument list) 2018-12-04 18:55:56 +01:00
cinap_lenrek 099da8cb82 devip: fix arpread, dont return partial entries 2018-11-28 12:41:18 +01:00
cinap_lenrek 4dee686ca5 pc, pc64: park application processors in rebootcode with mmu off
instead of having application processors spin in mpshutdown()
with mmu on, and be subject to reboot() overriding kernel text
and modifying page tables, park the application processors in
rebootcode idle loop with the mmu off.
2018-11-19 18:42:01 +01:00
cinap_lenrek 196da4ec6f devip: fix swapped tcp snd.scale and recv.scale in tcpstate() format (thanks joe9) 2018-11-18 04:14:41 +01:00
mischief a25418fddc devbridge: fix runt packets going through the bridge (thanks cinap)
linux will send small, unpadded arp packets which may arrive over
wifi, so allow small packets into the bridge and pad any packets that
are too small when going out.
2018-11-17 17:23:56 -08:00
mischief 744867de34 ether82563: ignore i82753 checksums, fixes T60 ethernet 2018-11-14 11:33:52 -08:00
aiju e6d99771e5 adding dtracy (crude early version) 2018-11-10 13:46:16 +00:00
cinap_lenrek 85afec4c2f bcm: intrenable() can happen from any cpu in case of dma interrupts 2018-11-08 20:26:32 +01:00
cinap_lenrek c0d21d35b1 bcm: cleanup timer code
- calculate hardcoded constants for more clarity
- avoid unneccesary modification of cntpns ctl register
- revert enabling IRQcntpns for cpu0
- remove unused Localintpending register offset constant
2018-11-07 17:02:09 +01:00
cinap_lenrek 385f52183c bcm: simplify irq handling by having per cpu Vctl chain 2018-11-07 16:49:50 +01:00
cinap_lenrek b0d226705c bcm: speed up co-processor operations by avoiding i+d cache flush on each operation
coproc.c generated the instrucitons anew each time,
requiering a i+d cache flush for each operation.

instead, we can speed this up like this:

given that the coprocessor registers are per cpu, we can
assume that interrupts have already been disabled by
the caller to prevent a process switch to another cpu.

we cache the instructions generated in a static append
only buffer and maintain separate end pointers for each
cpu.

the cache flushes only need to be done when new
operations have been added to the buffer.
2018-11-07 16:48:14 +01:00
aiju 0bd213b7b0 devvmx: remove bogus . direntry 2018-11-04 16:03:35 +00:00
cinap_lenrek 89c659d80b bcm: fix mysterious core clock resets under SMP (thanks richard miller)
reference: https://github.com/raspberrypi/firmware/issues/542

procsave(Proc* p)
{
	uvlong t;

	cycles(&t);
	p->pcycles += t;

// TODO: save and restore VFPv3 FP state once 5[cal] know the new registers.
	fpuprocsave(p);
	/*
	 * Prevent the following scenario:
	 *	pX sleeps on cpuA, leaving its page tables in mmul1
	 *	pX wakes up on cpuB, and exits, freeing its page tables
	 *  pY on cpuB allocates a freed page table page and overwrites with data
	 *  cpuA takes an interrupt, and is now running with bad page tables
	 * In theory this shouldn't hurt because only user address space tables
	 * are affected, and mmuswitch will clear mmul1 before a user process is
	 * dispatched.  But empirically it correlates with weird problems, eg
	 * resetting of the core clock at 0x4000001C which confuses local timers.
	 */
	if(conf.nmach > 1)
		mmuswitch(nil);
}
2018-11-04 16:00:32 +01:00
cinap_lenrek dd82b657c0 bcm: fix mistake in mkfile 2018-11-01 01:07:51 +01:00
cinap_lenrek 5608be398e bcm: fix /dev/reboot text/data corruption (thanks richard miller)
- clean dcache before turning off caches and mmu (rebootcode.s)
- use WFE and inter-core mailboxes for cpu startup (rebootcode.s)
- disable SMP during dcache invalidation before enabling caches and mmu (in armv7.s)
2018-10-31 19:48:16 +01:00
cinap_lenrek 8e9d2434e9 bcm: provide /dev/cputemp in a format stats can understand 2018-10-28 07:10:27 +01:00
cinap_lenrek b715c39bfa bcm: simplify reboot code
- synchronize rebootcode installation
- handle the 1MB identity map in mmu.c (mmuinit1())
- do not overlap CONFADDR with rebootcode, the non boot
  processors are parked there.
- make REBOOTADDR physical address
2018-10-28 06:16:10 +01:00
cinap_lenrek 0fc2adb43d bcm: cleanup clock code
- disable local clock on interrupt to prevent accidents when reenabling
- always regitster local clock interrupt handler, even for cpu0
- simplify microdelay()
- don't mess with watchdog
2018-10-28 06:09:05 +01:00
cinap_lenrek f17a5cc2cf bcm: fix l2 cache maintenance routines for raspi3 (armv8)
armv8 has 16-way l2, so adjust shift for the set-way cache
tag format.
2018-10-28 06:05:43 +01:00
cinap_lenrek 2ee4c08974 devuart: don't sleep in uartdrainoutput() when called splhi or without a process
uartdrainoutput() might be called in early initialization
from uartctl() without a process.
2018-10-27 20:00:12 +02:00
23hiro 05021e0579 add Centrino Wireless-N 1030 (thanks lksmk from brazil) 2018-10-25 08:09:10 +02:00
cinap_lenrek 83e20b4df1 bcm: import changes for raspi2/3 from richard miller 2018-10-20 19:56:31 +02:00
cinap_lenrek 796e5e6000 nusbrc: support for raspi3 ethernet 2018-10-20 19:53:57 +02:00
cinap_lenrek 37dcb25eee kernel: fix allocb for BLOCKALIGN*2 >= Hdrspc 2018-10-20 19:52:54 +02:00
cinap_lenrek c4ec69045e devusb: use Enotconf[] string constant 2018-10-20 19:41:37 +02:00
mischief 8eecdc9664 etheriwl: support type 2000 devices and the 2200 chip in x230t 2018-10-10 16:37:13 -07:00
mischief 67e14807e9 nusbrc: prevent nusb/kb from attaching to sony ps3 controller 2018-10-10 13:49:03 -07:00
cinap_lenrek 679a253931 usbxhci: only clear RW1C bits when set. 2018-10-08 07:10:59 +02:00
cinap_lenrek 2fecc5789e usbxhci: delay after reset, preserve reserved bits in legacy status control register in handoff()
when clering smi enable bits in the legacy control/status register,
preserve the reserved bits. clear the RW1C bits.

linux code claims intel xhci controller needs a 1ms delay before
accessing any register after reset.
2018-10-08 07:05:28 +02:00
cinap_lenrek c458216121 pc drivers: more pci cleanup 2018-10-07 23:38:41 +02:00
cinap_lenrek 9fec0e7360 pc drivers: use pcienable() to handle device power up and missing initialization 2018-10-07 22:28:21 +02:00
cinap_lenrek 4d7c195804 pc, pc64: add pcienable() and pcidisable() functions
pcienable() puts a device in fully powered on state
and does some missing initialization that UEFI might
have skipped such as I/O and Memory requests being
disabled.

pcidisable() is ment to shutdown the device, but
currently just disables dma to prevent accidents.
2018-10-07 21:52:53 +02:00
cinap_lenrek f9839ed0a2 usbehci, usbxhci: add *noehcihandoff= and *noxhcihandoff= parameters
on Samsung ATIV Smart PC Pro XE00T1C-A01CL, the EHCI handoff
causes the system to freeze in UEFI mode as soon as we assert
the os semaphore bit.

until a general solution is found, provide these parameters to
disable the handoff for now as it seems to otherwise work fine.
2018-10-06 00:29:05 +02:00
cinap_lenrek 83876083c9 pc, pc64: increase CONFADDR buffer from 4K to 24K
move APBOOTSTRAP and TMPADDR to make space available for
boot parameters. which can become quite long such as *e820.
2018-10-06 00:26:07 +02:00
cinap_lenrek b56450471f devip: remove unused QLock from udp and icmpv6 control blocks (thanks brho) 2018-10-03 00:47:34 +02:00
cinap_lenrek 02b867f01e devip: only add interface route for "on-link" prefixes
when a prefix is added with the onlink flag clear, packets
towards that prefix needs to be send to the default gateway
so we omit adding the interface route.

when the on-link flag gets changed to 1 later, we add the
interface route.

the on-link flag is sticky, so theres no way to clear it back
to zero except removing and re-adding the prefix.
2018-09-28 18:13:01 +02:00
cinap_lenrek 94333ce6a6 devip, ipconfig: avoid overflow on lifetime checks 2018-09-23 22:07:56 +02:00
cinap_lenrek 70c6bd0397 devip: valid and prefered life-time should be unsigned, add remove6 ctl command 2018-09-23 19:09:48 +02:00
cinap_lenrek 4a92a8f6b2 devip: fix default parameter calculation for router life-time
router life time is in seconds, while max ra interval is
in milliseconds!
2018-09-23 19:08:16 +02:00
cinap_lenrek 259ce5e3de devip: make updating ra6 router parameters atomic
when we fail to parse and validate the command, no update
should take place.
2018-09-23 17:24:59 +02:00
cinap_lenrek 6b9cc409de mtx, ppc: remove cistrcmp() and cistrncmp() redefinition 2018-09-18 19:34:29 +02:00
cinap_lenrek bd49212b46 kernel: fix livelock in rebalance (thanks Richard Miller)
Once a second rebalance() is called on cpu0 to adjust priorities,
so cpu-bound processes won't lock others out.  However it was only
adjusting processes which were running on cpu0.  This was observed
to lead to livelock, eg when a higher-priority process spin-waits
for a lock held by a lower priority one.
2018-09-18 00:53:05 +02:00
cinap_lenrek 2985d53b7a bootrc: add experimental reboot method to load another kernel
syntax: reboot!bootfile[!method...]

this echos bootfile to /dev/reboot, causing bootfile kernel
to be started.

when method is given, we first connect to the filesystem and
set bootargs so that bootfile can be loaded from the target
network or local fileserver.

note, when no bootfile is given, this causes the kernel to
reboot to bios.
2018-09-16 22:35:16 +02:00
mischief 5ea7337ae7 port: sync two longjmp fixes from drawterm
see drawterm commits f5e26ae93a6a and fa388286b4ca
2018-09-12 00:35:45 -07:00
cinap_lenrek b591ee195b devarch: reading msr 0xffffffff 2018-09-09 01:53:53 +02:00
cinap_lenrek ba7b07d51a devarch: restrict i/o port access to 64K, disallow msr 32-bit wrap arround (thanks aiju) 2018-09-09 01:41:35 +02:00
cinap_lenrek 97a2e35a0c devarch: fix /dev/msr (thanks joe9, aiju)
the end condition port < offset+n could never become
false when offset truncated to 32 bit signed port is
negative. change the condition variables to unsigned
int.

msr's are not byte addressible, so advance reads by
one instead of 8.
2018-09-08 22:24:36 +02:00
cinap_lenrek 2d9147a33c rtl8169: fix receive for nuc BOXNUC7CJYH 2018-08-31 22:39:46 +02:00
mischief 67b24e6dac nusbrc: add LG G5 for nusb/ether 2018-08-30 16:23:36 -07:00
cinap_lenrek 11d1947814 arp: interface address only specifies the interface, not the source address for route lookup 2018-08-30 21:17:54 +02:00
cinap_lenrek 5c945a0b48 devip: fix router adv/sol options validation (options padded to 8 bytes) 2018-08-27 20:58:48 +02:00
cinap_lenrek 5c326d9f35 devvga: disable cursor on shutdown avoiding graphics glitches on reboot 2018-08-25 21:44:08 +02:00
mischief 4e938841f0 igfx: support blanking by turning off panel power and backlight
tested on t61, x200, x230, x301, t420, w520
2018-08-21 11:31:45 -07:00
cinap_lenrek 670137bf0a devdraw: zero initialize DImage.dscreen pointer (vnc, drawterm) 2018-08-19 22:00:45 +02:00
cinap_lenrek cd752a39f8 ipv6 autoconfiguration on ethernet
for ip autoconfiguration, setup ipv6 link local addresses
and do SLAAC in parallel to DHCP.
2018-08-15 21:39:30 +02:00
cinap_lenrek e49f7fc1f7 devip: fix multicastarp() when ipconfig assigned the 0 address
sending multicast was broken when ipconfig assigned the 0
address for dhcp as they would wrongly classified as Runi.

this could happen when we do slaac and dhcp in parallel,
breaking the sending of router solicitations.
2018-08-11 16:18:12 +02:00
cinap_lenrek 445fc8e5a7 merge 2018-08-06 23:14:59 +02:00
cinap_lenrek abe463b931 wifi: lilu dallas multirate
now handle the supported rates element properly, only
providing the intersecting set of rates that the bss
advertises and what the driver supports, putting the
basic rates first.

also avoid using usupported rates.
2018-08-06 23:13:23 +02:00
mischief eb1be5b4df devaoe: really fix unit numbering, to be 0-based 2018-08-06 09:41:28 -07:00
mischief 796c41092a devaoe: fix unit numbering for Qdevlinkdir
a side effect of 3c77cd3ae664 changed the unit ordering to start at one, so fix the condition accordingly.
2018-08-06 08:50:40 -07:00
cinap_lenrek 2b619dc966 etheriwl: add pci did for WifiLink 5300 (thans senthil) 2018-07-31 18:33:42 +02:00
cinap_lenrek 6cd83e5d24 audiohda: support Intel Sunrise Point-LP on thinkpad X1 2018-07-26 02:48:00 +02:00
cinap_lenrek d07fb3261f devmouse: produce signed msec timestamp in /dev/mouse, accept unsigned on write 2018-07-23 19:29:15 +02:00
cinap_lenrek 0431ea242d pc, pc64: look for "RSD PTR " in ACPI reserved memory region from e820 map
nobody passes us the "RSD PTR " address when doing multiboot/kexec
on UEFI systems. so we search for it manually in the ACPI reserved
area as indicated in the e820 memory map.
2018-07-22 21:00:20 +02:00
cinap_lenrek 0d7bbda9b9 devmnt: make sure auth chan is on said conection in mntattach() 2018-07-16 01:35:02 +02:00
cinap_lenrek 51b0b0235b bootrc: write fatal error message to fd2 2018-07-14 17:20:49 +02:00
aiju d16a96daca pc64: update headers to match pc 2018-07-11 16:05:03 +01:00
aiju 6b0de3de8e pc: fix ugly and partially broken switch() statement 2018-07-11 15:12:24 +01:00
aiju 3a77c01f43 pc kernel: get rid of ugly and partially broken cpuid macros 2018-07-11 14:50:22 +01:00
cinap_lenrek a8a6429204 devip: make il connect fail quickly when theres no route 2018-07-10 09:11:19 +02:00
cinap_lenrek 9898aafa0c devip: don't pad the tag for routing commands (fixes removing routes with < 4 character tags) 2018-07-09 01:32:21 +02:00
cinap_lenrek 8dd003eb04 devip: fix flush, copy tag when replacing route entry 2018-06-19 21:17:15 +02:00
cinap_lenrek 0763dd4279 zunq: add sdram driver 2018-06-14 21:54:42 +02:00
cinap_lenrek 4971db9e32 udp: fix udp checksum
we did not apply the special case to store 0xFFFF (-0)
in the checksum field when the checksum calculation
returned zero. we survived this for v4 as RFC768 states:

> If the computed checksum is zero, it is transmitted as
> all ones (the equivalent in one's complement arithmetic).
>
> An all zero transmitted checksum value means that the
> transmitter generated no checksum (for debuging or for
> higher level protocols that don't care).

for ipv6 however, the checksum is not optional and receivers
would drop packets with a zero checksum.
2018-06-14 20:48:21 +02:00
cinap_lenrek 39fb26df70 9pc, 9pc64: make mapalloc() and mapfree() static in memory.c 2018-06-14 20:22:34 +02:00
cinap_lenrek de9141bc6d devip: don't send arp requests from null address
during dhcp, ipconfig assigns the null address :: which makes
ipforme() return Runi for any destination, which can trigger
arp resolution when we attempt to reply. so have v4local()
skip the null address and have sendarp() check the return
status of v4local(), avoing the spurious arp requests.
2018-06-14 00:07:45 +02:00
cinap_lenrek 71ce6f53a4 devip: reject incompatible multicast/interface ip address pairs for ipifcaddmulti() 2018-06-13 18:58:17 +02:00
cinap_lenrek 8fdd633d57 devip: fix missing wunlock() for "ipifc not yet bound to device" case, don't create multicast entry on error 2018-06-12 20:31:39 +02:00
cinap_lenrek 71402b2ea1 devip: fix use after free in ipifcremmulti()
closeconv() calls ipifcremmulti() like:

	while((mp = cv->multi) != nil)
		ipifcremmulti(cv, mp->ma, mp->ia);

so we have to defer freeing the entry after doing:

		if((lifc = iplocalonifc(ifc, ia)) != nil)
			remselfcache(f, ifc, lifc, ma);

which accesses the otherwise free'd ia and ma arguments.
2018-06-11 03:19:42 +02:00
cinap_lenrek 94f6f89ac1 devip: do not icmp reply on multicast destination 2018-06-11 03:14:28 +02:00
cinap_lenrek eed90aa0ad kernel: don't cap the minimum sleep time to TK2MS(1) for syssleep()
on HZ 100 systems like pc and pc64, the minium sleep time
was 10ms, which is quite high. the cap isnt really needed
as arch specific timerset() enforces its own limit, but on
a higher resolution.

background:

from Charles Forsyth:

I haven't really got an opinion on it. The 10ms interval was first used on
machines that were much slower.
I thought someone did set HZ to a bigger value, partly to support better
in-kernel timing. I haven't done it because I never had a need for it.
If I were doing (say) protocol implementation in user mode, I'd certainly
reconsider. Sleep itself forces at best ms granularity,
and for some applications that's too big.

initial mail from qwx raising the issue:

> Hello,
>
> I found out recently that sleep(2)'s resolution on 386 and 9front's amd64
> kernel is 10 ms rather than 1 ms.  The reason is that on those kernels,
> HZ is set to 100 rather than say 1000.  In syssleep, we get 1 tich every
> 10 ms.
>
> What is unclear is why.
>
> To paraphrase cinap_lenrek's answer to my question:
>
> In syssleep:
>                 if(ms < TK2MS(1))
>                         ms = TK2MS(1);
>                 tsleep(&up->sleep, return0, 0, ms);
>
> "TK2MS(1)" can be replaced with just "1", and the arch specific
> timerset() routine would do its own capping of the period if it's too
> small for the timer resolution, and make better decisions based on what
> the minimum timer period should be given the latency overhead of the
> given arch's interrupt handling and performance characteristics.
>
> Alternatively, HZ could be raised to 500 or 1000.
>
> It seems it's just trying to prevent excessive context switches and
> interrupts, but it seems somewhat arbitrary.  A ton of syscalls can be
> done in 1 ms, and it's the lowest we can go without changing the unit.
>
>
> What do you think?
>
> Thanks in advance,
>
> qwx
2018-06-10 19:47:21 +02:00
cinap_lenrek 56ffc907ac kernel: stop the practice of passing DMDIR to devir() perm argument
devdir internally replicates the qid in ther perm stat field
already and the practice of explicitely passing just causing
confusion when done inconsistently.
2018-06-03 23:33:35 +02:00
cinap_lenrek 8c70c09bfd devaoe: fix dotdot walk in devlinkdir, make perms consistent 2018-06-03 23:30:57 +02:00
cinap_lenrek a2623fd82a devenv: make #ec files not show up as world writable 2018-06-03 23:30:05 +02:00
cinap_lenrek 16c87febd3 sdram: properly support multiple ramdisks, so that ramdiskX corresponds to sdZX 2018-05-29 22:50:04 +02:00
cinap_lenrek 5da4f0fc0f sdram: experimental ramdisk driver
this driver makes regions of physical memory accessible as a disk.

to use it, ramdiskinit() has to be called before confinit(), so
that conf.mem[] banks can be reserved. currently, only pc and pc64
kernel use it, but otherwise the implementation is portable.

ramdisks are not zeroed when allocated, so that the contents are
preserved across warm reboots.

to not waste memory, physical segments do not allocate Page structures
or populate the segment pte's anymore. theres also a new SG_CHACHED
attribute.
2018-05-27 22:59:19 +02:00
cinap_lenrek 66eac7d687 pc64: fix fpu bug
fpurestore() unconditionally changed fpstate to FPinactive when
the kernel used the FPU. but in the FPinit case, the registers are
not saved by mathemu(), resulting in all zero initialized registers
being loaded once userspace uses the FPU so the process would have
wrong MXCR value.

the index overflow check was wrong with using shifted value.
2018-05-21 19:23:54 +02:00
cinap_lenrek c9bb6f68eb devip: don't set mtu of interface to zero when not specified (thanks joe9)
change 9f74a951ae6a introduced a bug that set the mtu of a new
interface to 0 when not specified in the add ctl.
2018-05-14 19:18:13 +02:00
qwx 70c7a9eb07 add signed fixed size integer typedefs 2018-05-12 19:19:52 +02:00
cinap_lenrek fcb974af3a merge 2018-05-10 19:38:01 +02:00
cinap_lenrek 298f239695 ip: add some primitive rate limiting knobs to counteract bufferbloat 2018-05-10 19:31:58 +02:00
aiju 0e5888a0cf add usb tablet support 2018-05-08 08:28:48 +00:00
cinap_lenrek 5aae3d344b devip: improve arp and ndp code
there appears to be confusion about the refresh flag of arpenter().
when we get an arp reply, it makes more sense to just refresh
waiting/existing entries instead creating a new one as we do not
know if we are going to communicate with the remote host in the future.

when we see an arp request for ourselfs however, we want to always
enter the senders address into the arp cache as it is likely the sender
attempts to communicate with us and with the arp entry, we can reply
immidiately.

reject senders from multicast/broadcast mac addresses. thats just silly.

we can get rid of the multicast/broadcast ip checks in ethermedium and
do it in arpenter() instead, checking the route type for the target to
see if its a non unicast target.

enforce strict separation of interface's arp entries by passing a
rlock'd ifc explicitely to arpenter, which we compare against the route
target interface. this makes sure arp/ndp replies only affect entries for
the receiving interface.

handle neighbor solicitation retransmission in nbsendsol() only. that is,
both ethermedium and the rxmitproc just call nbsendsol() which maintains
the timers and counters and handles the rotation on the re-transmission
chain.
2018-04-24 20:21:09 +02:00
cinap_lenrek 20b9326dad devip: fix ipv6 icmp unreachable handling, fix retransmit, fix ifc locking, remove tentative check 2018-04-22 18:54:13 +02:00
cinap_lenrek c80d94304d devip: cleanup ipmux.c 2018-04-22 18:50:45 +02:00
cinap_lenrek 8962551055 devip: increment in counter *AFTER* acquiering the ifc lock or loopbackmedium 2018-04-22 18:50:11 +02:00