Commit graph

227 commits

Author SHA1 Message Date
cinap_lenrek 529082d34d pc, pc64: preserve last KB of conventional memory (might contain bios tables)
we add new function convmemsize() that returns the size of
*usable* conventional memory that does some sanity checking
and reserves the last KB below the top of memory pointer.

this avoids lowraminit() overriding potential bios tables
and sigsearch() going off the rails looking for tables
at above 640K.
2014-11-20 19:05:43 +01:00
cinap_lenrek 4e00cf6b17 pc64: get rid of fixed 8MB INIMAP and dynamically map KZERO-end in l.s
traditionally, the pc kernel mapped the first 8MB of physical
address space. when the kernel size grows beyond that memory mapping,
it will crash on boot and theres no checking in the build process
making sure it fits.

with the pc64 kernel, it is not hard to always map the whole
kernel memory image from KZERO to end[], so that the kernel will
always fit into the initial mapping.
2014-11-15 11:43:05 +01:00
cinap_lenrek bd7e387b51 pc64: fix comment description of pc64 kernel configuration 2014-11-10 12:22:50 +01:00
cinap_lenrek bcb67353c1 pc, pc64: provide access to embedded controller with #P/ec file 2014-11-10 00:04:37 +01:00
cinap_lenrek b18a641397 kernel: remove implicit Proc* argument from procctl()
procctl() is always called with up and it would not
work correctly if passed a different process, so
remove the Proc* argument and use up directly.
2014-11-09 08:19:28 +01:00
cinap_lenrek bb95002c2d pc, pc64: implement acpi reset (for efi)
x230 booted in efi only (no csp) mode hangs
when traditional i8042reset() keyboard reset
is tried.

so we try acpireset() first which discoveres
and writes the acpi reset register.
2014-11-02 03:52:53 +01:00
cinap_lenrek 2020190f94 pc, pc64: more sanity checking for lowraminit() 2014-11-02 00:32:46 +01:00
cinap_lenrek 153f96ebc6 pc64: remove unused pdballoc and pdbfree counters from mach structure 2014-11-01 20:53:36 +01:00
cinap_lenrek e81e1a4aed pc, pc64: make mtrr() callable from interrupt context and before mpinit
to make it possible to mark the bootscreen framebuffer
as write combining in early initialization, mtrr() is
changed not not to error() but to return an error string.

as bootscreen() is used before multiprocessor initialization,
we have to synchronize the mtrr's for every processor as
it comes online. for this, a new mtrrsync() function is
provided that is called from cpuidentify() if mtrr support
is indicated.

the boot processor runs mtrrsync() which snarfs the
registers. later, mtrrsync() is run again from the
application processors which apply the values from the
boot processor.

checkmtrr() from mp.c was removed as its task is also
done by mtrrsync() now.
2014-10-21 06:03:03 +02:00
cinap_lenrek 0a6439a1f5 pc, pc64: allow passing RSDT pointer in *acpi= boot parameter, early bootscreeninit(), fix rampage() usage
rampage() cannot be used after meminit(), so test for
conf.mem[0].npage != 0 and use xalloc()/mallocalign()
instead. this allows us to use vmap() early before
mmuinit() which is needed for bootscreeninit() and
acpi.

to get memory for page tables, pc64 needs a lowraminit().

with EFI, the RSDT pointer is passed in *acpi= parameter
from the efi loader. as the RSDT is ususally at the end of
the physical address space (and not to be found in
bios areas), we cannot KMAP() it so we need to vmap().
2014-10-18 02:01:58 +02:00
mischief ee29c17639 pc64: enable rtl8169 driver (thanks awabimakoto for testing) 2014-09-24 14:19:22 -07:00
cinap_lenrek 47e52123d0 pc64: print "Plan 9" on boot, cleanup pccpu64 files 2014-09-21 16:06:25 +02:00
cinap_lenrek 6031dd83b6 pc64: enable ether8139 in kernel config (thanks hiro) 2014-08-22 00:00:06 +02:00
cinap_lenrek 0d5491fb08 pc, pc64: fix off by one error in _multibootentry 2014-08-18 03:16:11 +02:00
cinap_lenrek 0a101736b8 pc, pc64: make pc kaddr() check reject -KZERO address (thanks aiju) 2014-08-07 21:11:11 +02:00
cinap_lenrek ca4f815cfc pc64: fix wrong Ureg* argument on note handler (thanks _sl!)
_sl reported crash:

stats 593: suicide: sys: trap: fault write addr=0xffffffff8258d1b0 pc=0x204cc7

; acid 593
/proc/593/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
notejmp(ret=0x1,j=0x40ac90)+0x13 /sys/src/libc/amd64/notejmp.c:10
alarmed(a=0xffffffff8258d1b0,s=0x7ffffeffea58)+0x3f /sys/src/cmd/stats.c:718
notifier+0x3e /sys/src/libc/port/atnotify.c:15
acid:

note how a in alarmed is a kernel address!

the first Ureg* argument is passed to the note handler in the
RARG (BX) register, which was not loaded when returning to
userspace from syscall() thru forkret(). fix by returning thru
noteret() from syscall().
2014-08-07 19:55:25 +02:00
cinap_lenrek 1021caa395 pc64: cleanup syscallentry()
avoid the stack shuffeling and make syscallentry() and
forkret() use the same stack offsets.
2014-07-21 18:02:14 +02:00
cinap_lenrek c78c6e349a pc64: dont save/restore DS/ES/FS/GS segment registers on syscall or interrupt, they are ignored in long mode.
we do not support 32 bit processes and DS, ES, FS and GS segment
registers are ignored in long mode, so theres no point in saving
and restoring them.
2014-07-20 02:59:45 +02:00
cinap_lenrek 20b7a19c58 pc64: preserve user extern registers R14 and R15 across syscalls, use Ureg.bp (RARG) for syscall number
the 6c compiler reserves R14 and R15 for extern register variables,
which is used by the kernel to hold the m and up pointers. until
now, the meaning of R14 and R15 was undefined for userspace and
extern register would not work as the kernel trashes R14 and R15
on syscalls. with this change, user extern registers R14 and R15
are zeroed on exec and otherwise preserved across syscalls. so
userspace *could* use them for per process variables like the
kernel does.

use Ureg.bp (RARG) for syscall number instead of Ureg.ax. this is
less confusing and mirrors the amd64 calling convention.
2014-07-20 22:49:02 +02:00
cinap_lenrek 3a6a754051 pc, pc64: initial machine check architecture support 2014-07-09 22:45:51 +02:00
cinap_lenrek e7bfa556ad pc64: fix comment for preallocpages() 2014-06-22 16:05:53 +02:00
cinap_lenrek e6f37cf64e pc64: fix MS2HZ (thanks Anthony Martin) 2014-06-13 10:19:46 +02:00
cinap_lenrek fcfa74a1cf pc64: use pc/pcrandom.$O instead of port/random.$O for RDRAND instruction support 2014-06-08 04:40:18 +02:00
cinap_lenrek 72ba3571a3 kernel: remove _xinc()/_xdec()
as with the Block refcount changes, _xinc() and _xdec() arent
used anymore, so remove them.

architecure can still define ainc()/adec() when it needs them.
2014-06-08 01:35:22 +02:00
cinap_lenrek 865368f604 pc64: remove unneeded parens in pmap() 2014-06-07 09:43:37 +02:00
cinap_lenrek 7bc8f4d993 pc64: implement checkmmu() debug function 2014-06-07 09:26:57 +02:00
cinap_lenrek 76db435e3c pc64: dont trap _xinc()/_xdec() overflow/underflow, delete unused atomic functions 2014-06-05 07:57:23 +02:00
cinap_lenrek 1427ba3126 pc64: fix for unsigned comparsion of (top - base) >= size
the rounding of base can make it above top, so have to
use signed comparsion.
2014-06-01 06:54:55 +02:00
cinap_lenrek fb97665a14 pc64: use 2MB pages for preallocpages() 2014-06-01 06:31:50 +02:00
cinap_lenrek c9f91d5015 pc64: allocate palloc.pages from upages
the palloc.pages array takes arround 5% of the upages which
gives us:

16GB = ~0.8GB
32GB = ~1.6GB
64GB = ~3.2GB

we only have 2GB of address space above KZERO so this will not
work for long.

instead, pageinit() was altered to accept a preallocated memory
in palloc.pages. and preallocpages() in pc64/main.c allocates the
in upages memory, mapping it in the VMAP area (which has 512GB).

the drawback is that we cannot poke at Page structures now from
/proc/n/mem as the VMAP area is not accessible from it.
2014-06-01 03:13:58 +02:00
cinap_lenrek 5246416621 pc, pc64: simplify reboot code
as we do system reset and reboot only from boot processor cpu0 now,
theres no need for active.rebooting conditional variable.
mpshutdown() will unconditionally park application processors and
and cpu0 boots the new kernel or calls mpshutdown() causing system
reset.
2014-05-29 18:50:52 +02:00
cinap_lenrek c5214cd6d9 pc64: cleanup mmuzap 2014-05-25 20:34:26 +02:00
cinap_lenrek 06ad4e5fff pc64: remove cpuserver bigboy hack and honor *kernelpercent= 2014-05-19 06:57:04 +02:00
cinap_lenrek 17d932eca9 pc, pc64: add simd error exception name in trap.c 2014-05-11 06:17:13 +02:00
cinap_lenrek a9155014c0 pc, pc64: handle sse simd exceptions 2014-05-11 05:59:10 +02:00
cinap_lenrek 59e53f818d pc64: fix embrassing typo in mmuzap() 2014-05-06 18:59:56 +02:00
cinap_lenrek 405de1e6a2 pc64: increase sizes of physical memory bank maps
number of bank slots in Conf.mem[4] was too small
for kenjis machine, set it to maximum 16 (the
size of the RAM map in pc64/memory.c).

also increasing the UPA memory map to 64. the
e820 map on my x200s has 31 entries and many
holes. this gets rid of the "mapfree: ... losing"
messages on boot.
2014-05-01 17:24:50 +02:00
cinap_lenrek d4abe404b4 pc64: prevent dat.h from getting overwritten by ../pc/dat.h
the rule that was used to copy header files from ../pc
accidently overwrote dat.h when ../pc/dat.h was updated
because it matched on all *.h files that was also found
in ../pc directory. change to exact match on $PCHEADERS
to prevent this.
2014-03-24 19:00:34 +01:00
cinap_lenrek 294e940f57 pc64: serial console support 2014-03-21 18:59:21 +01:00
cinap_lenrek da62091c07 pc64: port etherbcm
do not store Block* pointer in packet descriptor, assumed
pointer would fit in a long. we use pointer table now to
record the Block* pointer and store index instead.
2014-03-19 09:00:20 +01:00
cinap_lenrek f2f46f4a33 pc64: amd64 kernel reboot support 2014-03-16 20:22:59 +01:00
cinap_lenrek 38c0dfacab pc64: fix swaped error/flags in dumpregs(), remove misleading comment in apbootstrap 2014-03-16 02:28:04 +01:00
cinap_lenrek 469dfca25f pc64: add R8-R15 in dumpregs() 2014-03-15 04:38:14 +01:00
cinap_lenrek a8af25ef81 kernel: interpret service= boot parameter to set "cpuserver" variable 2014-03-15 00:55:02 +01:00
cinap_lenrek 316d8ad76b pc64: fix segattach
the comment about Physseg.size being in pages is wrong,
change type to uintptr and correct the comment.

change the length parameter of segattach() and isoverlap()
to uintptr as well. segments can grow over 4GB in pc64 now
and globalsegattach() in devsegment calculates len argument
of isoverlap() by s->top - s->bot. note that the syscall
still takes 32bit ulong argument for the length!

check for integer overflow in segattach(), make sure segment
goes not beyond USTKTOP.

change PTEMAPMEM constant to uvlong as it is used to calculate
SEGMAXSIZE.
2014-03-04 22:37:15 +01:00
cinap_lenrek 2e6234da0f pc64: multiboot support 2014-03-01 19:35:40 +01:00
cinap_lenrek fd112b949f pc64: enable pmmc driver 2014-03-01 05:50:20 +01:00
cinap_lenrek ef1ec09cf7 pc64: fix mmu leak 2014-02-23 18:40:43 +01:00
cinap_lenrek 240ba73770 pc64: fix mistake 2014-02-15 16:58:35 +01:00
cinap_lenrek 25189924db pc64: simplify mmuwalk by factoring out mmu page table creation into separate function 2014-02-15 16:43:55 +01:00
cinap_lenrek ebeb501cff pc64: support for vmware PCnet ethernet 2014-02-15 06:17:38 +01:00
cinap_lenrek 32604cd830 pc64: move VMAP into its own PDP (for vmware)
modifying the kernel pdp (CPU0PDP) hangs vmware. so
we initialize the pdp with KZERO and KZERO+1GB map
in l.s and never change it. (except when removing
the zero double map which seems to work).

VMAP has its own pdp now allowing to map 512GB of
physical address space. this simplifies the code
a bit and gives nice virtual addresses.
2014-02-15 06:17:05 +01:00
mischief 7d73312def pc64: add ahci.h to PCHEADERS so it will be removed on mk clean 2014-02-12 03:02:23 -08:00
mischief 6edd7255c7 pc64: remove ethermii.h and copy it from pc instead 2014-02-12 03:00:12 -08:00
Matthew Veety 6a12aef885 added pccpu64 for cpuservers. also enabled etherigbe in pc64 and pccpu64 2014-02-12 21:05:04 -05:00
cinap_lenrek 7f73792ef9 pc64: limit memory of per processor mmu freelist to 1MB 2014-02-10 02:37:45 +01:00
cinap_lenrek c4679d743a pc64: return up in RUSER (BP) for devproc kregs file 2014-02-10 23:12:52 +01:00
cinap_lenrek 9bdf602ebb pc64: pass Ureg* argument in BP to userspace note handler 2014-02-09 02:23:33 +01:00
cinap_lenrek eaafcf2187 pc64: bump segment limit to 64GB 2014-02-08 00:23:18 +01:00
mischief fc7f6f8e99 pc64: ensure user pc is never set to a non-canonical address through setregisters
on intel processors, a general protection exception is fired if a non-canonical address is loaded into PC during SYSRET. this will cause the kernel to panic.

see http://www.kb.cert.org/vuls/id/649219 and the intel software developer manual for more information.
2014-02-06 18:03:17 -08:00
cinap_lenrek c065eadb53 pc64: fix note handling 2014-02-06 22:43:33 +01:00
cinap_lenrek bfbc5ab197 pc64: fix kmap()
kmapindex has to be per process, not per mach, as the process
can be switched to another processor while the mapping is
established.

to bootstrap the first process, we have to temporarily set up
so the kmap MMU's can be attached to the process. previously
we assumed that the first two pages for the initial process
where below 2GB and could be accessed with KADDR() directly.
with 16GB machine, all the 2GB above KZERO are dedicated to
the kernel so the user pages returned by newpage() need to
be mapped.
2014-02-06 22:41:42 +01:00
mischief 1eef373152 pc64: fix up pointer calculations and enable sdvirtio disk driver 2014-02-03 01:22:26 -08:00
cinap_lenrek 34f7e4ef9a pc64: remove cinaps cga screen interrupt debugger, was experiment... 2014-02-04 02:08:26 +01:00
cinap_lenrek de0712c0b5 pc64: dont dump user registers on exception, was experiment... 2014-02-04 02:06:11 +01:00
mischief 35d19fc6fb merge 2014-02-02 07:41:56 -08:00
cinap_lenrek 6a55790197 pc/pc64: move common code to pc/devarch.c 2014-02-03 06:24:31 +01:00
cinap_lenrek c3028fb924 pc64: implement shutdown and idlehands
just copies from pc kernel. should refactor into common
pc code.
2014-02-03 05:29:53 +01:00
mischief d082e3a5ae pc64: enable sdide driver 2014-02-02 07:34:54 -08:00
cinap_lenrek bfee76e5d3 pc64: track per process kmap page tables in separate MMU list.
we have to keep kmap page tables in ther own list
because user tables are subject to (virtual) tlb flushing.

we never free kmap page tables except in mmurelease()
where we just link the kmap mmu list in front of the user
mmus and call mmufree() which will free all the mmu's
of the process.
2014-02-02 18:01:13 +01:00
cinap_lenrek 02fef73b8f pc64: dont dump registers for user process on pagefault error, was experiment 2014-02-02 09:39:58 +01:00
cinap_lenrek 2a4f7a1eb1 pc64: no need to flush tlb in kunmap(), was experiment 2014-02-02 09:22:23 +01:00
cinap_lenrek db2e22aebe pc64: fix mmu structure leakage, implement global pool 2014-02-02 08:12:08 +01:00
cinap_lenrek 47f551bcea pc64: print only 8 hex chars dumpstack sp/pc
kernel addresses are sign extended to 64 bit. upper bits
are not really helpfull.
2014-02-02 05:49:30 +01:00
cinap_lenrek e289fd8ccd pc64: fix vmap
VMAP address calculation was all wrong resulting
in vmaps get mapped into KZERO map.
2014-02-02 05:10:58 +01:00
cinap_lenrek 0850718033 pc64: enable iahci support 2014-02-01 20:27:54 +01:00
cinap_lenrek 56343cafcf add experimental pc64 kernel 2014-02-01 10:25:10 +01:00