Commit graph

10338 commits

Author SHA1 Message Date
cinap_lenrek
ee2174eb6d telco: fix rfork() race for pid 2024-01-05 07:02:25 +00:00
cinap_lenrek
8d2b84747b ip/ppp: fix race condition with rfork()
ipinprocpid is static so shared with parent and child,
so we need a temporary variable on the local stack
to properly assign ipinprocpid.
2024-01-05 06:46:35 +00:00
cinap_lenrek
2ca3934809 ip/ppp: remove -> del 2024-01-05 05:48:37 +00:00
cinap_lenrek
e48a5c343d imx8: the mpid should not contain other bits from MPIDR_EL1, only the AFF bits
By looking at ATF, it seems only the affinity bits are
expected here, no MT bit.
2024-01-05 02:45:01 +00:00
cinap_lenrek
eaffa1ef55 kernel: fix EDF scheduler double ready() and more robust double-ready detection
Move the "double-ready" check into queueproc() function,
doing it while holding the runq lock, meaning
all transitions to Ready state are serialized.

We do not just check for double-ready but for any
"illegal" transisions:

ready() on Dead, Moribund, New, Ready, Running and Waitrelease
is not allowed.

ready() on Queueing*, Wakeme, Broken, Stopped and Rendez
is only valid when done from another process.

For rescheduling, we have to go to Scheding state
before calling ready(). (rebalance(), schedinit()...)

The EDF scheduler had this bug where it could ready() multiple
times as it was staying in Waitrelease state after releasing
the edflock. Now it transitions thru Scheding avoiding
the issue.
2024-01-05 02:12:42 +00:00
cinap_lenrek
39321d74d8 kernel: never do sched() in unlock() when not in "Running" state.
Some callers of unlock change the process state
(such as qlock()) which means they are committed
to calling sched() anyway, so no ned to call it
internally.
2024-01-05 01:58:37 +00:00
cinap_lenrek
381da3192f kernel: fix typo in sema assert= vs == (thanks moody) 2024-01-04 05:07:52 +00:00
cinap_lenrek
e38d42b4a7 kernel: handle errors in semacquire
Move waserror()/poperror() out of the loop,
so we can also catch errors from canacquire().

This is theoretically possible if memory has
been paged out and we get I/O errors when
trying to page it back in.
2024-01-04 04:49:33 +00:00
cinap_lenrek
16c1cc99ec kernel: .... aaand devswap :) 2024-01-04 04:46:30 +00:00
cinap_lenrek
feda4b1ed2 kernel: add extra "New" process state to catch invalid state transitions
For ready() to check invalid state transitions,
we want to ensure that ready() is never called
on a dead proc (or one that is currently dying),
however when we create a new process,
its initial state was "Dead" until is is ready()d.

Instead, introduce the state "New", which is
set when the proc is removed from the freelist
by newproc(), making New -> Ready -> Running
state transition valid.

Also make sure we never leave notes to deadly
processes or ones that are in "Broken" state.
2024-01-04 04:45:56 +00:00
cinap_lenrek
f16547d604 kernel: forgot portfns.h from last change 2024-01-04 04:35:12 +00:00
cinap_lenrek
29e9c7bf01 kernel: don't sched() for clock interrupt when up->state != Running
When we get a clock interrupt, we should not
call sched() when the process is not in "Running" state
as it is already committed to call sched() itself.

(An example is qlock(), just after the unlock() call).

As this is basically the same check as done in
preempted(), unify both and add a "clockintr"
argument to preempted().

Then most trap handlers just become:

preempted(irq());

Also, we do not want to call preempted() for traps,
as the trap handler has just setup some machine
state to resolve the trap. We can wait for the
clock interrupt if we really need the preempt.
2024-01-04 04:33:29 +00:00
cinap_lenrek
02015f69f6 kernel: make sure process is in Queueing state in qunlock() 2024-01-04 04:22:04 +00:00
cinap_lenrek
692023ee08 etherseeq: defer enabling controller until attach(), provide shutdown() function
On pnp(), just allocate descriptors and bring the controller
in a halted state.

Start the controller and dma in attach().

This prevents MAME from locking up when there is ethernet
traffic during bootup.
2024-01-02 23:51:22 +00:00
adventuresin9
5de941cbcf mt7688/uarti8250.c; fixed interrupts 2024-01-02 04:54:30 +00:00
cinap_lenrek
f62e54b13d sgi: make newport graphics work in MAME
MAME doesnt support RGB Map 1 mode so use RGB Map 0 instead.

Hardware cursor is screwed up too, so just implement
software cursor for now.
2024-01-02 02:06:08 +00:00
cinap_lenrek
59d4a6261f ip/dhcpd: don't override local address for gateway case 2024-01-01 21:14:28 +00:00
cinap_lenrek
f0ac2d0176 sgi: fix botched conversion to stacks below Proc. 2024-01-01 02:35:13 +00:00
Jacob Moody
a0c7560782 libc: add _callmain to share more initialization code
Before each arch had to implement the _privates array
themselves in assembly, which meant it was quite easy
for them to get out of sync. This cleans this up to be
a single enum and shares this initialization code.
2023-12-31 23:58:47 +00:00
cinap_lenrek
fb1eadf6ed /sys/lib/acid/kernel: fix proctab() 2023-12-31 19:23:22 +00:00
cinap_lenrek
835db8f796 7l: dont dump constant-pool in the middle of switch/case jump table 2023-12-31 17:00:05 +00:00
cinap_lenrek
069fd98950 ?c: fix nodret check
we used to compare the symbol to nodret->s to see if
we got the return pointer, but this is wrong as
nodret is a OIND, pointing to a ONAME and therefore
sym would be nil.

instead, just compare the symbol string to ".ret".
2023-12-29 16:38:04 +00:00
cinap_lenrek
caec06be08 qc: fix crash, nodet not nused/initialized 2023-12-29 03:56:56 +00:00
cinap_lenrek
94b1d3f0ad mk: Various improvements
Variables are lists, just as in rc,
so preserve emptry strings ('')
in variables properly: FOO='' bar baz
should result in FOO=('' bar baz) in
the environment, while FOO=
becomes a emptry list FOO=().

Get rid of the Evy struct, the environment
can be represented as just an array
of Symtab pointers, also meaning the
value can never be out of sync.

Embedd the name string in Symtab struct.
It is immutable and dont require
the caller to strdup() the name.

Make Word's immutable, embedding the
string value in the Word struct.
This avoids alot of extra allocations.

Provide a Strdup() function that handles
allocation error.

Handle variable overrides from the
command line internally, avoiding the
maketmp() file.

When executing a recipe, pass the body
using the -c flag to rc, avoiding
a pipe() and fork(). This also has
the advntage that rc can optimize the
script as it sees it in its entirety
and avoid fork() down the line.

Make sure not to leak file-descriptors
into sub-processes.

Do an attempt at freeing memory
(mostly for Arc's and environment values).
2023-12-28 18:10:41 +00:00
cinap_lenrek
6b0150764c rc: handle Xeflag in exitnext() 2023-12-27 23:07:06 +00:00
Ori Bernstein
37a8fc6168 ref: check if object is a commit when needed 2023-12-23 22:24:07 +00:00
Ori Bernstein
abc6e8ee6b git/log: ensure we're starting to log from a commit hash 2023-12-23 19:59:25 +00:00
cinap_lenrek
044d3e74eb kernel: add pc field in QLock for debugging
Maintain a QLock.pc and RWLock.wpc field which is
the callerpc() of the last owner of the qlock/wlock.

The previous patch that set QLock.use.pc was
kind of nonsensical as it will get overridden
by the next attempt to acquire the qlock.
2023-12-22 18:28:25 +00:00
rodri
858893ff8f libgeometry: fix typo from previous commit 2023-12-20 11:38:22 +00:00
rodri
e94d21ee3a libgeometry: add matrix minor and cofactor functions 2023-12-20 11:27:36 +00:00
cinap_lenrek
34e7b54c13 ethervirtio: make multicast work (thanks Arne)
> this fixes multicast on hypervisors without a command queue
> for the ethernet interface, like OpenBSD.
> Right now the driver does not install a multicast function when
> no command queue is ava> ilable.
> This breaks multicast because the network stack errors out in
> netif.c:netmulti.
> To fix this, move the check for the queue to the multicast and
> promiscuous functions and install those functions unconditionally.
2023-12-19 19:41:07 +00:00
cinap_lenrek
2c8181eed7 ip/cifsd: dont add pointless logging (already logged when debug is active) 2023-12-18 18:03:37 +00:00
Romano
0e96985e12 cifsd: clarify SMBv1 is supported, not SMB 2/3.
SMB 2/3 is not supported by cifsd, so clarify that in the man page and update teh code to mention in the log file if SMB2/3 is attempted. Also, while in the code, fix a typo, add a few more commands to the explicitly unsupported list, and align the return value for unsupported calls to the SMBv1 spec.
2023-09-28 06:34:09 +00:00
Ori Bernstein
5e336b9d96 qlock: keep the caller pc in the qlock for debugging
Keeping the PC for the qlock call isn't very useful,
since it's always going to be the same PC. Instead,
set the Lock's pc to the pc of the QLock locker.
2023-12-18 00:42:47 +00:00
cinap_lenrek
e33798c7e0 cc: don't rearrange constant scaling across unsigned casts
On 64-bit platforms, when the index being 32-bit unsigned,
any calculation there must be done modulo 2^32,
but rearranging the factors into the address calculation
is done in signed 64-bits yielding the wrong index.
2023-12-12 20:58:59 +00:00
cinap_lenrek
e74a87d537 ?c: allow registerizing .ret (thanks rodri)
In constrast to .safe, the .ret variable can
be registerized just fine which can avoid
some quite ugly code in functions manipulating
a returned struct.
2023-12-12 20:42:20 +00:00
cinap_lenrek
ef1b1e159b libmach: add TBZ and TBNZ instructions for arm64 2023-12-12 19:30:31 +00:00
Jacob Moody
3613f5061b libc: deduplicate fake cycles() imeplementation to port/
This also fixes the sparc and 68020 libc, since their mkfiles
referenced a dummy cycles.c that was never in their subdir.

Likewise while the 68000 libc would build, linking a program
against it would fail due to missing a _tas implementation.
This copies the 68020 implementation to alleviate this.
2023-12-11 18:42:31 +00:00
cinap_lenrek
85d0f0e1a2 7l: fix constant pool size for imm14 displacement for TBZ/TBNZ
The new TBZ/TBNZ instructions use imm14 displacement (±32K 4-byte
instruction aligned), so have to check constant pool more often.

Also, make the absolute pc value vlong.
2023-12-10 23:51:54 +00:00
cinap_lenrek
e4191b8d11 devether: handle bypass case for dmat 2023-12-09 17:32:07 +00:00
Jacob Moody
9d09242bee date: remove reference to dead -m flag (thanks Thim Cederlund) 2023-12-08 19:37:49 +00:00
cinap_lenrek
8d9a4e1502 devether: make dmatproxy part of devether
As we want to keep applying dmat translations
when bypassing a wifi interface, make the
dmat handling code part of devether instead
of doing it internally in the wifi driver.

The wifi driver just needs to allocate and
assign Ether.dmat pointer.
2023-12-07 16:23:04 +00:00
cinap_lenrek
f28d61ca22 aux/wpa: continue trying to connect when forked
The "auth" write can fail when the AP reboots or
vanishes temporarily. Don't sysfatal and continue
trying to connect.
2023-12-07 15:15:40 +00:00
cinap_lenrek
3f0f52ab69 ether4330: dmat support
move dmatproxy() function in its own module so we can use it
independently of wifi.c.
2023-12-07 14:50:09 +00:00
cinap_lenrek
7137060d85 ethermultilink: ignore link-status of primary
when link-status on secondary is lost, always switch
back to the primary regardless of if it has a link.

this works around some ethernet driver not setting
link-status consistently and wifi's that might
only indicate a link when connected to an ap.
2023-12-07 14:48:49 +00:00
cinap_lenrek
b8604dd760 ether4330: set link status, omit "status:" line from ifstats for aux/wpa when bypassed 2023-12-07 14:43:23 +00:00
cinap_lenrek
b388488ab6 ether4330: ignore join request while bypassed 2023-12-06 15:50:09 +00:00
Ori Bernstein
0231537cba ether8169: fix rx/tx on more recent realtek models (thanks uramekus)
Recent realtek models will not send packets if rx/tx is enabled before
configuration is complete. Additionally, the RXDV gate should be enabled
to put traffic on the fifo instead of the DMA controller.

this follows OpenBSD's sys/dev/pci/if_rge.c and FreeBSD's sys/dev/re/if_re.c
2023-12-04 17:31:54 +00:00
Ori Bernstein
73ffc757d5 git/fs: don't unload large objects when inserting into cache
When inserting an object into cache, we try to remove objects
from cache to keep the size below the limit. If the object is
larger than the cache, we try to unload not only every cached
object, but the object we're in the process of inserting.

This leads to an immediate unload of the object, which is very
wrong.
2023-12-02 21:08:52 +00:00
Jacob Moody
b07a6e33bd /lib/terry: speak no ill of the dead 2023-12-02 18:16:14 +00:00