akaros.git
5 years agoAdds the UCB-Plan 9 license
Barret Rhoden [Wed, 12 Mar 2014 03:26:22 +0000 (20:26 -0700)]
Adds the UCB-Plan 9 license

With a ref to it in LICENSE, for all the headers that just say LICENSE
and not LICENSE-PLAN9.

5 years agox86: moves the PIT into time.{h,c}
Barret Rhoden [Wed, 12 Mar 2014 03:18:28 +0000 (20:18 -0700)]
x86: moves the PIT into time.{h,c}

It's been cluttering the unrelated APIC files for about five years now.

5 years agox86: moves the PIC into its own file
Barret Rhoden [Wed, 12 Mar 2014 03:01:34 +0000 (20:01 -0700)]
x86: moves the PIC into its own file

5 years agox86: PICs for everyone!
Barret Rhoden [Wed, 12 Mar 2014 02:48:46 +0000 (19:48 -0700)]
x86: PICs for everyone!

Turns on the PIC all the time, but masks it.  And cleans up the PIC
initialization a bit, with the goal of removing ENABLE_MPTABLES.

5 years agox86: irq handler func pointers
Barret Rhoden [Wed, 12 Mar 2014 02:28:40 +0000 (19:28 -0700)]
x86: irq handler func pointers

This is more in line with modern OSs (plan 9, linux), where we have some
struct tracking what to do at a given vector, instead of branching on
the trap number.

5 years agoRemove dead code.
Ronald G. Minnich [Fri, 21 Mar 2014 22:41:55 +0000 (15:41 -0700)]
Remove dead code.

No longer used and can't even really be configured.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoThe last piece to test VMs; disable interrupts before starting one
Ronald G. Minnich [Fri, 21 Mar 2014 22:41:25 +0000 (15:41 -0700)]
The last piece to test VMs; disable interrupts before starting one

Can't test as IOAPIC is borked.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoMove timeout code to other side of uthread yield.
Kevin Klues [Fri, 21 Mar 2014 17:51:12 +0000 (10:51 -0700)]
Move timeout code to other side of uthread yield.

Also, only spin on awaiter->data if a timeout was set, and return the
proper value from the futx_wake() call.

5 years agoRearrange the timeout logic to be a little more efficient
Kevin Klues [Fri, 21 Mar 2014 09:49:06 +0000 (02:49 -0700)]
Rearrange the timeout logic to be a little more efficient

Also beef up the comments a bit

5 years agoUpdate pthread futexes to use alarms for timeouts
Kevin Klues [Fri, 21 Mar 2014 06:11:22 +0000 (23:11 -0700)]
Update pthread futexes to use alarms for timeouts

One side effect of this is that the pthread library now depends on
benchutil.  We may want to revisit this dependency.

5 years agoFix bug with duping fds for plan 9 files
Kevin Klues [Fri, 21 Mar 2014 05:53:06 +0000 (22:53 -0700)]
Fix bug with duping fds for plan 9 files

I added a new claim_fd() function similar to the get_fd() and put_fd()
functions in vfs.c.  When duping plan9 fds for a new_proc via dupfgrp()
we call claim_fd() to update the new_proc's open_file list shared with
the vfs.

I also swapped the order of put_fd() and setting the fd in
src/ns/sysfile.c to avoid a potential race condition with the assert in
newfd().

5 years agoRemove debug prints from cs and csquery
Ronald G. Minnich [Wed, 19 Mar 2014 15:12:19 +0000 (08:12 -0700)]
Remove debug prints from cs and csquery

These now work with the workaround for missing access(2)
and the fixed up llseek system call.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd llseek support for the plan 9 namespace
Ronald G. Minnich [Wed, 19 Mar 2014 14:59:05 +0000 (07:59 -0700)]
Add llseek support for the plan 9 namespace

This fixes, among other things, csquery.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoDebugging hacks.
Ronald G. Minnich [Wed, 19 Mar 2014 02:41:49 +0000 (19:41 -0700)]
Debugging hacks.

Note that offset is 17 in the Tread to cs. Bogus. How's it
getting set to 17?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoCopy hexdump over to parlib
Ronald G. Minnich [Wed, 19 Mar 2014 02:27:30 +0000 (19:27 -0700)]
Copy hexdump over to parlib

It's very handy at times.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix up bugs in IP query
Ronald G. Minnich [Wed, 19 Mar 2014 00:21:18 +0000 (17:21 -0700)]
Fix up bugs in IP query

the problem was we don't implement access(2) yet

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix csquery.c
Ronald G. Minnich [Tue, 18 Mar 2014 23:10:17 +0000 (16:10 -0700)]
Fix csquery.c

/net/cs

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFurther cleanup, but the behavior of procgen eludes me.
Ronald G. Minnich [Tue, 18 Mar 2014 00:35:39 +0000 (17:35 -0700)]
Further cleanup, but the behavior of procgen eludes me.

ctl is still not visible.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agolindent proc. Add in commands.
Ronald G. Minnich [Tue, 18 Mar 2014 00:13:23 +0000 (17:13 -0700)]
lindent proc. Add in commands.

We can now do kill and closefiles on procs. These
are extremely handy.

But the ctl file doesn't show up.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoForce the Qcoalesce flag on pipe fds
Kevin Klues [Fri, 14 Mar 2014 23:32:43 +0000 (16:32 -0700)]
Force the Qcoalesce flag on pipe fds

Without this writes can produce blocks of length 0, and reads can read
them.  This causes problems since reading a zero length blcok returns 0
, and 0 means EOF from the perspective of user space.  Turning on the
Qcoalesce flag removes these 0 length blocks from consideration.

5 years agoExplicitly set the SI_USER flag when signaling
Kevin Klues [Fri, 14 Mar 2014 03:04:52 +0000 (20:04 -0700)]
Explicitly set the SI_USER flag when signaling

Also set any default signal handlers that should be SIG_IGN to the
actualy SIG_IGN pointer instead of to a new function that just does
nothing.

5 years agoAdd a simple ps command.
Ronald G. Minnich [Thu, 13 Mar 2014 22:28:35 +0000 (15:28 -0700)]
Add a simple ps command.

ash /bin/ps works.
/bin/ps fails, for reasons I don't understand.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoremove monitor call that was used for debugging and is not needed
Ronald G. Minnich [Thu, 13 Mar 2014 22:24:39 +0000 (15:24 -0700)]
remove monitor call that was used for debugging and is not needed

5 years agoGet user to build with the new libraries.
Ronald G. Minnich [Thu, 13 Mar 2014 22:05:05 +0000 (15:05 -0700)]
Get user to build with the new libraries.

Lots of libraries came back, and things stopped building.
Note that Barret's cheap dial is commented out.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoGet status entry in /proc
Ronald G. Minnich [Thu, 13 Mar 2014 21:01:46 +0000 (14:01 -0700)]
Get status entry in /proc

Poor man's ps

/ $ cat '#p/1/status'
       1 WAITING         0/ $

Note: new newline.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoBring the proc device back.
Ronald G. Minnich [Thu, 13 Mar 2014 18:18:13 +0000 (11:18 -0700)]
Bring the proc device back.

We can now view namespaces and such.
I'll extend this more to get us real info.

/ $ ls '#p'
1          trace      tracepids
/ $ cat '#p/1/ns'
cd /
/ $ ash /ifconfig
bind #c -> /dev flag 1
bind #p -> /proc flag 1
bind #s -> /srv flag 1
bind #I -> /net flag 2
bind #l0 -> /net flag 2
Incoming IRQ, ISR: 73 on core 0
I am 10.0.2.15, default route 10.0.2.2
/ $ cat '#p/1/ns'
bind  /dev /dev
bind -b #c /dev
bind  /srv /srv
bind -b #s /srv
bind  /net /net
bind -a #I /net
bind -a #l /net
cd /
/ $

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd srvname back
Ronald G. Minnich [Thu, 13 Mar 2014 15:27:48 +0000 (08:27 -0700)]
Add srvname back

We'll need it for proc.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix omode handling in dev/srv; have csquery always open #s/cs until we are sure bindi...
Ronald G. Minnich [Tue, 11 Mar 2014 20:41:51 +0000 (13:41 -0700)]
Fix omode handling in dev/srv; have csquery always open #s/cs until we are sure binding works

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd the ndb files needed to make basic csquery work
Ronald G. Minnich [Tue, 11 Mar 2014 19:17:12 +0000 (12:17 -0700)]
Add the ndb files needed to make basic csquery work

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoPlan 9 programs for controlling and checking the network: cs.c, csquery.c, netstat.c
Ronald G. Minnich [Tue, 11 Mar 2014 19:14:05 +0000 (12:14 -0700)]
Plan 9 programs for controlling and checking the network: cs.c, csquery.c, netstat.c

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd ndblib and iplib
Ronald G. Minnich [Tue, 11 Mar 2014 19:04:43 +0000 (12:04 -0700)]
Add ndblib and iplib

Needed for connection services

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd default page fault handling to map to SIGSEGV in pthreads
Kevin Klues [Tue, 11 Mar 2014 18:42:16 +0000 (11:42 -0700)]
Add default page fault handling to map to SIGSEGV in pthreads

I refactored the signal handling code a bit so that page faults in our
pthread library trigger SIGSEGV signals that application code can
handle.

5 years agoMake building the VM optional
Ronald G. Minnich [Sat, 8 Mar 2014 05:02:00 +0000 (21:02 -0800)]
Make building the VM optional

It doesn't work anyway.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoGet the vm code to build again.
Ronald G. Minnich [Fri, 7 Mar 2014 17:44:11 +0000 (09:44 -0800)]
Get the vm code to build again.

Due to other changes the code had stopped building.
So get it to at least build. We also know the
source of the vm startup problems and will fix them as
soon as we have working hardware or a working qemu.

Also, enable more vmx options for qemu. Nope, still not
enough there yet. Qemu doesn't seem to do what it says it will
do.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agox86: irq asm handlers for non-PIC irqs
Barret Rhoden [Fri, 7 Mar 2014 07:23:01 +0000 (23:23 -0800)]
x86: irq asm handlers for non-PIC irqs

The APICS (IO, etc) can generate vectors beyond 47, so we need
IRQ_HANDLER stubs for them.

This was actually a fun commit: vim macro and CTRL-A to increment.

5 years agoAPIC MMIO reads/writes use the helper
Barret Rhoden [Fri, 7 Mar 2014 02:37:05 +0000 (18:37 -0800)]
APIC MMIO reads/writes use the helper

Some of the operations (like the IOAPIC version read) were getting
optimized such that they didn't work properly.  Like reading a byte
instead of the entire aligned 32 bit IOAPIC version.

5 years agox86: Maps in the full LAPIC and IOAPIC size (XCC)
Barret Rhoden [Thu, 6 Mar 2014 06:34:39 +0000 (22:34 -0800)]
x86: Maps in the full LAPIC and IOAPIC size (XCC)

MP spec says they are 1MB in size, not one page.  This changes a kernel
header, though not part userspace cares about.

5 years agox86_64: fixes bug in map_segment
Barret Rhoden [Thu, 6 Mar 2014 06:33:07 +0000 (22:33 -0800)]
x86_64: fixes bug in map_segment

Copy and paste from the submap case.

5 years agoVarious APIC debugging and IOAPIC IRQ routing
Barret Rhoden [Wed, 5 Mar 2014 01:27:06 +0000 (17:27 -0800)]
Various APIC debugging and IOAPIC IRQ routing

Still busted, but getting a bit closer.  apiconline() needs work, and needs to
be called for all cores.  IOAPIC routing is broken, and the interfaces to IRQ
code are sloppy.  We have a weird mix of plan9 code and Akaros code that do
different things with PCI and IRQ handling.

5 years agoACPI init reorg
Barret Rhoden [Wed, 5 Mar 2014 01:08:41 +0000 (17:08 -0800)]
ACPI init reorg

Init the ACPI as soon as possible, and handle the APIC during IDT init.

5 years agoExtracts sigscan/checksum
Barret Rhoden [Tue, 4 Mar 2014 19:20:34 +0000 (11:20 -0800)]
Extracts sigscan/checksum

Helpers to scan memory for a signature/pattern.  Now we can use them in
multiple places, without have the same code twice.

5 years agoLindent on the new APIC/ACPI files
Barret Rhoden [Tue, 4 Mar 2014 18:59:06 +0000 (10:59 -0800)]
Lindent on the new APIC/ACPI files

And the MP tables!  Oh, and devarch.

5 years agoRemvoe erroneous warning
Ronald G. Minnich [Tue, 4 Mar 2014 21:51:11 +0000 (13:51 -0800)]
Remvoe erroneous warning

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd an arch device
Ronald G. Minnich [Tue, 4 Mar 2014 17:48:04 +0000 (09:48 -0800)]
Add an arch device

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoOne final round of fixup/cleanup.
Ronald G. Minnich [Tue, 4 Mar 2014 16:25:15 +0000 (08:25 -0800)]
One final round of fixup/cleanup.

Not working.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoOne last attempt.
Ronald G. Minnich [Tue, 4 Mar 2014 15:57:23 +0000 (07:57 -0800)]
One last attempt.

Add the mp code. But it helpeth not. With luck we just
remove it again later, but now we can hack.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoClean up the prints, add some debug info
Ronald G. Minnich [Tue, 4 Mar 2014 02:00:50 +0000 (18:00 -0800)]
Clean up the prints, add some debug info

Still does not work of course but at least
we can learn more about why not.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoUse vmap_pmem
Ronald G. Minnich [Tue, 4 Mar 2014 00:34:33 +0000 (16:34 -0800)]
Use vmap_pmem

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoWe get further, this is enough for the code walkthrough
Ronald G. Minnich [Tue, 4 Mar 2014 00:23:53 +0000 (16:23 -0800)]
We get further, this is enough for the code walkthrough

I'm go to go contemplate the universe.
But this is the rough set of things that have to happen,
even if not all the bits are right.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoMore cleanup.
Ronald G. Minnich [Mon, 3 Mar 2014 23:25:16 +0000 (15:25 -0800)]
More cleanup.

Also, we needed tbdf in the ether struct as a "hook" for the ioapic.
ioapics really want that devno in the interrupt tables.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoMore set up for using ioapics
Ronald G. Minnich [Mon, 3 Mar 2014 22:25:35 +0000 (14:25 -0800)]
More set up for using ioapics

Everything *seems* to be getting done but interrupts still don't happen.
Note we had to change register_dev_interrupt to take a u32; the ioapic
requires it.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFirst pass at enabling interrupts.
Ronald G. Minnich [Mon, 3 Mar 2014 19:15:51 +0000 (11:15 -0800)]
First pass at enabling interrupts.

This may not be too wrong.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoBring a bit more apic infrastructure up.
Ronald G. Minnich [Mon, 3 Mar 2014 18:28:46 +0000 (10:28 -0800)]
Bring a bit more apic infrastructure up.

I hope this does not conflict too much with what's there
already, we can hash this out tomorrow.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoImprove visibility of apics/ioapics
Ronald G. Minnich [Mon, 3 Mar 2014 18:07:52 +0000 (10:07 -0800)]
Improve visibility of apics/ioapics

if you cat '#a/ioapic' and '#a/apic', you'll see some useful
info about them. This is much better than the simple kernel dump.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd a bit more info to the print, we can now see introvr flags and what they mean.
Ronald G. Minnich [Mon, 3 Mar 2014 17:35:06 +0000 (09:35 -0800)]
Add a bit more info to the print, we can now see introvr flags and what they mean.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd some comments/prints
Ronald G. Minnich [Mon, 3 Mar 2014 07:09:59 +0000 (23:09 -0800)]
Add some comments/prints

This is so Barret will figure out how to make the
ioapicintrinit
code work from ACPI :-)

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoSet up ACPI interrupt configuration
Ronald G. Minnich [Mon, 3 Mar 2014 06:47:30 +0000 (22:47 -0800)]
Set up ACPI interrupt configuration

This builds and boots, and we seem to get console interrupts,
but not ethernet interrupts (under QEMU). Things need to be fixed.
Only works if you enable CONFIG_MPTABLES (which should be renamed
since we don't parse them, hooray!)

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd the pci device
Ronald G. Minnich [Mon, 3 Mar 2014 06:46:40 +0000 (22:46 -0800)]
Add the pci device

This won't compile of course.
We need to work out our pci calls so we can write the spatches.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd a bit more info to #a/acpipretty
Ronald G. Minnich [Sat, 1 Mar 2014 07:06:59 +0000 (23:06 -0800)]
Add a bit more info to #a/acpipretty

It will let you get pretty prints to user mode at any point.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoRun the mpacpi code.
Ronald G. Minnich [Sat, 1 Mar 2014 06:39:29 +0000 (22:39 -0800)]
Run the mpacpi code.

This actually seems to print out reasonable configurations
for ACPI init.

We'll need to review what the current code does, by dumping
all the register sets it does, and then compare to what this
would do.

Also, add a file to #a,
acpipretty

which when you cat it prints out the acpi tables in a
pretty form. It's not complete. Note its hokey use of a static;
that was not my doing, and we need to undo it.

One good idea would be to merge apic.h and ioapic.h. All systems
we care about from now on will always have an ioapic.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoRestore call to apicinit.
Ronald G. Minnich [Sat, 1 Mar 2014 02:33:24 +0000 (18:33 -0800)]
Restore call to apicinit.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoSet up prototype for apicinit.
Ronald G. Minnich [Sat, 1 Mar 2014 02:31:05 +0000 (18:31 -0800)]
Set up prototype for apicinit.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoThis builds and boots.
Ronald G. Minnich [Sat, 1 Mar 2014 02:26:10 +0000 (18:26 -0800)]
This builds and boots.

if you ls '#a' you can see it parses ACPI.

Sorry for the huge code base churn. Our include files
really need some work however.

C compilers are fast now. I'd still push for just including
akaros.h and having it just include everything but that's me :-)

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoWell, it *almost* builds. What happened to core_id?
Ronald G. Minnich [Sat, 1 Mar 2014 02:13:56 +0000 (18:13 -0800)]
Well, it *almost* builds. What happened to core_id?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoSplits x86 arch for circular deps
Ronald G. Minnich [Sat, 1 Mar 2014 00:25:51 +0000 (16:25 -0800)]
Splits x86 arch for circular deps

Apic.h will need to include atomic.h, which needs arch (for irqs), which was also housing the coreid code that needs the LAPIC.  Hence the split.

Signed off and written by Barret  =)

5 years agoMore ioapic support, will it ever end.
Ronald G. Minnich [Fri, 28 Feb 2014 23:36:46 +0000 (15:36 -0800)]
More ioapic support, will it ever end.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoNot used any more
Ronald G. Minnich [Fri, 28 Feb 2014 22:14:00 +0000 (14:14 -0800)]
Not used any more

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoMore cleanup to prepare for ioapic support
Ronald G. Minnich [Fri, 28 Feb 2014 21:59:30 +0000 (13:59 -0800)]
More cleanup to prepare for ioapic support

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoPrepare to implement ioapic support
Ronald G. Minnich [Fri, 28 Feb 2014 21:42:05 +0000 (13:42 -0800)]
Prepare to implement ioapic support

first, remove unused stuff that does not ever seem to have worked.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoACPI now starts up.
Ronald G. Minnich [Fri, 28 Feb 2014 02:30:03 +0000 (18:30 -0800)]
ACPI now starts up.

This 'create your own fmt char' stuff is cute, but we're probably
blowing the stack out. It's not worth it, so I made it a
dumpGas
function. Which seems highly appropriate when discussing ACPI.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoACPI hanging
Ronald G. Minnich [Fri, 28 Feb 2014 02:07:39 +0000 (18:07 -0800)]
ACPI hanging

cat '#a' and watch the kernel lock up. NO ^g, no nothing. dead.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd ACPI support.
Ronald G. Minnich [Thu, 27 Feb 2014 23:40:40 +0000 (15:40 -0800)]
Add ACPI support.

From the shiny new GPL Plan 9 repo!

5 years agoMake hexdump only print the # bytes; add pahexdump; make syscall_table visible
Ronald G. Minnich [Tue, 25 Feb 2014 17:50:05 +0000 (09:50 -0800)]
Make hexdump only print the # bytes; add pahexdump; make syscall_table visible

hexdump would print too much; fix that.
pahexdump uses a physical address.
For VMs we need to make the syscall_table visible.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoUpdate gtag script
Barret Rhoden [Tue, 18 Feb 2014 19:43:31 +0000 (11:43 -0800)]
Update gtag script

Allows you to put symlinks in your .gtagsinclude file.  You might need a recent
version of global (like 6.2.10) to handle symlinks without silently failing.

5 years agoRemove unused UINT64 macro
Ronald G. Minnich [Tue, 18 Feb 2014 16:42:19 +0000 (08:42 -0800)]
Remove unused UINT64 macro

This is interfering with other definitions in user code.
If we ever want Ivy back we can conditionally include
ivy.h
based on a config variable or something, right?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoRemove emulate.o for now.
Ronald G. Minnich [Tue, 18 Feb 2014 16:13:46 +0000 (08:13 -0800)]
Remove emulate.o for now.

While we work on a different thing.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years ago2LS op for handling reflected faults
Barret Rhoden [Tue, 18 Feb 2014 02:00:42 +0000 (18:00 -0800)]
2LS op for handling reflected faults

The pthread one knows how to handle page faults on file-backed virtual
addresses.

I'm using the existing pthread syscall handling, so this sits in
pthread.c for now.  Most other 2LSs will do the same thing.  In the
future, we could have a uthread helper for it, but only if we redo some
of the other syscall stuff.  Due to the ev_q and how we track syscalls,
which is a 2LS decision, most of this will probably stay in the specific
2LS.

5 years agoAsync syscall helper
Barret Rhoden [Tue, 18 Feb 2014 01:59:40 +0000 (17:59 -0800)]
Async syscall helper

5 years agoSYS_populate_va (XCC)
Barret Rhoden [Tue, 18 Feb 2014 00:33:19 +0000 (16:33 -0800)]
SYS_populate_va (XCC)

Syscall for populating a range of virtual addresses.  This will usually
be used by PF handlers on file-backed VMRs, but it can be done for any
sort of user-controlled read-ahead that is desired.

If people want more control, like an FD interface that doesn't bother
with PTEs, let me know.

You need to reinstall your kernel headers.

5 years agoMM populate cleanup
Barret Rhoden [Tue, 18 Feb 2014 00:29:03 +0000 (16:29 -0800)]
MM populate cleanup

The main thing is the use of a history counter, which allows us to
detect changes in the VMRs, whether that change is just some prot
settings, or the existence of VMRs, etc.  While we can't reinspect the
vmr memory across an unlock-and-block, the history tells us it is safe
to keep following our previous instructions (keep mmaping a range of
pages).

5 years agoFault reflection and blocking page faults (XCC)
Barret Rhoden [Fri, 14 Feb 2014 23:21:43 +0000 (15:21 -0800)]
Fault reflection and blocking page faults (XCC)

Unhandled traps/faults will now be reflected back to userspace for MCPs
in uthread context.  SCPs and MCPs in vcore context retain the existing
behavior (death).

Hard page faults (that can't be serviced without blocking) for
file-backed VMRs will be reflected as unhandled PFs.  Userspace can tell
if the PF is on a valid VMR or not by checking the error code.

The RISCV stuff is all just stubs.  If I made any x86-like assumptions
that are unreasonable, let me know.

You need to reinstall your kernel headers.  Easiest way is to rebuild
your toolchain.

5 years agoEarly file mmaps are pinned and populated
Barret Rhoden [Thu, 13 Feb 2014 00:14:08 +0000 (16:14 -0800)]
Early file mmaps are pinned and populated

for memory, pinning is currently irrelevant, since the kernel never
revokes memory.  populating is just a performance tradeoff: soft-page
faults at the first access, vs wasting large blobs of RAM (like if Go
decides to mmap a huge contig region, but doesn't use it) and greater
initial mmap costs.  both of these might change in the future.

for files, we run into correctness issues with blocking in vcore context
(which we don't allow).  for code and data that are touched from vcore
context, we need them to be both pinned and populated.  pinning prevents
further removal, and population ensures we never take a hard page fault.

since there is a lot of libc magic at startup and no good way (yet) to
identify the file segments needed by vcore context, i just pin/populate
any file mmap that happens before uthread or application code takes
over.

the question is what to do about all of the other mmaps out there,
memory and file alike.  the current default *flags* are unpinned,
unpopulated. it's up to userspace to change this if they want.

for memory, that means that mallocs are not populated/pinned.  as
mentioned above, we don't revoke anonymous mmaps, so in essence the
default already is pinned, but unpopulated, even though the MAP_LOCKED
flag isn't set.  i'm okay with this, but we'll need to look at all sorts
of mallocs (like uthread structs, syscall structs, etc) if this ever
changes.

for files mmapped later, including dlopens, userspace will need to pin
and populate.  populating from blocking media is going to be pretty
expensive, so either way we want userspace to be in control.  but since
the existing norm is to use MAP_LOCKED, and MAP_POPULATE, it makes sense
to stick with those.

5 years agoAdd support for a crossed-native compiler build (XCC)
Kevin Klues [Sat, 15 Feb 2014 21:53:56 +0000 (13:53 -0800)]
Add support for a crossed-native compiler build (XCC)

5 years agoTrack the guest physical address used for VMs
Ronald G. Minnich [Fri, 14 Feb 2014 23:32:42 +0000 (15:32 -0800)]
Track the guest physical address used for VMs

It's pretty trivial to just track the guest pa in the
page struct, and it greatly simplifies VM code.

The alternatives are all ugly, as many of the extant VMs
out there show. We own this kernel, might as well make it easy.

pg_private was likely overcommited so I went this route.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoChanges to the kvm code
Ronald G. Minnich [Thu, 13 Feb 2014 02:06:44 +0000 (18:06 -0800)]
Changes to the kvm code

This allows us to build more than just the vm in this tree, so we can
test other kinds of VMs.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoBit ops/bit masks
Ronald G. Minnich [Thu, 13 Feb 2014 01:44:20 +0000 (17:44 -0800)]
Bit ops/bit masks

Wow, this turned into a saga.

What I'd like to do long term is figure out which of the gcc builtin ops
we could use and get rid of this nonsense, but that's a project for another
day. I did end up using __builtin_popcount, let's hope it actually works.
But by using that I got to NOT use some really awful stuff from the Linux
kernel that I never want to look at again.

This is reasonably good stuff from Linux, otherwise.

I'm turning off the vmx stuff for now because I'm doing some testing with Another
System and the two collide. The vm bits will no longer compile until some rework
is done on them anyway. Sorry.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoUpdate signals with proper default handlers and exit codes
Kevin Klues [Sat, 1 Feb 2014 05:42:38 +0000 (21:42 -0800)]
Update signals with proper default handlers and exit codes

5 years agoSlightly more working but we're back to not working.
Ronald G. Minnich [Tue, 11 Feb 2014 23:55:07 +0000 (15:55 -0800)]
Slightly more working but we're back to not working.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix VM capability check
Barret Rhoden [Tue, 11 Feb 2014 22:47:31 +0000 (14:47 -0800)]
Fix VM capability check

5 years agox86: Make reboot more robust
Barret Rhoden [Tue, 11 Feb 2014 22:47:03 +0000 (14:47 -0800)]
x86: Make reboot more robust

PCI reset method.

5 years agoRun a VM.
Ronald G. Minnich [Mon, 10 Feb 2014 21:36:50 +0000 (13:36 -0800)]
Run a VM.

This set of changes, along with the runvm script,
let you run a vm.

To tell it's running: run /runvm script and hit return
a LOT. At some point you'll see a message like
GO FOR IT!

If you look at the RIP that gets printed out, you'll see
it's 0000fffe, which means it ran all the xorl instructions
and hit the infinite loop.

I'll be removing all this printk stuff when things are further along.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoSCP pagefaults can block
Barret Rhoden [Sun, 9 Feb 2014 04:58:26 +0000 (20:58 -0800)]
SCP pagefaults can block

MCPs (even uthreads) still cannot have pagefault handlers that block.
For SCPs, the potential blocking point is treated similar to a yield,
such that if we block, then smp_idle() won't restart the SCP.

5 years agoFix elf loading 'current' management
Barret Rhoden [Sun, 9 Feb 2014 04:34:48 +0000 (20:34 -0800)]
Fix elf loading 'current' management

By not keeping current in sync with the cr3, and not properly switching
back, we expose ourselves to some issues.  Specifically, if we block
after improperly clearing current, we could come back with the
boot_pgdir (the one for current = 0), and then later fail to restore
that.  sys_proc_create caused this with KFS blocking.

5 years agoFixes bug on blocking during sys_exec()
Barret Rhoden [Sun, 9 Feb 2014 00:05:59 +0000 (16:05 -0800)]
Fixes bug on blocking during sys_exec()

Man, exec() is a pain.

5 years agoFixes TLB shootdown bug
Barret Rhoden [Sat, 8 Feb 2014 22:00:27 +0000 (14:00 -0800)]
Fixes TLB shootdown bug

Need to fix this crap permanently, soon!

5 years agoprint_user_ctx helper
Barret Rhoden [Sat, 8 Feb 2014 21:59:04 +0000 (13:59 -0800)]
print_user_ctx helper

Debugging.

5 years agommap() / page faults won't block while locking
Barret Rhoden [Fri, 7 Feb 2014 18:36:35 +0000 (10:36 -0800)]
mmap() / page faults won't block while locking

Rewrote the page filling parts in mm to not block while holding the VMR
lock.  HPF won't work correctly for blocking pm ops, since we return to
userspace, who then refaults over and over.

5 years agopm_load_page_nowait()
Barret Rhoden [Fri, 7 Feb 2014 06:02:10 +0000 (22:02 -0800)]
pm_load_page_nowait()

Will only return if the page cache has the page and is up to date.
Meaning, fill it, but don't block.

Some devices could have the ability to fill a page without blocking, so
we can add a PM op for that.

5 years agoPG_BUFFER set appropriately
Barret Rhoden [Wed, 5 Feb 2014 06:34:33 +0000 (22:34 -0800)]
PG_BUFFER set appropriately

Code that needs to use buffer heads sets the flag, not the page map.

5 years agoFix minor kthread bug
Barret Rhoden [Wed, 5 Feb 2014 06:33:37 +0000 (22:33 -0800)]
Fix minor kthread bug

If you block during initialization, you'll catch this.