Commit graph

1639 commits

Author SHA1 Message Date
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
cinap_lenrek dbf13129a7 devip: cleanup rudp.c 2018-04-22 18:49:01 +02:00
cinap_lenrek 9860172fce devip: cleanup tcp.c 2018-04-22 18:48:32 +02:00
cinap_lenrek c5c613357e devip: cleanup udp.c 2018-04-22 18:48:08 +02:00
cinap_lenrek 26aca332bb devip: various icmp stuff
no need to rlock ifc in targetttype() as we are called from icmpiput6(),
which the ifc rlocked.

for icmpadvise, the lport, destination *AND* source have to match.

a connection gets a packet when the packets destination matches the source
*OR* the packets source matches the destination.
2018-04-22 18:47:19 +02:00
cinap_lenrek 575398eb9b devip: verify ifcid on routehint check, check Route.ref for free'd routes
v4lookup() and v6lookup() do not acquire the routelock, so it is
possible to hit routes that are on the freelist. to detect these,
we set ref to 0 and check for this case, avoiding overriding the ifc.

re-evaluate routes when the ifcid on the route hint doesnt match.
2018-04-22 18:42:22 +02:00
cinap_lenrek 638b4a1ec1 devip: add "reflect" ctl message, fix memory leaks in icmpv6, fix source address for icmpttlexceeded, cleanup 2018-04-19 01:08:51 +02:00
kremlin 8666ec6b55 add missing ethermii.h dependencies. patch from cinap_lenrek 2018-04-12 17:50:10 -04:00
cinap_lenrek 874701d193 devip: make v4 ifc broadcast and multicast routes specific to address
this allows one to access the same network via multiple interfaces,
the local address then determines which interface is used.
2018-04-11 22:56:25 +02:00
cinap_lenrek 829a451c2b devip: properly initialize the connection ignoreadvice and tos flags 2018-04-10 20:02:03 +02:00
cinap_lenrek c2dd9b1da7 devip: implement source specific routing 2018-04-08 21:15:00 +02:00
cinap_lenrek 547f60b4c5 devip: pick source address for neighbor solicitations as of rfc4861 7.2.2, cleanup
rfc4861 7.2.2:

If the source address of the packet prompting the solicitation is the
same as one of the addresses assigned to the outgoing interface, that
address SHOULD be placed in the IP Source Address of the outgoing
solicitation.

this change adds ndbsendsol() which handles the source address selection
and also handles the arp table locking; avoiding access to the arp entry
after the arp table is unlocked.

cleanups:

- use ipmove() instead of memmove().
- useless extern qualifiers
2018-03-19 01:11:08 +01:00
cinap_lenrek 71f807873b devip: more v6 improvements
ipv4local() and ipv6local() now take remote address argument,
returning the closest local address to the source. this
implements the standartized source address selection rules
instead of just returning the first local v4 or v6 address.

the source address selection was broken for esp, rudp an udp,
blindly assuming ifc->lifc->local being a valid v4 address.
use ipv6local() instead.

the v6 routing code used to lookup source address route to
decide to drop the packet instead of checking the interface
on the destination route.

factor out the route hint from Conv and put it in Routehint
structure. avoiding stack bloat in v4 routing. implement the
same trick for v6 avoiding second route lookup in ipoput6.

fix memory leak in icmpv6 router solicitation handling.

remove old unfinished handling of multiple v6 routers. should
implement source specific routes instead.

avoid duplication, use common convipvers() function.

use isv4() instead of memcmp v4prefix.
2018-03-18 07:50:48 +01:00
cinap_lenrek c96fb5471a devusb: fix format print warnings for ep->ntds and ep->uframes 2018-03-17 21:55:39 +01:00
cinap_lenrek 2c1415277f pc64: fix _intrr(), avoid the linker moving _intrr() arround 2018-03-17 18:25:12 +01:00
cinap_lenrek 108063bc3a pc64: add magic _intrr() symbol for ktrace (thanks mischief) 2018-03-17 17:19:42 +01:00
qwx 199f090b6a devfs: revert commit 4000
induces a kernel panic under normal circumstances
2018-03-17 11:25:27 +02:00
qwx 372d359e28 kernel: let /rc/bin/diskparts attach #k after #S partitions are loaded up 2018-03-17 01:04:31 +02:00
qwx 14cd988a48 devfs: only set configed flag if config was read successfully
this is just to retry reading the configuration at least once after an error
2018-03-17 01:00:51 +02:00
aiju 56405e0919 usbehci: catch interrupt in tsleep 2018-03-07 08:45:06 +00:00
aiju 9226caf2a3 usbehci: add uframes control request to return uframes one at a time 2018-03-06 17:18:48 +00:00
cinap_lenrek 6f70699aec usbehci: fix medium- to low quality highspeed isochronous transfers
everything was broken. strting with hsinit not even chaining
the itd's into a ring. followed by broken buffer pointer pages.
finally, the interrupt handler's read transaction length
calculation was completely bugged, using the *FRAME* index
to access descriptors csw[] fields and not reseting tdi->ndata
thru the loop.

minor stuff:

iso->data needs to be freed with ctlr->dmafree()

put ival in iso->ival so ctl message cannot override the endpoints
pollival and screw up deallocation.
2018-03-05 06:09:31 +01:00
cinap_lenrek 6728a5ec23 devloopback: reassign device letter from #X to #λ to avoid collision with devvmx 2018-02-25 19:06:37 +01:00
cinap_lenrek b2d7992025 kernel: properly handle bad attach specifiers
- only accept decimal for numeric device id's
- exclude negative device id's
- device id's out of range yield Enodev
2018-02-25 17:11:18 +01:00
cinap_lenrek f0a314605f devether: remove (unimplemented) detach, allow device creation on attach
we allow devether to create ethernet cards on attach. this is useull
for virtual cards like the sink driver, so we can create a sink
by simply: bind -a '#l2:sink ea=112233445566' /net

the detach routine was never called, so remove it from the few drivers
that attempted to implement it.
2018-02-25 03:42:38 +01:00
cinap_lenrek 5560efb3db devip: fix crash on negative dev id on attach 2018-02-25 03:32:29 +01:00
cinap_lenrek 05cd5cb200 ns, devproc: quote path and spec arguments for /proc/$pid/ns, namespace(6) does support quoting 2018-02-25 03:24:31 +01:00
cinap_lenrek 729c9c39d9 devether: mux bridges, portable netconsole 2018-02-18 19:56:01 +01:00
cinap_lenrek 120ab04dd2 kernel: fix missing header dependency for ethersink.$O 2018-02-18 02:05:22 +01:00
cinap_lenrek 5d6a11c387 audiohda: add device id for x260's Intel Sunrise Point-LP. (thanks rodri) 2018-02-16 21:04:38 +01:00
cinap_lenrek df6a30f3c0 if ether, then etherif.h 2018-02-12 19:05:01 +01:00
cinap_lenrek 57c53564b3 ethersink: after the experiment, the zeros get dismantled. and then destroyed. 2018-02-12 01:48:20 +01:00
cinap_lenrek 3d0f4da104 ethersink: provide promisc and multicast functions for v6, set out queue limit to 0 on attach, add to pc64 config 2018-02-11 19:51:23 +01:00
cinap_lenrek d6e0e9c402 kernel: move devether and wifi to port/
the only architecture dependence of devether was enabling interrupts,
which is now done at the end of the driver's reset() function now.

the wifi stack and dummy ethersink also go to port/.

do the IRQ2->IRQ9 hack for pc kernels in intrenabale(), so not
every caller of intrenable() has to be aware of it.
2018-02-11 18:08:03 +01:00
aiju f113e2d6d5 zynq: fix 10BASE-T and 100BASE-TX support 2018-02-10 01:04:05 +00:00
cinap_lenrek 650e5db5a2 usbxhci: fix mistake in completering()
the td index "x" was incremented twice, once in for loop
and in the body expression. so r->rp only got updated
every second completion. this is wrong, but harmless.
2018-02-07 18:13:22 +01:00
cinap_lenrek 83d8a24215 pc64: fix kmap() and invlpg()
flushing tlb once the index wraps arround is not enougth
as in use pte's can be speculatively loaded. so instead
use invlpg() and explicitely invalidate the tlb of the
page mapped.

this fixes wired mount cache corruption for reads approaching
2MB which is the size of the KMAP window.

invlpg() was broken, using wrong operand type.
2018-01-29 08:26:42 +01:00
cinap_lenrek 6a23ef917b kernel: initialize cyclefreq for machno > 0 in guesscpuhz() 2018-01-27 19:58:48 +01:00
cinap_lenrek 950e22be67 ip: make pkt interfaces unbind on close (from inferno) 2018-01-22 21:33:22 +01:00
cinap_lenrek 9840c50a3e gre: don't drop pptp packets when smaller than v4 header 2018-01-20 15:13:11 +01:00
cinap_lenrek ccf72da47d set router R-flag when sendra is active for neighbor advertisement
windows 7 just drops the default router when it tries to
probe for router reachability but gets a neighbor avertisement
from the router with the router bit clear.

so set the R-flag when sendra is active, which implies that
we are a router.
2018-01-16 20:42:01 +01:00
cinap_lenrek 7b5cf8de2d ether79c970: dont disable promisc mode when multicast table is not empty 2018-01-13 11:41:37 +01:00
cinap_lenrek ad36593a99 ether82557: don't turn off promisc mode when mcast table is not empty
the driver doesnt implement multicast filter, but just turns
on promiscuous mode when a multicast address is added. but this
breaks when one actually enables and then disables promiscuous
mode with say, running snoopy.

we have to keep promisc mode active as long as multicast table
is not empty.
2018-01-13 07:16:17 +01:00
cinap_lenrek ba87e58876 wifi: learn target ip address from neighbor advertisements in dmat proxy 2018-01-12 18:28:50 +01:00
cinap_lenrek 2088f8c991 wifi: filter out loopback traffic from myself
broadcast traffic was received back on the wire causing
duplicate address detection to break with dmat proy as
the rewritten broadcasts where observable.

the fix is to just ignore packets from ourselfs received
from the air. devether already handles loopback.
2018-01-12 08:01:15 +01:00
cinap_lenrek acb206859d ether8169: deal with kernel memory exhaution
when kernel memory is exhausted, rtl8169replenish() can fail
to plant more receive descriptors and rtl8169receive() would
run over the receive tail and crash on the nil ctlr->rb[x].

rtl8169receive() is called on "Receive Descriptor Unavailable"
and "Packet Underrun" so we will try to replenish descriptors
in the beginning first in case memory was exhausted and memory
is available again and make sure not to run over the tail.
2018-01-08 00:23:26 +01:00
cinap_lenrek b437065950 stats: show amount of reclaimable pages (add -r flag)
reclaimable pages are user pages that are used for
caches like the image cache, mount cache and swap cache.
2018-01-05 00:52:14 +01:00
cinap_lenrek d3e54ff2d9 pc kernel: fix wrong simd exception mask (fixes go bootstrap) 2018-01-04 04:38:31 +01:00
cinap_lenrek ee89c82dd3 wifi: get rid of custom hextob() routine, use dec16(), avoid copies in parsekey() 2017-12-31 01:49:58 +01:00
cinap_lenrek ce2211b08c usbxhci: add missing pexit() in xhcirecover proc (thanks sam-d) 2017-12-29 06:10:25 +01:00