Commit graph

2178 commits

Author SHA1 Message Date
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 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
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
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
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 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
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
cinap_lenrek 972f95aa63 pc, pc64: load idt early in trapinit0()
loading the interrupt vector table early allows
us to handle traps during bootup before mmuinit()
which gives better diagnostics for debugging.

we also can handle general protection fault on
rdmsr() and wrmsr() which helps during
cpuidentify() and archinit() when probing for
cpu features.
2020-11-17 23:30:09 +01:00
cinap_lenrek 8cb33f2f18 pc/l.s: load virtual gdt pointer after mmu switch
before removing the double map at 0, load our
initial gdt pointer with its new KZERO based
virtual address.

this is prerequisite for handling traps early during
bootup before mmuinit() loads the final gdt.
2020-11-17 23:18:08 +01:00
cinap_lenrek 3f835565d5 etheriwl: bring back recovery on flushq timeout 2020-11-15 14:54:09 +01:00
cinap_lenrek 2a946b24a6 audiohda: do not enable interrupts before intrenable()
When using /dev/reboot, the MSI vecor might have already
been setup causing interrupts to fire on the designated
cpu while we send the commands to the card.
2020-11-15 14:34:17 +01:00
cinap_lenrek 0c846e605b audiohda: reset irbsts bits in hdainterrupt() (thanks LordCreepity)
reseting irbsts bits in hdacmd() only works
while interrupts are disabled during hdareset().
once interrupts are enabled we need to reset the
irbsts bits in the interrupt handler or else the
interrupt never clears and locks up the system.
2020-11-11 00:55:53 +01:00
cinap_lenrek 6cc223ee56 pc/pc64: fix faulty mtrr slot reuse (thanks Fulton)
The change 3306:c5cf77167bfe made the code reuse MTRR slots
of the default memory type.

But this did not take overlapping ranges into account!

If two or more variable-range MTRRs overlap, the following rules apply:

a.	If the memory types are identical, then that memory type is used.
b.	If at least one of the memory types is UC, then UC memory type is used.
c.	If at least of of the memory types is WT. and the only other memory type
	is WB, then th WT memory type is used.
d.	If the combination of memory types is not listed above,
	then the memory type used in undefined.

It so happend that on a Dell Latitude E7450 that the BIOS defines
the default type as UC. and the first slot defines a 16GB range
of type WB. Then the rest of the ranges mark the PCI space back
as UC, but overlapping the first WB range! This works because
of rule (B) above.

When trying to make the framebuffer write-combining, we would
falsely reuse one of the UC sub-ranges and making the UC memory
into WB as a side effect.

Thanks to Fulton for his patience and providing debug logs and
doing experiments for us to narrow the problem down.
2020-11-04 23:08:52 +01:00
cinap_lenrek 0ba91ae22a pc, pc64: allocate i/o port space for unassigned pci bars, move ioalloc() to port/iomap.c
With some newer UEFI firmware, not all pci bars get
programmed and we have to assign them ourselfs.

This was already done for memory bars. This change
adds the same for i/o port space, by providing a
ioreservewin() function which can be used to allocate
port space within the parent pci-pci bridge window.

Also, the pci code now allocates the pci config
space i/o ports 0xCF8/0xCFC so userspace needs to
use devpnp to access pci config space now. (see
latest realemu change).

Also, this moves the ioalloc()/iofree() code out
of devarch into port/iomap.c as it can be shared
with the ppc mtx kernel.
2020-11-03 20:46:09 +01:00
cinap_lenrek aad55ccc2d mtx: fix pci access routines (see changeset 8012:78891f472fbf) 2020-11-02 20:53:20 +01:00
cinap_lenrek 0205392410 audiohda: make it work with qemu (thanks mischief)
the driver was not using irb interrupts
and was just polling the irb write pointer
to wait for command completion.

this is not supported by qemu.

qemu requires the use of irb interrupt handshake
and it refuses to accept the next command until we
acknowledge the irb interrupt.
2020-10-27 15:16:03 +01:00
cinap_lenrek 87385accde sdiahci: accept AHCI controllers from ASMedia vendor id (thanks mischief) 2020-10-19 01:20:29 +02:00
cinap_lenrek a5764f8181 pc, pc64: remove mystery "type" bits in pcicfgrw*raw() (fixes qemu, thanks mischief)
the access functions for pci config space in config mode #1
used to set bit 0 in the register offset if the access was
to a device on any bus different from 0.

it is completely unclear why this was done and i can't find
any documentation on this.

but for sure, this breaks all pci config spacess access to
pci devices behind a bridge on qemu. with -trace pci* it
was discovered that all config space register offsets on
devies behind pci brige where off by one.

on real hardware, setting bit 0 in the offset doesnt appear
to be an issue.

thanks mischief for reporting and providing a qemu demo
configuration to reproduce the problem.
2020-10-18 23:39:07 +02:00
cinap_lenrek d1604b5f9c sdnvme: use PCIWADDR() instead of PADDR() 2020-10-18 17:02:42 +02:00
cinap_lenrek 96e9f3707c etherbcm: handle 64-bit host addresses, use PCIWADDR() instead of PADDR() 2020-10-18 17:01:50 +02:00
cinap_lenrek 30417c12fd audiohda: use PCIWADDR() instead of PADDR(), handle 64-bit dma addresses 2020-10-18 17:00:04 +02:00
Ori Bernstein 83efe2f157 etheriwl: delay before crystal calibration
On my 6235 card, if we calibrate the crystal
immediately after disabling wimax, the the
firmware gets unhappy. A short nap before
sending the command prevents the command from
timing out.
2020-10-18 10:50:07 -04:00
cinap_lenrek 3cfa8326b8 etheriwl: don't break controller on command flush timeout
ori and echoline are reporting regression on some 6000 cards;
which sometimes time out on crystal calibration command;
which is expected by the driver. but the new code used
to force a device reset on any command timeout.

reverting to old behaviour until for now until we have
a chance investigating.
2020-10-18 03:05:35 +02:00
cinap_lenrek cf8ff0e713 sdnvme: handle machines with more cpu's than submit queues (thanks mischief)
We used to assume a 1:1 pairing of processors to submit queues.
With recent machines, we now got more cpu cores than what some
nvme drives support so we need to distribute the queues across
these cpu's which requires locking on command submission.

There is a feature get/set command to probe the number of submit
and completion queues, but we decided to just handling
submission queue create command error gracefully as it is simpler
and has less chance of regression with existing setups.

Thanks to mischief for investigating and writing the code.
2020-10-18 02:51:32 +02:00
cinap_lenrek c7598b18f3 kernel: get rid of unused ucallocb
the whole idea of a ucallocb() is bad, as even access to the
metadata header would be in uncached memory. also, it tuns out
that it was never used by anyone.
2020-10-09 22:05:32 +02:00
Ori Bernstein 53234798c0 etheriwl: add Wireless 8260 card
After the latest tweaks to the order of operations,
the card works.
2020-10-05 14:10:12 -07:00
cinap_lenrek d49b9e1b84 etheriwl: remove stations *after* disabling binding quotas, drain all queues in rxoff7000() 2020-10-05 22:42:13 +02:00
cinap_lenrek 2aff96f17c etheriwl: add for Intel Wireless-AC 9260
the 9000 series uses a new receive descriptor format
wich appears to reqire 4k aligned buffers. the old
format "halfworks" and just makes the firmware not
respond to any commands after the enable paging command.

the smartfifo command appears to causes problems.
but apparently not issuing it at all seems to work
fine on both the 8265 and 9260. so removing the code
for now.

issuing the bindingquota command before associated
makes association impossible. but enabling afterwards
works fine. (tested in 8265 and 9260).

the prph access functions now mask the address with
0xfffff. it is unclear why linux and openbsd drivers
specify addresses beyond that in ther register constants.

the timeevent change is interesting. the timeevent
needs to be restarted when it has stoped to make sure
probing/association packets are sent during the evnet.
2020-10-04 21:10:53 +02:00
kvik fa1d6ffd83 bootrc: allow kbmap to be set via plan9.ini (thanks Aaron Bieber) 2020-10-01 17:47:52 +02:00
cinap_lenrek 4f85115526 kernel: massive pci code rewrite
The new pci code is moved to port/pci.[hc] and shared by
all ports.

Each port has its own PCI controller implementation,
providing the pcicfgrw*() functions for low level pci
config space access. The locking for pcicfgrw*() is now
done by the caller (only port/pci.c).

Device drivers now need to include "../port/pci.h" in
addition to "io.h".

The new code now checks bridge windows and membars,
while enumerating the bus, giving the pc driver a chance
to re-assign them. This is needed because some UEFI
implementations fail to assign the bars for some devices,
so we need to do it outselfs. (See pcireservemem()).

While working on this, it was discovered that the pci
code assimed the smallest I/O bar size is 16 (pcibarsize()),
which is wrong. I/O bars can be as small as 4 bytes.
Bit 1 in an I/O bar is also reserved and should be masked off,
making the port mask: port = bar & ~3;
2020-09-13 20:33:17 +02:00
cinap_lenrek 693485e9c4 etheriwl: add support for Intel Wireless AC 8265 2020-09-06 16:53:39 +02:00
cinap_lenrek a87b6909bc wifi: add packet timestamping support 2020-09-06 16:51:02 +02:00
cinap_lenrek 603d9812a7 kernel: fix Abind cyclic reference and mounthead leaks (thanks Alex Musolino)
The Abind case in namec() needs to cunique() the chan
before attaching the umh mount head pointer onto it.

This is because we cannot give a reference to the mount
head to any of the mh->mount...->to channels, as they
will never go away until the mount head goes away.
This is a cyclic reference.

This could be reproduced with:

	@{rfork n; mount -a '#s/boot' /mnt/root; bind /mnt/root /}

Also, fix memory leaks around cunique(), which can
error, leaking the mount head we got from domount().

Move the umh != nil check inside cunique().
2020-08-23 05:07:30 +02:00
cinap_lenrek e1da4f1750 kernel: don't strip binaries in bootfs.paq 2020-08-04 16:31:24 +02:00
cinap_lenrek d913f652f5 devmnt: print chanpath for unexpected reply tag 2020-08-04 16:23:22 +02:00
cinap_lenrek e7e6f4fc90 pc64: disable interrupts in mmuwalk() for checkmmu()
we have to disable interrupts during mmuwalk() of user pages
as we can get preempted during mmu walk and the original
m->pml4 might become one of a different process.
2020-07-16 03:11:27 +02:00
cinap_lenrek 77ddc8c654 kernel: make segments non-executable when icache is not maintained
This change makes it mandatory for programs to call segflush() on
code that is not in the text segment if they want to execute it.

As a side effect, this means that everything but the text segment
will be non-executable by default, even without the SG_NOEXEC
attribute. Segments with the SG_NOEXEC attribute never become
executable, even when segflush() is called on them.
2020-07-12 21:42:26 +02:00
cinap_lenrek 03852d9408 bcm64: increase maximum segment size to 8GB
make it possible for one process to use all
of physical memory.
2020-07-03 01:17:38 +02:00
cinap_lenrek 91994dc5d8 bcm64: handle 8GB of physical memory for raspberry pi4
widen and move the KMAP window to a new address so we can
handle the 8GB of physical memory of the new raspberry pi4.

the new memory map on pi4 uses the following 4 banks:

0x000000000	0x03e600000
0x040000000	0x0fc000000 <- soc.dramsize (only < 4GB)
0x100000000	0x180000000
0x180000000 0x200000000
2020-07-02 21:12:40 +02:00
cinap_lenrek bd23963c8f bcm64: fix usb xhci controller on pi4 8GB variant (thanks richard miller)
On the 8GB variant of the raspberry pi 4,
the eeprom chip for the xhci controller is missing and
instead loaded from sdram (by the gpu firmware).

for this, the gpu firmware needs to be notified of
the xhci controllers pci bus address (after reset)
that was assigned by our pci enumeration code.
2020-07-02 21:04:01 +02:00
cinap_lenrek 30ab804b58 kernel: segflush() needs to flush tlb of other processes
instruction cache maintenance is done on tlb miss;
when a page gets fauled in; with putmmu() checking
the page->txtflush cpu bitmap.

syssegflush() used to only call flushmmu() after
segflush() for the calling process, but when a segment
is shared with other processes, we have to flush the
other processes tlb as well.

this adds the missing procflushseg() call into segflush().

note that procflushseg() leaves the calling process alone,
so the flushmmu() call in syssegflush() is still required.

segmentioproc() does not need to call flushmmu() after
segflush() as it is never going to jump to the modified
page, hence the stale icache does not matter.
2020-06-28 16:26:59 +02:00
cinap_lenrek 55d8082842 usbxhci: implement isochronous in transfers (for webcam, audio recording) 2020-06-21 21:42:13 +02:00
cinap_lenrek 4fb65ae3e8 devusb: keep isochronous ep->hz consistent with maxpkt, ntds and pollival
The sample frequency is an artificial parameter used for
isochronous out transfers to better match the target
frequency (usually, a sound card).

when hz is set, devusb adjusts the endpoint's maxpkt to get
the requested frequency and a multiple of the samplesize per
packet.

however, when hz is not set, then we should calculate the
frequency from maxpkt, ntds and pollival, so all parameters
will be consistent with each other.
2020-06-21 21:36:50 +02:00
cinap_lenrek 5474646164 devip: implement ipv6 support in ipmux packet filter
Added a ver= field to the filter to distinguish the ip version.
By default, a filter is parsed as ipv6, and after parsing
proto, src and dst fields are converted to ipv4. When no
ver= field is specified, a ip version filter is implicitely
added and both protocols are parsed.

This change also gets rid of the fast compare types as the
filed might not be aligned correctly in the packet.

This also fixes the ifc= filter, as we have to check any
local address.
2020-06-07 16:56:01 +02:00
cinap_lenrek 85ffa283f6 devip: fix parseipmask() prototype in ip.h 2020-06-07 16:45:55 +02:00
cinap_lenrek e46000f076 devip: pick less surprising interface address in header for incoming UDP packets
We used to just return the first address of the incoming
interface regardless of if the address matches the source
ip type and scope.

This change tries to find the best interface address that
will match the source ip so it can be used as a source
address when replying to the packet.
2020-06-06 23:46:01 +02:00
cinap_lenrek 4c8d2b0ebf devlml: use 64-bit physical addresses 2020-06-06 16:31:39 +02:00
cinap_lenrek 7db23bb2f0 audiosb16: cleanup audioprobe(), cast ISAConf.port to ulong 2020-06-06 16:31:07 +02:00
cinap_lenrek 652508728d audioac97: use 64-bit physical addresses 2020-06-06 16:25:00 +02:00
cinap_lenrek 966cf77439 audiohda: use 64-bit physical addresses, check pci membar types 2020-06-06 16:23:58 +02:00
cinap_lenrek aff63ef284 pc/pcmciamodem: cast i/o port to ulong 2020-06-06 16:21:42 +02:00
cinap_lenrek 7347012d42 pc/pmmc: check pci membar type 2020-06-06 16:19:25 +02:00
cinap_lenrek e49d187dff uartaxp: use 64-bit physical addresses and check pci membar types 2020-06-06 16:18:52 +02:00
cinap_lenrek 403fef45c1 pc/wavelan: print Ether.port as 64-bit value 2020-06-06 16:18:06 +02:00
cinap_lenrek 13963cd5e0 sd53c8xx: use 64-bit physical addresses 2020-06-06 16:16:48 +02:00
cinap_lenrek 8003f4f00f sdmv50xx: use 64-bit physical addresses and check pci membar type 2020-06-06 16:16:03 +02:00
cinap_lenrek 15e90cedc1 sdiahci: use 64-bit physical addresses 2020-06-06 16:14:58 +02:00
cinap_lenrek caf8df6478 sdodin: use 64-bit physical addresses and check pci membar type 2020-06-06 16:14:02 +02:00
cinap_lenrek 2907f7ffc4 sdnvme: make sure pci membar type is memory 2020-06-06 16:10:58 +02:00
cinap_lenrek dd2d6c9430 usbuhci: make sure pci membar type is i/o 2020-06-06 16:10:04 +02:00
cinap_lenrek a3626a6efa usbehcipc: use 64-bit physical addresses and check pci membar type 2020-06-06 16:05:40 +02:00
cinap_lenrek 8243b6600f pc/ether*: use 64-bit physical addresses and check pci membar types and sizes 2020-06-06 16:04:24 +02:00
cinap_lenrek 3bebd3f5e2 pc/vga*: use 64-bit physical addresses and check pci membar types and sizes 2020-06-06 15:58:18 +02:00
cinap_lenrek a8f64e53fe archacpi: use 64-bit uvlong for physical addresses 2020-06-06 15:44:17 +02:00
cinap_lenrek 6184a4ef2e devvga: use 64-bit physical addresses for framebuffer 2020-06-06 15:23:50 +02:00
cinap_lenrek 182e18ecff devpccard: use 64-bit physical addresses 2020-06-06 15:21:27 +02:00
cinap_lenrek 4eeaedbcaf usbxhci: use 64-bit physical addresses 2020-06-06 15:18:18 +02:00
cinap_lenrek b6becc7a64 devpnp, devether, devusb: cast ISAConf.port to uvlong (for 32-bit implementations)
The ISAConf.port might still be 32-bit on some archs.
2020-06-06 15:17:08 +02:00
cinap_lenrek 6ae50ce330 devusb: print Hci.port as 64-bit uvlong 2020-06-06 15:12:50 +02:00
cinap_lenrek d4213dbce5 devether: print Ether.port as 64-bit uvlong 2020-06-06 15:11:56 +02:00
cinap_lenrek 0a96d33a1c devpnp: print pci membar as 64-bit uvlong 2020-06-06 15:10:23 +02:00
cinap_lenrek 7bf5c61ea5 bcm64: bring pci code in line with the pc/pc64 2020-06-06 15:06:07 +02:00
cinap_lenrek 142bb6d5cf bcm64: use uvlong for ISAConf.port 2020-06-06 15:01:56 +02:00
cinap_lenrek c7d9da8f5a bcm64: use 64-bit uvlong physical address in vmap() 2020-06-06 15:01:20 +02:00
cinap_lenrek 3bcc34f276 pc, pc64: implement 64-bit pci membar support 2020-06-06 14:58:20 +02:00
cinap_lenrek 93f6ce24f4 pc, pc64: use 64-bit physical addresses for ISAConf.port 2020-06-06 14:52:16 +02:00
cinap_lenrek 21e4d88a51 pc, pc64: use 64-bit physical addresses for vmap() and upaalloc() 2020-06-06 14:43:24 +02:00
cinap_lenrek 94916808dd kernel: remove unused segment argument in freepte() 2020-05-31 17:25:16 +02:00
cinap_lenrek 30bf1c45ca pc, xen: make PAT support optional (for xen) 2020-05-31 14:32:19 +02:00
cinap_lenrek 153fcabb00 pc, pc64: fix wrong mtrr physmask() for machines without extended address size msr 2020-05-24 17:50:37 +02:00
cinap_lenrek f59101231a usbehci: release ctlr ilock before calling pollcheck() 2020-05-24 02:43:21 +02:00
cinap_lenrek 3869d7a843 usbehci: avoid kproc() while holding poll lock 2020-05-24 02:11:37 +02:00
cinap_lenrek b86bb35c7d pc, pc64: do page attribute table (PAT) init early in cpuidentify()
the page attribute table was initialized in mmuinit(), which is
too late for bootscreen(). So now we check for PAT support and
insert the write-combine entry early in cpuidentify().

this might have been the cause of some slow EFI framebuffers on
machines with overlapping or insufficient MTRR entries.
2020-05-22 23:58:24 +02:00
cinap_lenrek 27fc79b04b devip: fix ifc recursive rlock() deadlock
ipiput4() and ipiput6() are called with the incoming interface rlocked
while ipoput4() and ipoput6() also rlock() the outgoing interface once
a route has been found. it is common that the incoming and outgoing
interfaces are the same recusive rlocking().

the deadlock happens when a reader holds the rlock for the incoming interface,
then ip/ipconfig tries to add a new address, trying to wlock the interface.
as there are still active readers on the ifc, ip/ipconfig process gets queued
on the inteface RWlock.

now the reader finds the outgoing route which has the same interface as the
incoming packet and tries to rlock the ifc again. but now theres a writer
queued, so we also go to sleep waiting four outselfs to release the lock.

the solution is to never wait for the outgoing interface rlock, but instead
use non-queueing canrlock() and if it cannot be acquired, discard the packet.
2020-05-10 22:51:40 +02:00
cinap_lenrek dbfec06bf1 kernel: fix checkpages() and segflush() on SG_PHYSICAL type segments
do not touch s->map on SG_PHYSICAL type segments as they do
not have a pte map (s->mapsize == 0 && s->map == nil).

also remove the SG_PHYSICAL switch in freepte(), this is never
reached.
2020-05-10 16:54:42 +02:00
cinap_lenrek c474179f9a usbxhci: fix wrong control endpoint 0 output device context address
the calculation for the control endpoint0 output device context
missed the context size scaling shift, resulting in botched
stall handling as we would not read the correct endpoint status
value.

note, this calculation only affected control endpoint 0, which
was handled separately from all other endpoints.
2020-05-10 02:43:39 +02:00
cinap_lenrek 04066fe973 bcm64: fix kernels cmpswap() function
spectacular bug. cmpswap() had a sign extension bug
using sign extending MOV to load the old compare
value and LDXRW using zero extension while the CMP
instruction compared 64 bit registers.

this caused cmpswap with negative old value always
to fail.

interestingly, libc's version of this function was
fine.
2020-05-07 23:27:27 +02:00
cinap_lenrek 8e2cfc0464 ether82543gc, ether82557, ethervirtio: do kproc() call ouside of spinlock 2020-05-02 15:32:19 +02:00
cinap_lenrek 61a062ee9f kernel: improve page reclaimation strategy and locking
when reclaiming pages from an image, always reclaim all
the hash chains equally. that way, we avoid being biased
towards the chains at the start of the Image.pghash[] array.

images can be in two states: active or inactive. inactive
images are the ones which are not used by program while
active ones aare.

when reclaiming pages, we should try to reclaim pages
from inactive images first and only if that set becomes
exhausted attempt to release text pages and attempt to
reclaim pages from active images.

when we run out of Image structures, it makes only sense
to reclaim pages from inactive images, as reclaiming pages
from active ones will never free any Image structures.

change putimage() to require a image already locked and
make it unlock the image. this avoids many pointless
unlock()/lock() sequences as all callers of putimage()
already had the image locked.
2020-04-26 19:54:46 +02:00
cinap_lenrek 4fb7462bd5 pc, pc64: use softscreen double buffering for *bootscreen= framebuffer
it is probably almost always a good idea to use
double buffering with a unaccelerated framebuffer.
2020-04-24 20:26:38 +02:00
cinap_lenrek 759656ad4c bcm, bcm64: dancing to the drum of the linux clowns for device tree memory size detection (thanks kenji)
looks like linux changed the device tree names for
the memory node:

4b17654f51 (diff-ac03c9402b807c11d42edc9e8d03dfc7)

this fixes the memory size detection with latest firmware
on raspberry pi4-b (4GB) for kenji.
2020-04-22 19:57:25 +02:00
Ori Bernstein eb266ded8d remove unused macro from chan.c 2020-04-21 17:32:02 -07:00
cinap_lenrek 1aa80c1d10 kernel: remove unused mem2bl() prototype 2020-04-12 16:11:41 +02:00
cinap_lenrek 1fe3143e4c kernel: cleanup the software mouse cursor mess
The swcursor used a 32x32 image for saving/restoring
screen contents for no reason.

Add a doflush argument to swcursorhide(), so that
disabling software cursor with a double buffered
softscreen is properly hidden. The doflush parameter
should be set to 0 in all other cases as swcursordraw()
will flushes both (current and previours) locations.

Make sure swcursorinit() and swcursorhide() clear the
visibility flag, even when gscreen is nil.

Remove the cursor locking and just do everything within
the drawlock. All cursor functions such as curson(),
cursoff() and setcursor() will be called drawlock
locked. This also means &cursor can be read.

Fix devmouse cursor reads and writes. We now have the
global cursor variable that is only modified under
the drawlock. So copy under drawlock.

Move the pc software cursor implementation into vgasoft
driver, so screen.c does not need to handle it as
a special case.

Remove unused functions such as drawhasclients().
2020-04-10 17:12:51 +02:00
cinap_lenrek 7b309d2e28 pc, pc64: remove "got unassigned irq" prints
most pc's are multiprocessors these days, that use apic or
msi interrupts, then the irq does not matter anymore. and
uefi does not even assign irq to pci devices anymore. if
we have a problem enabling an interrupt, we will print.
2020-04-09 13:05:10 +02:00
cinap_lenrek 9e2344a5be pc64: remove rampage() nil check
rampage() never returns nil
2020-04-06 01:29:12 +02:00
cinap_lenrek a35cd0f861 pc: zero rampage() memory (thanks LordCreepity)
memory returned by rampage() is not zeroed, so we have to
zero it ourselfs. apparently, this bug didnt show up as we
where zeroing conventional low memory before the new memory
map code. also rampage() never returns nil.
2020-04-06 01:28:34 +02:00
cinap_lenrek f5352eb501 merge 2020-04-04 17:17:15 +02:00
cinap_lenrek 339112abc3 mtx, ppc: use proctab() to index into process table 2020-04-04 16:52:08 +02:00
cinap_lenrek 30cbaa5c48 kernel: remove scheddump() comment for delay() in */fns.h 2020-04-04 16:50:37 +02:00
cinap_lenrek 5f1b70f437 pc, pc64: new memory map code
This replaces the memory map code for both pc and pc64
kernels with a unified implementation using the new
portable memory map code.

The main motivation is to be robust against broken
e820 memory maps by the bios and delay the Conf.mem[]
allocation after archinit(), so mp and acpi tables
can be reserved and excluded from user memory.

There are a few changes:

new memreserve() function has been added for archinit()
to reserve bios and acpi tables.

upareserve() has been replaced by upaalloc(), which now
has an address argument.

umbrwmalloc() and umbmalloc() have been replaced by
umballoc().

both upaalloc() and umballoc() return physical addresses
or -1 on error. the physical address -1 is now used as
a sentinel value instead of 0 when dealing with physical
addresses.

archmp and archacpi now always use vmap() to access
the bios tables and reserve the ranges. more overflow
checks have been added.

ramscan() has been rewritten using vmap().

to handle the population of kernel memory, pc and pc64
now have pmap() and punmap() functions to do permanent
mappings.
2020-04-04 16:48:37 +02:00
cinap_lenrek 8debb0736e kernel: add portable memory map code (port/memmap.c)
This is a generic memory map for physical addresses. Entries
can be added with memmapadd() giving a range and a type.
Ranges can be allocated and freed from the map. The code
automatically resolves overlapping ranges by type priority.
2020-04-04 16:04:27 +02:00
cinap_lenrek 7451bb405d ether8390: remove unused variables 2020-04-04 15:55:48 +02:00
cinap_lenrek 6498ce3bf2 ether8003: use physical addresses for ISAConfig ether->mem
Fix the inconsistent use of ether->mem. Always use physical
addresses. Let ether8390 convert to virtual addresses using
KADDR() when we have to copy data in/out.
2020-04-04 15:47:50 +02:00
Sigrid 4756cf549a devkbd: bits bad! revert repeat/delay, better patches welcome 2020-04-01 11:31:19 +02:00
cinap_lenrek 480ce0314e audiohda: add pci vid/did for AMD Raven HD Audio Controller (T495) 2020-03-31 19:00:32 +02:00
cinap_lenrek 4dcb3ce2ab xen: fix rebootcode linkage
need to strip the a.out header, just like with the pc
kernel.
2020-03-29 22:47:42 +02:00
Sigrid f5f37ba5eb pc64: enable uartpci (thanks taw9 for testing) 2020-03-29 19:28:39 +02:00
cinap_lenrek 1b8d87555a pc, pc64: ignore the 64-bit bar flag when reserving membar
a bar with bit 3 set means the bar is the low half of
a 64-bit wide bar.
2020-03-29 00:49:07 +01:00
cinap_lenrek 3c36cadefd pc: fix mp boot regression due mistake in mkfile
the previous mkfile had a sneaky hack that would use
sed to delete the first 2 lines of hex output to strip
the 32 byte long a.out header for apbootstrap and rebootcode.

use 8l -H3 flag to strip the header from the output file.
2020-03-29 00:44:09 +01:00
Sigrid 9014360921 kbd: add "repeat" file to set typematic repeat rate/delay on PS/2 keyboards 2020-03-28 15:37:48 +01:00
cinap_lenrek 28f3a3aad8 boorc, nusbrc: fix wrong redirections after &
the rc & operator changes stdin to /dev/null, so we
have to do the <[0=1] inside the {}

this never showed up as an issue because many
fileservers just read 9p messages from standard
output.
2020-03-08 20:53:30 +01:00
cinap_lenrek f99b9cae6a devshr: unmount service on #σc/share/mount removal
when the control mountpoint side gets removed, close
mount channel immediately. this is usefull for implementing
automatic cleanup with ORCLOSE create mode.
2020-03-08 18:23:07 +01:00
cinap_lenrek a609c1a2f8 devproc: return process id when reading /proc/n/ctl file
allow reading the control file of a process and return
its pid number. if the process has exited, return an error.

this can be usefull as a way to test if a process is
still alive. and also makes it behave similar to
network protocol directories.

another side effect is that processes who erroneously
open the ctl file ORDWR would be allowed todo so as
along as they have write permission and the process is
not a kernel process.
2020-03-08 14:11:23 +01:00
cinap_lenrek a0879abae4 devproc: don't allow /proc/$pid/ctl to be opens for reading 2020-03-07 23:58:47 +01:00
cinap_lenrek a87c9cfc6c devproc: fix syscalltrace read for ratrace 2020-03-05 20:46:01 +01:00
cinap_lenrek 69e28c6513 kernel: simplify exec()
progarg[0] can be assigned to elem directly as it is a
copy in kernel memory, so the char proelem[64] buffer
is not neccesary.

do the close-on-exit outside of the segment lock. there
is no reason to keep the segment table locked.
2020-02-29 21:06:45 +01:00
cinap_lenrek 17a92f3995 devproc: make sure writewatchpt() doesnt overflow the watchpoint array
the user buffer could be changed while we parse it resulting
in a different number of watchpoints than initially calculated.
so add a check to the parse loop so we wont overflow the
watchpoint array.
2020-02-28 16:48:42 +01:00
cinap_lenrek adb36de077 kernel: make sure we wont run into the tos when copying exec() arguments
in case the calling process changes its arguments under us, it could
happen that the final argument string lengths become bigger than
initially calculated. this is fine as we still make sure we wont
overflow the stack segment, but we could overrun into the tos
structure at the end of the stack. so change the limit to the
base of the tos, not the end of the stack segment.
2020-02-28 16:45:20 +01:00
cinap_lenrek ff3e0eeb22 devproc: cleanup procwrite size checks
writes to /proc/n/notepg and /proc/n/note should be able to write
at ERRMAX-1 bytes, not ERRMAX-2.

simplify write to /proc/n/args by just copying to local buf first
and then doing a kstrdup(). the value of Proc.nargs does not matter
when Proc.setargs is 1.
2020-02-28 16:41:09 +01:00
cinap_lenrek ab5c4799d9 devcons: fix permissions for reboot and sysstat
#c/reboot is a write only file
#c/sysstat should not be writable by everyone (write resets counters)
2020-02-23 20:42:00 +01:00
cinap_lenrek 9fcce48b38 kernel: avoid selecting the boot process in killbig() 2020-02-23 18:58:06 +01:00
cinap_lenrek 4a80d9d029 kernel: fix multiple devproc bugs and pid reuse issues
devproc assumes that when we hold the Proc.debug qlock,
the process will be prevented from exiting. but there is
another race where the process has already exited and
the Proc* slot gets reused. to solve this, on process
creation we also have to acquire the debug qlock while
initializing the fields of the process. this also means
newproc() should only initialize fields *not* protected
by the debug qlock.

always acquire the Proc.debug qlock when changing strings
in the proc structure to avoid doublefree on concurrent
update. for changing the user string, we add a procsetuser()
function that does this for auth.c and devcap.

remove pgrpnote() from pgrp.c and replace by static
postnotepg() in devproc.

avoid the assumption that the Proc* entries returned by
proctab() are continuous.

fixed devproc permission issues:
	- make sure only eve can access /proc/trace
	- none should only be allowed to read its own /proc/n/text
	- move Proc.kp checks into procopen()

pid reuse was not handled correctly, as we where only
checking if a pid had a living process, but there still
could be processes expecting a particular parentpid or
noteid.

this is now addressed with reference counted Pid
structures which are organized in a hash table.
read access to the hash table does not require locks
which will be usefull for dtracy later.
2020-02-23 18:00:21 +01:00
cinap_lenrek f7c6023066 devswap: dont assume Proc* structures returned from proctab() are continuous 2020-02-23 14:08:33 +01:00
cinap_lenrek b7089d66ad sdiahci, sdodin: avoid calling kproc() while holding ilock() 2020-02-23 14:05:01 +01:00
Roberto E. Vargas Caballero 5f7a6b7ea3 bcm: change ARGB32 to XRGB32 for framebuffer to avoid slow drawing 2020-02-09 21:39:17 +01:00
cinap_lenrek 77a7e3f8fc kernel: cleanup makefile for $CONF.$O target 2020-02-02 20:46:58 +01:00
cinap_lenrek 023d957e6b kernel: restore old behaviour that kprocs have ther noteid == pid 2020-01-27 02:17:14 +01:00
cinap_lenrek 46a733c328 kernel: fix mistake from previous commit (noteid not being inherited by default) 2020-01-27 01:51:35 +01:00
cinap_lenrek 8d51e7fa1a kernel: implement portable userinit() and simplify process creation
replace machine specific userinit() by a portable
implemntation that uses kproc() to create the first
process. the initcode text is mapped using kmap(),
so there is no need for machine specific tmpmap()
functions.

initcode stack preparation should be done in init0()
where the stack is mapped and can be accessed directly.

replacing the machine specific userinit() allows some
big simplifications as sysrfork() and kproc() are now
the only callers of newproc() and we can avoid initializing
fields that we know are being initialized by these
callers.

rename autogenerated init.h and reboot.h headers.
the initcode[] and rebootcode[] blobs are now in *.i
files and hex generation was moved to portmkfile. the
machine specific mkfile only needs to specify how to
build rebootcode.out and initcode.out.
2020-01-26 19:01:36 +01:00
cinap_lenrek 60bb408acc ppc: remove old duplicate of devtls.c 2020-01-25 18:37:28 +01:00
aiju 639500b748 cycv: support for registers 2020-01-13 23:22:35 +00:00
aiju 561346d07f cyclone v kernel: fpga support, fix CONFADDR 2020-01-12 03:40:42 +00:00
cinap_lenrek 16784a2e45 devdraw: fix topnwindows() panic when images are not windows (thanks aiju)
Crashes drawterm and native:

#include <u.h>
#include <libc.h>
#include <draw.h>

void
main(int argc, char **argv)
{
 	initdraw(nil, nil, nil);

 	Image *a[] = {screen, display->black};

 	topnwindows(a, nelem(a));
 	flushimage(display, 1);
}
2020-01-12 00:07:27 +01:00
cinap_lenrek 5254e41f6b pc64: adapt vgaradeon driver to 64-bit (thanks Robert Ransom)
Not yet tested.
2020-01-11 23:31:54 +01:00
cinap_lenrek 361b65e4df kernel: remove relics of CPU 'load balancing' policy in scheduler (thanks Robert Ransom)
This code was deleted from Plan 9 before the 9front repo began.
Proc.movetime was used by it, but has never been referenced in 9front.
2020-01-11 21:26:42 +01:00
cinap_lenrek dfda1cc878 bootrc: fix comment typo (thanks Robert Ransom) 2020-01-11 21:25:05 +01:00
aiju ffd9c39d1c dont spin on MDIO 2020-01-10 20:43:24 +00:00
aiju d64f76c96c add cycv ethernet driver 2020-01-10 18:49:33 +00:00
aiju 17ebe55031 add cycv kernel 2020-01-08 02:35:01 +00:00
cinap_lenrek f12744b5db devip: fix packet loss when interface is wlocked
to prevent deadlock on media unbind (which is called with
the interface wlock()'ed), the medias reader processes
that unbind was waiting for used to discard packets when
the interface could not be rlocked.

this has the unfortunate side effect that when we change
addresses on a interface that packets are getting lost.
this is problematic for the processing of ipv6 router
advertisements when multiple RA's are getting received
in quick succession.

this change removes that packet dropping behaviour and
instead changes the unbind process to avoid the deadlock
by wunlock()ing the interface temporarily while waiting
for the reader processes to finish. the interface media
is also changed to the mullmedium before unlocking (see
the comment).
2020-01-05 18:20:47 +01:00
Alex Musolino 8fa9b7d6ff pc, pc64: fix cputemp decimal handling in amd10temprd (thanks Robert Ransom) 2019-12-19 15:19:02 +10:30
cinap_lenrek 52e4e51b50 devcons: fix write length of writebintime() (thanks BurnZeZ) 2019-12-11 23:52:05 +01:00
cinap_lenrek 13785bbbef pc: replace duplicated and broken mmu flush code in vunmap()
comparing m with MACHP() is wrong as m is a constant on 386.

add procflushothers(), which flushes all processes except up
using common procflushmmu() routine.
2019-12-07 02:19:14 +01:00
cinap_lenrek 28836f3ff5 kernel: avoid useless mmu flushes, implement better wait condition for procflushmmu()
procflushmmu() returns once all *OTHER* processors that had
matching processes running on them flushed ther tlb/mmu state.
the caller of procflush...() takes care of flushing "up" by
calling flushmmu() later.

if the current process matched, then that means m->flushmmu
would be set, and hzclock() would call flushmmu() again.

to avoid this, we now check up->newtlb in addition to m->flushmmu
in hzclock() before calling flushmmu().

we also maintain information on which process on what processor
to wait for locally, which helps making progress when multiple
procflushmmu()'s are running concurrently.

in addition, this makes the wait condition for procflushmmu()
more sophisticated, by validating if the processor still runs
the selected process and only if it matchatches, considers
the MACHP(nm)->flushmmu flag.
2019-12-07 02:13:51 +01:00
cinap_lenrek f48f1a324a bcm: use extended small pages so XN bit can work
the change to support no-execute bits broke the original
raspberry pi1, as it uses backwards compatible page table
format.

to use the XN bit, subpage AP bits have to be disabled
using the XP bit in CP15 Control Register c1 Bit 23.
2019-12-04 22:02:51 +01:00
cinap_lenrek c9570c14af 9/boot/net.rc: suppress error from grep if ethernet ifstats file is not found
this can happen with nusb/ether, which does not implement ifstats file.
2019-12-04 21:56:13 +01:00
cinap_lenrek 5d59a44c21 pc, pc64: clear debug watchpoint registers on exec and exit
when a process does an exec syscall, procsetup() is called and
we have to disable the debug watchpoint registers. just clearing
p->dr is not enougth as we are not going thru a procsave() and
procrestore() cycle which would disable and reload the saved
debug registers.

instead of clearing debug registers in procfork(), we should
clear the saved debug registers before a process goes to die
(pexit() calls sched() with up->state = Moribund) as the Proc
structure can get reused for kernel processes (kproc) which
never call procfork() and would therefore have debug registers
loaded.
2019-12-02 23:32:24 +01:00
cinap_lenrek d80826d6e5 vgai81x: remove unused mach0 variable 2019-12-02 08:26:34 +01:00
cinap_lenrek a9be1374a0 pc: fix ldt memory leak in procsetup() 2019-12-02 07:43:45 +01:00
cinap_lenrek 70498378cf kernel: add missing FPillegal definition for kw and omap kernels 2019-12-02 07:35:25 +01:00
cinap_lenrek 08d6b0f043 kernel: improve diagnostics by reversing the roles of Proc.parentpid and Proc.parent
for better system diagnostics, we *ALWAYS* want to record the parent
pid of a user process, regardless of if the child will post a wait
record on exit or not.

for that, we reverse the roles of Proc.parent and Proc.parentpid so
Proc.parentpid will always be set on rfork() and the Proc.parent
pointer will point to the parent's Proc structure or is set to nil
when no wait record should be posted on exit (RFNOWAIT flag).

this means that we can get the pid of the original parent process
from /proc, regardless of the the child having rforked with the
RFNOWAIT flag. this improves the output of pstree(1) somewhat if
the parent is still alive. note that theres no guarantee that the
parent pid is still valid.

the conditions are unchanged:

a user process that will post wait record has:

up->kp == 0 && up->parent != nil && up->parent->pid == up->parentpid

the boot process is:

up->kp == 0 && up->parent == nil && up->parentpid == 0

and kproc's have:

up->kp != 0 && up->parent == nil && up->parentpid == 0
2019-12-01 17:57:14 +01:00
cinap_lenrek 21a599743e pc, pc64: merge adjacent e820 map entries of same type
some machines give us over 300 e820 ram entries that are
all adjacent to each other causing us to run out of Map
end Emap entries.

this change adds e820clean() function, which sorts the
current e820 map and discards unusable entries and merges
adjacent entries. e820clean() is called after we parsed
the *e820= boot parameter or when we run out of entries.

an example of such a broken e820 map (thanks mischief):

*e820=1 0000000000000000 0000000000008000 1 0000000000008000 000000000000c000 1 000000000000c000 000000000003f000 1 000000000003f000 0000000000040000 1 0000000000040000 00000000000a0000 1 0000000000100000 0000000001000000 1 0000000001000000 0000000001020000 1 0000000001020000 0000000009d82000 2 0000000009d82000 000000000a000000 1 000000000a000000 000000000a200000 4 000000000a200000 000000000a20b000 1 000000000a20b000 000000000b000000 2 000000000b000000 000000000b020000 1 000000000b020000 0000000010000000 1 0000000010000000 000000001000b000 1 000000001000b000 00000000d9634000 1 00000000d9634000 00000000d96be000 1 00000000d96be000 00000000d96cc000 1 00000000d96cc000 00000000d96db000 1 00000000d96db000 00000000d97df000 1 00000000d97df000 00000000d97ed000 1 00000000d97ed000 00000000d9837000 1 00000000d9837000 00000000d9844000 1 00000000d9844000 00000000d985e000 1 00000000d985e000 00000000d9865000 1 00000000d9865000 00000000d9897000 1 00000000d9897000 00000000d98d7000 1 00000000d98d7000 00000000d98db000 1 00000000d98db000 00000000d98dd000 1 00000000d98dd000 00000000d999d000 1 00000000d999d000 00000000d9a8e000 1 00000000d9a8e000 00000000d9add000 1 00000000d9add000 00000000d9ae2000 1 00000000d9ae2000 00000000d9af3000 1 00000000d9af3000 00000000d9af4000 1 00000000d9af4000 00000000d9af6000 1 00000000d9af6000 00000000d9af7000 1 00000000d9af7000 00000000d9af8000 1 00000000d9af8000 00000000d9af9000 1 00000000d9af9000 00000000d9b5e000 1 00000000d9b5e000 00000000d9b60000 1 00000000d9b60000 00000000d9b8c000 1 00000000d9b8c000 00000000d9b8d000 1 00000000d9b8d000 00000000d9c85000 1 00000000d9c85000 00000000d9c8a000 1 00000000d9c8a000 00000000d9caf000 1 00000000d9caf000 00000000d9cb5000 1 00000000d9cb5000 00000000d9cc1000 1 00000000d9cc1000 00000000d9cc2000 1 00000000d9cc2000 00000000da986000 1 00000000da986000 00000000daeb6000 1 00000000daeb6000 00000000daed7000 1 00000000daed7000 00000000daed8000 1 00000000daed8000 00000000daf61000 1 00000000daf61000 00000000daf7c000 1 00000000daf7c000 00000000db3e6000 1 00000000db3e6000 00000000db4ea000 1 00000000db4ea000 00000000db57d000 1 00000000db57d000 00000000db587000 1 00000000db587000 00000000db58a000 1 00000000db58a000 00000000db58b000 1 00000000db58b000 00000000db591000 1 00000000db591000 00000000db5a7000 1 00000000db5a7000 00000000db5b2000 1 00000000db5b2000 00000000db5ba000 1 00000000db5ba000 00000000db5bb000 1 00000000db5bb000 00000000db5c6000 1 00000000db5c6000 00000000db5c7000 1 00000000db5c7000 00000000db5c8000 1 00000000db5c8000 00000000db5c9000 1 00000000db5c9000 00000000db5cb000 1 00000000db5cb000 00000000db5d0000 1 00000000db5d0000 00000000db5e8000 1 00000000db5e8000 00000000db5ea000 1 00000000db5ea000 00000000db5eb000 1 00000000db5eb000 00000000db5ee000 1 00000000db5ee000 00000000db601000 1 00000000db601000 00000000db602000 1 00000000db602000 00000000db60e000 1 00000000db60e000 00000000db610000 1 00000000db610000 00000000db612000 1 00000000db612000 00000000db614000 1 00000000db614000 00000000db61d000 1 00000000db61d000 00000000db645000 1 00000000db645000 00000000db64c000 1 00000000db64c000 00000000db650000 1 00000000db650000 00000000db651000 1 00000000db651000 00000000db653000 1 00000000db653000 00000000db658000 1 00000000db658000 00000000db659000 1 00000000db659000 00000000db661000 1 00000000db661000 00000000db662000 1 00000000db662000 00000000db665000 1 00000000db665000 00000000db677000 1 00000000db677000 00000000db69d000 1 00000000db69d000 00000000db6a0000 1 00000000db6a0000 00000000db6a8000 1 00000000db6a8000 00000000db6ae000 1 00000000db6ae000 00000000db6c2000 1 00000000db6c2000 00000000db6d4000 1 00000000db6d4000 00000000db6de000 1 00000000db6de000 00000000db6e0000 1 00000000db6e0000 00000000db6e2000 1 00000000db6e2000 00000000db6ef000 1 00000000db6ef000 00000000db6f0000 1 00000000db6f0000 00000000db6f2000 1 00000000db6f2000 00000000db6f3000 1 00000000db6f3000 00000000db810000 1 00000000db810000 00000000db815000 1 00000000db815000 00000000db81f000 1 00000000db81f000 00000000db821000 1 00000000db821000 00000000db85d000 1 00000000db85d000 00000000db869000 1 00000000db869000 00000000db881000 1 00000000db881000 00000000db889000 1 00000000db889000 00000000db88e000 1 00000000db88e000 00000000db88f000 1 00000000db88f000 00000000db891000 1 00000000db891000 00000000db899000 1 00000000db899000 00000000db8a9000 1 00000000db8a9000 00000000db8ab000 1 00000000db8ab000 00000000db8af000 1 00000000db8af000 00000000db8b1000 1 00000000db8b1000 00000000db8b5000 1 00000000db8b5000 00000000db8b7000 1 00000000db8b7000 00000000db8be000 1 00000000db8be000 00000000db8c2000 1 00000000db8c2000 00000000db8c7000 1 00000000db8c7000 00000000db8cf000 1 00000000db8cf000 00000000db8e0000 1 00000000db8e0000 00000000db8e1000 1 00000000db8e1000 00000000db8e2000 1 00000000db8e2000 00000000db8e6000 1 00000000db8e6000 00000000db8e8000 1 00000000db8e8000 00000000db8f4000 1 00000000db8f4000 00000000db904000 1 00000000db904000 00000000db90c000 1 00000000db90c000 00000000db91c000 1 00000000db91c000 00000000db91d000 1 00000000db91d000 00000000db922000 1 00000000db922000 00000000db923000 1 00000000db923000 00000000db929000 1 00000000db929000 00000000db92b000 1 00000000db92b000 00000000db92d000 1 00000000db92d000 00000000db92f000 1 00000000db92f000 00000000db933000 1 00000000db933000 00000000db934000 1 00000000db934000 00000000db936000 1 00000000db936000 00000000db937000 1 00000000db937000 00000000db952000 1 00000000db952000 00000000db96b000 1 00000000db96b000 00000000db998000 1 00000000db998000 00000000db9a1000 1 00000000db9a1000 00000000db9a2000 1 00000000db9a2000 00000000db9a3000 1 00000000db9a3000 00000000db9a4000 1 00000000db9a4000 00000000db9a5000 1 00000000db9a5000 00000000db9a7000 1 00000000db9a7000 00000000db9a8000 1 00000000db9a8000 00000000db9aa000 1 00000000db9aa000 00000000db9ba000 1 00000000db9ba000 00000000db9da000 1 00000000db9da000 00000000db9f7000 1 00000000db9f7000 00000000dba00000 1 00000000dba00000 00000000dba0a000 1 00000000dba0a000 00000000dba11000 1 00000000dba11000 00000000dba12000 1 00000000dba12000 00000000dba51000 1 00000000dba51000 00000000dba5d000 1 00000000dba5d000 00000000dba6c000 1 00000000dba6c000 00000000dba88000 1 00000000dba88000 00000000dba92000 1 00000000dba92000 00000000dba94000 1 00000000dba94000 00000000dbac0000 1 00000000dbac0000 00000000dbac6000 1 00000000dbac6000 00000000dbad2000 1 00000000dbad2000 00000000dbad9000 1 00000000dbad9000 00000000dbae0000 1 00000000dbae0000 00000000dbaeb000 1 00000000dbaeb000 00000000dbaf6000 1 00000000dbaf6000 00000000dbb01000 1 00000000dbb01000 00000000dbb17000 1 00000000dbb17000 00000000dbb1f000 1 00000000dbb1f000 00000000dbb20000 1 00000000dbb20000 00000000dbb23000 1 00000000dbb23000 00000000dbb24000 1 00000000dbb24000 00000000dbb25000 1 00000000dbb25000 00000000dbb3a000 1 00000000dbb3a000 00000000dbb3d000 1 00000000dbb3d000 00000000dbb43000 1 00000000dbb43000 00000000dbb45000 1 00000000dbb45000 00000000dbb49000 1 00000000dbb49000 00000000dbb4c000 1 00000000dbb4c000 00000000dbb4e000 1 00000000dbb4e000 00000000dbb51000 1 00000000dbb51000 00000000dbb54000 1 00000000dbb54000 00000000dbb5a000 1 00000000dbb5a000 00000000dbb5e000 1 00000000dbb5e000 00000000dbb62000 1 00000000dbb62000 00000000dbb67000 1 00000000dbb67000 00000000dbb91000 1 00000000dbb91000 00000000dbb93000 1 00000000dbb93000 00000000dbb94000 1 00000000dbb94000 00000000dbb9d000 1 00000000dbb9d000 00000000dbb9f000 1 00000000dbb9f000 00000000dbbcf000 1 00000000dbbcf000 00000000dbbd0000 1 00000000dbbd0000 00000000dbbd1000 1 00000000dbbd1000 00000000dbbd5000 1 00000000dbbd5000 00000000dbbd6000 1 00000000dbbd6000 00000000dbbd7000 1 00000000dbbd7000 00000000dbbd8000 1 00000000dbbd8000 00000000dbbd9000 1 00000000dbbd9000 00000000dbbdd000 1 00000000dbbdd000 00000000dbbdf000 1 00000000dbbdf000 00000000dbbe1000 1 00000000dbbe1000 00000000dbbeb000 1 00000000dbbeb000 00000000dbbec000 1 00000000dbbec000 00000000dbbef000 1 00000000dbbef000 00000000dbbff000 1 00000000dbbff000 00000000dbc01000 1 00000000dbc01000 00000000dbc05000 1 00000000dbc05000 00000000dbc0f000 1 00000000dbc0f000 00000000dbc11000 1 00000000dbc11000 00000000dbc12000 1 00000000dbc12000 00000000dbc14000 1 00000000dbc14000 00000000dbc15000 1 00000000dbc15000 00000000dbc20000 1 00000000dbc20000 00000000dbc21000 1 00000000dbc21000 00000000dbc22000 1 00000000dbc22000 00000000dbc2a000 1 00000000dbc2a000 00000000dbc2c000 1 00000000dbc2c000 00000000dbc2d000 1 00000000dbc2d000 00000000dbc2f000 1 00000000dbc2f000 00000000dbc30000 1 00000000dbc30000 00000000dbc42000 1 00000000dbc42000 00000000dbc44000 1 00000000dbc44000 00000000dbc54000 1 00000000dbc54000 00000000dbc5c000 1 00000000dbc5c000 00000000dbc5e000 1 00000000dbc5e000 00000000dbc60000 1 00000000dbc60000 00000000dbc64000 1 00000000dbc64000 00000000dbc6d000 1 00000000dbc6d000 00000000dbc7f000 1 00000000dbc7f000 00000000dbc85000 1 00000000dbc85000 00000000dbca3000 1 00000000dbca3000 00000000dbca6000 1 00000000dbca6000 00000000dbcb9000 1 00000000dbcb9000 00000000dbcba000 1 00000000dbcba000 00000000dbcbb000 1 00000000dbcbb000 00000000dbcbc000 1 00000000dbcbc000 00000000dbcbd000 1 00000000dbcbd000 00000000dbcd5000 1 00000000dbcd5000 00000000dbcd8000 1 00000000dbcd8000 00000000dbcd9000 1 00000000dbcd9000 00000000dbcda000 1 00000000dbcda000 00000000dbce1000 1 00000000dbce1000 00000000dbce3000 1 00000000dbce3000 00000000dbce4000 1 00000000dbce4000 00000000dbd06000 1 00000000dbd06000 00000000dbd07000 1 00000000dbd07000 00000000dbd0a000 1 00000000dbd0a000 00000000dbd0b000 1 00000000dbd0b000 00000000dbd0c000 1 00000000dbd0c000 00000000dbd0e000 1 00000000dbd0e000 00000000dbd10000 1 00000000dbd10000 00000000dbd12000 1 00000000dbd12000 00000000dbd15000 1 00000000dbd15000 00000000dbd17000 1 00000000dbd17000 00000000dbd19000 1 00000000dbd19000 00000000dbd1b000 1 00000000dbd1b000 00000000dbd44000 1 00000000dbd44000 00000000dbd46000 1 00000000dbd46000 00000000dbd60000 1 00000000dbd60000 00000000dbd70000 1 00000000dbd70000 00000000dbd79000 1 00000000dbd79000 00000000dbd7a000 1 00000000dbd7a000 00000000dbd7c000 1 00000000dbd7c000 00000000dbd7d000 1 00000000dbd7d000 00000000dbd90000 1 00000000dbd90000 00000000dbd93000 1 00000000dbd93000 00000000dbd97000 1 00000000dbd97000 00000000dbd9a000 1 00000000dbd9a000 00000000dbd9b000 1 00000000dbd9b000 00000000dbd9e000 1 00000000dbd9e000 00000000dbda1000 1 00000000dbda1000 00000000dbda5000 1 00000000dbda5000 00000000dbda9000 1 00000000dbda9000 00000000dbdaf000 1 00000000dbdaf000 00000000dbdb3000 1 00000000dbdb3000 00000000dbdb4000 1 00000000dbdb4000 00000000dbdbe000 1 00000000dbdbe000 00000000dbdbf000 1 00000000dbdbf000 00000000dbdc0000 1 00000000dbdc0000 00000000dbdc1000 1 00000000dbdc1000 00000000dbdc2000 1 00000000dbdc2000 00000000dbdc5000 1 00000000dbdc5000 00000000dbdc6000 1 00000000dbdc6000 00000000dbdc7000 1 00000000dbdc7000 00000000dbdcb000 1 00000000dbdcb000 00000000dbdcf000 1 00000000dbdcf000 00000000dbdd5000 1 00000000dbdd5000 00000000dbdd8000 1 00000000dbdd8000 00000000dbddf000 1 00000000dbddf000 00000000dbde1000 1 00000000dbde1000 00000000dbde5000 1 00000000dbde5000 00000000dbde8000 1 00000000dbde8000 00000000dbded000 1 00000000dbded000 00000000dbdf0000 1 00000000dbdf0000 00000000dbdf4000 1 00000000dbdf4000 00000000dbdf7000 1 00000000dbdf7000 00000000dbdfb000 1 00000000dbdfb000 00000000dbe1e000 1 00000000dbe1e000 00000000dbe20000 1 00000000dbe20000 00000000dbe23000 1 00000000dbe23000 00000000dbe27000 1 00000000dbe27000 00000000dbe28000 1 00000000dbe28000 00000000dbe2a000 1 00000000dbe2a000 00000000dbe2b000 1 00000000dbe2b000 00000000dc24d000 1 00000000dc24d000 00000000dc25c000 1 00000000dc25c000 00000000dc25d000 1 00000000dc25d000 00000000dc25e000 1 00000000dc25e000 00000000dc273000 1 00000000dc273000 00000000dc274000 1 00000000dc274000 00000000dc275000 1 00000000dc275000 00000000dc276000 1 00000000dc276000 00000000dc27a000 1 00000000dc27a000 00000000dc27e000 1 00000000dc27e000 00000000dc283000 1 00000000dc283000 00000000dc284000 1 00000000dc284000 00000000dc2a2000 1 00000000dc2a2000 00000000dc2a6000 1 00000000dc2a6000 00000000dd163000 2 00000000dd163000 00000000dd2a8000 1 00000000dd2a8000 00000000dd42a000 4 00000000dd42a000 00000000dd83e000 1 00000000dd83e000 00000000de38b000 1 00000000de38b000 00000000de430000 1 00000000de430000 00000000de733000 1 00000000de733000 00000000de74f000 1 00000000de74f000 00000000de770000 1 00000000de770000 00000000de77d000 1 00000000de77d000 00000000de783000 1 00000000de783000 00000000de78b000 1 00000000de78b000 00000000de7a4000 1 00000000de7a4000 00000000de7b4000 1 00000000de7b4000 00000000de7c9000 1 00000000de7c9000 00000000de7e0000 1 00000000de7e0000 00000000deff9000 1 00000000deff9000 00000000df000000 1 0000000100000000 000000021f380000 2 00000000000a0000 0000000000100000 2 00000000df000000 00000000e0000000 2 00000000f8000000 00000000fc000000 2 00000000fd000000 0000000100000000
2019-12-01 14:06:30 +01:00
cinap_lenrek d32e5d130c sd53c8xx: fix the driver for amd64, fix alignment/padding issues, fix freechain handling 2019-11-24 21:56:54 +01:00
cinap_lenrek 44615fba43 sdiahci: implement reset timeout for ahciencreset(), make blink() never block, fix map[] access in ledkproc()
Ori_B reports that his controller gets stuck in the ahciencreset()
wait loop. so we implement a 1000 ms timeout. we replace delay()
with esleep() as we are always called from the ledkproc().

blink() could enter infinite delay loop as well, so instead of
waiting for the message to get transmitted we exit making it
non-blocking (we will get called again anyway).

the access to the controller map[] was wrong in ledkproc(). the
index is the controller number, not the drive number!
2019-11-17 21:19:55 +01:00
cinap_lenrek 521a0b336c bootrc: for wireless netbooting, set the WPA/WPA2 preshard key with wpapsk=password boot parameter
this allows automatic netbooting without password prompt
for the wirelss network.
2019-11-17 19:04:38 +01:00
cinap_lenrek b638c7753d devip: use the routing table for local source ip address selection
when making outgoing connections, the source ip was selected
by just iterating from the first to the last interface and
trying each local address until a route was found. the result
was kind of hard to predict as it depends on the interface
order.

this change replaces the algorithm with the route lookup algorithm
that we already have which takes more specific desination and
source prefixes into account. so the order of interfaces does
not matter anymore.
2019-11-10 19:50:46 +01:00
cinap_lenrek 82d04a4e63 bcm: fix software cursor avoidance for loadimage() case (thanks bitmapper) 2019-10-27 23:51:11 +01:00
cinap_lenrek e38f75fc45 ether82563: fix multicast for i210
MTA has 128 entries, according to section 8.10.15 in the datasheet.
this fixes ipv6 in apu2 which has 3x i210 (8086/157b).
2019-10-11 21:38:12 +02:00
cinap_lenrek db911d4fef sdiahci: force Hudson SATA Controller to AHCI mode 2019-10-08 13:53:57 +02:00
cinap_lenrek c0f464b98f pc: move low-level allocation details out of mmu.c into memory.c rampage() function 2019-10-02 01:01:34 +02:00
cinap_lenrek 0ee738ef8c vgai81x: use vmap() for uncached access to cursor data instead of manipulating kernel page table
on 386, the kernel memory region is mapped using huge 4MB pages
(when supported by the cpu). so the uncached pte manipulation
does not work to map the cursor data with uncached attribute.

instead, we allocate a memory page using newpage() and map
it globally using vmap(), which maps it uncached.
2019-10-02 00:58:46 +02:00
cinap_lenrek 490c3d87cb usbxhci: fix endpoint stall recovery, handle Ep.clrhalt flag
after issuing CR_RESETEP command, we have to invalidate
the endpoints output context buffer so that the halted/error
status reflects the new state. not doing so resulted in
the halted state to be stuck and we continued issuing
endpoint reset commands when we where already recovered.

handle the devusb Ep.clrhalt flag from devusb that userspace
uses to force a endpoint reset on the next transaction.
2019-09-22 18:51:41 +02:00
cinap_lenrek 5993760e14 devip: fix permission checking
permission checking had the "other" and "owner" bits swapped plus incoming
connections where always owned by "network" instead of the owner of
the listening connection. also, ipwstat() was not effective as the uid
strings where not parsed.

this fixes the permission checks for data/ctl/err file and makes incoming
connections inherit the owner from the listening connection.

we also allow ipwstat() to change ownership to the commonuser() or anyone
if we are eve.

we might have to add additional restrictions for none at a later point...
2019-09-21 23:28:37 +02:00
cinap_lenrek b56909157f bootrc: unmount devip *before* starting factotum
we want devip to get reattached after hostowner has been written. factotum
already handles this with a private authdial() routine that mounts devip
when it is not present. so we detach devmnt before starting factotum,
and attach once factotum finishes.
2019-09-21 18:48:14 +02:00
cinap_lenrek 5b7d8e1f6f bootrc: remount devip after /dev/hostowner has been written by factotum
devip remembers the attach uname so after we set hostowner we
remount devip so future connections have the right owner.
2019-09-21 18:11:52 +02:00
cinap_lenrek 12fa017f3f devproc: fix fishy locking in proctext(), check proc validity, static functions
the locking in proctext() is wrong. we have to acquire Proc.seglock
when reading segments from Proc.seg[] as segments do not
have a private freelist and can therefore be reused for other
data structures.

once we have Proc.seglock acquired, check that the process pid
is still valid so we wont accidentally read some other processes
segments. (for both proctext() and procctlmemio()). this also
should give better error message to distinguish the case when
the process did segdetach() the segment in question before we
could acquire Proc.seglock.

declare private functions as static.
2019-09-21 16:36:40 +02:00
cinap_lenrek c45458b929 devproc: move proctab() call after Qnotepg special case in procwrite() 2019-09-19 02:24:23 +02:00
cinap_lenrek 24d1fbde27 kernel: simplify pgrpnote(); moving the note string copying to procwrite()
keeps handling of devproc's note and notepg files similar and in the
same place and reduces stack usage.
2019-09-19 02:07:46 +02:00
cinap_lenrek fc4bfd57d2 bcm64: add addarchfile() prototype to fns.h (for qeed) 2019-09-15 04:53:45 +02:00
cinap_lenrek acab8881bc bcm64: enter page tables in mmutop *AFTER* switching asid in mmuswitch()
there was a small window between modifying mmutop and switching the
asid where the core could bring in the new entries under the old asid
into the tlb due to speculation / prefetching.

this change moves the entering of the page tables into mmutop after
setttbr() to prevent this scenario.

due to us switching to the resereved asid 0 on procsave()->putasid(),
the only asid that could have potentially been poisoned would be asid 0
which does not have any user mappings. so this did not show any noticable
effect.
2019-09-14 14:02:34 +02:00
cinap_lenrek 481a4c75fd usbehci: silence "param declared but not used" compiler warning in itdinit()/sitdinit() 2019-09-09 16:58:45 +02:00
cinap_lenrek 7de7444c6e sdide: silence compiler warning in atadebug() 2019-09-09 16:56:01 +02:00
cinap_lenrek 62eec43340 kernel: clear FPillegal in pexit() and before pprint()
pexit() and pprint() can get called outside of a syscall
(from procctl()) with a process that is in active note
handling and require floating point in the kernel on amd64
for aesni (devtls).
2019-09-08 19:02:01 +02:00
cinap_lenrek 6ad06b36b2 devproc: restore psstate info string in procstopwait() 2019-09-08 18:53:12 +02:00
cinap_lenrek 0cb4115b82 kernel: get rid of tmperrbuf and use syserrstr swapping instead in namec() 2019-09-04 02:44:39 +02:00
cinap_lenrek 6aa7ebcf49 kernel: make exec clear errstr, stop side-channels and truncate on utf8 boundary
make exec() clear the per process error string
to avoid spurious errors and confusion.

the errstr() syscall used to always swap the
maximum buffer size with memmove(), which is
problematic as this gives access to the garbage
beyond the NUL byte. worse, newproc(), werrstr()
and rerrstr() only clear the first byte of the
input buffer. so random stack rubble could be
leaked across processes.

we change the errstr() syscall to not copy
beyond the NUL byte.

the manpage also documents that errstr() should
truncate on a utf8 boundary so we use utfecpy()
to ensure proper NUL termination.
2019-09-04 02:40:41 +02:00
cinap_lenrek e4a57c8b8a bcm64: enable devgpio in kernel configuration (thanks qeed) 2019-09-02 19:38:44 +02:00
cinap_lenrek 7bb1a9a185 pc64: map kernel text readonly and everything else no-execute
the idea is to catch bugs and make kernel exploitation
harder by mapping the kernel text section readonly
and everything else no-execute.

l.s maps the KZERO address space using 2MB pages so
to get the 4K granularity for the text section we use
the new ptesplit() function to split that mapping up.

we need to set EFER no-execute enable bit early
in apbootstrap so secondary application processors
will understand the NX bit in our shared kernel page
tables. also APBOOTSTRAP needs to be kept executable.

rebootjump() needs to mark REBOOTADDR page executable.
2019-08-29 07:35:22 +02:00
cinap_lenrek d9fec3c70a kernel: prohibit changing cache attributes (SG_CACHED|SG_DEVICE) in segattach(), set SG_RONLY in data2txt()
the user should not be able to change the cache
attributes for a segment in segattach() as this
can cause the same memory to be mapped with
conflicting attributes in the cache.

SG_TEXT should always be mapped with SG_RONLY
attribute. so fix data2txt() to follow the rules.
2019-08-27 06:16:20 +02:00
cinap_lenrek d25ca13ed8 kernel: make user stack segment non-executable 2019-08-27 04:04:46 +02:00
cinap_lenrek 1e773c97e7 pc64: implement NX bit discovery, map kernel mappings no-execute 2019-08-27 03:55:12 +02:00
cinap_lenrek 49411b2ca1 kernel: catch execution read fault on SG_NOEXEC segment (for mips) 2019-08-27 03:48:51 +02:00
cinap_lenrek 2149600d12 kernel: catch execution read fault on SG_NOEXEC segment
fault() now has an additional pc argument that is
used to detect fault on a non-executable segment.
that is, we check on read fault if the segment
has the SG_NOEXEC attribute and the program counter
is within faulting page.
2019-08-27 03:47:18 +02:00
cinap_lenrek 128ea44a89 kernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, add PTECACHED bits
a portable SG_NOEXEC segment attribute was added to allow
non-executable (physical) segments. which will set the
PTENOEXEC bits for putmmu().

in the future, this can be used to make non-executable
stack / bss segments.

the SG_DEVICE attribute was added to distinguish between
mmio regions and uncached memory. only matterns on arm64.

on arm, theres the issue that PTEUNCACHED would have
no bits set when using the hardware bit definitions.
this is the reason bcm, kw, teg2 and omap kernels use
arteficial PTE constants. on zynq, the XN bit was used
as a hack to give PTEUNCACHED a non-zero value and when
the bit is clear then cache attributes where added to
the pte.

to fix this, PTECACHED constant was added.

the portable mmu code in fault.c will now explicitely set
PTECACHED bits for cached memory and PTEUNCACHED for
uncached memory. that way the hardware bit definitions
can be used everywhere.
2019-08-26 22:34:38 +02:00
cinap_lenrek 51cfe763a4 emmc: 50MHz highspeed support (from richard miller) 2019-08-25 20:02:53 +02:00
cinap_lenrek a8c50a7943 bcm64: replace emmc2 driver with richard millers sdhc driver
the new driver supports 50MHz highspeed bus mode
and uses ADMA instead of SDMA.
2019-08-25 18:45:29 +02:00
cinap_lenrek bcf988aff1 bcm64: deal with discontinuous memory regions, avoid virtual memory aliasing, implement vmap() proper
on the 2GB and 4GB raspberry pi 4 variants, there are two
memory regions for ram:

[0x00000000..0x3e600000)
[0x40000000..0xfc000000)

the framebuffer is somewhere at the end of the first
GB of memory.

to handle these, we append the region base and limit
of the second region to *maxmem= like:

*maxmem=0x3e600000 0x40000000 0xfc000000

the mmu code has been changed to have non-existing
ram unmapped and mmukmap() now uses small 64K pages
instead of 512GB pages to avoid aliasing (framebuffer).

the VIRTPCI mapping has been removed as we now have
a proper vmap() implementation which assigns vritual
addresses automatically.
2019-08-23 21:39:20 +02:00
cinap_lenrek e6d22570a8 bcm: invalidate cache on Fbinfo after firmware completion 2019-08-22 02:54:06 +02:00
cinap_lenrek aca0293f0b bcm: flush out early boot messages on uart and screen initialization
make early boot messages available by writing out
kmesg.buf after uart and screen initialization.
2019-08-22 02:52:21 +02:00
cinap_lenrek b4cb19235e bcm: set XN bits for kernel device mappings 2019-08-21 18:28:01 +02:00
cinap_lenrek 6280c0f17b bcm64: do not use OTP_BOOTMODE_REG to determine OSC frequency (thanks richard miller)
the register does not seem to be accessible on the Rpi 3b.
so instead hardcode oscfreq in the Soc structure.
2019-08-19 16:42:20 +02:00
cinap_lenrek f35d5ee5b0 bcm64: add support for more than 1GB of ram (untested)
this adds a 4GB KMAP window into the kernel address space
so we can access all physical ram on raspberry pi 4 for
user pages.

note that kernel memory above KZERO is still limited
to 1GB because of DMA restrictions.
2019-08-18 21:16:30 +02:00
cinap_lenrek 3fc8d1bdae bcm64: add driver for emmc2 controller 2019-08-18 18:50:24 +02:00
cinap_lenrek bc8c31dbd5 bcm: fix typo in gpio.c on unused AFedge0 constant 2019-08-16 19:35:46 +02:00
cinap_lenrek 031f5756ab bcm64: poll gisb arbiter for asynchronous bus errors 2019-08-16 19:24:00 +02:00
cinap_lenrek 54becb8466 ethergenet: remove debugging
the hangs where caused by missing NX bits on the mmio mappings,
so the debug code is not needed anymore.
2019-08-16 19:22:28 +02:00
cinap_lenrek 3bf49f1814 bcm64: set XN bits for kernel device mappings 2019-08-16 19:05:04 +02:00
cinap_lenrek 05f9a66fd4 bcm, bcm64: add vcore support for raspberry pi 3 GPIO expander 2019-07-28 11:39:57 +02:00
cinap_lenrek 8630bd35a6 bcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup
according to the following linux change, BCM2711 uses a different
method for changing pullup/down mode:

abcfd09286 (diff-cf078559c38543ac72c5db99323e236d)

gpiomeminit() was broken, using virtual address for the gpio physseg
instead of the physical one.

cleanup the code, avoid repetition by declaring static u32int *regs
variable. make local variable names consistent.
2019-07-27 20:00:53 +02:00
cinap_lenrek ea2a5a33ca bcm64: fix wrong prescaler for generic timer on rpi4
the raspberry pi 4 uses 54 instead of 19.2 MHz crystal.
detect which frequency is used by reading OTP bootmode
register:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/otpbits.md

Bit 1: sets the oscillator frequency to 19.2MHz
2019-07-27 17:59:25 +02:00
cinap_lenrek 834f670349 ethergenet: fix flow control negotiation 2019-07-25 17:44:47 +02:00
cinap_lenrek 1717368f64 bcm, bcm64: clean dma destination buffer before issuing dma in case of non cache-line-size aligned buffer 2019-07-25 13:55:17 +02:00
cinap_lenrek 706926f818 bcm64: add config for raspberry pi 4 2019-07-25 09:12:40 +02:00
cinap_lenrek 3bc4e5a6d5 bcm64: work in progress genet ethernet driver for raspberry pi 4 2019-07-25 09:11:53 +02:00
cinap_lenrek 2a4c767c41 bcm64: reorganize virtual memory map for rapberry pi4 2019-07-25 09:10:07 +02:00
cinap_lenrek 4200778861 bcm64: update io.h for pci express and raspberry pi 4 2019-07-25 09:08:35 +02:00
cinap_lenrek 6d9edeeb67 bcm64: add pci express driver for raspberry pi 4 2019-07-25 09:04:50 +02:00
cinap_lenrek 676ef0ca0b bcm64: add gic interrupt controller driver for raspberry pi 4 2019-07-25 09:02:47 +02:00
cinap_lenrek 10b456ff44 bcm64: add gisb arbiter driver to catch bus timeouts 2019-07-25 09:01:44 +02:00
cinap_lenrek 811b80cae1 bcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()
the raspberry pi 4 has a new interrupt controller and
pci support, so get rid of intrenable() macro and
properly make intrenable function with tbdf argument.
2019-07-25 08:58:58 +02:00
cinap_lenrek dfea95b3c2 bcm64: strip debug symbols to make sure .img file is multiple of 4 bytes
the raspberry pi4 firmware refuses to enable the GIC interrup controller
for arm64 when the .img file is not a multiple of 4 bytes. yes, this
is insane and nowhere documented.
2019-07-25 08:52:46 +02:00
cinap_lenrek 5a0c2e2d17 bcm, bcm64: add dmaflush() function and make virtio size and virtual address configurable in Soc.virtio and Soc.iosize 2019-07-25 08:41:37 +02:00
cinap_lenrek 4983adfa2c bcm, bcm64: add support for device tree parameter passing
the new raspberry pi 4 firmware for arm64 seems to have
broken atag support. so we now parse the device tree
structure to get the bootargs and memory configuration.
2019-07-25 08:19:12 +02:00
cinap_lenrek a6a1806c17 usbxhci: implement portable dma flush operations and move to port/ 2019-07-17 10:30:06 +02:00
cinap_lenrek 19a883ce7a usbehci: introduce dmaflush() function to handle portable cache invalidation for device drivers 2019-07-17 10:24:50 +02:00
cinap_lenrek a1a6f26110 kernel: move common ethermii to port/ 2019-07-11 07:47:39 +02:00
cinap_lenrek 7111de631c devuart: make sure uart is enabled in uartkick() 2019-07-11 07:45:34 +02:00
cinap_lenrek 54f9b36720 usbxhci: fix mysterious ENABLESLOT failures (update to XHCI spec revision 1.2 (2019))
Ori Bernstein had Sunrise Point-H USB 3.0 xHCI Controller that would mysteriously
crash on the 5th ENABLESLOT command. This was reproducable by even just allocating
slots in a loop right after init.

It turns out, the 1.2 spec extended the Max Scratchpad Buffers in HCSPARAMS2 so our
driver would not allocate enougth scratchpad buffers and controller firmware would
crash once it went beyond our allocated scratchpad buffer array.

This change also fixes:

- ignore bits 16:31 in PAGESIZE register
- preserve bits 10:31 in the CONFIG register
- handle ADDESSDEV command failure (so it can be retried)
2019-07-02 05:34:13 +02:00
cinap_lenrek b2c7a8d84a pc64: preallocate mmupool page tables
preallocate 2% of user pages for page tables and MMU structures
and keep them mapped in the VMAP range. this leaves more space
in the KZERO window and avoids running out of kernel memory on
machines with large amounts of memory.
2019-06-28 18:12:13 +02:00
cinap_lenrek 4d96bacd35 bcm, kw, omap, teg2: implement setregisters() 2019-06-20 13:17:36 +02:00
cinap_lenrek 2d83ae8fb2 pc64: actually fix it, what was i THINKING 2019-06-20 00:36:51 +02:00
cinap_lenrek a40364218d pc64: fix compiler warning in rebootjump() entry calculation 2019-06-20 00:32:54 +02:00
cinap_lenrek 8d36cd8d8a devdtracy: make machlocks and dtktab static 2019-06-14 10:30:50 +02:00
cinap_lenrek f42e53655e bcm64: implement dtracy support 2019-06-14 10:28:30 +02:00
cinap_lenrek 197ff3ac2f devip: if the server does not support TCP ws option, disable window scaling (thanks joe9)
if the server responds without a window scale option in
its syn-ack, disable window scaling alltogether as both
sides need to understand the option.
2019-05-22 22:20:31 +02:00
cinap_lenrek c881e33e8e bcm, bcm64: fix cache operations for dma and emmc
always clean AND invalidate caches before dma read,
never just invalidate as the buffer might not be
aligned to cache lines...

we have to invalidate caches again *AFTER* the dma
read has completed. the processor can bring in data
speculatively into the cache while the dma in in
flight.
2019-05-19 16:54:50 +02:00
cinap_lenrek d5e4558078 bcm64: remove unneccesary tlb flush on mmuidmap() 2019-05-17 18:57:05 +02:00
cinap_lenrek 2235660f86 bcm64: no need to flush instruction cache when switching TTBR0 2019-05-17 18:56:34 +02:00
cinap_lenrek 5c5c1b6666 bcm64: switch to 64k page size 2019-05-17 18:35:14 +02:00
cinap_lenrek b24ed2bfac bcm64: generalize mmu code
make user page table list heads arrays so we can
index into the right level avoiding the special
cases for differen PTLEVELS.
2019-05-15 16:19:20 +02:00
cinap_lenrek 47d3e8fc63 bcm64: fix mmu0clear() mistake from previous commit 2019-05-15 13:24:34 +02:00
cinap_lenrek adf96a529e bcm: add cache invalidate before accessing prop buffer 2019-05-13 19:21:14 +02:00
cinap_lenrek a3b5e3994f bcm64: implement reboot support 2019-05-13 19:20:21 +02:00
cinap_lenrek 3b36daa2bb bcm, bcm64: preserve memsize across reboots, avoid trashing atags while parsing cmdline
we override atag memory on reboot, so preserve
the memsize learned from atag as *maxmem plan9
variable. the global memsize variable is not
needed anymore.

avoid trashing the following atag when zero
terminating the cmdline string.

zero memory after plan9.ini variables.
2019-05-13 19:12:41 +02:00