akaros.git
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.

5 years agoDebugging: print_free_mem()
Barret Rhoden [Wed, 5 Feb 2014 02:46:39 +0000 (18:46 -0800)]
Debugging: print_free_mem()

Used this to track down some memory leaks.  Called via kfunc.

5 years agoMonitor commands for PM debugging
Barret Rhoden [Wed, 5 Feb 2014 02:26:30 +0000 (18:26 -0800)]
Monitor commands for PM debugging

fs pmflusher will spawn a never-ending ktask that will flush every VFS
PM every 5ms.

5 years agoPage cache rewrite, including page removal
Barret Rhoden [Tue, 4 Feb 2014 23:21:38 +0000 (15:21 -0800)]
Page cache rewrite, including page removal

Lightly tested.  pm_remove_contig() is made to handle all sorts of
races, but I haven't been able to test all of them.

If I screwed up something, like tracking dirty pages, we probably won't
notice til data magically disappears and programs silently fail.  It'd
be great to have someone review this, but that'll probably end up being
future-barret.

5 years agoSilences TLB proc-state warning
Barret Rhoden [Tue, 4 Feb 2014 22:35:09 +0000 (14:35 -0800)]
Silences TLB proc-state warning

TLB shootdowns are known (by me at least) to be screwed up.

5 years agoWritepage methods
Barret Rhoden [Tue, 4 Feb 2014 22:24:19 +0000 (14:24 -0800)]
Writepage methods

Dummy for now, and probably forever for these FSs.

5 years agoRadix change to return the slot address
Barret Rhoden [Tue, 4 Feb 2014 22:19:16 +0000 (14:19 -0800)]
Radix change to return the slot address

Needed for the upcoming page cache changes.

5 years agoFixes warning in coreboot.c
Barret Rhoden [Sun, 9 Feb 2014 07:22:22 +0000 (23:22 -0800)]
Fixes warning in coreboot.c

5 years agoMore debugging for VMs.
Ronald G. Minnich [Sat, 8 Feb 2014 01:47:04 +0000 (17:47 -0800)]
More debugging for VMs.

Remove some of the chattier bits.

Add a new file, kern/kfs/bin/POR, which is a representation of
the F (bios) segment with one instruction, HLT.

Fix an incorrect test in root which would not allow the kernel to
read files (the check for user addresses should be in the system call).

Still not quite there.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoThis gets us to a known emulation exit
Ronald G. Minnich [Fri, 7 Feb 2014 22:30:07 +0000 (14:30 -0800)]
This gets us to a known emulation exit

Before this change we got exception 8. Now we're
getting an exit for a reason we know.

Just what that reason is we don't know yet :-)

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoVMX sort of worked.
Ronald G. Minnich [Fri, 7 Feb 2014 21:47:03 +0000 (13:47 -0800)]
VMX sort of worked.

This actually does a vm enter, and catches the vmexit. No GPFs
or bad faults. We seem to have started a guest. But we'll see.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoChange the runvm script to be more ambitious
Ronald G. Minnich [Thu, 6 Feb 2014 16:20:54 +0000 (08:20 -0800)]
Change the runvm script to be more ambitious

not that it works, or anything. But it's closer.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd support for coreboot tables
Ronald G. Minnich [Thu, 6 Feb 2014 16:20:18 +0000 (08:20 -0800)]
Add support for coreboot tables

This is handy on chromebooks and other coreboot-based systems.
Not complete.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFurther progress on vmx
Ronald G. Minnich [Thu, 6 Feb 2014 16:18:37 +0000 (08:18 -0800)]
Further progress on vmx

we're failing on setting some gs/fs msrs

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix a simple bug in vmx support
Ronald G. Minnich [Wed, 5 Feb 2014 17:52:38 +0000 (09:52 -0800)]
Fix a simple bug in vmx support

It's not nice to try to run on core -1

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd defines needed for more modern PCI devices
Ronald G. Minnich [Wed, 5 Feb 2014 17:52:13 +0000 (09:52 -0800)]
Add defines needed for more modern PCI devices

In particular, MSI-x

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoGet rid of this, we can get a better one soon.
Ronald G. Minnich [Wed, 5 Feb 2014 03:16:47 +0000 (19:16 -0800)]
Get rid of this, we can get a better one soon.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agohlt is not a binary, 0x2001 bytes long
Ronald G. Minnich [Mon, 3 Feb 2014 16:59:15 +0000 (08:59 -0800)]
hlt is not a binary, 0x2001 bytes long

with the hlt at the end.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agomake hlt start at 0x2000
Ronald G. Minnich [Sun, 2 Feb 2014 17:33:33 +0000 (09:33 -0800)]
make hlt start at 0x2000

kvm does not like loading at 0.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd a hlt kernel
Ronald G. Minnich [Sun, 2 Feb 2014 17:04:38 +0000 (09:04 -0800)]
Add a hlt kernel

This is for virtualization. It's a kernel that does nothing but
hlt. I'm adding the binary because, well, it's 734 bytes,
so we don't need to build it.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix vm code
Ronald G. Minnich [Sat, 1 Feb 2014 13:54:32 +0000 (05:54 -0800)]
Fix vm code

OK, we're back where we were before the Cataclysm.

VM hardware is found and set up on my haswell laptop;
it will not be found and it will not break anything
on qemu.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoClean up the msr command.
Ronald G. Minnich [Fri, 31 Jan 2014 22:43:26 +0000 (14:43 -0800)]
Clean up the msr command.

With the smp fixes things seem to be better. Although, in
QEMU, I still can't set 3a!

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoUpdate pthread futex_waiti() to unlock after yield
Kevin Klues [Fri, 31 Jan 2014 22:00:35 +0000 (14:00 -0800)]
Update pthread futex_waiti() to unlock after yield

The previous version of the futex code was adopted from the linux parlib
code, which doesn't have to worry about uthreads spuriously dropping
into vcore context while not holding a pdr lock.  Without this change,
it was possible for a vcore to spin indefinitely on a futex_wait() while
the uthread it was trying to wake had not actually yielded yet (and
couldn't because it was trying to yield on the very same vcore that was
spinning trying to wake it).

With this change we now have to hold the futex lock a little longer, but
it is necessary for correctness.  In the future, we will probably want
to use some sort of hashtable to maintain one lock per futex, rather
than a global futex lock, and this will help alleviate some of these
costs.

5 years agox86: Fixes smp_call_function
Barret Rhoden [Fri, 31 Jan 2014 21:54:49 +0000 (13:54 -0800)]
x86: Fixes smp_call_function

This broke back when I added multiple IRQ handlers to a given vector.
Old handler/data pairs were never being removed.

5 years agoFixes vendor_id
Barret Rhoden [Fri, 31 Jan 2014 21:22:38 +0000 (13:22 -0800)]
Fixes vendor_id

Need to return something, compiler warning.

5 years agoFix up the msr command to run on all cores
Ronald G. Minnich [Fri, 31 Jan 2014 20:32:51 +0000 (12:32 -0800)]
Fix up the msr command to run on all cores

save it now behaves very badly, usually causing traps.

Barret?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agosys_readlink works.
Ronald G. Minnich [Fri, 31 Jan 2014 20:11:21 +0000 (12:11 -0800)]
sys_readlink works.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFix up sys*stat
Ronald G. Minnich [Fri, 31 Jan 2014 20:02:39 +0000 (12:02 -0800)]
Fix up sys*stat

I'd rather not go into how big a mess I made of these
functions. It's all better now.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoCreate akaros wrappers for sysstat and sysfstat
Ronald G. Minnich [Fri, 31 Jan 2014 16:50:38 +0000 (08:50 -0800)]
Create akaros wrappers for sysstat and sysfstat

We'll need this as we need to see the raw dir struct
for sys_readlink.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoProperly pass S_IFLINK back
Ronald G. Minnich [Fri, 31 Jan 2014 16:25:27 +0000 (08:25 -0800)]
Properly pass S_IFLINK back

If DMSYMLINK is set, convert it to S_IFLINK.
We now see proper stat for files served by (e.g.) ufs.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd the inferno mkroot script
Ronald G. Minnich [Fri, 31 Jan 2014 16:18:39 +0000 (08:18 -0800)]
Add the inferno mkroot script

I used this to build the code currently in kern/drivers/dev/root.c

It's handy for reference. It's also no longer right for the structs
in there.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd the e1000 kbuild
Ronald G. Minnich [Fri, 31 Jan 2014 16:17:48 +0000 (08:17 -0800)]
Add the e1000 kbuild

This is the gpxe driver. We'll either finish it or dump it,
although 'dump it' now seems the likelier choice

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoPrint the name of the device as well as the pointers
Ronald G. Minnich [Fri, 31 Jan 2014 16:17:17 +0000 (08:17 -0800)]
Print the name of the device as well as the pointers

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd DMSYMLINK
Ronald G. Minnich [Fri, 31 Jan 2014 16:16:25 +0000 (08:16 -0800)]
Add DMSYMLINK

the value is compatible with 9p2000.u

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoadd a command to read and write msrs
Ronald G. Minnich [Fri, 31 Jan 2014 16:15:51 +0000 (08:15 -0800)]
add a command to read and write msrs

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agovmx: don't try to do vmx on cpus that don't do vmx.
Ronald G. Minnich [Fri, 31 Jan 2014 15:56:49 +0000 (07:56 -0800)]
vmx: don't try to do vmx on cpus that don't do vmx.

Which seems obvious, doesn't it?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoAdd a function to return vendor_id string
Ronald G. Minnich [Fri, 31 Jan 2014 15:55:32 +0000 (07:55 -0800)]
Add a function to return vendor_id string

Needed so we can figure out what we are.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFixes krealloc()
Barret Rhoden [Thu, 30 Jan 2014 23:57:46 +0000 (15:57 -0800)]
Fixes krealloc()

Two things:

1) It was assuming the memory of buf was from a slab.  For large
regions, it's from contiguous memory.

2) It was assuming that the size of the memory from whatever source
(slab or pages) was for the entire buffer.  We need room for the kmalloc
tag.

Something like this happened: a krealloc to 8192 thought that it had
8192 already, even though it was just shy of 8192.  The memmove
(probably) clobbered the slab allocator bufctl of the object, which is
stored right after the slab object.  Random bytes then were interpreted
as a pointer, which caused a GPF (the address was non-canonical).

Man, krealloc for large regions has to be terribly slow.  The only thing
worse than our contiguous page allocator is calling the contiguous page
allocator repeatedly.

5 years agoAdds rootwstat, for chmod
Barret Rhoden [Thu, 30 Jan 2014 20:21:34 +0000 (12:21 -0800)]
Adds rootwstat, for chmod

Plus some other chmod tidbits.

I also have a new busybox config, with chmod built in.  You'll need to
copy it to your .config, rebuild busybox, and load it in KFS.

5 years agoTest script for the vm device.
Ronald G. Minnich [Thu, 30 Jan 2014 21:46:00 +0000 (13:46 -0800)]
Test script for the vm device.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agochmod() touchups
Barret Rhoden [Thu, 30 Jan 2014 19:13:23 +0000 (11:13 -0800)]
chmod() touchups

Mode sanitization, t_path memory, and syswstat doesn't throw errors.

5 years agoSample chmod implementation.
Ronald G. Minnich [Thu, 30 Jan 2014 18:41:32 +0000 (10:41 -0800)]
Sample chmod implementation.

You'll need this sort of thing for rename, chown, etc.
Anything that does a wstat.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoProperly extract errno from p9 rpc; fix incorrect mkdir error
Ronald G. Minnich [Thu, 30 Jan 2014 18:08:04 +0000 (10:08 -0800)]
Properly extract errno from p9 rpc; fix incorrect mkdir error

mkdir /mnt/tmp/xxx would fail with the wrong errno (EEXIST)
because we could not properly get errno from the Plan 9 RPC.

I've fixed my version of go9p (github.com/rminnich/go9p) to
return Rerror strings in the form 'XXXX error message'
(space after XXXX is important) where XXXX is the hex-encoded
errno (this is how I did it for the original Linux 9p in 1998).
This format has the advantage of being all text; later implementations
(e.g. 9p2000.[ul]) break the rule and embed binary data in the string
and were a backward step IMHO.

I've fixed Akaros 9p parsing to look for a string at least 5 bytes long,
with the first 4 bytes being hex digits, and if that is the case to
set_errno using those digits.

I added get_errno to allow code to save the current errno value.

Finally, in the namec create case, I save errno as well as errstr
and restore them on the errpath.

mkdir /mnt/tmp/xxx now returns the correct errno/error message.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoDevroot fixup
Barret Rhoden [Thu, 30 Jan 2014 03:08:31 +0000 (19:08 -0800)]
Devroot fixup

There's a lot of changes, especially with gen.  There are also some bug
fixes that aren't as big of a deal.  Gen is usually the hard part.

5 years agoQTFILE isn't 0...
Barret Rhoden [Thu, 30 Jan 2014 02:37:40 +0000 (18:37 -0800)]
QTFILE isn't 0...

This might cause some bugs, but I can't stand when we use the value 0
for a bit.  You can't tell the difference between no type and QTFILE.

5 years agoFixes remove bug
Barret Rhoden [Wed, 29 Jan 2014 23:48:20 +0000 (15:48 -0800)]
Fixes remove bug

Inferno has this annoying habit of assuming a dev type == 0 means "do a
noop on close".  Devroot used to be the first in the devtab, but we
can't guarantee that since devtab is built by the linker.

5 years agoFixes mkdir
Barret Rhoden [Wed, 29 Jan 2014 23:45:16 +0000 (15:45 -0800)]
Fixes mkdir

I think.  We should be passing DMDIR in the perms argument.  Also, this
tries to catch issues with nasty "mode"/permissions from userspace.

5 years agoFile creation working but ... broken
Ronald G. Minnich [Wed, 29 Jan 2014 21:48:43 +0000 (13:48 -0800)]
File creation working but ... broken

try cp /root '#r/srv/root'

The error is
rootcreate: c 0xffff80007fff8850, name root, omode 1101, perm 81ed
kernel warning at kern/src/ns/sysfile.c:113, from core 0: Trunc mode issue: mode 1, mode minus trunc 1, chan mode 0

So somehow the chan mode is getting set wrong.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agomkdir works.
Ronald G. Minnich [Wed, 29 Jan 2014 20:51:15 +0000 (12:51 -0800)]
mkdir works.

Was checking in the wrong place.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoFinally! at least the hierarchy is right
Ronald G. Minnich [Wed, 29 Jan 2014 20:37:50 +0000 (12:37 -0800)]
Finally! at least the hierarchy is right

There were some issues due to the changed use of this code.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
5 years agoLindent pass
Barret Rhoden [Wed, 29 Jan 2014 20:14:58 +0000 (12:14 -0800)]
Lindent pass

Downside: it messes up git's history for specific lines.

Here's a useful command (from the last time we did this):

git diff --name-status master..HEAD | grep '^A' | cut -f 2 | grep
'^kern' | grep -v Kbuild | xargs ./scripts/lindent

5 years agoCloser.
Ronald G. Minnich [Wed, 29 Jan 2014 15:57:43 +0000 (07:57 -0800)]
Closer.

File creation kind of works. Turns out the ptr struct member
in the table is the child pointer for directories, which I
should have realized. The translation from NIX to Inferno
keeps bollixing me up.

No more kernel panics, things seem to be right, but
mkdir #r/srv/x
cat #r/srv
shows x there, but 'ls '#r/srv' gets an error that x is not
there.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>