Commit graph

7621 commits

Author SHA1 Message Date
cinap_lenrek ab103ba349 devproc: allow anyone to change user of its own processes to "none" 2020-12-23 13:09:31 +01:00
Sigrid 7bcdd1b5d8 libvorbis: 1.3.5 → 1.3.7 (fixes a bunch of CVE and other small issues) 2020-12-23 12:18:07 +01:00
cinap_lenrek a7a08647b6 ape: re-implement getlogin() by stating /proc/$pid/status 2020-12-23 02:32:13 +01:00
cinap_lenrek dced7255ec libc: re-implement getuser() by stating /proc/$pid/status
The idea is to avoid the magic files that contain
per process information in devcons when possible.
It will make it easier to deprecate them in the future.
2020-12-23 02:31:28 +01:00
cinap_lenrek f11526708e kw: use ethermii.c from port/ (thanks stuart) 2020-12-22 22:17:44 +01:00
cinap_lenrek 809a7402fc aout2uimage: fix missing \n in usage print (thanks james) 2020-12-22 19:33:49 +01:00
cinap_lenrek 1619629835 upasfs(4): fix small typos (thanks igor) 2020-12-22 17:44:26 +01:00
cinap_lenrek 157166d4fc kbdfs: fix mistake, remove leftover static user variable (thanks umbraticus and igor) 2020-12-22 16:36:45 +01:00
cinap_lenrek 29f60cace1 kernel: avoid palloc lock during mmurelease()
Previously, mmurelease() was always called with
palloc spinlock held.

This is unneccesary for some mmurelease()
implementations as they wont release pages
to the palloc pool.

This change removes pagechainhead() and
pagechaindone() and replaces them with just
freepages() call, which aquires the palloc
lock internally as needed.

freepages() avoids holding the palloc lock
while walking the linked list of pages,
avoding some lock contention.
2020-12-22 16:29:55 +01:00
cinap_lenrek 2fb5fbbd73 merge 2020-12-22 00:47:53 +01:00
Alex Musolino f2919dfd14 rio(4): list window states in order (thanks umbracticus) 2020-12-22 10:11:03 +10:30
cinap_lenrek 0ad4ceb8d0 kernel: make addbroken() static, remove misleading Proc* argument 2020-12-21 22:03:46 +01:00
cinap_lenrek 5a059477f8 pc, xen: move fpu setup/fork/save/restore handlers to pc/fpu.c 2020-12-21 15:04:48 +01:00
cinap_lenrek 932995bb27 kernel: update procsave() comment, we'r not holding up->rlock anymore 2020-12-21 14:41:10 +01:00
cinap_lenrek 41c60689b3 ndb/dns: handle dnskey RR's (thanks moody)
On 12/18/20, Jacob Moody wrote:
> Hello,
>
> I recently ran in to some issues with pointing an unbound server towards a
> 9front dns server as its upstream.
> The parsing seemed to fail when ndb/dns received a DNSKEY RR from it's own
> upstream source on behalf of unbound.
> This patch catches and stores the DNSKEY from the upstream server to prevent
> this.
2020-12-20 23:08:11 +01:00
cinap_lenrek e4ce6aadac kernel: handle tos and per process pcycle counters in port/
we might as well handle the per process cycle
counter in the portable part instead of duplicating the code
in every arch and have inconsistent implementations.

we now have a portable kenter() and kexit() function,
that is ment to be used in trap/syscall from user,
which updates the counters.

some kernels missed initializing Mach.cyclefreq.
2020-12-20 22:34:41 +01:00
cinap_lenrek 08c1622b0d [12kq]l: remove unix compat code for cputime() 2020-12-19 19:15:02 +01:00
cinap_lenrek 0527345e0a libthread: remove unused _times() function 2020-12-19 18:47:17 +01:00
cinap_lenrek 58e6750401 kernel: remove Proc* argument from procsetuser() function 2020-12-19 18:07:12 +01:00
cinap_lenrek eb1dfed9ab libauth: change programs to use the new procsetuser() function 2020-12-19 18:02:37 +01:00
cinap_lenrek fc5070c600 libauth: add procsetuser() function to change user id of the calling process
Provide a central function to change the user id
of the calling process.

This is mostly used by programs to become the none
user, followed by a call to newns().
2020-12-19 17:46:55 +01:00
cinap_lenrek daccd2b226 aux/kbdfs: use getuser() from libc 2020-12-19 15:52:41 +01:00
cinap_lenrek ba20914d01 acme: use global user string variable instead of getuser() 2020-12-19 15:50:30 +01:00
cinap_lenrek c7fc69bd6a acme: use getuser() in fsinit() 2020-12-19 15:36:07 +01:00
cinap_lenrek 672cf179a1 libc: implement getppid() reading /proc/$pid/ppid instead of /dev/ppid
The devcons driver is really the wrong place to
serve per process information.
2020-12-19 15:15:38 +01:00
cinap_lenrek d919ad3b5e devsons: remove #c/pgrpid
The process group id is essentially a unique id
of the namespace but it was never well documented
nor is it used by any program.
2020-12-19 14:59:19 +01:00
Ori Bernstein 4dc437c076 vt: rfork environment varibles (thanks fshahriar)
vt sets several environment variables ($TERM, $COLS, $LINES)
after exiting. This change rforks the environment so that this
detritus doesn't get left behind.
2020-12-18 19:23:48 -08:00
Ori Bernstein 2db3642b8d strndup: don't assume buffer is terminated
Using strlen in strndup will walk past the first
n bytes up to the terminator, which may not be
present. This is not what we want.

While we're here, do some cleanups.
2020-12-18 07:16:29 -08:00
kvik f097883644 kbmap: add Turkish keymap (thanks Kemal) 2020-12-18 15:15:49 +01:00
Ori Bernstein c2aa8c997a hpost: support custom headers (thanks julienxx)
hget supports adding custom headers with -r;
it makes sense for hpost to do the same, both
because custom headers are more likely necessary
with POSTs, and for consistency.
2020-12-17 20:26:38 -08:00
Ori Bernstein 658c1b9f68 libap: add strndup
strndup is part of POSIX.1, so APE should provide it.
This patch adds it, so need to patch it out of fewer
programs going forward.
2020-12-17 19:20:04 -08:00
cinap_lenrek 646c502b15 ether2114x: make sure pci bar0 is I/O 2020-12-17 21:02:11 +01:00
cinap_lenrek 318fe6a702 ether2114x: vetting the driver for pc64
the tulip driver is used in microsofts hypver-v
as the legacy ethernet adapter for pxe booting.

to make the driver work on pc64, we need to
store the Block* pointers in a separate array
instead of stuffing them into buffer address 2
of the hardware descriptor.

also, enable the driver in the pc64 kernel.
2020-12-17 20:55:59 +01:00
Sigrid 5016ac0c63 pc: set exit status depending on errors 2020-12-15 14:37:36 +01:00
Sigrid d0c6ade53d pc: treat EOF gracefully, allowing easier use within sam command language 2020-12-15 14:25:59 +01:00
Alex Musolino 3749e92cdb merge 2020-12-15 20:55:41 +10:30
Alex Musolino 404c901f29 ico: avoid potential nil pointer dereferences
Bgeticon can fail, leaving the Icon img pointers nil.
2020-12-15 20:45:26 +10:30
Alex Musolino 81647c2025 ico: fix interpretation of 0 widths/heights 2020-12-15 20:44:11 +10:30
cinap_lenrek 32291b52bc iostats: dup 9p pipe to both fd 0 and fd 1 for exportfs 2020-12-13 20:23:03 +01:00
cinap_lenrek 08a9a6952d cpu(1): refer to oexportfs(4) 2020-12-13 20:11:44 +01:00
cinap_lenrek 6f932de718 import(4): refer to oexportfs(4) 2020-12-13 20:11:30 +01:00
cinap_lenrek 27a83106f4 oexportfs: move legacy code for cpu and import to separate program
The initial protocol handling in exportfs for
cpu and import services is a huge mess.

Saparate the code out into its own program with
its own oexportfs(4) manpage.
2020-12-13 20:09:03 +01:00
cinap_lenrek 0b33b3b8ad kernel: implement per file descriptor OCEXEC flag, reject ORCLOSE when opening /fd, /srv and /shr
The OCEXEC flag used to be maintained per channel,
making it shared between all the file desciptors.

This has a unexpected side effects with regard to
channel passing drivers such as devdup (/fd),
devsrv (/srv) and devshr (/shr).

For example, opening a /srv file with OCEXEC
makes it impossible to be remounted by exportfs
as it internally does a exec() to mount and
re-export it. There is no way to reset the flag.

This change makes the OCEXEC flag per file descriptor,
so a open with the OCEXEC flag only affects the fd
group of the calling process, and not the channel
itself.

On rfork(RFFDG), the per file descriptor flags get
copied.

On dup(), the per file descriptor flags are reset.

The second modification is that /fd, /srv and /shr
should reject the ORCLOSE flag, as the files that
are returned have already been opend.
2020-12-13 16:04:09 +01:00
cinap_lenrek b2b2d2cb4c sdiahci: assume 64-bit PCIWADDR() 2020-12-12 18:16:06 +01:00
cinap_lenrek 5ea540e75d sdiahci: enable pci busmaster before ahciconfigdrive() (fix qemu crash)
enable pci busmaster before set the fis-receive-enable
bit in the port command register.

not doing so triggers a crash in qemu like:

address_space_unmap: Assertion `mr != NULL' failed.

as qemu tries to process the dma command list as soon
as we set that flag and busmaster dma needs to be enabled
at this point.
2020-12-12 18:00:41 +01:00
cinap_lenrek b1d1fa04b9 merge 2020-12-11 15:24:35 +01:00
cinap_lenrek fc0f08c651 pc, pc64: make sure write combining is supported in MTRR's before setting it 2020-12-11 15:23:03 +01:00
cinap_lenrek 658c994cff pc, pc64: ignore MTRR's when MTRRCap.vcnt and MTRRCap.fix are zero
Bhyve returns 0 in MTRRCap register, so we
can use that instead on relying on cpuid only
to see if MTRR's are supported.

That way we can get rid of the sanity check
in memory.c.
2020-12-11 15:21:44 +01:00
Sigrid 345e93dd4c update Finnish kbmap: fix ¤ on shift+4 and add more AltGr variants 2020-12-11 15:18:41 +01:00
Sigrid f5d1fce9b5 vmx: clean up mksegment, memset only if segment existed (devsegment clears new ones) 2020-12-10 12:19:45 +01:00
cinap_lenrek cef91f23e7 pc, pc64: work around bhyve all uncached MTRR's 2020-12-10 01:47:19 +01:00
cinap_lenrek 635be84831 merge 2020-12-09 01:05:14 +01:00
cinap_lenrek eb3d055eb3 backout OCEXEC changes when potentially opening /srv files
Opening a /srv file sets the close-on-exec flag on the
shared channel breaking the exportfs openmount() hack.

The devsrv tries to prevent posting a channel with the
close-on-exec or remove-on-close flags. but nothing
currently prevents this poisoning on open.

Until this gets fixed in eigther exportfs or devsrv,
i'll back out the changes that could have potential side
effects like this.
2020-12-09 01:04:03 +01:00
kvik 07d3d9bf0c sega(1): fix keys (thanks bigato) 2020-12-08 21:20:13 +01:00
cinap_lenrek 5149f204b7 plan9.ini(8): document *nomtrr= and order the table 2020-12-08 17:16:12 +01:00
cinap_lenrek 8efbd243e1 pc, pc64: cleanup cpuidentify() and some comments 2020-12-08 16:58:41 +01:00
cinap_lenrek b2ffb6ccc5 pc, pc64: add *nomtrr= kernel parameter 2020-12-08 16:34:36 +01:00
cinap_lenrek 263dc8093d pc64: preserve reserved bits in CR0/CR4 for amd64 in mtrr setstate()
On AMD64, CR0/CR4 are 64-bit registers, with
the upper half reserved. So use uintptr type
to store the register values to get 32 bit on 386
and 64 bit on AMD64.
2020-12-08 16:00:57 +01:00
cinap_lenrek 4db8a82f5a vncv: backing out previous change, this needs another revision 2020-12-08 15:15:13 +01:00
Sigrid b1da2bb10b vncv: do NOT map Kaltgr to meta, introduce Mod4 (Super) as an extra key to use instead 2020-12-08 14:32:28 +01:00
Sigrid 93c6f8cb0d vmx(1): build vmxgdb by default, clean it up as well 2020-12-08 13:18:10 +01:00
cinap_lenrek 4ba5cb6c6a vmx: nanosec(): fix non-interruptable temporary, assign fasthz only once after xstart 2020-12-08 13:04:52 +01:00
cinap_lenrek 01eb04060b pc: move ldmxcsr() prototype to fpu.c 2020-12-08 12:42:36 +01:00
cinap_lenrek de5770c352 vmx: add fmt checking, fix fmt errors, remove duplication for vmdebug 2020-12-08 12:40:28 +01:00
Sigrid 07805ac892 nusb/kb: update button state if event was actually received, fix typos (thanks umbraticus) 2020-12-08 11:47:15 +01:00
Sigrid 3d9abd96ae devmouse: remove redundant check 2020-12-08 11:21:18 +01:00
Sigrid e812aa617f mouse(3): blankS, setS to follow the convention (thanks umbraticus) 2020-12-08 10:34:10 +01:00
Sigrid 014bf3fe7c mouse(3): document "scrollswap" ctl message, fix style a bit (thanks umbraticus) 2020-12-08 10:21:17 +01:00
Sigrid 8f9d4d7c27 vesa: make unsupported function not an error, set return status 2020-12-08 10:08:49 +01:00
Sigrid 96850d8bb4 vmx: add -D option to enable debug messages, use vmdebug for non-fatal "errors" 2020-12-08 10:01:44 +01:00
cinap_lenrek c74458c98b vmx: add -v|-w flag to control window creation behaviour
The -v flag now does not create a new rio window,
while -w flag does (restores the old behaviour).

This allows vmx to run under vncs and is in general
mode aligned to other emulators and programs.
2020-12-07 18:59:54 +01:00
cinap_lenrek 1bb96d542c libcomplete: open internal file-descriptor with OCEXEC flag 2020-12-07 17:18:33 +01:00
cinap_lenrek 383a2ca79b libsec: open internal file-descriptors with OCEXEC flag 2020-12-07 17:14:34 +01:00
cinap_lenrek d5928fb515 merge 2020-12-07 16:48:19 +01:00
cinap_lenrek f7e21d7692 libauthsrv: open internal file-descriptors with OCEXEC flag 2020-12-07 16:47:06 +01:00
cinap_lenrek f433f1426b libauth: open internal file-descriptors with OCEXEC flag 2020-12-07 16:46:34 +01:00
Sigrid 6c29cf79f0 aux/kbdfs, kbmaps: enable Kmod4 for other layouts, not just neo2 2020-12-07 16:42:56 +01:00
cinap_lenrek f341ae8c77 libdraw: open file-descriptor with OCEXEC flag in readcolmap() 2020-12-07 16:30:27 +01:00
cinap_lenrek 1a900513fb libndb: open internal file-descriptors with OCEXEC flag 2020-12-07 15:15:02 +01:00
cinap_lenrek 5e59c57bb1 lib9p: open internal file-descriptor with OCEXEC flag in getremotesys() 2020-12-07 14:54:27 +01:00
cinap_lenrek 4d4b6a19de lib9p: open /mnt/factotum/rpc with OCEXEC flag in auth9p() 2020-12-07 14:51:53 +01:00
cinap_lenrek d570229e82 lib9p: improve reqqueuecreate()
- open /proc/n/ctl with OCEXEC flag
- format pid as ulong
- don't leak the fd
2020-12-07 14:49:12 +01:00
cinap_lenrek b3c9249500 merge 2020-12-07 14:33:51 +01:00
cinap_lenrek 4d22dbb0f5 libdraw: open internal file-descriptors with OCEXEC flag 2020-12-07 14:32:34 +01:00
cinap_lenrek e8b871ef5a libdraw: remove unused Error label in freescreen() 2020-12-07 14:32:12 +01:00
cinap_lenrek c10e21b491 libthread: reduce stack usage of threadkill*(), open /proc/n/ctl with OCEXEC flag 2020-12-07 14:31:02 +01:00
cinap_lenrek e45bd6814a libthread: reduce stack usage for ioprocs, open /proc/n/ctl with OCEXEC flag 2020-12-07 14:29:45 +01:00
cinap_lenrek 1e2657ee97 libthread: simplify threadsetname()
- open /proc/n/args with OCEXEC flag
- reduce stack usage by using smaller buffer for path
- format pid as ulong
2020-12-07 14:27:46 +01:00
cinap_lenrek f1e15da8f5 libc: open internal file-descriptor with OCEXEC flag 2020-12-07 14:24:51 +01:00
cinap_lenrek 544bca0290 rio: format pid's as ulongs 2020-12-07 14:23:41 +01:00
cinap_lenrek ed3ae3faa3 rio: open /dev/snarf with OCEXEC flag when writing 2020-12-07 14:23:23 +01:00
cinap_lenrek c86a960880 rio: simplify filsysinit() by using getuser(), format pid's as ulongs 2020-12-07 14:22:30 +01:00
kvik a92ffdbbfb libndb: remove db file size limit
Removes the 128 kB limit for files making up the database.
We used to skip over and complain about files that exceeded
the limit, forcing the user to generate hash files.

This caused things to inexplicably stop working after a file
hit the hidden limit, which is unreasonable behaviour considering
that libndb happily, albeit slowly, works with bigger files.
2020-12-07 00:36:41 +01:00
cinap_lenrek c924edb91d merge 2020-12-06 22:06:32 +01:00
cinap_lenrek 23b52bbf23 pc64: assign fpsave/fprestore only once in fpuinit() 2020-12-06 22:05:00 +01:00
kvik d15439ee76 ptrap: implement filtering on plumb attributes 2020-12-06 21:52:01 +01:00
cinap_lenrek cd38d41356 pc64: AMD64 mandates SSE support, remove the check in fpuinit() 2020-12-06 21:44:26 +01:00
cinap_lenrek dcdb2bfb9a xen: use pc/fpu.c 2020-12-06 21:28:11 +01:00
cinap_lenrek 8c1bde46f0 pc, pc64: move all fpu specific code from main.c to fpu.c 2020-12-06 21:07:30 +01:00
Sigrid dbbae6d384 xen: fix for the last avx changes 2020-12-06 20:28:53 +01:00
Sigrid 97b3291533 amd64: FP: back to static size for allocation and copying 2020-12-06 19:40:57 +01:00
Sigrid 334c5e1134 amd64: FP: always use enough to fit AVX state and align to 64 bytes 2020-12-06 19:31:56 +01:00
Sigrid 66b6185845 amd64, vmx: support avx/avx2 for host/guest; use *noavx= in plan9.ini to disable 2020-12-06 18:48:32 +01:00
cinap_lenrek 753a35b52a rio: undo previous commit, was a stupid idea 2020-12-06 15:08:23 +01:00
cinap_lenrek a0d12784bd rio: give visual clue during sweep and bandsizing when window is too small
We color the window border with a dark red in case the
window is too small.
2020-12-06 14:50:50 +01:00
cinap_lenrek bf2a6f7865 rio: use libdraw's badrect() to exclude some extreme cases in goodrect() 2020-12-06 14:44:23 +01:00
cinap_lenrek 082560fd5b rio: rewrite better portion() function 2020-12-06 13:20:29 +01:00
Sigrid f5d9b2222b rio: handle corner selection for resizing better (thanks cinap) 2020-12-06 13:04:36 +01:00
Sigrid a696951c6c rio: goodrect: clarify minimal height and actually use the smallest reasonable value 2020-12-06 13:02:33 +01:00
Sigrid 7f7c151687 rio: allow windows as small as one line of text, still scrollable 2020-12-06 12:17:05 +01:00
Sigrid ecb12c8718 aux/status^(bar msg): few small fixes (thanks umbraticus) 2020-12-06 11:55:27 +01:00
Alex Musolino 5d790e08ca cwfs: fix interpretation of startdump argument 2020-12-06 13:54:10 +10:30
cinap_lenrek abcc56afef pc/dma, pc/sdide: use uintptr for physical address instead of ulong 2020-12-05 17:01:24 +01:00
cinap_lenrek 178a9d12c6 pc, pc64: allocate dma bounce buffer right after xinit() 2020-12-05 16:59:30 +01:00
cinap_lenrek 99696c414a pc, pc64: exclude memory regions with unusual MTRR cache attributes
Use the MTRR registers to exclude memory ranges that
do not have the expected cache attributes:

RAM -> writeback
UMB -> uncached
UPA -> uncached
2020-12-05 16:57:12 +01:00
Sigrid 4ca5e1b3a3 faces: add -c option to remove faces with button 1 click (thanks sirjofri) 2020-12-04 09:33:55 +01:00
cinap_lenrek 4b6072e60f merge 2020-12-02 00:57:21 +01:00
cinap_lenrek 1bce6d0981 libdraw: do not force flushimage() on freescreen()
This causes visual flashes of white in rio. If it is
really needed (it is rare) it should be done by the caller.
2020-12-02 00:56:21 +01:00
cinap_lenrek 7d55aa8a32 rio: properly restore the windows contents on /dev/mouse close
The previous resize optimization now means that the wfill()
is skipped on resize for libdraw programs.

So do it once /dev/mouse is closed and the window processes
the Refresh message.
2020-12-02 00:53:58 +01:00
Ori Bernstein 2652cbee57 proof: don't confuse ""(1) (thanks Stuart Morrow)
"" looks for patterns in the form 'prompt;' or 'prompt%',
and gets confused when proof emits 'illegal;'. This change
replaces the ';' with a ':', which both matches other
conventional error outputs and prevents "" from getting
confused.
2020-11-30 13:13:49 -08:00
Ori Bernstein 07e8c324a8 tmdate(2): remove lies
Initially the code tried to guess the date format. This
turned out to be a bit too magical, so the feature was
removed, but the manpage still documented the nonfeature.
2020-11-30 07:41:49 -08:00
cinap_lenrek c931e96364 rio: avoid redrawing window text on resize for programs using libdraw
As long as the client as the mouse file open
and maintains reading the winname file of the window
after a resize we will avoid drawing the text frame
on a resize as it will be overdrawn by the client.

This reduces flicker on resize somewhat for slow systems.
2020-11-29 17:51:57 +01:00
cinap_lenrek 1d93a5628a pc, pc64, xen: rewrite interrupt handling code
This implements proper intrdisable() support for all
interrupt controllers.

For enable, (*arch->intrassign)(Vctl*) fills in the
Vctl.enable and Vctl.disable pointers with the
appropriate routines and returns the assigned
vector number.

Once the Vctl struct has been linked to its vector
chain, Vctl.enable(Vctl*, shared) gets called with a
flag if the vector has been already enabled (shared).

This order is important here as enabling the interrupt
on the controller before we have linked the chain can
cause spurious interrupts, expecially on mp system
where the interrupt can target a different cpu than
the caller of intrenable().

The intrdisable() case is the other way around.
We first disable the interrupt on the controller
and after that unlink the Vctl from the chain.
On a multiprocessor, the xfree() of the Vctl struct
is delayed to avoid freeing it while it is still
in use by another cpu.

The xen port now also uses pc/irq.c which has been
made generic enougth to handle xen's irq scheme.
Also, archgeneric is now a separate file to avoid
pulling in dependencies from the 8259 interrupt
controller code.
2020-11-29 17:43:22 +01:00
Alex Musolino 32a5ff9658 games/mix: fix decoding of shift instructions 2020-11-28 23:03:44 +10:30
Alex Musolino 2619be4d4d games/mix: fix SLAX and SRAX instructions (thanks nicolagi)
MIX shift instructions shift by bytes not bits.
2020-11-28 23:02:28 +10:30
Sigrid 0b9c6fa117 fplot: add hyperbolic functions 2020-11-27 10:51:16 +01:00
Sigrid c696998ec3 fplot(1): use abs() 2020-11-27 10:35:57 +01:00
Sigrid df18213ce3 fplot: add abs 2020-11-27 10:34:16 +01:00
Alex Musolino 68c4119ae7 merge 2020-11-27 11:28:25 +10:30
Alex Musolino 2a907fd459 games/mix: fix implementation of MOVE instruction (thanks nicolagi)
Plan 9 memcpy(2) uses the same implementation as memmove(2) to handle
overlapping ranges.  Hovewer, the MIX MOVE instruction, as described
in TAOCP, specifically does not do this.  It copies words one at a
time starting from the lowest address.

This change also expands the address validation to check that all
addresses within the source and destination ranges are valid before
proceeding.
2020-11-27 11:19:49 +10:30
Ori Bernstein 7dcc3eb27a kbmap/neo2: add support for neo2 kbmak (thanks jstsmthrgk) 2020-11-26 11:18:41 -08:00
Alex Musolino 781a8f8d9f upas: fix mk nuke 2020-11-25 19:54:52 +10:30
Ori Bernstein bd6747ccd0 upas/*: fix mkfile issues (thanks amavect)
Fixes 3 issues in our upas mkfiles:
- mk/mkfile and send/mkfile were rebuilding
  only the rfc822.tab.$O, even though the
  header also needed to be rebuilt.
- CLEANFILES had a pattern that  would not
  get expanded.
- Third, ../upas/mkfile was being included
  in the wrong place and making the wrong
  rule default.
2020-11-22 11:36:23 -08:00
cinap_lenrek a041c90431 pc, pc64: move common irq handling code out of trap.c
Move the common irq handling code out of trap.c
into pc/irq.c so that it can be shared between 386
and amd64 ports.
2020-11-22 17:44:21 +01:00
mischief d1dc287210 9boot(8): update manual to reflect efi loader search order changes
the efi loader now looks for plan9.ini and the kernel in the ESP
first, before looking elsewhere.
2020-11-21 14:55:33 -08:00
mischief 486ce60546 efi: prefer plan9.ini from ESP we loaded from
currently the EFI loader's behavior is to search all disks in a
firmware-defined order.  we search the list returned by the firmware
in reverse order in the hopes of searching the first 9FAT instead of
the ESP, but this results in unintuitive behavior when there are
multiple FAT partitions (possibly in multiple disks), such as loading
a plan9.ini and kernel from a different disk than the one you executed
the EFI loader from.

to resolve this, we change the EFI loader to instead prefer read
plan9.ini and the kernel from the same disk as the EFI loader was read
from, and then fall back to the old behavior, since the old behavior
is relied on by current installations.
2020-11-21 14:18:52 -08:00
Ori Bernstein ad9b1234c3 dc: fix crashes with : operator (thanks istvan bak)
dc crashes because a Blk* sometimes ends getting double freed.
To make it crash, any of these lines will do:
(each line is a separate input to dc):

1 sa 2 :a le d sa v :a
1 sa 2 :a le d sa :a
1 sa 2 :a le d sa c

Fix by assigning p to sptr->val before EMTPY causes a jump.

Additionally, dcgetwd() can return 0. all other uses check for
0 ptr; Also fix a buffer overflow.
2020-11-21 17:56:34 -08:00
Ori Bernstein 03f209427b upas: make 'all' the default target
When consolidating the duplicated targets, the
one that actually got built ended up arbitrary.
Put in a 'default' target that runs 'mk all'.
2020-11-21 16:13:20 -08:00
cinap_lenrek 6dd605dbe2 pc, pc64: fix grub multiboot
It appears that our IDT overlaps with the data structures
passed from grub in multiboot load.

So defer setup of the interrupt table after the multiboot
parameters have been processed.
2020-11-21 23:15:19 +01:00
cinap_lenrek 59308f15dd merge 2020-11-21 22:04:15 +01:00
cinap_lenrek b438fd9d09 ether8169: fix interrupt panic before init, defer initialization until attach
The driver used to register the interrupt handler just
after reset, tho the Ctlr struct, including the buffer
descriptor arrays where only allocated on attach.

This moves most of the reset/init out of pnp
function and into attach. This also means we can
error out and even retry on the next attach.

The logic of the reseter kproc has been changed:
now it is only started once the first initialization
completely succeeded. This avoids the strange qlock
passing.

Implement a shutdown function so the device gets
halted for /dev/reboot.

Assume 64 bit physical addresses for dma.

Check that pci bar0 is actually I/O.
2020-11-21 22:03:13 +01:00
cinap_lenrek 0f56fefd45 pc, pc64: implement disabling of msi interrupts 2020-11-21 21:48:25 +01:00
mischief f8738fd757 nusb/kb, nusb/joy: dont try to set protocol on nonboot devices
the hid 1.11 specification says that for hid devices which arent in
the boot subclass (subclass 1), it is only optional to support the set
protocol command.  for my devices, trying to set protocol results in a
stall error and unusable devices.

fixes my Tex Shinobi keyboard and Playstation 4 controller.
2020-11-21 12:31:54 -08:00
cinap_lenrek 2594b99629 pc, pc64: new MTRR code supporting AMD TOM2 MSR and fixed mtrr ranges
The new MTRR code handles overlapping ranges
and supports AMD specific TOM2 MSR.

The format in /dev/archctl now only shows
the effective cache ranges only, without
exposing the low level registers.
2020-11-21 16:26:46 +01:00
cinap_lenrek e6684dbfda pc, pc64: disable all pci devices for /dev/reboot
Make sure all pci busmaster activity is disabled,
including MSI/MSI-X interrupts, before switching
control to the new kernel.
2020-11-21 16:17:20 +01:00
cinap_lenrek c5d08a602c pc, pc64: disable all pci devices in pcicfginit()
Make sure all pci busmaster activity is disabled,
including MSI/MSI-X interrupts. Drivers will later
reenable once taking control of a device.
2020-11-21 16:10:56 +01:00
cinap_lenrek 1376d39ef1 kernel: add portable pcimsienable()/pcimsidisable(), disable MSI/MSI-X on pcidisable()/pcireset()
This avoids some duplication in the pci support code and
allows pcireset() to diable MSI and MSI-X interrupts
when disabling or reseting a device.
2020-11-21 16:02:21 +01:00
cinap_lenrek cedded7b50 etherm10g: remove duplicated pci capability enum 2020-11-21 00:45:44 +01:00
cinap_lenrek da54e4bfc2 kernel: remove unused pcinextcap() function 2020-11-21 00:41:57 +01:00
cinap_lenrek 9f054063ec pc/l.s: remove unsued m0gdtptr/m0idtptr structs 2020-11-21 00:06:55 +01:00