Barret Rhoden [Mon, 9 Feb 2015 19:10:31 +0000 (14:10 -0500)]
Adds epoch_*sec() helpers
The number of sec/msec/usec/nsec since 1 Jan 1970.
Barret Rhoden [Fri, 6 Feb 2015 16:44:06 +0000 (11:44 -0500)]
Adds warn_on() and warn_on_once()
warn_on() is check(), but named more clearly.
Barret Rhoden [Thu, 5 Feb 2015 20:06:20 +0000 (15:06 -0500)]
Struct ether accesses netif anonymously
To fix any out-of-tree drivers, apply the spatch remove_netif.cocci.
After spatching, I modified ip.h manually.
Barret Rhoden [Thu, 5 Feb 2015 15:35:38 +0000 (10:35 -0500)]
Linux workqueue wrappers
Dropped them in with the BSD taskqueues.
Barret Rhoden [Wed, 4 Feb 2015 20:14:44 +0000 (15:14 -0500)]
Updates spatch-me.sh
Sometimes you need to pass extra arguments to spatch.
Barret Rhoden [Wed, 4 Feb 2015 20:01:32 +0000 (15:01 -0500)]
Linux's MMIO helpers
Similar to read_mmreg32, but they cover all the bytes. Need to see if void* or
uintptr_t is better.
Barret Rhoden [Wed, 4 Feb 2015 17:10:00 +0000 (12:10 -0500)]
Static initializers for semaphores
Similar to the SPINLOCK_INITIALIZERS. I thought it'd be more of a pain, but
since Linux did it, then so can we.
Barret Rhoden [Wed, 4 Feb 2015 16:30:24 +0000 (11:30 -0500)]
Lite VM uses Linux's lists
And a large chunk of Akaros now includes it, thanks to dependencies.
Barret Rhoden [Wed, 4 Feb 2015 16:25:25 +0000 (11:25 -0500)]
Adds Linux's list.h
struct list_head and hlist, from commit
bc208e0ee0f4.
Linux's lists also use LIST_HEAD, like the BSD lists. Well, since the
two kids can't get along, then no one gets LIST_HEAD.
Linux list users that normally use LIST_HEAD will now use
LINUX_LIST_HEAD. Otherwise, list.h is the same as usual.
Barret Rhoden [Wed, 4 Feb 2015 16:18:52 +0000 (11:18 -0500)]
Renames BSD's LIST_* to BSD_LIST_*
Linux's list.h also has a LIST_HEAD, and Akaros only has one user of the BSD
LIST_.
Incidentally, newer man pages for sys/queue.h (try man queue) don't have SLISTS
or the STAILQs anymore. It's still in the header, but not part of the manual.
Perhaps they are cutting things out?
Barret Rhoden [Wed, 4 Feb 2015 16:18:10 +0000 (11:18 -0500)]
Lite VM fakes struct list_head
Merging in Linux's lists shortly.
Barret Rhoden [Wed, 4 Feb 2015 16:08:29 +0000 (11:08 -0500)]
Removes listable
Unused code.
Barret Rhoden [Tue, 3 Feb 2015 23:27:15 +0000 (18:27 -0500)]
Endian typedefs and #defines
The typedefs are similar to Linux's, minus the static analysis good-stuff.
The __.*ENDIAN are used in BNX2X and other things. I noticed the old BXE
driver also dealt with the LITTLE_ENDIAN -> __LITTLE_ENDIAN conversions.
Barret Rhoden [Fri, 16 Jan 2015 00:12:39 +0000 (16:12 -0800)]
Bus space barriers (XCC)
On x86, a LOCK will flush the write buffers. This is what BSD does under the
hood for their bus_space_barriers. I don't know when the LOCKs should be used
compared to lfence/sfence/mfence.
Technically, these are kernel headers we're messing with (the membar), but
don't worry about it.
Ron Minnich [Sat, 17 Jan 2015 08:42:58 +0000 (00:42 -0800)]
net: add LRO feature
Needed for lots of things, so let's just add it in.
is TSO the same as LRO? I did not think so but ... Andrew?
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Barret Rhoden [Wed, 28 Jan 2015 22:04:05 +0000 (17:04 -0500)]
kthread_usleep()
It's the guts of what sys_block did: blocks a kthread for X usec. The classic
issue is where we run the alarm handler and where to restart the kthread.
Barret Rhoden [Thu, 26 Feb 2015 16:25:58 +0000 (11:25 -0500)]
PCI/MSI: pci_msix_init()
Drivers that want to use MSIX should call pci_msix_init() during reset (which
is at boot time). If they do this, they can register_irq() at attach time,
which is after booting. Otherwise, they must register_irq() during reset.
Barret Rhoden [Mon, 23 Feb 2015 14:46:19 +0000 (09:46 -0500)]
PCI/MSI: debug helper
Dumps the device's MSIX table.
Barret Rhoden [Thu, 19 Feb 2015 18:44:29 +0000 (13:44 -0500)]
PCI: use Linux's PCI register #defines
We were using some of them. Now we use a lot more.
Barret Rhoden [Tue, 17 Feb 2015 21:03:46 +0000 (16:03 -0500)]
PCI: fixups and helpers
The previous membar helper might have returned nonzero for a BAR that
was the second half of a 64 bit BAR.
There's a helper for mmapping a BAR, which can clean up driver code.
Barret Rhoden [Mon, 9 Feb 2015 22:21:45 +0000 (17:21 -0500)]
PCI: helper to make a TBDF from a pcidev
All of the PCI devices need to do this, and it'll be easier on an
spatch.
Barret Rhoden [Mon, 9 Feb 2015 21:39:57 +0000 (16:39 -0500)]
PCI: adds device-specific data pointer
This is useful, even if we don't use it in the short term. Both BSD and
Linux have something similar (possibly with an intermediate device).
Barret Rhoden [Mon, 26 Jan 2015 18:40:42 +0000 (13:40 -0500)]
PCI helper find_cap
Adds a find_cap helper, similar to the BSD one.
Barret Rhoden [Fri, 23 Jan 2015 20:42:08 +0000 (15:42 -0500)]
Adds PCI config dump helper
You can probably do this from userspace too, via devarch's PIO hooks.
Barret Rhoden [Fri, 23 Jan 2015 00:03:55 +0000 (19:03 -0500)]
Adds PCI iobar helper
This stuff is a bit clunky; you need to check after each pci_get_whatever().
Not sure if there's a nicer way, esp given we have a bunch of device code from
2-3 OSs in here.
Barret Rhoden [Wed, 21 Jan 2015 17:18:58 +0000 (12:18 -0500)]
Clarifies alarm usage
Alarms can run in IRQ context or RKM context. The choice is made when the
waiter is initialized.
Barret Rhoden [Thu, 15 Jan 2015 23:49:17 +0000 (15:49 -0800)]
PCI: helpers for BSD
Including CARDBUS versions!
Barret Rhoden [Thu, 15 Jan 2015 23:29:08 +0000 (15:29 -0800)]
Makes bcopy part of string.h
So it is accessible outside of string.c.
Barret Rhoden [Wed, 14 Jan 2015 23:24:32 +0000 (15:24 -0800)]
BSD taskqueues via KMSGs
BSD taskqueues are kernel threads that execute work asynchronously. Check out
http://www.freebsd.org/cgi/man.cgi?query=taskqueue for more info.
We could implement them with ktasks that sleep on queues, and pump the tasks
into the queues. But the tasks are basically slimmed down kernel messages, so
we can just send a message.
In the future, we may want better support or more taskqueue behaviors, both in
BSD code and more generally throughout Akaros. We can always reimplement
taskqueues in a more appropriate manner at that time.
Barret Rhoden [Wed, 14 Jan 2015 22:33:07 +0000 (14:33 -0800)]
Useful script for spatching
Spatch gets cranky if you give it multiple files at a time.
Godfrey van der Linden [Tue, 17 Feb 2015 22:02:35 +0000 (14:02 -0800)]
Return bool from reset_alarm_* apis.
In the presence of kernel pre-emption or multi-core scheduling leak free
clean up is a challenge. This idiom is the best I've found but it must
have support from the underlying apis.
Say a hot plugging device driver is dynamically unloadable and it has a
kreffed context and after a command completes we now have scheduled the
next I/O and have to reset the timeout alarm.
struct context {
bool is_active; // Set to false on unloading
}
void start_next_io()
{
[snipped]
// Reschedule an alarm
// Always take a reference for the alarm function’s context
kref_get(context, 1);
if (reset_alarm_abs(...)) {
// We caught the alarm in time, i.e. the reference from the original
// set_awaiter_* is still good, clear our reference.
kref_put(context);
}
[snipped]
}
void alarm_func(context)
{
if (context->is_active) { // Various atomic ops can go here
// Do work referring to context
}
kref_put(context); // Potentially releasing the context now
}
Ron Minnich [Fri, 27 Feb 2015 16:06:37 +0000 (08:06 -0800)]
Emergency commit to fix a gitastrophe
Somehow 10 days ago I was on the wrong branch, sorry.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Ron Minnich [Wed, 18 Feb 2015 16:26:08 +0000 (08:26 -0800)]
Barret pointed out that the inclusion of regions was a mistake.
Also, initial non-working code to enable vmx. It's wrong.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Ron Minnich [Tue, 17 Feb 2015 18:13:20 +0000 (10:13 -0800)]
Restart with just vmm rebased on master.
Much cleaner, the bhyve stuff was interfering.
Next step: fix vm to handle the vmm bits.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Barret Rhoden [Mon, 16 Feb 2015 16:05:18 +0000 (11:05 -0500)]
Finishes removal of x86_32 (XCC)
You won't be able to select the a non-64 bit kernel from Kconfig. The
symbol CONFIG_X86_64 is still around, since some code we port from other
OSs might expect it.
I didn't mess around much with gcc/glibc. We're lucky that all works.
But you won't be able to ask our build system to make a 32 bit
toolchain.
I tested a cross-compiler rebuild and get_html. I didn't test the
jenkins change.
Godfrey van der Linden [Sun, 15 Feb 2015 03:28:06 +0000 (19:28 -0800)]
Fix error & poperror macros, update set_errstr.
Canonicalise the two brace bracketed error handling macros. All sorts of
odd things can happen when a macro has just bare braces. The do {}
while(false) idiom makes them into canonical C statements.
Add const to set_errstr fmt argument. Then we can used const char* error
strings, and compile without error.
Godfrey van der Linden [Sun, 15 Feb 2015 03:35:34 +0000 (19:35 -0800)]
Fix kprof attach leaks.
When you perform 'ls -lR \#K' on a system that hasn't bound the kprof
device it repeatedly attaches/closes the #K device. This leaks
cpu_buffers (not a big issue, alloc_cpu_buffers defends itself),
oprof_alarms and kprof.systrace queue.
This fix is not ideal, but it only allocates the resources once, I
didn't want to implement an atomic execute once when I don't understand
the code in detail.
Godfrey van der Linden [Sat, 14 Feb 2015 02:31:32 +0000 (18:31 -0800)]
Add placeholder handling to devgen.
The current devgen assumes that the dirtab is static, which until now it
has been. However, the gen functions are allowed to return 0 if the
entry exists for that 's' but shouldn't be active.
Overload dirtab->qid.vers to indicate if the dirtab entry is inactive
and return 0 if vers == -1.
Godfrey van der Linden [Sat, 14 Feb 2015 02:28:22 +0000 (18:28 -0800)]
Update phony targets for tests Makefile.
The toplevel make file now calls install and uninstall rather than the
kfs based phony targets.
Godfrey van der Linden [Sat, 14 Feb 2015 02:23:14 +0000 (18:23 -0800)]
Minor formatting changes
Remove trailing whitespace in cpu_buffer.c
and:
80char comment rewrap in dev/vm.c
Godfrey van der Linden [Sat, 14 Feb 2015 02:20:15 +0000 (18:20 -0800)]
Fix potential compile warning.
Godfrey van der Linden [Sat, 14 Feb 2015 02:09:24 +0000 (18:09 -0800)]
De-copy-and-paste the devip gen functions.
Simplified and removed some of the common copy and pasted code from the
gen functions of the devip '#I' device.
Ron Minnich [Fri, 13 Feb 2015 23:31:52 +0000 (15:31 -0800)]
remove 32 bit and uses of it.
This is a first stab at getting out of the 32-bit architecture business.
There's lots more to do but you have to start somewhere, and I'm tired of
tags finding the wrong symbols because of these leftover bits of code
we don't compile any more.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Kevin Klues [Wed, 4 Feb 2015 17:30:11 +0000 (09:30 -0800)]
Add implementation of sem_timedwait.
Ron Minnich [Tue, 3 Feb 2015 22:56:57 +0000 (14:56 -0800)]
Use the small id pool for tags.
I benched the old way against the small id pool and the small id pool is
at least 16x (!) faster. I tested this by running go test std, which
pounds on devmnt pretty well.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Barret Rhoden [Fri, 30 Jan 2015 02:25:42 +0000 (21:25 -0500)]
Fixes pcpu lock tracer
Core 0 was saying it was ready to trace locks before it allocated the
buffer. That's probably been broken for a while!
Thanks to Godfrey for his commit, which made me test the lock tracer.
Godfrey van der Linden [Thu, 29 Jan 2015 17:17:32 +0000 (09:17 -0800)]
Fix void* arithmetic bug. Add dassert facility.
In C the behaviour of arthmatic on void * pointers is undefined. GCC has
a language extension that equates it with a uint8_t, but other compilers
don't. Change the tr_buf to a unsigned char to define byte arithmatic.
Split the __get_tr_slot into two adding __get_tr_slot_overwrite for the
version that masks the slot down to a limited range.
Add dassert() for assertions that are only optionally compiled in. Used
at the moment to check index is in range in __get_tr_slot.
Barret Rhoden [Thu, 29 Jan 2015 02:38:47 +0000 (21:38 -0500)]
Adds a test for the u16 pool
Misc complaints about the testing framework:
- ASSERT_M only lets you have a string, not a format string.
- put doesn't return, so we have a "loud" test for that. alternatively,
we could have put panic, but then we couldn't test it at all. and i
don't particularly want it to have a return value.
- ASSERT_M just blindly returns. we're leaking memory.
Barret Rhoden [Wed, 28 Jan 2015 18:22:09 +0000 (13:22 -0500)]
Cleans up smallpool, adds locking
I tried various CAS schemes, but they don't work very well. Using a
history counter, I was able to make get/pop lock-free, but not put/push.
The issue was that the pusher needs to have 'v' written by the time it
decrements, but it can't be sure of its slot when until decrement
succeeds. It would work with only one pusher, or with an additional
'ready' flag per slot, similar to BCQs.
Barret Rhoden [Tue, 27 Jan 2015 18:03:24 +0000 (13:03 -0500)]
Lindent + comments
We should be able to do something atomically, but it'll require some
rewriting and using a history counter. Maybe.
Barret Rhoden [Wed, 28 Jan 2015 23:59:39 +0000 (18:59 -0500)]
Adds some programs to busybox's default
Hexdump etc. All courtesy of Drew.
Rebuild BB for it to take effect.
Barret Rhoden [Wed, 28 Jan 2015 23:58:34 +0000 (18:58 -0500)]
Busybox will rebuild when defconfig changes
Previously, you'd have to make clean, then make.
Barret Rhoden [Tue, 27 Jan 2015 16:27:22 +0000 (11:27 -0500)]
Removes debugging code
Accidentally added in aaa7e62.
Ron Minnich [Mon, 26 Jan 2015 23:40:55 +0000 (15:40 -0800)]
For your inspection: small id pool
This is a stack and it's about 30 times faster than the current
tag allocator used in devmnt (yes, 30).
It could be used for any id pool that's less than 64K, including
VPID and the 16-bit tags used in VMID.
I doubt I need to use the first element of the array as a top of
stack, that's a little too cute maybe, but not returning element
0 is a good idea, that is reserved in many situation SUCH AS
vpid and so on.
Can we do some sort of ACAS on the TOS in such a way that it never
increments beyond 0xfffe?
Comments appreciated.
Signed-off-by: Ron Minnich <rminnich@google.com>
Barret Rhoden [Fri, 23 Jan 2015 14:37:48 +0000 (09:37 -0500)]
Busybox build infrastructure (BB)
You can now build and install busybox from within the kernel repo.
$ cd tools/apps/busybox
$ make [x86_64 | riscv] // default x86_64
$ profit
As new patches are added, you'll just need to make. Busybox is small
enough that I just trash the old one and rebuild whenever there is a
change. If there is a new CC, you may need to make clean.
Barret Rhoden [Fri, 23 Jan 2015 02:08:03 +0000 (21:08 -0500)]
Removes KFS symlinks
They will be installed by a busybox install target shortly.
Barret Rhoden [Thu, 22 Jan 2015 23:58:01 +0000 (18:58 -0500)]
Slightly more useful error() in validname()
This is popping up with some memory corruptions, and %q doesn't do anything.
Ron Minnich [Thu, 22 Jan 2015 01:41:51 +0000 (17:41 -0800)]
Clean up the debug printing
change %ud to %u, add a trailing space so it's easier to read.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Ron Minnich [Thu, 22 Jan 2015 01:20:35 +0000 (17:20 -0800)]
Remove a moron error in test/cs.c
in my anxiety to get better error messages I made an unholy mess
of rwalk and managed to introduce a free bug.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Godfrey van der Linden [Tue, 20 Jan 2015 22:16:19 +0000 (14:16 -0800)]
Enable __builtin_clz for all architectures.
According to Andrew Waterman, gcc provides a default implementation that
is efficient for any RTL that does not support support the command
directly. I suspect that LLVM/clang is similar, though we can worry
about that in the future.
Barret Rhoden [Tue, 20 Jan 2015 20:50:53 +0000 (15:50 -0500)]
Removes the option ENABLE_MP_TABLES
Everyone should be saying 'Y' at this point, so much so that I don't want to
support the old style. ENABLE_MP_TABLES was also a catch-all for anything
related to mptables, acpi, msi-x, etc.
Godfrey van der Linden [Thu, 15 Jan 2015 18:42:34 +0000 (10:42 -0800)]
Use builtin_clz log2 for x86 architectures.
Also fix LOG2_UP which would fail if n > 2^32. (1 << (uintptr_t) 33) ==
0 unfortunately, the << operator does not promote the one to uint64_t.
Then I booted the kernel using both old and new versions and paniced if
they didn't agree. This code has also been tested using a clang compiler
on x86_64 using the following loop in a standalone app.
for (i = 0; i < 64; i++) {
uintptr_t v = (uintptr_t) 1 << i;
assert(new_log2_up(v) == old_log2_up(v));
assert(new_log2_up(v-1) == old_log2_up(v-1));
assert(new_log2_up(v+1) == old_log2_up(v+1));
assert(new_log2_down(v) == old_log2_down(v));
assert(new_log2_down(v-1) == old_log2_down(v-1));
assert(new_log2_down(v+1) == old_log2_down(v+1));
}
Barret Rhoden [Tue, 20 Jan 2015 02:26:47 +0000 (21:26 -0500)]
Fixes busybox perror patch (BB)
The old patch to BB was buggy. fputs() now sets errno internally in
some cases, which is legal. I shouldn't have checked errno blindly
without checking the ret of fputs().
You'll need to repatch and build busybox. The 'easiest' way is to
download the tarball, extract the old echo.c, and reapply the patch.
From the directory containing busybox-1.17.3:
$ wget http://www.busybox.net/downloads/busybox-1.17.3.tar.bz2
$ tar -xjf busybox-1.17.3.tar.bz2 busybox-1.17.3/coreutils/echo.c
$ patch -p1 < $AKAROS_REPO/tools/patches/busybox/bb-echo-perror.patch
$ cd busybox-1.17.3 ; make
$ cp busybox_unstripped $AKAROS_REPO/kern/kfs/bin/busybox
Barret Rhoden [Mon, 19 Jan 2015 23:38:01 +0000 (18:38 -0500)]
Fixes O_CLOEXEC
O_CLOEXEC, the open flag from glibc (sometimes called the mode in 9ns)
was being saved as a struct file f_flag, instead of on the file
descriptor. Likewise, fcntl() was doing the same.
To deal with the races that O_CLOEXEC was made for (and which make the
fcntl SETFD option arguably useless) we need to set FD_CLOEXEC
atomically when the FD is inserted into the FD table. This required
work with both VFS and 9ns.
I'm not sure how inferno/9ns actually handled CLOEXEC, since newfd()
doesn't take any flags.
Barret Rhoden [Mon, 19 Jan 2015 23:36:07 +0000 (18:36 -0500)]
Fixes kernel argument checking in "m"
Need at least one argument before dereferencing.
Also, debugcmd is pretty handy.
Barret Rhoden [Mon, 19 Jan 2015 22:09:34 +0000 (17:09 -0500)]
Fixes "m"
Need to pass all of the args as one argument to echo, otherwise they
could be sent one at a time to the kernel. I've had this happen when
calling m from a script.
Kevin Klues [Sat, 17 Jan 2015 18:28:56 +0000 (10:28 -0800)]
__nlink_t is 64 bits in stat struct, not 32
Looking at the changelog, it's been this way since 2000.
From glibc-2.19/Changelog.11
2000-06-16 Jes Sorensen <jes@linuxcare.com>
...
* sysdeps/unix/sysv/linux/ia64/bits/types.h: Make __ino_t,
__nlink_t and __blkcnt_t 64 bit to accomodate new kernel stat data
structure.
...
My hunch is that things got reorganized such that previously the
default typedef for __nlink_t was 32 bits, while a linux specific one
was 64 bit. It appears they have now made the default one 64 bit as
well.
Kevin Klues [Fri, 16 Jan 2015 23:22:35 +0000 (15:22 -0800)]
Update ifconfig for c99 at berkeley
c99 is a 32 core ivybridge machine accessible the same way as c89
Barret Rhoden [Thu, 15 Jan 2015 18:03:13 +0000 (10:03 -0800)]
Fixes glibc stage 2 pthread errors (XCC)
On many, but not all, Akaros installations, the toolchain build would fail in
stage 2 of glibc, during the nss build.
The failure was due to the make system clobbering Parlib's pthread.h with the
one from glibc-2.19/include/pthread.h. Not all systems would do the install,
which is rather mystifying. It looks like the build system would see pthread.h
was needed, and then generate dependencies on both ../include/pthread.h and on
$TOOLCHAIN_SYSROOT/usr/include/pthread.h (the latter is Akaros's). Some
systems would install include/pthread.h into the toolchain sysroot. Others
would not.
By removing include/pthread.h, the dependency on that file was never created,
and thus never attempted to be installed.
Old dependency info:
$ grep -r pthread.h x86_64-ucb-akaros-glibc-stage2-builddir/
...
x86_64-ucb-akaros-glibc-stage2-builddir/nss/db-init.os.d: ../nscd/nscd.h ../include/pthread.h \
x86_64-ucb-akaros-glibc-stage2-builddir/nss/db-init.os.d: $TOOLCHAIN_INSTALL/x86_64-ucb-akaros/sysroot/usr/include/pthread.h
...
Old dependency info:
$ grep -r pthread.h x86_64-ucb-akaros-glibc-stage2-builddir/
...
x86_64-ucb-akaros-glibc-stage2-builddir/nss/db-init.os.d: $TOOLCHAIN_INSTALL/x86_64-ucb-akaros/sysroot/usr/include/pthread.h
...
You'll need to make clean your toolchain and rebuild.
Godfrey van der Linden [Wed, 14 Jan 2015 21:36:15 +0000 (13:36 -0800)]
Ignore all cscope files.
Barret Rhoden [Wed, 14 Jan 2015 21:21:26 +0000 (13:21 -0800)]
Fixes x86 spinlocks with new gcc
Newer versions of GCC screw up our ancient spinlocks.
The issue was that "m" can include (%rax) implicitly, and GCC does not give us
a way to tell it to not use that register. Previously, putting "eax" in the
clobber list was enough (maybe!) to tell GCC to not mess with it. But it
really only tells GCC not to use it afterwards. There is no way to tell it to
not use it during. And we don't know which register they picked. The fix is
to use a dummy variable, to force GCC to give us a register to play with.
To make things fun to track down, the location of the KMSG immediate lock in
pcpui mattered for this, since the clobber of rax's lower byte made a
diffference with how this would show up.
If we have any other inline asm with "m" in the input:output, we'll need to
take a look.
For a similar horror story, check out:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58758
Note the answer was basically "don't use inline asm."
Barret Rhoden [Mon, 12 Jan 2015 17:13:45 +0000 (12:13 -0500)]
Fixes smp_call_function (again)
2e856c58 was wrong; past-barret was right. It's a checklist, so you tick off
items as they are done. The confusing part when debugging was that the IRQ
handlers were firing, but were not downing the checklist.
The root of the problem was that the SMP_CALL IRQ numbers didn't line up with
the "clever" initialization routine used for the handler wrappers. A while
back I reorganized the x86 IRQ vectors and moved SMP_CALL0 to 224 from 240.
The initialization didn't change, so the smp_call vectors were still 240. 240
happened to be the timer IRQ, which means an smp_call_function would run on the
timer tick too. The main thing was that the check for downing the checklist
didn't happen, since it expected 224-228, so the checklist would never clear.
That appeared like the waiting code was wrong, which it was not.
Barret Rhoden [Wed, 7 Jan 2015 22:43:33 +0000 (17:43 -0500)]
Fixes waiton_checklist()
Geez, this bug was around since nearly the dawn of time (2009-04-17).
If someone actually did an smp_call with a wait wrapper, they might get lucky
and have core 0 blow through the check before anyone set a bit.
I'd love to get rid of the smp_call_function business, and replace it with
broadcast kernel messages (at least do so internally) or something. It is a
somewhat cheap version of a broadcast message, albeit with a limited number of
slots.
Barret Rhoden [Wed, 7 Jan 2015 19:33:09 +0000 (14:33 -0500)]
nix: slightly better memory allocation
The paddr and size of the nix image is controlled by CONFIG_s. There's still
only one image for the entire system.
Barret Rhoden [Wed, 7 Jan 2015 19:25:59 +0000 (14:25 -0500)]
get_cont_phys_pages_at()
Allocates a chunk of physical memory at a particular paddr. We might have
rules in the future regarding the alloc size and the alignment
Barret Rhoden [Wed, 7 Jan 2015 19:22:30 +0000 (14:22 -0500)]
Helper: nr_pages()
It felt familiar writing this again in pmap.h. I named it the same as the mm
helper and the compiler helped me out. At least I didn't write it with new
bugs this time around.
Barret Rhoden [Wed, 7 Jan 2015 16:19:06 +0000 (11:19 -0500)]
nix: allow only one nix and comment cleanup
We can only handle one nix - enforced on clone attempts.
I've left various comments around for whenever we want to have more than one
nix or stop a nix (short of rebooting).
Barret Rhoden [Wed, 7 Jan 2015 16:00:23 +0000 (11:00 -0500)]
read_exactly_n()
Yanked from nix.c. We aren't using it yet, but looks useful in the future.
Note my comment about clobbering underlying errors with our Eshort.
Barret Rhoden [Wed, 7 Jan 2015 15:53:36 +0000 (10:53 -0500)]
nix: Fixes QID2NIX
Using q.vers was just lucky, since our index was already 0.
Barret Rhoden [Wed, 7 Jan 2015 15:36:03 +0000 (10:36 -0500)]
nix: removes debug printing
Barret Rhoden [Wed, 7 Jan 2015 15:10:24 +0000 (10:10 -0500)]
nix: Fixes lock and atomic_t initialization
Apparently you can attempt to spinlock_init an atomic_t, since the atomic_t is
a void*. You'll get a nasty PF though.
Ron Minnich [Tue, 6 Jan 2015 23:19:38 +0000 (15:19 -0800)]
cleanup in response to some good comments.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Barret Rhoden [Tue, 6 Jan 2015 21:01:45 +0000 (16:01 -0500)]
Nix work assignments use RKMs
Instead of one RKM to mwait a host on the core, we send RKMs with the specific
assignments to the core. These cores need to be assigned to particular nixes.
The user-visible change is that each nix (e.g. #t/nix0) needs to reserve the
CPUs it will use.
$ echo reserve COREID|-1 > \#t/nix0/ctl
-1 reserves any core, in case you don't care which gets used.
Barret Rhoden [Tue, 6 Jan 2015 20:59:58 +0000 (15:59 -0500)]
Adds missing include
DECLARE_BITMAP needs it.
Barret Rhoden [Tue, 6 Jan 2015 20:06:56 +0000 (15:06 -0500)]
Ports uses of get_any_idle_core()
ARSCs and NIX use the new way to get a CG core.
Barret Rhoden [Tue, 6 Jan 2015 17:55:38 +0000 (12:55 -0500)]
Adds interfaces to get/put CG cores for the kernel
For things like the ARSCs, NIX mode, or whatever else you want. This takes a
core out of the idle list, meaning MCPs will not receive them.
If a core was idle (unallocated) but provisioned, these interfaces will not
choose those cores. It would mess up other parts of the ksched.
Barret Rhoden [Fri, 2 Jan 2015 19:36:01 +0000 (14:36 -0500)]
Mwait cleanup
"rax" isn't the input specifier; it is "a". That loads void* eax into rax, and
we don't need the movq to rax.
Also, we were leaving the monitor value in rax instead of using an appropriate
hint. I don't know what passing gibberish does to mwait. Incidentally,
nothing I pass here matters in qemu - the VM still hogs CPU time.
Finally, any real use of monitor/mwait needs to deal with the race on the
monitored address. After we monitor, we should check and see if the address
has been changed, similar to how futexes and CAS work. We'll probably need a
couple helpers and a nice top-level function for this.
Ron Minnich [Fri, 14 Nov 2014 02:22:08 +0000 (18:22 -0800)]
NIX mode.
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Barret Rhoden [Mon, 5 Jan 2015 21:20:18 +0000 (16:20 -0500)]
Monitor interface for debug_addr_pid
db addr PID 0xADDR
It'll print out info for that process's address. Specifically, if the addr
belongs to a file-backed VMR, it'll print the filename and offset of that
address within the file.
Don't forget you can access the monitor from userspace with the script "m".
$ m db addr 1 0xWHATEVER
Barret Rhoden [Mon, 5 Jan 2015 21:09:29 +0000 (16:09 -0500)]
Adds stub for gethostname (XCC)
One of the changes in glibc from 2.14 to 2.19 was the inclusion of
sysdeps/posix/gethostname.c, which overrides the old misc/gethostname.c. The
new one calls uname() (from posix/uname.c), which calls gethostname.c. That
infinite loop eventually runs out off the end of the stack, causing a page
fault in netperf.
In lieu of building in gethostname (which I imagine could be a file in devmisc
or something), we just error out like we did in glibc 2.14.
Copy the new file into glibc-2.19 and rebuild, or just make clean.
Barret Rhoden [Fri, 2 Jan 2015 17:00:21 +0000 (12:00 -0500)]
More useful debug info for unhandled faults
It's almost always a PF, and in those cases the VMRs and error interpretation
is very useful.
Barret Rhoden [Fri, 2 Jan 2015 16:22:58 +0000 (11:22 -0500)]
Fixes busybox compilation failure
Looks like older busyboxes have trouble with newer glibcs. I've ported this
patch from:
http://lists.busybox.net/pipermail/busybox/2013-January/078833.html
Apply this patch with p1 in your bb directory. Incidentally, I didn't need to
do this one one computer. Perhaps I had old headers sitting around that were
getting included magically.
Barret Rhoden [Thu, 1 Jan 2015 23:40:42 +0000 (18:40 -0500)]
Implements werrstr in glibc (XCC)
Userspace needs a helper to write errstr. The kernel's version is
set_errstr(). I left the user's as werrstr, which is the Plan 9 name for the
function.
I put it in glibc, since that manages the errstr code and also uses it (e.g.
openat()). Finding a place for it was a pain. Don't try to #include stdio.h
from within errno.c.
Incidentally, the #warning to do this was around a while, but it was a bit of
motivation to get it done (esp as part of the new toolchain).
Barret Rhoden [Wed, 31 Dec 2014 18:02:37 +0000 (13:02 -0500)]
Warning clean up
Barret Rhoden [Wed, 31 Dec 2014 15:51:36 +0000 (10:51 -0500)]
Adds __ALIGN_MASK (XCC)
Helper used in bitmap code. We could use it in kmalloc_align if we want. To
keep that option open, I've asserted kmalloc aligns are a power of 2. The
current code (ROUNDUP) can handle non-powers of 2.
Technically, ros/common.h is a kernel header, but don't worry about it in this
case.
Barret Rhoden [Wed, 31 Dec 2014 04:10:22 +0000 (23:10 -0500)]
Fixes barrier() and LOCK_PREFIX
Linux has barrier(), which is a cmb() on Akaros. LOCK_PREFIX is just "lock ".
Maybe when compiling for uniprocessors we would #define that to be "" to avoid
the instruction overhead.
Barret Rhoden [Wed, 31 Dec 2014 03:47:24 +0000 (22:47 -0500)]
Disable -Wmaybe-uninitialized for setjmp
Gcc 4.9.2 complains.
Setting bool err = 0 or something doesn't matter btw; the actual complaint is
for an anonymous variable. The returns twice might be confusing, or maybe that
the compiler can't see the code for slim_setjmp. The usages of slim_setjmp in
ASM looks fine (immediately tests eax).
Barret Rhoden [Wed, 31 Dec 2014 03:29:12 +0000 (22:29 -0500)]
__always_inline now includes inline
Newer gcc's complain about always_inline attribs without inline. See the
comments on this bug for some info:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49614
Barret Rhoden [Wed, 31 Dec 2014 03:17:38 +0000 (22:17 -0500)]
Slightly refactors kthread sleeping
This is a little clearer and doesn't need the goto.
Barret Rhoden [Tue, 30 Dec 2014 21:19:59 +0000 (16:19 -0500)]
Kthread sleeping uses setjmp
The old save_kernel_ctx was doing the same thing as setjmp, but with more
overhead and possible some other issues that were triggering
-Wmaybe-uninitialized.