Commit graph

10918 commits

Author SHA1 Message Date
Lennart Jablonka
d73932922b 6l: relocate operands with REX correctly
If rexflag is non-zero, it's used to insert an REX prefix byte in
asmins.  That's a while after put4 and put8 take note of the address
of a relocation.  So let them be aware that if rexflag is non-zero,
the relocation's address is to be higher.

Reproduction:

The program

	int global;
	int f(void){return global;}

is compiled to the IR assembly

	TEXT	f+0(SB),0,$0
	MOVL	global+0(SB),AX
	RET	,
	RET	,
	GLOBL	global+0(SB),$4
	END	,

and (using 6l -u) the machine code

	8b042508 000000c3

The relocation (see a.out(6)) correctly applies to the 08 00 00 00.
The program

	int *global;
	int *f(void){return global;}

is compiled to

	TEXT	f+0(SB),0,$0
	MOVQ	global+0(SB),AX
	RET	,
	RET	,
	GLOBL	global+0(SB),$8
	END	,

and the machine code

	488b0425 10000000 c3020000 00000000

What's different is the added REX prefix 0x48, but the relocation is
done at the same place in the binary, which now is 25 10 00 00 instead
of the correct 10 00 00 00.
2024-12-29 13:55:02 +00:00
Arne
8c86e440c2 ethervgbe: implement proper speed and link detection 2025-01-11 22:04:11 +00:00
cinap_lenrek
0336b2fad3 netif: simplify locking and cleanup
We do not need a QLock per Netfile, just
serializing open/close/write with Netif.QLock
should be sufficient. This avoids the
lock ordering violation in netifclose().

Netfile's are accessed without locking by
ethermux(), so ensure coherence before
setting the pointer. This also ensures:
Netif.f[x] == nil || Netif.f[x]->in != nil.

Netaddr's for multicast are accessed without
locking by activemulti(), so do coherence()
before linking them into the hashtable.

Remove "Lock netlock" for netown() permission
check. This is now all serialized thru
Netif.QLock.

Put waserror() guards for all the Netif
driver callbacks and wifi qwrite().
2025-01-11 18:54:10 +00:00
Arne
4730816fa4 ip/ipconfig: only write out /net/ndb when something changed
keep track of changes by calculating a hash in putndb() and only
update /net/ndb when something changed. use this to also only call refresh()
after changes and to garbage collect stale ipv6 networks after we receive
router advertisements.
2025-01-11 15:03:56 +00:00
cinap_lenrek
511cd4dc31 devether: handle input queue size for bypass mode
when the interface is bypassed, use a fixed large
receive queue (1MB) and ignore speed/link state
changes.

also, zap the mac table when the link state changes.
2025-01-10 22:50:24 +00:00
cinap_lenrek
09b5619466 wifi: don't try to associate when bypassed
when the interface is bypassed, stop trying to
associate/authenticate to the access point.
just scan and collect beacon statistics.
my asus access point sends spoofed ethernet
frames otherwise on the lan, breaking
ethermultilink.
2025-01-10 22:48:27 +00:00
cinap_lenrek
3459c8cb8e allocb: implement buffer pools for ethernet drivers
Some ethernet drivers implemented their own buffer pools
using Block.free() callbacks.

Usually, these implementations have the defect that the
driver only allocates a fixed number of buffers total.

This upper bound is impossible to predict (depends
on protocol queue limits).

Also, allocation is not space efficient when large
alignments are needed.

This change removes the Block.free() callback and
replaces it with a common buffer pool implementation:

A Bpool struct, containing the block size and
alignment needed for the blocks. Block.pool
is non-nil when the block is from a pool.

growbp(Bpool*,int) supplies new blocks to a pool.

Allocation is done such that the data area and
Block headers are in separate allocations.

All the blocks share the same allocation for
data avoiding waste as not every block needs
to add alignment slack individually.

Block *iallocbp(Bpool*) allocates a block,
growing the pool if neccessary.

freeb(): returns the block back to the pool.

We also tweak the input queue sizes for devether,
making it twice as large as the transmit queue.
2025-01-10 14:32:50 +00:00
Ori Bernstein
8b7a03c5e9 gefs: remove daed mkfile bits
when we imported gefs, we put the manpages in the right
place, and moved the paper to /sys/doc; we don't need
the rules to build and install them any more
2025-01-09 05:20:08 +00:00
Arne
b0e7312a62 gefs(8): fix indent of empty snapshot paragraph 2025-01-08 19:36:17 +00:00
cinap_lenrek
c6a91038b1 stats: add etherovf value (hw and software overflows on input queue) 2025-01-07 11:54:07 +00:00
cinap_lenrek
22d3ade384 devether: don't print link-status until netif is initialized 2025-01-07 11:52:48 +00:00
cinap_lenrek
705a2c3c28 netif: fix potential memory leak in netifwstat()
convM2D() might fault and raise error, leaking
sizeof(Dir)+n allocation.
2025-01-07 06:49:40 +00:00
cinap_lenrek
00c25292d7 devether: print mbps only on link-up
To avoid frequent prints of the current link speed,
which in case of wifi is adjusted based link quality,
print the link speed only on link up events.
2025-01-07 03:50:45 +00:00
cinap_lenrek
5dde462f96 devether: make link status prints consistent
Provide ethersetlink() function for norifying about
link status changes, which will do the printing
that includes the controller number.
2025-01-07 03:10:35 +00:00
cinap_lenrek
682e47137a ether2114x: fix automatic media detection
We used to reject media info if FD was not specified
in plan9.ini. Instead, initialize fd override to -1
which makes us use it if the infoblock tells us to
and provide a "HD" option to force half-duplex mode.

This makes the media detection work on hyper-v.
2025-01-07 00:45:41 +00:00
cinap_lenrek
3ff88ede01 libmp: fix mips build breakage from previous commit (thanks eyss) 2025-01-06 07:25:11 +00:00
Ori Bernstein
b3d44a5141 gefs: use broke() when we get a corrupt block
now that broke() doesn't abort the whole fs, but instead
makes it go read-only, it makes sense to just use it in
all cases that get a corrupt block
2025-01-06 02:45:53 +00:00
cinap_lenrek
ce4926cfc2 merge 2025-01-06 00:53:15 +00:00
cinap_lenrek
c91fd35518 gefs: getblk(): remove duplicate getcallerpc(), check b->bp.gen from cache 2025-01-06 00:51:36 +00:00
Ori Bernstein
9a648220b6 configfs: adjust phrasing on file system state/usecases 2025-01-05 23:35:20 +00:00
Ori Bernstein
01f50db963 inst/configfs: make gefs visible in the installer 2025-01-05 22:36:06 +00:00
Ori Bernstein
c709e09178 gefs: don't abort when the fs breaks
it's useful to debug when something goes wrong
2025-01-05 22:25:35 +00:00
cinap_lenrek
66d2e1ac59 gefs: use freeblk() instead of freebp() when we already have the block 2025-01-05 21:28:04 +00:00
Ori Bernstein
e0358fd432 mkfiles: stop cargo culting UPDATE=
UPDATE= is used by mk update, which
calls 'update $UPDATE'; we don't have
an update binary.
2025-01-05 21:13:43 +00:00
cinap_lenrek
11ac75e789 devether: provide ethersetspeed() function to adjust queue sizes
When the link-speed changes, we want to adjust not
only the output queue limit (done by some drivers)
but also the input queue limit per netif file.

Now, instead of setting Ether->mbps directly,
drivers should call ethersetspeed(ether, mbps).
2025-01-05 20:16:14 +00:00
Ori Bernstein
3b5e83f164 9/pc64: remove reference to stale conf
we don't have a pccpu64 kernel any more, it's all just pc64;
remove it from the mkfile
2025-01-05 19:49:07 +00:00
Ori Bernstein
a8361bc1b4 gefs: flush limbo lists on halt
the limbo lists are full of blocks that are queued
for deferred free -- if we exit, we lose track of
them, and they never get freed.
2025-01-05 18:07:53 +00:00
cinap_lenrek
ddfbf28cd4 htmlroff: fix tcs pipe leak 2025-01-05 17:52:36 +00:00
Jacob Moody
8d0702ad19 /sys/doc/fs: don't make fs.html by default
The convention is to only make ps and pdf's by default.
2025-01-05 17:49:10 +00:00
Jacob Moody
7ed56c370d /sys/doc: remove generated files 2025-01-05 02:35:40 +00:00
Jacob Moody
05f2965980 /sys/doc: add mk clean
Add a mk clean to remove all generated files,
and add pdf generation to subdirs missing it.
2025-01-05 02:35:00 +00:00
Jacob Moody
28465682cf kprof: don't downsample the pc
Kprof rounded the pc to 8 byte boundaries in order to save memory.
With x86 instruction rounding this can lead to some pretty misleading
results.

With the old rounding kpdata was ~680kb for a pc64 kernel, with this
change we use ~5.4M (8x) and considering we only allocate when we
first attach this seems reasonable.
2025-01-05 00:26:52 +00:00
cinap_lenrek
4de9d8a511 gefs: fix waserror() bugs 2025-01-05 00:12:16 +00:00
cinap_lenrek
2a622dfcec gefs: fix dlist cache limit by maintaining fs->dlcount 2025-01-05 00:11:47 +00:00
cinap_lenrek
5a460a150b nusb/ether: dont break lan78xx chip (rpi3b+)
The rpi3b+ uses different chip lan78xx.
This one does not append fcs in received frames,
so the previous change broke ethernet.
2025-01-03 09:24:18 +00:00
Jacob Moody
ef5a8a7337 aux/mnihongo: formatting 2025-01-03 00:41:09 +00:00
Jacob Moody
3273db5a84 aux/mnihongo: use memdraw instead of draw
We used to rely on there being a draw(3) there in order to render the
characters in to, this resulted in flashing the rio window white and
made some documents only buildable under a terminal environment.  This
fixes both of those issues.
2025-01-03 00:43:05 +00:00
Jacob Moody
9e0913fa71 libmemdraw: change openmemsubfont() to accept rune minimum as argument
Subfonts for non ascii characters are offset by some minimum rune,
typically specified within the parent font file.  Because libmemdraw
only deals in subfonts, if we want to have it draw non ascii runes we
need some method of providing that base offset.

This function is only used in one place, so update the function
signature and fix the only caller.
2025-01-03 00:51:43 +00:00
cinap_lenrek
a101561223 auth/factotum: avoid static buffer from netmkaddr()
factotum calls authdial() in parallel, so use
the reentrant version netmkaddrbuf() instead.
2025-01-02 20:11:22 +00:00
cinap_lenrek
e981a26000 libc: provide netmkaddrbuf() function avoiding the static buffer
We need a reentrant version for netmkaddr() that
can be used in multithreaded programs.
2025-01-02 20:09:50 +00:00
cinap_lenrek
5ea80693ba usbuhci, usbehci: remove portlck qlock
Everything is already serialized by usbd. For ehci, portlck
also doubled for waiting for doorbell, so rename it to match
its use case.
2024-12-29 17:09:51 +00:00
Jacob Moody
68c89f4a43 acid: remove outdated 8.out binary default (thanks Tekk) 2024-12-27 19:29:34 +00:00
cinap_lenrek
b849349e0c devusb: fix enable delays to avoid device suspend (thanks cgnarne)
cgnarne experienced issues with his xbox controller when
connected to uhci root-port.

doing some experiments, we determined that the delay
between clearing reset and setting enable needed to
be between 5µs and 2.7ms for it to attach successfully.

this timing is close to the 3ms idle time that makes
devices enter suspend mode, so we concluded that the
delay here must be shortend (50ms -> 2ms).
2024-12-26 17:35:44 +00:00
Jacob Moody
242e1dc552 vdiff: accept diff as filename argument and man page touch-up (thanks humm) 2024-12-26 03:54:31 +00:00
Jacob Moody
ed318aac59 rio(4): fix paragraph spacing (thanks humm) 2024-12-26 03:53:18 +00:00
Ori Bernstein
0bfa3ffcb4 gefs: fix error handling in readsnap() 2024-12-26 00:46:07 +00:00
Ori Bernstein
d4938f099d auth/totp(1): separate docs for auth/totp, auth/userpasswd 2024-12-25 17:33:17 +00:00
cinap_lenrek
e05e30eaca auth/userpasswd: remove factotum-bug work-around from 2002, cruft (thanks ori) 2024-12-25 17:08:34 +00:00
Ori Bernstein
21731dd45e auth/factotum: add support for TOTP code generation 2024-12-25 02:18:43 +00:00
cinap_lenrek
1a91932731 ip/dhcpd: impvoe validip(), make validipmask() reject ipv6 masks
Because isv4() is never true for IPnoaddr,
we can skip the check.

Make validipmask() ensure that the top IPv4off
bytes are all 0xff, then check that the low
4 bytes are a valid mask (must be a power
of two minus one).
2024-12-23 16:12:35 +00:00