Commit graph

8445 commits

Author SHA1 Message Date
cinap_lenrek ecb5eab76b imx8: add xhci driver for the soc
This is mostly a copy of port/usbxhci.c with PCIWADDR() replaced
by PADDR() and the pci specific code stripped out.

This could be refactored at a later time.

There is a gpio line for the main hub reset that needs to be
asserted and some power management functions that are currently
done by u-boot (using "usb start" command).

We will do these ourselfs once we have the infrastructure for
it in place.
2022-05-30 21:55:38 -04:00
Jacob Moody 760f18ff4a kernel: disable wstat for devpipe 2022-05-30 21:55:38 -04:00
Jacob Moody 11c0f4e7dd fork(2): fix parens in RFNOMNT references (thanks Amavect) 2022-05-30 21:55:38 -04:00
Xiao-Yong Jin 5eda53a050 vt: increase buffer size
This patch increases the buffer sizes in vt(1) to reduce
the latency from the roundtrip between terminal and cpu
server.
2022-05-30 21:55:38 -04:00
Jacob Moody 32235c2e41 fork(2): Document RFNOMNT edge cases. 2022-05-30 21:55:37 -04:00
cinap_lenrek 5a7ed2e652 uartimx: fix interrupts
need to turn off transmitter fifo interrupt when we run out of
data to transmit, and set rx fifo ready fifo threshold to one.
2022-05-30 21:55:37 -04:00
cinap_lenrek cb8e638d2a imx8: implement psci calls for system reset and multicore startup 2022-05-30 21:55:37 -04:00
cinap_lenrek cb92827769 remove empty /sys/src/cmd/cpu.c 2022-05-30 21:55:37 -04:00
cinap_lenrek 22934e123c imx8: add work in progress i.MX8MQ kernel for the mntreform2 laptop
This is a work in progress port to the mntreform2 laptop.

Working so far:

- mmu (same as raspberry pi 3b+)
- arm generic timer
- gicv3
- uart1
- enet

With access to the uart, one can netboot this kernel in u-boot
using the following commands:

> dhcp
> bootm
2022-05-30 21:55:37 -04:00
cinap_lenrek 08a2cd30ba kernel: fix noteid change race condition from devproc while forking (thanks joe7)
devproc allows changing the noteid of another process
which opens a race condition in sysrfork(), when deciding
to inherit the noteid of "up" to the child and calling
pidalloc() later to take the reference, the noteid could
have been changed and the childs noteid could have been
freed already in the process.

this bug can only happen when one writes the /proc/n/noteid
file of a another process than your own that is in the
process of forking.

the noteid changing functionality of devproc seems questinable
and seems to be only used by ape's setpgrid() implementation.
2022-05-30 21:55:37 -04:00
umbraticus@prosimetrum.com 7d01c96ada sam: ignore autoindent in cmd window 2022-05-30 21:55:37 -04:00
phil9 4148ebcf0e mothra: make scrollbar style consistent with other applications
Scrollbar was drawn using a wide dark gutter over a white background
	whereas other applications (window, sam, ...) use a thinner scrollbar with an
	inverse colorscheme.
	This makes the scrollbar more consistent with other 9front applications.
2022-05-30 21:55:37 -04:00
phil9 cc9d153723 mothra: enable mousewheel scrolling in history list
In the history list, scrolling was only possible using the scrollbar
	but not the mousewheel like in the text panel.
2022-05-30 21:55:37 -04:00
Ori Bernstein 826d64c11c rc: squelch 'Write error' warning
When writing to a large variable in /env, we
spam 'Write error', in spite of the env var
working. This is new behavior, as of commit
b90036a062.

It produces a lot of scary, noisy warnings,
which are probably bogus.
2022-05-30 21:55:37 -04:00
Ori Bernstein 71d2bfabfc git/pull: remove '-b' and '-a' option
we do the right thing by default now, let's not
add knobs that nobody cares about.
2022-05-30 21:55:37 -04:00
Ori Bernstein fd3ab99fa9 git/common.rc: create required directories
we forgot a couple of directories when branching.
2022-05-30 21:55:37 -04:00
Ori Bernstein 4f3d5d083b git: rename internal 'git/fetch' plumbing to 'git/get'
This caused some confusion, so to make it clear that
it's plumbing and has nothing to do with 'git fetch',
rename it.
2022-05-30 21:55:37 -04:00
Ori Bernstein 0375d0a3ab git/send: fill in 'theirs' object, even if we miss it
When pushing, git/send would sometimes decide we had all the
objects that we'd need to update the remote, and would try
to pack and send the entire history of the repository. This
is because we only set the 'theirs' ref when we had the object.

If we didn't have the object, we would set a zero hash,
then when deciding if we needed to force, we would think
that we were updating a new branch and send everything,
which would fail to update the remote.
2022-05-30 21:55:37 -04:00
Ori Bernstein 7ab99af0ea git/serve: log correct error message
Sending the packet on failure could junk the errstr,
so set it after we send the message.
2022-05-30 21:55:37 -04:00
Ori Bernstein dba98f649c git/merge: preserve exec bit correctly
A while ago, qwx noticed that we clobbered the exec
bit when merging files. This is not what we want, so
we changed the operator precedence to avoid merging
dirty files implicitly.

But we do want to merge, because it's convenient for
maintaining permissions. So, instead, we should do a
3 way merge of the exec bit.

This patch does that, as well as reverting the rollback
of that change.

While we're here, we adjust the timestamps correctly
in git/branch.

This requires changes to git/fs, because without an open
handler, lib9p allows opening any file with any mode,
which confuses 'test -x'.
2022-05-30 21:55:36 -04:00
Ori Bernstein 6949c4a707 git/pull: fetch all branches (please test)
there was a diff that went in a while ago to improve
this, but it got backed out because it encounters a
bug in upstream git -- the spec says that a single
ACK should be sent when not using multi-ack modes,
but they send back multiple ones.

This commit brings back the functionality, and works
around the upstream git bug in two different ways.

First, it skips the packets up until it finds the
start of a pack header.

Second, it deduplicates the want messages, which
is what seems to trigger the duplicate ACKs that
cause us trouble.
2022-05-30 21:55:36 -04:00
umbraticus@prosimetrum.com 6730cc562d make = command's output plumbable
This patch makes sam's = cmd output what seems to me a more
useful (plumbable) format: /full/path/to/file:addr , where
addr is line(s) under = and rune(s) under =#.
2022-05-30 21:55:36 -04:00
Michael Forney d2942d4de3 git/import: squash leading/trailing/consecutive blanks and strip trailing space
This fixes importing patches with multiline commit messages generated
by git-format-patch.  It also matches commit message sanitation done
by git-am.
2022-05-30 21:55:36 -04:00
cinap_lenrek 36b0897a42 aux/aout2uimage: fix text section size rounding (for data section alignment)
the a.out header is not considered part of the image and
should not be loaded. it also has no contribution to the
rounding of the text section size.
2022-05-30 21:55:36 -04:00
rodri ddabc765ca 9pqueue(2): fix typo 2022-05-30 21:55:36 -04:00
cinap_lenrek 185ced3d1e sol(8): fix example (vncv vs vnc) 2022-05-30 21:55:36 -04:00
cinap_lenrek 4d1c1f5c6e ip/sol: handle timeout on password entry for digest auth 2022-05-30 21:55:36 -04:00
cinap_lenrek eb81b7602c ip/torrent: fix silly readn() error check (thanks pr) 2022-05-30 21:55:36 -04:00
Amavect 761bf6c347 shorten strchr and runestrchr 2022-05-22 22:38:11 +00:00
Jacob Moody 47cff2e833 auth(8): bugs have been squashed 2022-06-02 16:51:55 +00:00
Jacob Moody b75e549126 kernel: be more careful about argc for /dev/drivers writes
Not crashing on 'chdev &' is important.
2022-05-28 17:23:41 +00:00
Ori Bernstein 01a6de812c git: performance enhancements
Inspired by some changes made in game of trees, I've
implemented a number of speedups in git9.

First, hashing the chunks during deltification with
murmurhash instead of sha1 speeds up the delta search
significantly.

The stretch function was micro-optimized a bit as well,
since that was taking a large portion of the time when
chunking.

Finally, the full path is not stored. We only care about
grouping files with the same name and path. We don't care
about the ordering. Therefore, only the hash of the path
xored with the hash of the diretory is kept, which saves
a bunch of mallocs and string munging.

This reduces the time spent repacking some test repos
significantly.

9front:
	% time git/repack
	deltifying 97473 objects: 100%
	writing 97473 objects: 100%
	indexing 97473 objects: 100%
	58.85u 1.39s 61.82r 	 git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 97473 objects: 100%
	writing 97473 objects: 100%
	indexing 97473 objects: 100%
	43.86u 1.29s 47.51r 	 /sys/src/cmd/git/6.repack

openbsd:

	% time git/repack
	deltifying 2092325 objects: 100%
	writing 2092325 objects: 100%
	indexing 2092325 objects: 100%
	1589.48u 45.03s 1729.18r 	 git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 2092325 objects: 100%
	writing 2092325 objects: 100%
	indexing 2092325 objects: 100%
	1238.68u 41.49s 1373.15r 	 /sys/src/cmd/git/6.repack

go:
	% time git/repack
	deltifying 529507 objects: 100%
	writing 529507 objects: 100%
	indexing 529507 objects: 100%
	345.32u 7.71s 369.25r     git/repack

	% time /sys/src/cmd/git/6.repack
	deltifying 529507 objects: 100%
	writing 529507 objects: 100%
	indexing 529507 objects: 100%
	248.07u 4.47s 257.59r 	 /sys/src/cmd/git/6.repack
2022-05-28 16:38:07 +00:00
Jacob Moody 57fa781188 aux/listen: Allow per service namespace files 2022-05-28 02:34:43 +00:00
Jacob Moody 774529e440 kernel: add /rc to devroot
This makes it much easier to run a rc
program without needing to bind in all of '#s/boot'.
2022-05-28 02:31:26 +00:00
Jacob Moody eaa1949ba0 auth/newns: add chdev command 2022-05-28 02:27:59 +00:00
Jacob Moody 6926080a2d add chdev(1) 2022-05-28 02:25:56 +00:00
Jacob Moody e9bb7876e1 kernel: add chdev command to devcons 2022-05-28 02:23:29 +00:00
Michael Forney 806896c19d tmparse: remove incorrect isalpha definition
Checking the range of c|0x60 incorrectly classifies many characters
as alphabetic (digits, control characters 0x01-0x20, and punctuation
characters '!'-':'). This prevents tmparse from parsing dates with
a timezone bounded by those characters (for example, "12:11:56 (PDT)").

Instead, just reuse the isalpha macro provided by ctype.h.
2022-05-26 20:23:11 +00:00
Ori Bernstein b8d7bbf223 kbmap: add latin american keymap (thanks ssf) 2022-05-24 16:29:05 +00:00
Ori Bernstein 6fbb1acc8f diff: clean up some comments
I did the tidying and fixes. Let's remove those
comments.
2022-05-22 21:49:08 +00:00
Ori Bernstein a59e61a6a4 patch(1): remove bell labs patch scripts
bell labs is dead, and nobody is listening; 9front
has our own patch submission proces.
2022-05-22 17:27:31 +00:00
Ori Bernstein 23f8872bc1 diff: retain original file names
When diffing non-regular files, like /dev/null,
pipes, and similar, diff will generate a temp
file to diff against. This is the right thing
to do, but the temp file leaks into the diff.

This patch retains the original file name all
the way through to diff output.
2022-05-22 16:41:47 +00:00
Ori Bernstein 4649189126 diff: fix style
remove useless macros, bring formatting closer
to regular 9front formatting, and use the
ARGBEGIN/ARGEND macros. No functional change.
2022-05-22 16:34:33 +00:00
Ori Bernstein 408242edcf git: improve error on short read
we don't recover from an invalid packet, so just
sysfatal with a useful message.
2022-05-20 17:16:41 +00:00
Jacob Moody f87c5f7f43 aux/listen: remove Service struct
An announcing process already knows what port
it announced on, we don't need to derive it
from every connection.
2022-05-20 06:58:13 +00:00
Jacob Moody 25ad126d8c aux/listen: remove argument clutter
addr and proto are globals. protodir should be
a global. let's also avoid reading the remote
addr more then once.
2022-05-20 04:05:49 +00:00
Jacob Moody a8bf0b365d aux/listen: remove unused cpu global 2022-05-20 01:13:34 +00:00
Jacob Moody 316230f625 kernel: remove dead case from devpipe
This code is checking the return of devwalk for
a walk resulting in a clone of an open pipe file. However,
devclone ensures that the chan we are cloning is not
currently open.
2022-05-19 04:45:06 +00:00
cinap_lenrek 1da20fd5d8 imx8: add xhci driver for the soc
This is mostly a copy of port/usbxhci.c with PCIWADDR() replaced
by PADDR() and the pci specific code stripped out.

This could be refactored at a later time.

There is a gpio line for the main hub reset that needs to be
asserted and some power management functions that are currently
done by u-boot (using "usb start" command).

We will do these ourselfs once we have the infrastructure for
it in place.
2022-05-15 11:57:52 +00:00
Jacob Moody fdbe335d3a aux/listen: remove special cases for depreciated datakit
The getserv function has remained mostly unchanged since
1ed. These checks are for handling string local ports
or lack thereof. This was used by datakit at the time,
where 'ports' were service strings. This made the default
datakit service 'login' when a connector did not give
a specific service. The checks for directory traversal also
seemed specifically to guard against a connector from providing
a malicious service string. With datakit gone all current protocols
use numerics as ports so these checks and defaults become uneeded.

1ed reference:
https://github.com/plan9foundation/plan9/tree/1e-1992-09-21
2022-05-17 03:25:30 +00:00
Ori Bernstein 5dd9b370a0 git/merge: correctly preserve permissions when merging
when doing a 3 way merge of a file, we also need to do a
merge of the permission bits to avoid clobberign them.
2022-05-15 16:29:48 +00:00
Sigrid Solveig Haflínudóttir 1470d22cdb icanhasvmx: our vmx requires unrestricted guest too 2022-05-15 16:23:13 +00:00
Jacob Moody 4ee54b1416 fork(2): fix commas in RFNOMNT references 2022-05-15 16:14:36 +00:00
Jacob Moody 9429dd64f7 kernel: disable wstat for devpipe 2022-05-15 05:44:59 +00:00
Jacob Moody 2c67fb9794 fork(2): fix parens in RFNOMNT references (thanks Amavect) 2022-05-15 03:01:49 +00:00
Xiao-Yong Jin 0aa0096066 vt: increase buffer size
This patch increases the buffer sizes in vt(1) to reduce
the latency from the roundtrip between terminal and cpu
server.
2022-05-11 04:02:57 +00:00
Jacob Moody e614e819e3 fork(2): Document RFNOMNT edge cases. 2022-05-12 17:50:08 +00:00
cinap_lenrek 6ca8e6bbaf uartimx: fix interrupts
need to turn off transmitter fifo interrupt when we run out of
data to transmit, and set rx fifo ready fifo threshold to one.
2022-05-09 17:22:00 +00:00
cinap_lenrek 7aa8c6d47e imx8: implement psci calls for system reset and multicore startup 2022-05-08 20:26:56 +00:00
cinap_lenrek cac30a565e remove empty /sys/src/cmd/cpu.c 2022-05-08 17:37:39 +00:00
cinap_lenrek fff070f2cb imx8: add work in progress i.MX8MQ kernel for the mntreform2 laptop
This is a work in progress port to the mntreform2 laptop.

Working so far:

- mmu (same as raspberry pi 3b+)
- arm generic timer
- gicv3
- uart1
- enet

With access to the uart, one can netboot this kernel in u-boot
using the following commands:

> dhcp
> bootm
2022-05-08 16:50:29 +00:00
cinap_lenrek 9126ee3eea kernel: fix noteid change race condition from devproc while forking (thanks joe7)
devproc allows changing the noteid of another process
which opens a race condition in sysrfork(), when deciding
to inherit the noteid of "up" to the child and calling
pidalloc() later to take the reference, the noteid could
have been changed and the childs noteid could have been
freed already in the process.

this bug can only happen when one writes the /proc/n/noteid
file of a another process than your own that is in the
process of forking.

the noteid changing functionality of devproc seems questinable
and seems to be only used by ape's setpgrid() implementation.
2022-05-02 19:34:00 +00:00
umbraticus@prosimetrum.com 641bd4512f sam: ignore autoindent in cmd window 2022-04-29 05:31:30 +00:00
xfnw 0b95092e3d add stats.mono 2022-04-16 22:24:37 -04:00
xfnw ada39fd98c newuser script 2022-04-16 22:17:11 -04:00
xfnw 5e89dcb387 Merge branch 'newpatch' into front 2022-04-16 21:50:35 -04:00
xfnw be4132b248 add patches to git 2022-04-16 21:49:41 -04:00
nature 061ec57021 vncv: allow the use of the Mod4 (Super) key 2022-04-09 10:29:11 +00:00
cinap_lenrek f84cf1e604 /sys/lib/newuser: fix wsys botch, crate bin/arm64 2022-04-13 13:53:12 +00:00
phil9 63f8dc8084 mothra: make scrollbar style consistent with other applications
Scrollbar was drawn using a wide dark gutter over a white background
	whereas other applications (window, sam, ...) use a thinner scrollbar with an
	inverse colorscheme.
	This makes the scrollbar more consistent with other 9front applications.
2022-04-06 16:46:58 +00:00
phil9 aba0c7fcea mothra: enable mousewheel scrolling in history list
In the history list, scrolling was only possible using the scrollbar
	but not the mousewheel like in the text panel.
2022-04-06 15:29:41 +00:00
Ori Bernstein a63472edf5 rc: squelch 'Write error' warning
When writing to a large variable in /env, we
spam 'Write error', in spite of the env var
working. This is new behavior, as of commit
b90036a062.

It produces a lot of scary, noisy warnings,
which are probably bogus.
2022-04-29 01:51:01 +00:00
Ori Bernstein a271f62bf2 git/pull: remove '-b' and '-a' option
we do the right thing by default now, let's not
add knobs that nobody cares about.
2022-04-28 03:35:54 +00:00
Ori Bernstein 3d047ddf03 git/common.rc: create required directories
we forgot a couple of directories when branching.
2022-04-19 14:34:48 +00:00
Ori Bernstein 929b0ff087 git: rename internal 'git/fetch' plumbing to 'git/get'
This caused some confusion, so to make it clear that
it's plumbing and has nothing to do with 'git fetch',
rename it.
2022-04-17 17:03:47 +00:00
Ori Bernstein 08447e5d64 git/send: fill in 'theirs' object, even if we miss it
When pushing, git/send would sometimes decide we had all the
objects that we'd need to update the remote, and would try
to pack and send the entire history of the repository. This
is because we only set the 'theirs' ref when we had the object.

If we didn't have the object, we would set a zero hash,
then when deciding if we needed to force, we would think
that we were updating a new branch and send everything,
which would fail to update the remote.
2022-04-17 01:19:10 +00:00
Ori Bernstein 8319b750ea git/serve: log correct error message
Sending the packet on failure could junk the errstr,
so set it after we send the message.
2022-04-17 00:22:43 +00:00
Ori Bernstein 03e5d9e9e2 git/merge: preserve exec bit correctly
A while ago, qwx noticed that we clobbered the exec
bit when merging files. This is not what we want, so
we changed the operator precedence to avoid merging
dirty files implicitly.

But we do want to merge, because it's convenient for
maintaining permissions. So, instead, we should do a
3 way merge of the exec bit.

This patch does that, as well as reverting the rollback
of that change.

While we're here, we adjust the timestamps correctly
in git/branch.

This requires changes to git/fs, because without an open
handler, lib9p allows opening any file with any mode,
which confuses 'test -x'.
2022-04-16 23:53:19 +00:00
Ori Bernstein 261d1ac0e3 git/pull: fetch all branches (please test)
there was a diff that went in a while ago to improve
this, but it got backed out because it encounters a
bug in upstream git -- the spec says that a single
ACK should be sent when not using multi-ack modes,
but they send back multiple ones.

This commit brings back the functionality, and works
around the upstream git bug in two different ways.

First, it skips the packets up until it finds the
start of a pack header.

Second, it deduplicates the want messages, which
is what seems to trigger the duplicate ACKs that
cause us trouble.
2022-04-16 23:52:10 +00:00
umbraticus@prosimetrum.com d606d83ed8 make = command's output plumbable
This patch makes sam's = cmd output what seems to me a more
useful (plumbable) format: /full/path/to/file:addr , where
addr is line(s) under = and rune(s) under =#.
2022-04-16 06:53:35 +00:00
Michael Forney 798375ad45 git/import: squash leading/trailing/consecutive blanks and strip trailing space
This fixes importing patches with multiline commit messages generated
by git-format-patch.  It also matches commit message sanitation done
by git-am.
2022-04-26 19:06:53 +00:00
cinap_lenrek e0fdebf394 aux/aout2uimage: fix text section size rounding (for data section alignment)
the a.out header is not considered part of the image and
should not be loaded. it also has no contribution to the
rounding of the text section size.
2022-04-23 18:27:31 +00:00
rodri 70e2b4f7ec 9pqueue(2): fix typo 2022-04-19 20:21:37 +00:00
cinap_lenrek 56c86739a8 sol(8): fix example (vncv vs vnc) 2022-04-19 02:09:06 +00:00
cinap_lenrek dfa6b6c670 ip/sol: handle timeout on password entry for digest auth 2022-04-19 02:06:33 +00:00
cinap_lenrek 9993b3909e ip/torrent: fix silly readn() error check (thanks pr) 2022-04-18 21:03:40 +00:00
Michael Forney 909205036d git/branch: remove duplicate assignment of dirtypaths 2022-04-04 23:09:49 +00:00
Michael Forney 331f19ef21 git/branch: fix typo in error message 2022-04-04 22:54:09 +00:00
cinap_lenrek 55a0abdd43 auth/as: fix wrong filesystem permissions due to wrong factotum being attached
to change user, have to (re-)mount factotum under the new user,
so it can authenticate us under the correct user for the filesystems.
2022-04-04 22:25:08 +00:00
cinap_lenrek 90a08cf1fd vncv: some fixes to work with intel amt kvm 2022-04-03 04:23:25 +00:00
cinap_lenrek 1a4e03cf93 ip/sol: kvm (vnc) redirect, bring back plain authentication as a fallback (when unsupported) 2022-04-03 04:19:46 +00:00
cinap_lenrek 8597051d64 uartpci: AMT SOL Redirection interface (x200s) 2022-04-03 04:06:27 +00:00
cinap_lenrek 31294b6c1a ip/sol: use httpdigest authentication
httpdigest authentication allows one to share the key
in factotum with the amt webserver on https://target:16993
2022-04-02 21:47:00 +00:00
Sigrid Solveig Haflínudóttir 4a401e7703 draw(3): add a missing .br 2022-04-02 21:37:51 +00:00
cinap_lenrek fc0eee2980 webfs: do not reuse digest Authorization headers
We must use the digest authorization header only
once for a single request.
2022-04-02 20:29:20 +00:00
cinap_lenrek 8166868375 webfs: implement RFC2617 qop extension for http digest authentication 2022-04-02 19:20:56 +00:00
Sigrid Solveig Haflínudóttir 945fef7ff2 devdraw: printmesg: implement "z" fmt arg (safe since printmesg is disabled) 2022-04-02 11:12:12 +00:00
Sigrid Solveig Haflínudóttir 30f5752710 draw(3): .IR on memlorigin(2), fix wrong "t" param name (should be "top") 2022-04-02 10:37:39 +00:00
cinap_lenrek ca60e03c5b ip/sol: add intel AMT serial-over-lan console program 2022-04-01 21:24:42 +00:00
Sigrid Solveig Haflínudóttir 5ddff68167 libtags: m4a: do not div by zero 2022-03-30 20:55:33 +00:00
Sigrid Solveig Haflínudóttir cb4d441cb8 libtags: wav: do not div by zero (fixup) 2022-03-30 20:54:11 +00:00
Sigrid Solveig Haflínudóttir 2cdd31f8f4 libtags: wav: do not div by zero 2022-03-30 20:51:03 +00:00
Sigrid Solveig Haflínudóttir 7f2e622965 libtags: id3v2: make sure extra id3 tag does not cause infinite loop 2022-03-30 20:28:03 +00:00
cinap_lenrek f05b8af71e devsd: cache SDunit pointer in Chan.aux, improve error handling
Avoid calling sdgetdev() for every I/O. Instead,
put the SDunit pointer for #S/sdXX/* files in Chan.aux
and keep a reference to SDev between sdopen()/sdclose().

This avoids having to do the sdindex() lookup and
qlock(),incref(),decref() on every read/write
operation. Removal of SDev's is quite rare and only
can happen with pcmcia ide controllers, and i assume
that for that we can assume thet fileservers having
been exited properly and closed their files before
we attempt to remove a device.

The rest is improving waserror() codepaths, making
sure we release the locks for any of the interface
callbacks (verify/online).

Also get rid of tas() and instead only change the
unit's rawopen flag while holding raw qlock.
2022-03-30 19:23:26 +00:00
Sigrid Solveig Haflínudóttir 12802b94c6 libtags: flac: check sample rate before dividing by zero; also check number of channels 2022-03-30 16:59:35 +00:00
Sigrid Solveig Haflínudóttir bc5b0254d0 pc: do not access out of bounds array element 2022-03-28 17:23:04 +00:00
cinap_lenrek 89ae389eb6 libsec: fix wrong tls1.0 prf regression
The change 775a4bea43
"libsec: various changes to tls"
...
4. simply prf code...

... broke the TLS1.0 prf function, missing the fact
that the prf ouput for sha1 and md5 need to be
xored together.
2022-03-27 20:28:41 +00:00
cinap_lenrek 00542efd15 devuart: allow serial console on late detected uarts
pci uarts are detected late and usually do not contain
the console= parameter logic.

for these, we can just enable them when devuart is reset,
and replay the boot messages once enabled.

this is usefull as it allows us to use these uarts for
kernel debugging in interrupt context.
2022-03-19 15:53:40 +00:00
Michael Forney 27fe8ee356 games/gb: minor style fixes 2022-03-18 17:32:11 -07:00
Michael Forney d5368b0799 games/gb: various RTC fixes
MBC3 write switches on a>>13, so the RTC register is 5 (0xA000-0xBFFF).

Mask off upper bits of DH register when updating the timer. Only the
lowest bit is part of the day counter.

Use uint for x in timerforward() so that we don't set negative values
for timer registers if it happens to overflow.

Update timer and then latch rather than the other way around.
Otherwise, timer remains static and will overflow after 512 days.
2022-03-18 17:25:43 -07:00
Michael Forney 638b82129e git/fetch: use read for reading packfiles instead of readn 2022-03-18 23:45:43 +00:00
cinap_lenrek 02d1725d71 uartpci: add serial-over-lan uart from x230/AMT 2022-03-18 20:18:19 +00:00
cinap_lenrek e83917a658 ip/dhcpd: ignore ipv6 addresses when looking up static binding 2022-03-18 19:54:23 +00:00
cinap_lenrek 488f378470 sdide: add pci id for AMT IDE-r controller on x230 2022-03-18 19:53:11 +00:00
Michael Forney d55a64c905 git: use commit date as traversal hint instead of author date
Although git9 always uses the same commit date and author date, other
implementation do make a distinction.  Since commit date is more
representative of the commit graph order, use this as a traversal hint
instead of author date.
2022-03-17 01:41:44 +00:00
Michael Forney 8bd5be7c70 git/fetch: improve detection of dumb http protocol
If the server only supports the dumb protocol, the first 4 bytes of
response will be the initial part of the hash of the first ref.

The http-protocol documentation says that we should fall back to the
dumb protocol when we don't see a content-type of
application/x-$servicename-advertisement.  Check this before
attempting to read a smart git packet.
2022-03-17 01:41:09 +00:00
Michael Forney 2e47badb88 git/query: refactor graph painting algorithm (findtwixt, lca)
We now keep track of 3 sets during traversal:
- keep: commits we've reached from head commits
- drop: commits we've reached from tail commits
- skip: ancestors of commits in both 'keep' and 'drop'

Commits in 'keep' and/or 'drop' may be added later to the 'skip' set
if we discover later that they are part of a common subgraph of the
head and tail commits.

From these sets we can calculate the commits we are interested in:
lca commits are those in 'keep' and 'drop', but not in 'skip'.
findtwixt commits are those in 'keep', but not in 'drop' or 'skip'.

The "LCA" commit returned is a common ancestor such that there are no
other common ancestors that can reach that commit.  Although there can
be multiple commits that meet this criteria, where one is technically
lower on the commit-graph than the other, these cases only happen in
complex merge arrangements and any choice is likely a decent merge
base.

Repainting is now done in paint() directly.  When we find a boundary
commit, we switch our paint color to 'skip'.  'skip' painting does
not stop when it hits another color; we continue until we are left
with only 'skip' commits on the queue.

This fixes several mishandled cases in the current algorithm:
1. If we hit the common subgraph from tail commits first (if the tail
   commit was newer than the head commit), we ended up traversing the
   entire commit graph.  This is because we couldn't distinguish
   between 'drop' commits that were part of the common subgraph, and
   those that were still looking for it.
2. If we traversed through an initial part of the common subgraph from
   head commits before reaching it from tail commits, these commits
   were returned from findtwixt even though they were also reachable
   from tail commits.
3. In the same case as 2, we might end up choosing an incorrect
   commit as the LCA, which is an ancestor of the real LCA.
2022-03-16 21:41:59 +00:00
Igor Böhm 873f381e29 acme: fix hiding of top windows when loading a dump file (thanks Xiao-Yong)
When loading an acme dump file that contains a window with only one
tag line, there are cases where acme hides that window (i.e.  not even
its tag is visible).

The following commands reproduce the issue:

 % ed <<EOE
1
i
/tmp
/lib/font/bit/pelm/unicode.8.font
/lib/font/bit/pelm/unicode.8.font
          0
f          0           5         175         175           1
          5          40         175           1           0 /sys/src/cmd/acme/ Del Snarf Get | Look
f          0           4         330         330           3
          4          27         330           1           0 /tmp/ Del Snarf Get | Look
.
,w /tmp/test.dump
Q
EOE
 % window -dx 900 -dy 600  'acme -l /tmp/test.dump'

This issue was introduced in commit 47b7dc5ccd.
2022-03-15 10:49:00 +00:00
cinap_lenrek ca313087c1 ip(3): use flags instead of tag for 8 column route add/remove
This avoids ipconfig having to explicitely specify the tag
when we want to set route type, as the tag can be provided
implicitely thru the "tag" command.
2022-03-14 18:45:27 +00:00
cinap_lenrek d4e89fe76a ape: fix wrong write size for _assert() 2022-03-14 11:16:11 +00:00
cinap_lenrek 263251da75 ip/dhcpd: ignore icmp advice
should ignore advice as we are handling all connections
thru a single udp connection.
2022-03-13 20:43:16 +00:00
cinap_lenrek 5186cb3b99 ip(3): document the trans argument for add/try. 2022-03-13 17:38:06 +00:00
cinap_lenrek c8507f428f ipconfig(8): add -t flag to enable source address translation 2022-03-13 17:29:16 +00:00
cinap_lenrek 6e4a1fda8c devip: allow setting the "trans" flag on a logical interface
This makes the interface route have the "t"-flag,
which causes packets routed to the interface to get
source translated.
2022-03-13 17:16:54 +00:00
cinap_lenrek d2a7d88662 devip: implement network address translation routes
This adds a new route "t"-flag that enables network address translation,
replacing the source address (and local port) of a forwarded packet to
one of the outgoing interface.

The state for a translation is kept in a new Translation structure,
which contains two Iphash entries, so it can be inserted into the
per protocol 4-tuple hash table, requiering no extra lookups.

Translations have a low overhead (~200 bytes on amd64),
so we can have many of them. They get reused after 5 minutes
of inactivity or when the per protocol limit of 1000 entries
is reached (then the one with longest inactivity is reused).

The protocol needs to export a "forward" function that is responsible
for modifying the forwarded packet, and then handle translations in
its input function for iphash hits with Iphash.trans != 0.

This patch also fixes a few minor things found during development:

- Include the Iphash in the Conv structure, avoiding estra malloc
- Fix ttl exceeded check (ttl < 1 -> ttl <= 1)
- Router should not reply with ttl exceeded for multicast flows
- Extra checks for icmp advice to avoid protocol confusions.
2022-03-12 20:53:17 +00:00
cinap_lenrek c14ea9fdd1 awk: fix off-by-one string buffer overflow from gsub
the bug happens when we did the fast exit thru "done" label,
where we would not make sure that theres space in the buffer
for the NUL terminator.

instead, avoid the fast exit and always do the final
adjbuf() that makes sure we have space for the NUL terminator.

remove the pointless pb checks, they'r wrong (should'v
been bp >= buf+bufsz) and adjbuf() already makes sure this
can never happen.
2022-03-12 12:29:15 +00:00
Alex Musolino af6f03e528 hjfs: fix group ownership of home dirs created by newuser command 2022-03-08 13:25:52 +00:00
Michael Forney 0f890140f2 igfx: fix some typos in comments 2022-03-05 01:06:20 +00:00
Michael Forney d52f25ecdc igfx: add TypeILK, since it differs slightly from SNB
ILK's LVDS transcoder select field only has 1 bit, like G45.
2022-03-02 10:26:37 +00:00
Michael Forney a00957efee igfx: maintain single/double-channel LVDS mode from BIOS 2022-03-02 10:26:36 +00:00
Michael Forney 79c7e4514d igfx: fix FDI link training on ironlake
Ironlake uses bits 29:28 in the RX control register to select the
training pattern.
2022-03-02 10:26:38 +00:00
cinap_lenrek 9c02337fc3 merge 2022-03-02 18:54:36 +00:00
Michael Forney 954f9f1fcf aux/vga: return modes according to EDID timing priority order
EDID 1.3 section 5 gives a table describing the priority order of
timing information. Use this ordering when constructing the EDID
mode list.

Since aux/vga selects the first mode in the modelist that matches
the given size, it will now select the mode of that size with the
highest preference. Or, if you set vgasize=auto (or some other
string without an 'x'), aux/vga will select the Preferred Detailed
Timing.

This should make it unnecessary to modify vgadb in many cases.
2022-02-28 21:20:52 +00:00
cinap_lenrek d082a8972f ether82563: add pci id for ethernet on dell optiplex 7090 micro (thanks leimy)
0.31.6: net  02.00.00 8086/15f9 255 0:70900000 131072
         Intel Corporation
2022-02-28 13:18:13 +00:00
cinap_lenrek 5886b999d5 devbridge: fix vlan range parsing 2022-02-27 13:32:58 +00:00
Ori Bernstein 840d16912a git/revert: update modification time on revert
when reverting files, 'cp -x' updates the mtime
to the time the file was committed. this prevents
'mk' from rebuilding the file, leading to stale
builds.

this change touches the file on revert, so that
we rebuild the file.
2022-02-27 04:27:56 +00:00
cinap_lenrek fd1cfc824a snoopy: add vlan protocol (802.1q) 2022-02-27 03:33:01 +00:00
cinap_lenrek 9944e16b16 devbridge: improve locking, unbind ports automatically on read error and more...
Use an RWlock so readers can work in parallel in
the common case (no cache updates).

When a reader needs to update the cache to add
a new learned source mac address, it will drop
the rlock and aquire the wlock to do the update.

When we get a read error, we now unbind the
port to avoid further packets being forwarded
to it.

This is usefull for hotplug ethernet devices
like usb ones or tunnels.

Simplify the unbind, getting rid of the refcount,
by having only the reader proc call freeport().

Avoid holding the bridge lock while opening
and closing ethernet/tunnel device files during
bind and unbind.

Dont use smalloc() (especially when holding locks).

Allocate bridges dynamically, so we do not waste
the memory when we do not need them.

Reject non-hostowner from allocating new bridges.

Use consistent naming: port -> port

Use consistent comment style: // -> /* */
2022-02-26 22:05:32 +00:00
cinap_lenrek be0a80faf3 nusb/disk: use setalt(), print argv0 in prints instead of "disk:" 2022-02-23 18:38:28 +00:00
cinap_lenrek 045936a778 nusb/cam: fix mistake (nil vs -1) 2022-02-23 18:13:00 +00:00
cinap_lenrek 8bf71adc94 nusb/audio: use setalt(), make sure endpoint has right direction. 2022-02-23 18:03:53 +00:00
cinap_lenrek 11e12ea0c0 nusb/cam: use setalt() 2022-02-23 18:02:02 +00:00
cinap_lenrek 67750a093f nusb/ether: use setalt() 2022-02-23 18:01:15 +00:00
cinap_lenrek bea20cd152 nusb/lib: provide a setalt() function to set the interface to its altsetting 2022-02-23 18:00:34 +00:00
cinap_lenrek 9cd55a085d nusb/ether: remove csp check for rndis, already done in nusbrc 2022-02-23 17:59:13 +00:00
Sigrid Solveig Haflínudóttir 0e3a955652 libFLAC: update to 1.3.4 2022-02-21 21:11:19 +00:00
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
cinap_lenrek 14bb9734a6 usbxhci: endpoint address needs to be masked with Epmax from endpoint number 2022-02-21 18:46:47 +00:00
cinap_lenrek 4b637a24f9 devbridge: implement experimental vlan support 2022-02-16 22:38:03 +00:00
cinap_lenrek 7289f371a0 devip: dont hold ifc wlock during medium bind/unbind
Wlock()'ing the ifc causes a deadlock with Medium
bind/unbind as the routine can walk /net, while
ndb/dns or ndb/cs are currently blocked enumerating
/net/ipifc/*.

The fix is to have a fake medium, called "unbound",
that is set temporarily during the call of Medium
bind and unbind.

That way, the interface rwlock can be released while
bind/unbind is in progress.

The ipifcunbind() routine will refuse to unbind a
ifc that is currently assigned to the "unbound"
medium, preventing any accidents.
2022-02-16 22:31:31 +00:00
cinap_lenrek 755880b19f rc: fix globbing with lists (thanks qwx)
Pattern matching with lists no longer works:

	; ls /tmp/*.c
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c
	; ls /tmp/^(*.c)
	ls: /tmp/*.c: '/tmp/*.c' directory entry not found
	; 9fs dump
	; bind /n/dump/2021/1002/amd64/bin/rc /bin/rc
	; rc
	; ls /tmp/^(*.c)
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c

the fix:

we have to propagate the glob attribute thru lists
as well. before it was only handled for single words
and propagated thru concatenations...

the Xglob instruction now works on list, and we
propagate the glob attribute thru PAREN and WORDS
and ARGLIST nodes.

also, avoid using negative numbers for the Tree.glob
field as char might be unsigned on some targets.
2022-02-16 18:07:21 +00:00
Michael Forney 5c96a51f3a nusb/serial: fix pl2303 usbcmd error checks
Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
(excluding the setup packet), so adjust the expected return values
accordingly.
2022-01-01 22:51:18 +00:00
Igor Böhm 5d69d42ee3 git(1): fix quotes in git/conf example 2021-12-15 22:45:59 +00:00
Tobias Heinicke 53fb93e64a delete import, oexportfs src 2021-12-14 19:39:59 +00:00
qwx af561602ea aux/wacom: fix race in read queue
this fixes `no concurrent reads, please' errors when using
aux/wacom with aux/tablet on eg. x61t
2021-12-14 23:54:05 +00:00
Ori Bernstein 7efbea82c6 devssl, cpu, import, oexportfs: delete
SSL is implemented by devssl. It's extremely
obsolete by now, and is not used anywhere but
cpu, import, and oexportfs.

This change strips out the devssl bits, but
does not (yet) remove the code from libsec.
2021-12-13 02:17:02 +00:00
qwx b4d4cf69be vga/igfx: add missing pci did's for hwblank for known mobile models 2021-12-08 09:52:07 +00:00
Ori Bernstein 3710ed60fd git: fully init objq
we were leaving objq.best uninitialized, and
would therefore read garbage if we didn't
find a best match.
2021-12-08 00:20:32 +00:00
cinap_lenrek be0b39f9c5 acmed(8), rsa(8): add role=client attribute to rsa keys 2021-12-06 15:40:18 +00:00
Humm 69249e8313 troff: we are not htmlroff
If we don’t explicitly check for ‘h’ in troff, we can’t reliably check
for non-htmlroff well.

Consider the following:

	.if h \{\
	.	de M
	.		tm m
	..\}

Without this change, this will print m and not define macro M.
2021-11-24 19:56:44 +00:00
Ori Bernstein f0adfb4ded git: improve pack cache heuristics
the pack cache was very stupid: it would close packs
as early as possible, which would prevent packs from
getting reused effectively. It would also select a
bad pack to close.

This picks the oldest pack, refcounts correctly, and
keeps up to Npackcache open at once (though it will
go over if more are in use).
2021-12-05 00:13:54 +00:00
cinap_lenrek d3743d40c2 netaudit, ndb(6): the dom= attribute in ndb should be specified without the trailing period 2021-11-29 20:07:04 +00:00
cinap_lenrek 78c7ad88ff kernel: add extra negative and power-of-two check to pcibarsize() 2021-11-26 21:47:15 +00:00
cinap_lenrek 2a531d444c aux/vga: use vlong for pci bar size 2021-11-26 20:55:58 +00:00
cinap_lenrek 20ea113790 kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TB
This makes vmap()/vunmap() take a vlong size argument,
and change the type of Pci.mem[].size to vlong as well.

Even if vmap() wont support large mappings, it is nice to
get the original unruncated value for error checking.

pc64 needs a bigger VMAP window, as system76 pangolin
puts the framebuffer at a physical address > 512GB.
2021-11-26 20:51:45 +00:00
Sigrid Solveig Haflínudóttir add3a0a4da aescbc: flush before exit and report an error (if any) 2021-11-25 21:42:12 +00:00
Igor Böhm a27afe904d prep(8): fix typos, wording, and formating 2021-11-21 22:45:51 +00:00
Igor Böhm d1a81aa81f rsa(8): fix spelling and adjust macros to fix formating 2021-11-20 22:59:43 +00:00
qwx b5a2fa5e5e audiohda: add support for intel cannon point-lp (t490s) 2021-11-18 17:15:08 +00:00
Humm 05b513a687 snap(4): remove non-existent -s from snapfs 2021-11-17 19:57:03 +00:00
cinap_lenrek fc412aef3d 6c: extern registers must be considered used on return
the peephole optimizer would remove stores to extern
register before a return statement as it would think
they are only set, but not used.
2021-11-17 01:23:57 +00:00
Igor Böhm 3473fa237c nusbrc(8): fix typo in BUGS section 2021-11-16 08:06:50 +00:00
Sigrid Solveig Haflínudóttir 78b55b64c8 mklatin: fix compose sequences starting with a space char (␣ and ı) 2021-11-14 20:16:30 +00:00
Sigrid Solveig Haflínudóttir 0f50c54b5e kbdfs: allow X and x to be used not just for hex composition 2021-11-14 14:27:15 +00:00
qwx 2ab25e3ec0 vgaigfx: add x1 carbon 3rd gen 2021-11-13 23:04:04 +00:00
Kyle Milz 41ac2d80c7 igfx: add x1 carbon 3rd gen (broadwell) 2021-11-12 18:37:33 +00:00
Igor Böhm c7775b365e rc: fix leaking runq->cmdfile
To reproduce run the following on a terminal:
<snip>
cpu% leak -s `{pstree | grep termrc | sed 1q | awk '{print $1}'}
src(0x00209a82); // 12
src(0x0020b2a6); // 1
cpu% acid `{pstree | grep termrc | sed 1q | awk '{print $1}'}
/proc/358/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x0020b2a6)
/sys/src/cmd/rc/plan9.c:169
 164		if(runq->argv->words == 0)
 165			poplist();
 166		else {
 167			free(runq->cmdfile);
 168			int f = open(runq->argv->words->word, 0);
>169			runq->cmdfile = strdup(runq->argv->words->word);
 170			runq->lexline = 1;
 171			runq->pc--;
 172			popword();
 173			if(f>=0) execcmds(openfd(f));
 174		}
acid:
</snap>

Another `runq->cmdfile` leak is present here (captured on a cpu server):
<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002051d2)
/sys/src/cmd/rc/exec.c:1056
 1051
 1052	void
 1053	Xsrcfile(void)
 1054	{
 1055		free(runq->cmdfile);
>1056		runq->cmdfile = strdup(runq->code[runq->pc++].s);
 1057	}
acid:
</snap>

These leaks happen because we do not free cmdfile on all execution paths
where `Xreturn()` is invoked. In `/sys/src/cmd/rc/exec.c:/^Xreturn`

<snip>
void
Xreturn(void)
{
	struct thread *p = runq;
	turfredir();
	while(p->argv) poplist();
	codefree(p->code);
	runq = p->ret;
	free(p);
	if(runq==0)
		Exit(getstatus());
}
</snip>

Note how the function `Xreturn()` frees a heap allocated instance of type
`thread` with its members *except* the `cmdfile` member.

On some code paths where `Xreturn()` is called there is an attempt to free
`cmdfile`, however, there are some code paths where `Xreturn()` is called
where `cmdfile` is not freed, leading to a leak.

The attached patch calls `free(p->cmdfile)` in `Xreturn()` to avoid leaking
memory and handling the free in one place.

After applying the patch this particular leak is removed. There are still
other leaks in rc:

<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x00209a82)
/sys/src/cmd/rc/subr.c:9
 4	#include "fns.h"
 5
 6	void *
 7	emalloc(long n)
 8	{
>9		void *p = malloc(n);
 10		if(p==0)
 11			panic("Can't malloc %d bytes", n);
 12		return p;
 13	}
 14
</snap>

To help fixing those leaks emalloc(…) and erealloc(…) have been amended to use
setmalloctag(…) and setrealloctag(…). The actual fixes for other reported leaks
are *not* part of this merge and will follow.
2021-11-10 13:01:38 +00:00
cinap_lenrek a4c1f3cc18 devtls: reject zero length records (thanks sigrid)
zero length record causes ensure() todo nothing,
while qgrab() assumes there is at least one buffer
in the queue and would dereference the nil buffer.
2021-11-09 01:46:13 +00:00
cinap_lenrek 68572ab451 diff: revert last change, this breaks git/diff 2021-11-09 01:29:30 +00:00
Igor Böhm a7ec6ee4e8 git(1): fix git/add -r spacing and wording in BUGS section 2021-11-08 01:05:51 +00:00
cinap_lenrek a87ce74d60 kernel/rdb: need to reenable polling mode on the uart, remove cruft 2021-11-07 17:58:52 +00:00
cinap_lenrek 9eb192f586 bcm64: parse the emmc2bus/dma-ranges device-tree property and provide *emmc2bus kernel parameter
/*
  * emmc2 has different DMA constraints based on SoC revisions. It was
  * moved into its own bus, so as for RPi4's firmware to update them.
  * The firmware will find whether the emmc2bus alias is defined, and if
  * so, it'll edit the dma-ranges property below accordingly.
  */
 emmc2bus: emmc2bus {
 compatible = "simple-bus";
 ranges = <0x0 0x7e000000  0x0 0xfe000000  0x01800000>;
 dma-ranges = <0x0 0xc0000000  0x0 0x00000000  0x40000000>;
 emmc2: mmc@7e340000 {
 compatible = "brcm,bcm2711-emmc2";
 reg = <0x0 0x7e340000 0x100>;
 interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
 clocks = <&clocks BCM2711_CLOCK_EMMC2>;
 status = "disabled";
 };
 };
2021-11-07 17:51:12 +00:00
cinap_lenrek 80268af29e bcm64/sdhc: add *emmc2bus kernel parameter to set dma dram bus address
On the raspberry pi 4, depending on the chip revision,
the emmc2 controller has different dram bus address window,
so make it configurable.
2021-11-07 17:47:09 +00:00
cinap_lenrek a2baa86348 bcm/emmc: remove unused cardr wakeup(), use MACHP(0) as tick reference 2021-11-07 17:43:36 +00:00
cinap_lenrek 2925fb09a6 sdmmc: do card init in a background process after the first try
Some mmc controllers have no card detect pin, so the only
way to detect card presence is to issue the ACMD41 which will
fail after a pretty long timeout.

To avoid mmconline() blocking, we only try to initialize the
card synchronous once, and then retry in a background process,
while returning immediately from mmconline() while the retry
is in progress.

This speeds up network boot times significantly on a raspi
without a sdcard inserted.
2021-11-07 17:41:57 +00:00
Igor Böhm efa6937460 acme: fix leaking memory allocated by getenv("font")
If the font chosen for acme is retrieved via `getenv("font")` its
memory is leaked:

<snip>
	if(fontnames[0] == nil)
		fontnames[0] = getenv("font");
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> getenv(…) mallocs memory

	if(fontnames[0] == nil)
		fontnames[0] = "/lib/font/bit/vga/unicode.font";
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[0] = estrdup(fontnames[0]);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> if the `getenv("font")` path was taken above, this assignment
> will leak its memory.
</snap>

The following leak/acid session demonstrates the issue:

<snip>
cpu% leak -s 212252
src(0x002000cb); // 1
cpu% acid 212252
/proc/212252/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002000cb)
/sys/src/cmd/acme/acme.c:107
 102			fprint(2, "usage: acme [-aib] [-c ncol] [-f font] [-F fixedfont] [-l loadfile | file...]\n");
 103			exits("usage");
 104		}ARGEND
 105
 106		if(fontnames[0] == nil)
>107			fontnames[0] = getenv("font");
 108		if(fontnames[0] == nil)
 109			fontnames[0] = "/lib/font/bit/vga/unicode.font";
 110		if(access(fontnames[0], 0) < 0){
 111			fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
 112			exits("font open");
acid:
</snap>

The fix tries to first check if a font has been set via
command line options in which case the font string is
malloced via estrdup(…).

If no font has been selected on the command line getenv("font")
is used. If no getenv("font") var is found we malloc a default
font via estrdup(…).

<snip>
	if(fontnames[0] != nil)
		fontnames[0] = estrdup(fontnames[0]);
	else
		if((fontnames[0] = getenv("font")) == nil)
			fontnames[0] = estrdup("/lib/font/bit/vga/unicode.font");
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[1] = estrdup(fontnames[1]);
</snap>

This resolves the memory leak reported by leak(1).
2021-11-05 23:51:55 +00:00
Kyle Milz cd7480f68f diff: fix -u when comparing identical files 2021-11-05 19:03:20 +00:00
Igor Böhm 160e36aaef git(1): fix typo in git/push section 2021-11-06 00:15:28 +00:00
Igor Böhm 775608db7c leak(1): document how to generate pool.$objtype.acid
/sys/lib/acid/leak requires /sys/src/libc/port/pool.$objtype.acid
which is not present by default, describe how to generate it.
2021-11-04 23:11:56 +00:00
qwx 9827a6b178 audiohda: add support for intel comet lake-s, fix typo 2021-11-05 22:26:28 +00:00
cinap_lenrek 6c70026fa4 acme: fix plumb message leaks (thanks igor) 2021-11-05 18:49:40 +00:00
Kyle Milz e2e4a46f26 git/revert: fix empty invocation
git/revert requires a file name argument, but when none is given
it fails in a strange way:

	% git/revert
	usage: cleanname [-d pwd] name...
	/bin/git/revert:15: null list in concatenation
2021-11-04 19:08:02 +00:00
Stuart Morrow 3f49507786 mainly just spelling and typos 2021-11-01 20:49:43 +00:00
cinap_lenrek cdf3be65ea snoopy: dns: add caa record type, fix rrtypestr() 2021-11-03 21:44:24 +00:00
cinap_lenrek c37de33463 ndb/dns: use decimal encoding for txt rr string escapes
rfc883 suggests to use decimal digits to escape txt rr strings,
and unix dig appears to use the same.
so change from octal to decimal.
2021-11-03 20:38:23 +00:00
cinap_lenrek 6285c19b33 snoopy: adjust for new dns txt rr format 2021-11-03 20:21:03 +00:00
cinap_lenrek 5de1f3d9cf ndb/dns: handle txt rr strings as binary, remove nullrr ndb code
txt and caa rr strings might contain binary control characters
such as newlines and double quotes which mess up the output
in ndb(6) format.
so handle them as binary blobs internally and escape special
characters as \DDD where D is a octal digit when printing.

txtrr() will unescape them when reading into internal
binary representation.

remove the undocumented nullrr ndb attribute parsing code.
2021-11-03 20:09:02 +00:00
cinap_lenrek 2899b719ae libndb: move mkptrname() into libndb to avoid duplication 2021-11-03 19:38:36 +00:00
Sigrid Solveig Haflínudóttir 2d56837b2f zuke: fix search function ignoring matching artist name 2021-11-03 14:45:27 +00:00
Noam Preil 4584fbf577 venti(8): change documented behavior to match actual 2021-11-03 03:48:48 +00:00