Commit graph

10370 commits

Author SHA1 Message Date
cinap_lenrek
45f7b30244 ndb/dns: built-in tcp server, remove cruft, refactor
Remove external ndb/dnstcp (tcp53) service and serve
tcp clients directly fron ndb/dns process,
taking advantage from the cache.

This avoids slow startup delay for tcp as dnstcp
would need to parse the full network database for
each request. Also, for unknown reasons, dnstcp
would "refresh" the main server on exit, causling
ander database reload for no reason.

Remove cruft:

- straddeling server configuration (-o flag)

I dont think anyone has used this in 9front and
the logic is hard to maintain and test.

- UDP forwarding (-T flag)

Just use snoopy. Or use ipmux and aux/trampoline.

- zonerefreshprogram (-z flag)

This interface sucks. Anyone on the internet can
trigger a refresh and there is no way to authenitcate
the sender.

- undocumented "dump" and "stats" messages.

This should instead be exposed in the file-system
interface. For now, one can access the stats with
acid(1).

Fix bugs:

Handling of unknown RR types was wrong. convM2RR()
would skip ahead in the message when hitting a
unknown RR type, but this gets out of sync with
rrloop()'s rr counter causing spurious parse errors.

Instead, add a Block into the RR type RR.unknown,
where we can stuff the RR data of unknown requests
when the rr is not supported: rrsupported() == 0.

These "unknown" RR types can be printed, but are
discarded in rrattach() as the cache should never
contain unknown RR's.

Fix ip/snoopy -f 'tcp(dns)', need to skip the 2 byte
length field as dns code assumes UDP format.

The refactor:

Big sweep over dnresolve.c, keeping stuff local
on the stack (such as the reply message, fd's)
while putting common stuff in the Query (such as
the recursion depth).

Make logging consistent. Dont have ndb/dnsdebug
enable debuguing, spewing crap on the console.
2023-10-29 13:36:00 +00:00
Keegan Saunders
dd79854239 add arm64 qemu kernel
This kernel is designed for running on the QEMU "virt"
machine. It implements the QEMU ECAM-based PCIe and
utilizes VirtIO drivers for networking and storage.
USB, screen and so on are umimplemented, because this
kernel is meant to be installed via UART, and then
administered as a CPU server via rcpu. It is booted
using U-Boot, so the QEMU "virt" machine "firmware"
is required, otherwise installation is straightforward.

This is the QEMU command used to run this kernel on
an M1 Mac under Hypervisor.framework:

	qemu-system-aarch64 -M virt-2.12,accel=hvf,gic-version=3 \
		-cpu host -m 4G -smp 4 \
		-bios u-boot.bin \
		-drive file=9front.arm64.qcow2,if=none,id=disk \
		-device virtio-blk-pci-non-transitional,drive=disk \
		-serial stdio

This code is based off of the i.MX 8 kernel.
2023-10-29 00:41:46 +00:00
Ori Bernstein
0d9119da0f git/branch: prevent deleting current branch, skip dirty check for deleting branches 2023-10-28 18:10:34 +00:00
Ori Bernstein
b237834cde git(1): document 'git/diff -u' 2023-10-27 20:38:36 +00:00
Ori Bernstein
7bc6d45519 git/diff: make '-u' flag imply '-s'
Without '-s', '-u' makes no sense: it acts like
a weird version of cat that prepends each line
with '+'.
2023-10-27 20:38:22 +00:00
Jacob Moody
5d68e51152 ip/snoopy: sync with ndb/dns 2023-10-23 16:16:02 +00:00
cinap_lenrek
6bc544f3da ndb/dns: refresh the cached dnsserver domain ndb entries in db2cache()
baddelegation() kept a cache of Ndbtuples
for its own machine's domain names that
was never refreshed.

now update that cache at the end of db2cache().
2023-10-22 19:22:21 +00:00
cinap_lenrek
a79465e118 ndb/dns: fix RR.caa leak 2023-10-22 18:03:23 +00:00
cinap_lenrek
14ac74fce1 ndb/dns: embedd name string into DN struct
Avoid some indirection and malloc overhad
and just embedd the name string directy in
the DN struct at the end.
2023-10-22 18:03:00 +00:00
Keegan Saunders
fb96a050f8 bcm: add wifi driver
Thanks Richard Miller
2023-10-22 14:53:02 +00:00
cinap_lenrek
f2cfee358f ndb/dns: implement concurrent garbage collection
Get rid of the blocking in getactivity()/putactivity(),
and instead split garbage collection over 2 phases (mark bit)
so that dnageall() runs the mark phase only for the current mark
bit and sweep for the previous mark (which then becomes
the current mark after the collection). Note that dnageall()
only runs once the previous phase (previous mark) has no
more active procs.

Also, fix the ageing period controller and make it
more agressive once dnvars.names is twice the target
so we can actually sustain being hammered with new
domain name queries.
2023-10-22 13:21:23 +00:00
cinap_lenrek
c6ec2041ad games/md: ignore invalid writes (makes cave story work) 2023-10-21 03:43:29 +00:00
Ori Bernstein
22cf5562fa git/*: reduce object cache size
the cache is too big; it doesn't measurably improve
performance for most uses, and will run out of memory
on smaller machines. 128 megs ought to be enough for
everybody.
2023-10-18 20:48:38 +00:00
cinap_lenrek
a99b016643 7l: avoid hitting old 7c bug with 64-bit constant propagation
This is just to prevent breaking builds in case
someone compiles 7l with a old 7c compiler that
has the constant propagation bug.

The solution is to move the 64-bit assignments
together at the front.
2023-10-16 17:57:09 +00:00
qwx
72cb1da8c2 file: recognize MOD files (thanks umbraticus) 2023-10-16 00:33:27 +00:00
qwx
30e6dc997f file: use xiph mimetypes to clearly differentiate ogg/vorbis from ogg/opus et al (thanks sigrid) 2023-10-16 00:27:43 +00:00
qwx
83978bb12d troff: embiggen troff character size limit to support huge fonts 2023-10-16 00:03:01 +00:00
qwx
65ab0d034b file: recognize and differentiate opus 2023-10-16 00:01:35 +00:00
cinap_lenrek
69e9efa847 ndb/dns: avoid blocking 9p on refresh, use shorter 15second query timeout, cleanup
When writing "refresh" control message to trigger
garbage collection and there are other (query) processes active,
the 9p loop would block until these processes complete.

Instead, defer the garbage collection operation to these
outstanding processes once any of them completes,
keeping the 9p loop un-contended for longer.

When theres no other processes, we can garbage collect
ourselfs immediately (just as before).

Only acquire the dnvars lock on Twrite, so we can handle
other 9p requests while garbage collection is going on.

Also reduce the 60 second timeout to 15 second for queries.
Other dns servers usually use something between 10 and 30
seconds.

Avoid excessive nsec() and time() calls by having timems()
function that only uses nsec() and then updates global
nowms (millisecons) and now (seconds) variable.

After the end of readnet(), timems() needs to be called
anyway to update the query statistics so we can use that
as the new "now".
2023-10-15 21:20:30 +00:00
Ori Bernstein
6fbf81a98f walk: handle removed files correctly
A file that was not checked in, added, and
then removed would be shown as modified, and
not skipped. It would also be stuck in the
index forever.

This change skips showing untracked moved files
and purges them from the index.
2023-10-15 17:20:28 +00:00
Ori Bernstein
aa0b6bedf4 git/walk: filter out files from within the .git repo
Bugs in utilities like git/add can accidentally add files
that should be impossible to track; git/walk should just
not print them.
2023-10-15 17:10:20 +00:00
Ori Bernstein
a3cbab3dc2 git/walk, git/save: be less restrictive about permission matching
Files will inherit permissions from the parent directory, which
means that a file will show different permissons depending on
where they get checked out. Showing that the file has been
modified this case is technically correct but confusing.

Since git only stores the exec bit, we should only check the
owner exec bit when checking files in and out of git.
2023-10-15 17:09:20 +00:00
Ori Bernstein
a15863b8ae git/add: don't include paths in the .git directory
git/add .git/foo would happily add files in the
.git directory, leaving it to other tools to filter
them out; we shouldn't do that.

While we're in here, speed things up by not iterating
over long lists of files, and allow removing files
that have not yet been committed.
2023-10-15 17:05:00 +00:00
cinap_lenrek
af36a8b50a 6c: fix wrong signed type conversion from char/short -> float/double 2023-10-15 03:28:29 +00:00
Ori Bernstein
9b144a94e2 git/query: allow arbitrary length queries 2023-10-14 21:32:02 +00:00
cinap_lenrek
eacf9fbbee devsd, sd*: use seprint() style start/end pointer for rctl() function
This makes it consistent also with rtopctl()
and simpliefies the code.
2023-10-14 19:13:42 +00:00
Ori Bernstein
5692962407 git/query: check for nil return from seprint 2023-10-14 18:00:26 +00:00
Ori Bernstein
014b9a62ac idn: fix crash with long domain names
When a domain name gets long enough, we can end
up passing a remaining length of 0 to seprint.
When seprint has no buffer space at all, it returns
nil, which then crashes our DNS server.

This checks for a nil return from seprint and returns
an error
2023-10-14 17:50:55 +00:00
cinap_lenrek
4bc5793a2c cpurc, termrc, bootrc: organize default device binds
reorganise device binds for bootrc, cpurc and termrc.

make parallel port, audio, i2c and pci available in
cpurc/termrc console namespace.

remove redundant binds (which are handled by other
scripts).

detailed list:

¤ ¶:
cap and swap need to be bound only in bootrc.
for cpurc/termrc, it is bound from /lib/namespace.

P:
devarch, always good to have.

S f æ:
sd, floppy, aoe are always good to have in the console
namespace. regardless if its a cpu or terminal.
also bound in bootrc for obvious reasons.

note that #k is bound by diskparts script.

t:
uart; we always need it.

b m:
keyboard and mouse only needed in bootrc
for kbdfs and nusb/kb hid devices.

for cpurc/termrc, keyboard is provided by /srv/cons,
and mouse is bound by screenrc.

u:
usb stack, never needs to be bound manually as this
is handled by nusbrc.

v i:
vga and devdraw not needed to be bound here,
handled by screenrc.

L A J $:
parallel port, audio, i2c and pci are good to have in
cpurc/termrc console namespace for trouble shooting
and custom per site / machine rc scripts.
2023-10-14 17:12:05 +00:00
cinap_lenrek
f9a61a0813 bcm, bcm64: Add bitbang i2cgpio driver
Adding a bitbang i2cgpio driver to overcome the
limitations and brokenness of the i2cbcm driver
and broadcom hardware.

Move the i2cbcm driver from bcm64/ to bcm/ and
comment it out in all kernel configurations
using i2cgpio instead.
2023-10-13 15:46:53 +00:00
Keegan Saunders
f24038d601 nusb/kb: fix Glorious Model O mouse
Ensure we are using the DWC OTG before enabling the workaround.
Otherwise, we risk breaking devices which don't like a Setidle
of 8<<8.
2023-10-12 22:54:02 +00:00
Romano
4607b18740 grabrfc: update fetching
The canonical server for fetching draft RFCs is defunct for ftp
access, so a mirror site is now used.  Add -d flag to fetch draft RFCs
but otherwise do not.  When fetching drafts, also fetch index and
abstract files.  For both normal and draft RFCs, only look for .txt
files as there a lot of other files in remote directories that are not
relevant.
2023-10-10 03:16:04 +00:00
sl
7213f4a34d /lib/theo: You get to adapt to what we produce. 2023-10-08 02:14:29 +00:00
cinap_lenrek
acc45bda27 devpipe: remove bogus "wstat on closed pipe" note
This cannot happen ever. qsetlimit() will never
raise an error and it would only go into the waserror()
case when invalid argument checks fail.
2023-10-06 19:44:18 +00:00
Ori Bernstein
05d0456a30 upas/fs: don't try to fstat a renamed fd
cwfs apparently can get unhappy about it.
2023-10-03 15:26:45 +00:00
cinap_lenrek
7cd0b81c83 history: set missing execute bit 2023-10-02 20:15:59 +00:00
Ori Bernstein
49bd8a86f3 git/fs: fix leak of uid strings 2023-10-02 16:14:40 +00:00
Jacob Moody
e69ca9af53 diff: fix no newline test 2023-10-02 05:41:08 +00:00
Sigrid Solveig Haflínudóttir
4a0aaf774d pipe: bring back wstat, set size (in bytes) of the pipe buffer 2023-10-01 21:21:40 +00:00
Keegan Saunders
f8fd3d5d28 7l: use wider INITTEXT and INITDAT
Currently we use a 32-bit value for these values which means
that large values passed to -T will be truncated and sign-extended,
rather than stored verbatim. This means load addresses in between
low 2GB and high 2GB will not be respected.

It appears this has been fixed in 6l already, so we can leave it alone.
2023-10-01 17:26:43 +00:00
Ori Bernstein
dfb4b52283 git/save: fix warning 2023-10-01 17:04:51 +00:00
cinap_lenrek
61f4c085c4 7c: fix constant propagation for negative 64-bit constants
the issue is that MOVW $imm, R does not sign extend to 64-bit,
leaving the upper 32 bit of the register as zeros.

this means we have to be carefull when propagating negative
constants across loads.

add a "as" argument for the move instruction type,
we can always substitute if we have the same move operation,
then, we test for special cases where it doesnt matter.

to reproduce the issue:

void
main(void)
{
	long foobar = -1;
	vlong x = -1;
	print("%d\n", x == -1);
}

with the change:

/fd/5:2,9 - /fd/4:2,10
  	RETURN
  	TEXT	main+0(SB),0,$32
  	MOVW	$-1,R1
+ 	MOV	$-1,R3
  	MOV	$.string<>+0(SB),R0
- 	CMN	$1,R1
+ 	CMN	$1,R3
  	BNE	3(PC)
  	MOVW	$1,R5
  	B	2(PC)
2023-09-30 22:50:42 +00:00
cinap_lenrek
a327175a3c nusb/usbd: attach spam protection for reset loops and flanky devices
When attach happens on a port within Attachdelay (3 seconds),
we count it as a repeated attach and if this happens
Attachcount (5) times in a row, we print an error and
refuse to attach the device.

Ori needs this as he has a usb hid device rgb led controller
in his computer that just gives read errors and causes
a continuous reset loop on the port, spamming the console.
2023-09-30 17:06:58 +00:00
Romano
6d199d6a31 git: document git/import -n 2023-09-28 06:41:20 +00:00
cinap_lenrek
d8b23eb588 nusb/usbd: don't spam opendevdata() transaction errors before timeout, error printing 2023-09-29 23:15:54 +00:00
adventuresin9
46cf9d4eb0 i2cbcm: clean up and fixes 2023-09-27 20:47:46 +00:00
cinap_lenrek
82da41a2eb nusbrc: use exponential backoff and timeout usb enumeration
nusbrc used to wait forever until initial device
enumeration was completed. the reason is mainly
so that usb stoage or ethernet devices can be
used as boot media.

but this can result in a system getting completely stuck
on boot if usb enumeration gets stuck. (this really
depends on the device driver if some timeouts
have been implemented during attach).

as a compromise, we will wait for usb enumeration
to complete using exponential back-off with a maximum
total wait time of ~10 seconds.

typical times for single device initial enumeration is
0.4 to 0.6 seconds.

largest case i measured with 20 random devices was
7 seconds.

so we will probably be safe with the 10 second timeout.
2023-09-27 19:19:09 +00:00
Jacob Moody
5c448c618a cpp: don't bail on all '?'
Earlier trigraph change deleted too much.
2023-09-26 14:40:56 +00:00
Ori Bernstein
b0ad72be22 upas/fs: write index out to temp file
pridx() can be extremely slow when reading from
imap, because it ensures each message is cached.
Ensuring each message is cached may take a round
trip to the IMAP server.

Instead, we should write the index to a temp file,
and rename it, to reduce the window wher the index
can be broken.
2023-09-26 01:54:03 +00:00
Ori Bernstein
fc6d319a3f upas/fs: don't abort when the server gives us invalid dates 2023-09-26 01:24:17 +00:00