akaros.git
3 years agoHave switch_{to,back} use an opaque uintptr_t
Barret Rhoden [Mon, 7 Dec 2015 21:31:40 +0000 (16:31 -0500)]
Have switch_{to,back} use an opaque uintptr_t

The value happens to include a struct proc *, but users of switch_{to,back}
should not assume that.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoUse a temp process for test_uaccess
Barret Rhoden [Thu, 10 Dec 2015 16:19:30 +0000 (11:19 -0500)]
Use a temp process for test_uaccess

The usage of switch_to(0) is a little problematic.  This way, we just have
a temp process and can control its address space for the tests.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoUse a kthread flag to save the address space
Barret Rhoden [Mon, 7 Dec 2015 20:46:42 +0000 (15:46 -0500)]
Use a kthread flag to save the address space

Previously, it was assumed that ktasks never care about their address
space.  This is not true - some ktasks (full ktasks with names, RKMs,
things executing in the kernel on their own, etc) may want to send an
event.

Now, with this flag, we can fix switch_to for ktasks.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoDefine a set of default flags for kthreads
Barret Rhoden [Mon, 7 Dec 2015 20:28:27 +0000 (15:28 -0500)]
Define a set of default flags for kthreads

The default flags are those for general purpose kthreads: they handle user
space syscalls and IRQs while processes are running.  In contrast, a ktask
is a special case of a kthread.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoTrack ktasks with a flag instead of a bool
Barret Rhoden [Mon, 7 Dec 2015 15:59:50 +0000 (10:59 -0500)]
Track ktasks with a flag instead of a bool

I'll have more flags shortly.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFix lock debugging issue with page faults and IRQs
Barret Rhoden [Fri, 4 Dec 2015 20:48:02 +0000 (15:48 -0500)]
Fix lock debugging issue with page faults and IRQs

There was a brief window between enabling IRQs and disabling lock checking.
If you receive an IRQ in here and that IRQ grabs a lock (e.g. timer IRQ),
you'll panic.

If you build with spinlock debugging and execute something like:

/ $ ash looper.sh prov -p1 -tc -m > /dev/null

and wait a minute or two, you'll catch a bug.  What's going on is that
looper and prov eventually get the kernel to trigger a soft page fault.
Then we get an IRQ during the window after enable_irq.  The lock debugger
flips out since we grab a lock with a kernel trap depth, which is
dangerous.  The old code was trying to work around this by disabling the
debugger, but it should have done so before enabling interrupts.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFlags RSI, RDI, ECX as RW operands so that GCC does not assume const
Davide Libenzi [Thu, 10 Dec 2015 03:55:47 +0000 (19:55 -0800)]
Flags RSI, RDI, ECX as RW operands so that GCC does not assume const

Flags RSI, RDI, ECX as RW operands so that GCC does not assume const.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoUse core_id_early() in kprof trace buffer print code
Davide Libenzi [Tue, 8 Dec 2015 01:42:25 +0000 (17:42 -0800)]
Use core_id_early() in kprof trace buffer print code

Use core_id_early() in kprof trace buffer print code.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd a test program for reproducing bugs related to too many block extra data slots
Xiao Jia [Thu, 3 Dec 2015 23:20:01 +0000 (15:20 -0800)]
Add a test program for reproducing bugs related to too many block extra data slots

Signed-off-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agomlx4: Enable TX checksum offload
Xiao Jia [Thu, 3 Dec 2015 23:20:00 +0000 (15:20 -0800)]
mlx4: Enable TX checksum offload

Signed-off-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agomlx4: Fix cq by using irqsave spin lock
Xiao Jia [Thu, 3 Dec 2015 23:19:59 +0000 (15:19 -0800)]
mlx4: Fix cq by using irqsave spin lock

Signed-off-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFix a deadlock bug in MCS-PDR locks
Barret Rhoden [Fri, 4 Dec 2015 20:31:03 +0000 (15:31 -0500)]
Fix a deadlock bug in MCS-PDR locks

The MCS-PDR locks have an optimization built in where most vcores ensure the
lockholder runs.  The other style is to ensure whoever is directly ahead in
line (the predecessor) runs, which we fall back to in some tricky corner
cases.  That all is fine.

In the unlock case, the lockholder needs to ensure whoever is next in line
runs (the lockholder's successor).  Waiting on a_tail requires that
everyone in line is ensuring their predecessor runs, which is not what
happens by default.  By clearing the lockholder_vcoreid, we can fall back
to this "get out of corner cases by following the chain" approach.

I've been chasing this one off and on for a couple years.  I managed to
recreate it once or twice and was able to peak at the userspace contexts.
I could see all but one of them were calling ensure_vcore_runs(2), and VC 2
was calling ensure_vcore_runs(1).  Two other vcores were preempted.  I
could see VC 2 was in an unlock.  There were no syscalls coming from that
process.

It was actually simple after that.  What happened was that a vcore signed
up for the lock (L391), but hadn't set pred->next yet (L396).  Then it gets
preempted.  VC 2 was its pred, and it acquired the lock with no issues.
When it went to unlock, it needed to ensure it's successor was running.  VC
2 was the lockholder_vcoreid.  Everyone in the chain behind the preempted
VC kept ensuring 2 ran.  No one ensured the preempted VC ran.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agox86: Use partial contexts for all entries [2/2]
Barret Rhoden [Wed, 2 Dec 2015 18:39:28 +0000 (13:39 -0500)]
x86: Use partial contexts for all entries [2/2]

Syscalls, traps, and IRQs all use partial contexts when entering from
userspace.  Note that the traps and IRQs that occur while a kernel context
is running does not mess with swapgs or partial contexts.  Partial contexts
(and pcpui current_ctx in general) has nothing to do with the kernel's
context / HW TF.  They are for user contexts.

This change takes about 260ns off of a sys_null() call, and we're down to
about 220ns (on my devbox).  Quite an improvement.  The expensive bit was
messing with the TLS MSRs, since those operations are unfortunately slow.
This isn't true on more recent x86 machines, which have support for fast
instructions to change the GS and FS base.  However, many machines,
(notable Qemu) do not support those instructions, and we'd need the kernel
and userland to decide which method of changing GS/FS to use, either during
compilation or at runtime.

In the long run, with support for quickly changing the TLS, the hardware
and software partial contexts savings won't be as important.  But partial
contexts are likely to be important for the upcoming virtual machine
context type.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agox86: Add support for partial contexts [1/2]
Barret Rhoden [Wed, 2 Dec 2015 17:20:01 +0000 (12:20 -0500)]
x86: Add support for partial contexts [1/2]

This adds the arch-specific handling for partial contexts within the
kernel's C code.  As of this commit, there are no partial contexts;
everything that comes in from trapentry62.S is a full context.

For hardware and software contexts, the distinction in x86 is whether or
not TLS MSRs are dealt with.  For partial contexts, GS is the kernel's
desired GS, MSR_KERNEL_GS_BASE is the user's old GS, and FS is the user's
FS.  The TF's GS and FS are 0.  After finalization, the GS is still the
kernel's GS.  MSR_KERNEL_GS_BASE is the kernel's GS, and the TF has the
user's GS and FS.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoSupport partial contexts
Barret Rhoden [Fri, 20 Nov 2015 00:22:08 +0000 (16:22 -0800)]
Support partial contexts

Partial contexts are those where the full context is split between the
parts in the struct and the parts still loaded in hardware.

When entering the kernel, the kernel only needs to save enough of the
context so that it can perform its work.  The hardware may have other
bits of context that remain, and we'll copy out that state once we think
we are not going to return to the (previously) current context.

The rule is that if we ever either:
1) run the context somewhere else, or
2) run another context here

then we need to finalize the context, by ripping it off the core
completely.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoUse a helper to copy out the current context
Barret Rhoden [Thu, 19 Nov 2015 23:05:56 +0000 (15:05 -0800)]
Use a helper to copy out the current context

The helper allows us to run some code before we copy out the current
context.  I'll use this shortly as the location to 'finalize' the
context (fully copy it out of hardware).  In the future, we might want
other things in here.

I considered making this take the cur_ctx * to avoid another core_id()
call, but most callers were already passing current_ctx.  Also, if we
didn't use current_ctx (and took a pointer) we could inline the call in
trap.h.  But it's not really worth the hassle yet.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMake __proc_save_context_s assume the current_ctx
Barret Rhoden [Thu, 19 Nov 2015 22:13:08 +0000 (14:13 -0800)]
Make __proc_save_context_s assume the current_ctx

All callers of this function pass in the current_ctx.  There's no
reasonable use case where we're trying to save any other context for an
SCP.  If there is a need for that in the future, the function
implementing that will need to deal with finalizing partial user
contexts.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agox86: Add swap_gs helper
Barret Rhoden [Thu, 19 Nov 2015 02:22:57 +0000 (18:22 -0800)]
x86: Add swap_gs helper

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoPrint ${remote}:${head} in link for code review
Kevin Klues [Wed, 25 Nov 2015 15:12:12 +0000 (07:12 -0800)]
Print ${remote}:${head} in link for code review

Previously I was showing urls of the sort:
https://github.com/brho/akaros/compare/abe793d...0780d03

which was fine, except that if I ever did a 'push -f' to update a
branch, the link wouldn't reflect the state of the branch anymore. This
commit changes the link to e.g.:

https://github.com/brho/akaros/compare/abe793d...klueska:corealloc-packed

which will reflect the newest changes to the branch.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFix up some whitespace in ak-code-review.sh
Kevin Klues [Wed, 25 Nov 2015 15:11:54 +0000 (07:11 -0800)]
Fix up some whitespace in ak-code-review.sh

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd a test for devvars
Barret Rhoden [Wed, 25 Nov 2015 22:41:37 +0000 (17:41 -0500)]
Add a test for devvars

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd an assert for UTEST that takes a format string
Barret Rhoden [Wed, 25 Nov 2015 22:39:07 +0000 (17:39 -0500)]
Add an assert for UTEST that takes a format string

UT_ASSERT_M() just prints the message verbatim.  Its va_args are cleanup
routines.  UT_ASSERT_FMT() takes a format string, and its va_args is the
values for the format string.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd the #vars device to export kernel variables
Barret Rhoden [Tue, 24 Nov 2015 13:29:44 +0000 (08:29 -0500)]
Add the #vars device to export kernel variables

With #vars, you can specify certain variables, such as num_cores, to be
exposed to userspace.  If you want, you can:

$ bind -a \#vars /dev
$ cat /dev/num_cores!dw

For debugging, you can add entries with the DEVVARS_ENTRY(name, format)
macro.  'format' is two chars, the data_format and the data_size, using
Qemu's notation.

Privileged users (i.e. anyone) can add new entries to #vars, which
internally will do a lookup in the symbol table and trust the format
string.  This is a little dangerous.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemove the edata symbol
Barret Rhoden [Wed, 25 Nov 2015 17:16:40 +0000 (12:16 -0500)]
Remove the edata symbol

It is mostly useless and probably confusing.  I'm not even sure if the
linker had to put it directly after .data, or if it could put it wherever
it wanted before the .bss, since it was not inside the .data section.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMemset the BSS explicitly
Barret Rhoden [Wed, 25 Nov 2015 17:05:40 +0000 (12:05 -0500)]
Memset the BSS explicitly

Previously, we were assuming that everything from the end of .data to the
end of the kernel image was .bss.  That is definitely not the case, which
becomes apparent if you try to add an attribute for another section and
then you wonder why said section is zeroed at runtime (but not in the
object!).

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd kmalloc_array() interface
Barret Rhoden [Mon, 30 Nov 2015 21:04:08 +0000 (16:04 -0500)]
Add kmalloc_array() interface

One thing to be careful of is that these functions can fail and return 0,
regardless of your kmalloc flags.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRename 'reallocarray' to 'kreallocarray'.
Dan Cross [Wed, 25 Nov 2015 22:34:40 +0000 (17:34 -0500)]
Rename 'reallocarray' to 'kreallocarray'.

...as it should have been named originally.
My oversight: apologies for that.

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agox86: Provide an option to enable legacy USB
Barret Rhoden [Thu, 19 Nov 2015 02:08:21 +0000 (18:08 -0800)]
x86: Provide an option to enable legacy USB

If you want to use a USB keyboard, you'll need to enable this CONFIG.
It is disabled by default, since we usually use serial access and it is
a source of interference.  Sometimes you want a keyboard for debugging.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoUpdate Makelocale.template for syslinux
Barret Rhoden [Thu, 19 Nov 2015 01:54:41 +0000 (17:54 -0800)]
Update Makelocale.template for syslinux

Our USB sticks expect a kernel named 'akaros' in /boot.  The kernel can
be either a compressed kernel or uncompressed.  I recommend compressed.
(Have your Makelocal's usb target depend on CMP_KERNEL_OBJ).

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded test for devarch MSR file
Davide Libenzi [Mon, 9 Nov 2015 04:11:28 +0000 (20:11 -0800)]
Added test for devarch MSR file

Added test for devarch MSR file.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded whitelisting to MSR read/write code
Davide Libenzi [Tue, 10 Nov 2015 00:33:48 +0000 (16:33 -0800)]
Added whitelisting to MSR read/write code

Added whitelisting to MSR read/write code.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded APIs to read and write MSR values on multiple CPUs
Davide Libenzi [Sun, 8 Nov 2015 19:33:56 +0000 (11:33 -0800)]
Added APIs to read and write MSR values on multiple CPUs

Added APIs to read and write MSR values on multiple CPUs.
Cleaned up devarch.c code to remove unused code.
Plugged MSR read and write APIs into devarch MSR file.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded address range library utility to be able to express whitelists
Davide Libenzi [Mon, 9 Nov 2015 23:10:44 +0000 (15:10 -0800)]
Added address range library utility to be able to express whitelists

Added address range library utility to be able to express whitelists for
MSR code, and potentially anything which can be expressed as address
range (ie, PCI, DMA, ...).

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded API to run a function in multiple CPUs, and wait for completion
Davide Libenzi [Mon, 16 Nov 2015 19:14:52 +0000 (11:14 -0800)]
Added API to run a function in multiple CPUs, and wait for completion

Added API to run a function in multiple CPUs, and wait for completion.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoWired GP fault exception tables handling
Davide Libenzi [Tue, 24 Nov 2015 20:22:53 +0000 (12:22 -0800)]
Wired GP fault exception tables handling

Wired GP fault exception tables handling.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded exception table based safe MSR access APIs
Davide Libenzi [Tue, 24 Nov 2015 14:30:46 +0000 (06:30 -0800)]
Added exception table based safe MSR access APIs

Added exception table based safe MSR access APIs.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded CPU set data structure
Davide Libenzi [Sun, 8 Nov 2015 19:27:01 +0000 (11:27 -0800)]
Added CPU set data structure

Added CPU set data structure.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded completion data structure
Davide Libenzi [Sun, 8 Nov 2015 19:25:39 +0000 (11:25 -0800)]
Added completion data structure

Added completion data structure. It allows waiters to be woken up once
the given number of complete operations have been issued.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoA utest to test nanosleep, sleep, and usleep
Kevin Klues [Fri, 20 Nov 2015 02:14:33 +0000 (18:14 -0800)]
A utest to test nanosleep, sleep, and usleep

We currently don't test the abort path for these calls, and this is
added as a TODO in the test file.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd support for sleep, nanosleep, and usleep (XCC)
Kevin Klues [Fri, 20 Nov 2015 02:11:18 +0000 (18:11 -0800)]
Add support for sleep, nanosleep, and usleep (XCC)

The nanosleep call is a pass through to SYS_nanosleep, the usleep call
is a pass through to SYS_block, and sleep is implemented in terms of
nanosleep. We previously had our own copy of sysdeps/posix/sleep.c in
sysdeps/akaros, but this is now removed in favor of
sysdeps/posix/sleep.c which uses nanosleep under the hood.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd the nanosleep syscall
Kevin Klues [Fri, 20 Nov 2015 02:07:45 +0000 (18:07 -0800)]
Add the nanosleep syscall

This syscall provides the nanosleep API as specified here:

http://pubs.opengroup.org/onlinepubs/009695399/functions/nanosleep.html

However, it currently runs with a microsecond alarm under the hood, so
all requests are rounded to tbe nearest microsecond. In the future we
may change the underlying alarm subsystem to be nanosecond-based, at
which time we will update the precision of this sleep call.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoImport 'reallocarray' from OpenBSD.
Dan Cross [Tue, 24 Nov 2015 02:57:01 +0000 (21:57 -0500)]
Import 'reallocarray' from OpenBSD.

Add this new function: a safe version of 'realloc' that avoids
integer overflow when computing the new size of the thing to
allocate.

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemove kernel scheduler dependence on sched_pcore
Kevin Klues [Thu, 12 Nov 2015 20:17:11 +0000 (12:17 -0800)]
Remove kernel scheduler dependence on sched_pcore

There is no need for the kernel scheduler to be aware of the internal
sched_pcore struct.  Instead it can operate completely on pcoreids.
Currently we still include the sched_pcore struct as part of the
fcfs_corealloc.h header file, but this is now only necessary so that we
can provide inline functions for getting at its various fields.  If we
decide this doesn't matter much, we can probably push the definition of
this struct into a .c file somwhere. Though this may be difficult given
the separation of coreprov.c and *_corealloc.c, which both need access
to this struct. Regardless, we should be able to hide it if necessary in
an "internal" header file or something.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMove coreprov_proc_init() to corealloc_proc_init()
Kevin Klues [Tue, 6 Oct 2015 02:16:08 +0000 (19:16 -0700)]
Move coreprov_proc_init() to corealloc_proc_init()

Initially we were initializing the fields of the core_reuqest_data
struct in coreprov.c, but now that we have allocator specific
definitions for this struct, it makes more sense to have them
initialized in the core allocator they are associated with. Moreover,
it was unclear when we first introduced the coreprov_proc_init()
function that the initialization of the core request data should have
been associated with this file in the first place (the fields it
contains are really more about allocation anyway, even though they work
with a list of provisioned cores).

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoDeclare sched_pcore in allocator specific file
Kevin Klues [Tue, 6 Oct 2015 00:08:18 +0000 (17:08 -0700)]
Declare sched_pcore in allocator specific file

As part of this, we need to move the definitions of any helper functions
in corerequest.h which access fields of the sched_pcore or otherwise
depend on its size. This will become more important as we start to add
other allocators that need extra fields in the sche_pcore struct, and we
want the accessor functions (e.g. spc2pcoreid()) to remain as static
inlines so they are fast.

We also need to move our declaration of core_reqeust_data struct into
the allocator specific header as well.

I don't really like the #ifdef around including the allocator specific
header files, but it's the best compromise if we want our accessor
functions to remain in the header file. Altrnatively, we could try and
come up with a way to not need these accessor functions at all, but that
is for another day.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoKconfig option to change core allocation policy
Kevin Klues [Mon, 5 Oct 2015 22:27:42 +0000 (15:27 -0700)]
Kconfig option to change core allocation policy

We still have only option for core allocation at this point, but the
scaffolding is now in place to add others. As part of this, we rename
corealloc.c to fcfs_corealloc.c because we want to be able to add a
prefix to files that implement other core allocation strategies.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMove is_ll_core(), max_vcores() to corerequest.h
Kevin Klues [Mon, 5 Oct 2015 22:00:59 +0000 (15:00 -0700)]
Move is_ll_core(), max_vcores() to corerequest.h

These make more logical sense in this file now. They can be used by both
corealloc.c and coreprov.c as well as schedule.c if desired.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (7/7)
Kevin Klues [Tue, 29 Sep 2015 01:47:14 +0000 (18:47 -0700)]
Refactor to move alloc stuff to corealloc.c (7/7)

This commit moves the printing of the idlecore map from schedule.c into
corealloc.c. With this commit, all references to the idlecore map are
removed from schedule.c. There are still a few "core" specific functions
hanging around in schedule.c, but that's because they are all currently
protected by the sched_lock. We should consider either making the
locking finer grained, or externing the sched_lock so these functions
can be completely removed.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (6/7)
Kevin Klues [Tue, 29 Sep 2015 01:22:25 +0000 (18:22 -0700)]
Refactor to move alloc stuff to corealloc.c (6/7)

This commit moves the primary logic of the next_core() and sort_idles()
functions from schedule.c into corealloc.c. These are one off functions
to make 'pcoreid' the next core chosen by the core allocation algorithm
(so long as no provisioned cores are still idle), and to sort the idle
core list for debugging. These functions only really make sense for this
simple core request algorithm. We should revisit their usefulness once
we start to add in more sophisticated core allocation policies.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (5/7)
Kevin Klues [Tue, 29 Sep 2015 01:00:59 +0000 (18:00 -0700)]
Refactor to move alloc stuff to corealloc.c (5/7)

This commit moves the find_best_core() function out of schedule.c and
puts it in corealloc.c. It is renamed to __find_best_core_to_alloc() to
make it clearer what its intended purpose is.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (4/7)
Kevin Klues [Tue, 29 Sep 2015 00:45:43 +0000 (17:45 -0700)]
Refactor to move alloc stuff to corealloc.c (4/7)

This commit moves the primary logic of the get_any_idle_core(),
get_specific_idle_core(), put_idle_core() functions from schedule.c into
corealloc.c. The 'get' calls are intended to allow external code to extract
idle cores from consideration by the core allocation algorithm.  Once
obtained, the core allocation algorithm forgets about them until they are
reinserted via a call to put_idle_core().

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (3/7)
Kevin Klues [Tue, 29 Sep 2015 00:18:24 +0000 (17:18 -0700)]
Refactor to move alloc stuff to corealloc.c (3/7)

In this commit we move over the __prov_track_alloc() and
__prov_track_dealloc() functions from schedule.c into corealloc.c. We
also rename them to more meaningful names in the process.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (2/7)
Kevin Klues [Tue, 29 Sep 2015 00:01:10 +0000 (17:01 -0700)]
Refactor to move alloc stuff to corealloc.c (2/7)

In this commit we introduce inline helper functions in our corerequest.h
header to acces the alloc_proc and prov_proc fields of the sched_pcore
struct. We do this so that all references to internal fields of this
struct can eventually be moved completely out of schedule.h.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move alloc stuff to corealloc.c (1/7)
Kevin Klues [Mon, 28 Sep 2015 23:04:27 +0000 (16:04 -0700)]
Refactor to move alloc stuff to corealloc.c (1/7)

This series of commits refactors the kernel scheduler to move all core
allocation logic out into a file called corealloc.c. In this first
commit, we move the idlecore list and the all_pcores list over to this
file along with their initialization. Future commits will move the rest
of the logic over.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move prov stuff to coreprov.c (4/4)
Kevin Klues [Mon, 28 Sep 2015 22:09:54 +0000 (15:09 -0700)]
Refactor to move prov stuff to coreprov.c (4/4)

This is the final commit of this series. It moves the functionality
to initialize the proc_alloc_me and prov_not_alloc_me lists out of
schedule.c and into coreprov.c.

At first it was unclear if we wanted to do the initialization of these
lists here, or wait until we do initialization in our corealloc.c file
(because these lists are used in the coreallocation process as well).
However, these list only exist because provisioning exits, so it
probably makes sense to initialize them here. Anyway, the lists are only
accessed by the core allocation logic upon branching to determine that a
core is provisioned in the first place.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move prov stuff to coreprov.c (3/4)
Kevin Klues [Mon, 28 Sep 2015 21:38:37 +0000 (14:38 -0700)]
Refactor to move prov stuff to coreprov.c (3/4)

In this commit we move the printing of a process's list of provisioned
cores from schedule.c into coreprov.c

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move prov stuff to coreprov.c (2/4)
Kevin Klues [Mon, 28 Sep 2015 21:32:30 +0000 (14:32 -0700)]
Refactor to move prov stuff to coreprov.c (2/4)

In this commit we move the logic out of schedule.c for unprovisioning
all cores from a process at once.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRefactor to move prov stuff to coreprov.c (1/4)
Kevin Klues [Mon, 28 Sep 2015 21:16:04 +0000 (14:16 -0700)]
Refactor to move prov stuff to coreprov.c (1/4)

In this commit we first move the primary logic for actually provisioning
a core out of schedule.c and into coreprov.c. In subsequent commits we
will move the rest of the functionality out as well.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMove spc2pcoreid and pcoreid2spc into header file
Kevin Klues [Mon, 28 Sep 2015 21:52:33 +0000 (14:52 -0700)]
Move spc2pcoreid and pcoreid2spc into header file

All of schedule.c, coreprov.c and corealloc.c will need access to these
functions, and we want them to be fast. To make this possible, we move
the *definition* of these functions into the corerequest.h header file
(otherwise we would just put their declaration in the header). It's a
little unfortunate that we need to extern in the all_pcores variable
(mostly because this ties us to an implementation where all pcores are
allocated next to each other in memory), but it's worth it to make this
call fast.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMove sched_pcore and friends to corerequest.h
Kevin Klues [Mon, 28 Sep 2015 21:04:10 +0000 (14:04 -0700)]
Move sched_pcore and friends to corerequest.h

We are now starting to begin our separation of corerequest logic from
scheduler logic so that alternate core request strategies can be chosen.
This commit simply moves the sched_pcore struct and parts of the
sched_proc_data into corelloc.h (which is now contained in a standalong
corerequest_data struct). We still need access to corerequest_data
inside sched_proc_data, we just embed it now as its own type in a field
called 'crd' (for core_request_data). As such, we've had to modify
schedule.c to access this data through that field.

Eventually, all code that ever references 'crd' will sit inside
coreprov.c and corealloc.c, and schedule.c will not reference it
directly.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFirst step to move corerequest API from schedule.c
leymariv [Wed, 23 Sep 2015 20:57:59 +0000 (13:57 -0700)]
First step to move corerequest API from schedule.c

This is the first step to refactor the akaros kernel scheduler to move
the core-provisioning and core-allocation APIs into 3 new files:
corerequest.h, coreprov.c and corealloc.c. The corerequest.h file
contains the full API for both allocating and provisioning cores, while
the coreprov.c and corealloc.c files implement the provisiong and
allocation APIs respectively.  We separate these implementation so that
alternate core provisioning and core allocation strategies can be
implemented without duplicating code.

In the next commits we will eventually move the code for provisioning
into coreprov.c and the code for core allocation into corealloc.c

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoCreate ak-kill-9pserver.sh that kills ufs server
Edward Hyunkoo Jee [Tue, 17 Nov 2015 20:58:15 +0000 (12:58 -0800)]
Create ak-kill-9pserver.sh that kills ufs server

Signed-off-by: Edward Hyunkoo Jee <edjee@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoIgnore build output for snc and kprof2perf in git
Barret Rhoden [Wed, 18 Nov 2015 18:17:42 +0000 (10:17 -0800)]
Ignore build output for snc and kprof2perf in git

Any byproducts of building must be ignored by git.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded test case for circular buffer code
Davide Libenzi [Fri, 6 Nov 2015 02:04:48 +0000 (18:04 -0800)]
Added test case for circular buffer code

Added test case for circular buffer code.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemoved lingering error string variables
Davide Libenzi [Mon, 2 Nov 2015 03:05:29 +0000 (19:05 -0800)]
Removed lingering error string variables

Removed lingering error string variables, leftovers after the migration
to the new error handling code.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded simple netcat client for Akaros
Davide Libenzi [Mon, 26 Oct 2015 01:09:55 +0000 (18:09 -0700)]
Added simple netcat client for Akaros

Added simple netcat client for Akaros. It allows to cat files to remote
servers listening with real netcat.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded patch to Linux perf to allow it to work with Akaros
Davide Libenzi [Wed, 28 Oct 2015 17:45:45 +0000 (10:45 -0700)]
Added patch to Linux perf to allow it to work with Akaros

Added patch to Linux perf to allow it to work with Akaros.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded kprof to perf converter
Davide Libenzi [Tue, 24 Nov 2015 02:47:16 +0000 (18:47 -0800)]
Added kprof to perf converter

Added kprof to perf converter.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoEnabled /prof/kptrace collection of anything which goes into cprintf
Davide Libenzi [Sun, 8 Nov 2015 02:47:16 +0000 (18:47 -0800)]
Enabled /prof/kptrace collection of anything which goes into cprintf

Enabled /prof/kptrace collection of anything which goes into cprintf,
printk, and its associates.
The kptrace collector is a circular buffer whose default size is 128KB.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoImplemented the new profiler
Davide Libenzi [Wed, 21 Oct 2015 23:39:04 +0000 (16:39 -0700)]
Implemented the new profiler

Implemented the new profiler format and added simple userspace
stack trace (waiting for copy_from_user()).

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
[checkpatch touchups]
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded API to append data into a circular buffer
Davide Libenzi [Fri, 6 Nov 2015 01:30:24 +0000 (17:30 -0800)]
Added API to append data into a circular buffer

Added API to append data into a circular buffer. The buffer data is
allocated once at init time, and no more allocations happen after that.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded generic backtrace functions to allow backtrace output on buffers
Davide Libenzi [Thu, 5 Nov 2015 20:31:37 +0000 (12:31 -0800)]
Added generic backtrace functions to allow backtrace output on buffers

Added generic backtrace functions to allow backtrace output on buffers.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded API to enumerate the VM regions of a process
Davide Libenzi [Tue, 27 Oct 2015 22:29:10 +0000 (15:29 -0700)]
Added API to enumerate the VM regions of a process

Added API to enumerate the VM regions of a process.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded API to retrieve the current set of processes on the system
Davide Libenzi [Tue, 27 Oct 2015 22:04:15 +0000 (15:04 -0700)]
Added API to retrieve the current set of processes on the system

Added API to retrieve the current set of processes on the system.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoExtend hash enumeration API to accept an opaque pointer
Davide Libenzi [Tue, 27 Oct 2015 21:46:49 +0000 (14:46 -0700)]
Extend hash enumeration API to accept an opaque pointer

Extend hash enumeration API to accept an opaque pointer.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded API to retrieve the full path of a struct dentry
Davide Libenzi [Sat, 24 Oct 2015 02:50:43 +0000 (19:50 -0700)]
Added API to retrieve the full path of a struct dentry

Added API to retrieve the full path of a struct dentry.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded APIs to access process startup information
Davide Libenzi [Thu, 22 Oct 2015 17:56:37 +0000 (10:56 -0700)]
Added APIs to access process startup information

Added APIs to access process startup information. For now only argc and
argv copies are supported.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded full binary path into the proc structure
Davide Libenzi [Thu, 22 Oct 2015 21:30:26 +0000 (14:30 -0700)]
Added full binary path into the proc structure

Added full binary path into the proc structure.
Fixed a bug where we would set the progname on the current process,
and not the new one.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdded struct proc pointer to base of the executable args block
Davide Libenzi [Thu, 22 Oct 2015 17:32:37 +0000 (10:32 -0700)]
Added struct proc pointer to base of the executable args block

Added struct proc pointer to base of the executable args block.
This allows kernel code to be able to access the executable startup
info, which previous code would have discarded.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoDo not race when multiple init happen at the same time
Davide Libenzi [Tue, 20 Oct 2015 23:34:26 +0000 (16:34 -0700)]
Do not race when multiple init happen at the same time

Do not race when multiple init happen at the same time, and handle
proper cleanup when all users are gone.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemoved unused old oprofile code
Davide Libenzi [Tue, 20 Oct 2015 22:57:58 +0000 (15:57 -0700)]
Removed unused old oprofile code

Removed unused old oprofile code. Most of it wasn't even used
in the previous code.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoCompletely restructured profiler code cutting all the unused code
Davide Libenzi [Tue, 20 Oct 2015 22:53:08 +0000 (15:53 -0700)]
Completely restructured profiler code cutting all the unused code

Completely restructured profiler code cutting all the unused code
that was imported from Linux.
Moved the kernel/userspace detection logic into the profiler code
to open the door to userspace stack traces.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
[checkpatch touchups]
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoReplace the Inferno console driver with a less-crippled Plan 9 driver.
Dan Cross [Thu, 29 Oct 2015 18:02:23 +0000 (14:02 -0400)]
Replace the Inferno console driver with a less-crippled Plan 9 driver.

Integrate the console driver from the UCB Plan 9 release into Akaros,
in preparation for getting rid of devfs.c and moving towards getting
rid of the VFS.

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRun spatch on devcons.c
Dan Cross [Thu, 29 Oct 2015 15:34:00 +0000 (11:34 -0400)]
Run spatch on devcons.c

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRun lindent on devcons.c
Dan Cross [Thu, 15 Oct 2015 20:07:48 +0000 (16:07 -0400)]
Run lindent on devcons.c

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoImport the unmodified Plan 9 console driver.
Dan Cross [Thu, 15 Oct 2015 20:00:06 +0000 (16:00 -0400)]
Import the unmodified Plan 9 console driver.

Step 1 in replacing the relatively less-functional Inferno
console driver with the Plan 9 driver from the UCB Plan 9
release. This is the original, unmodified source from the
Plan 9 distribution.

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemove old virtualization debugging programs
Barret Rhoden [Mon, 16 Nov 2015 23:31:43 +0000 (15:31 -0800)]
Remove old virtualization debugging programs

These were blobs that Ron used for old virtualization debugging.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd support for EPIPE and SIGPIPE (XCC)
Kevin Klues [Tue, 27 Oct 2015 18:05:23 +0000 (11:05 -0700)]
Add support for EPIPE and SIGPIPE (XCC)

With this change, we now support proper handling of SIGPIPE.  This
allows us to now run things such as:

$ hexdump -C bin/hexdump | head

However, this only currently works for files in the vfs. Things are
still broken for chans in the 9ns.  For example,

$ hexdump -C mnt/go.cpio | head

will page fault in the kernel with an error of "rpc tags".  The SIGPIPE
is still generated properly. but the call to sys_proc_destroy in the
SIGPIPE signal handler never completes. Specifically, the kernel never
returns from the call to close_fdt() in proc_destroy(). My guess is a
call to cclose() on the fd for 'mnt/go.cpio' is sleeping on its
kref->release(), and never recovering properly.

For now we can ignore this, since a workaround is to just copy the file
into the vfs, but we will need to figure this out eventually.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd a sigself() signal_op
Kevin Klues [Wed, 11 Nov 2015 08:46:25 +0000 (00:46 -0800)]
Add a sigself() signal_op

All of the existing signal_ops map directly to traditional signal
operations fro glibc. This commit introduces a new operation, called sigself().
This operation is meant to trigger a signal immediately on the calling
thread.  Before this call returns, the signal passed into it will be
generated and run to compeltion.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd signal support to our basic thread0 scheduler
Kevin Klues [Wed, 11 Nov 2015 08:43:59 +0000 (00:43 -0800)]
Add signal support to our basic thread0 scheduler

As part of this, I needed to add an implementation of thread_paused()
since the signal stuff relies on this.  Since it would do nothing other
than call thread0_thread_runnable, I just reuse this function directly
in the function pointer table.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMigrate signal code from pthread.c to signal.c
Kevin Klues [Wed, 11 Nov 2015 03:00:04 +0000 (19:00 -0800)]
Migrate signal code from pthread.c to signal.c

Previously all of the code to support intraprocess signals was isolated
to the pthread library.  However, the actual functionality it provided
was quite generic.  This commit pushes all of that code into
parlib/signal.c and makes uthreads aware of the ability handle posix
signals. It is still up to the specific 2LS to actually use these
facilities in their scheduler though. For 2LSs that don't require posix
signals, the only waste is a few words in the uthread struct, and a few
unnecessary instructions to clear these fields when a uthread is first
initialized.  There is no actual performance hit unless the APIs from
parlib/signal.h are actually called (as they are in pthread.c now).

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd uthread_paused() API call
Kevin Klues [Wed, 11 Nov 2015 02:10:27 +0000 (18:10 -0800)]
Add uthread_paused() API call

This call is much like uthread_has_blocked(), except that it indicates
that some external component has temporarily paused a uthread, rather
than blocked it. That is, the external component calls uthread_yield()
directly, but then wishes to hand control of the uthread back to the 2LS
in the body of theyield callback.

It is the job of the 2LS to implement sched_ops->paused() such that the
thread becomes runnable again. This sched op actually already exists
because things like preemption can trigger it. Now it is triggerable by
any external component that wishes to temporarily pause a uthread with
its own yield call.

This functionality will prove useful when pausing a temporarily pausing
thread to run a signal handler in its place.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoEncapsulate pthread sigstate into a single struct
Kevin Klues [Tue, 10 Nov 2015 22:58:14 +0000 (14:58 -0800)]
Encapsulate pthread sigstate into a single struct

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoRemove need for externally alloced sigdata struct
Kevin Klues [Tue, 10 Nov 2015 21:52:31 +0000 (13:52 -0800)]
Remove need for externally alloced sigdata struct

We now use space on the stack for storing the original user context and
and any signal specific state when triggering a posix signal on a
pthread.

As a side effect, we should now be able to safely longjmp out of a
signal handler because there is no longer any external state
to clean up when the signal handler completes.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd arch independent accessor for user ctx stack
Kevin Klues [Tue, 10 Nov 2015 21:50:52 +0000 (13:50 -0800)]
Add arch independent accessor for user ctx stack

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoWeasel apart parlib/libc symbols for signals (XCC)
Kevin Klues [Tue, 10 Nov 2015 02:45:25 +0000 (18:45 -0800)]
Weasel apart parlib/libc symbols for signals (XCC)

Previously, all of the akaros signal handling code was in parlib, which meant
that none of the glibc functions could use it. Moreover, there was no
good way for an individul 2LS to overwrite many of the commong signal
handling functions with its own functionality.  This commit weasels
apart some of this mess, allowing a 2LS to hook in its own set of
functions for common functions for masking/relaying posix signals.
Moreover, it allows glibc to now access the generic signal_ops struct,
so any function pointers a 2LS wishes to set in there can be called from
glibc if desired.  This will prove useful when implementing SIGPIPE in a
subsequent commit.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoAdd parlib-compat.c for weak symbols with parlib
Kevin Klues [Mon, 9 Nov 2015 22:56:26 +0000 (14:56 -0800)]
Add parlib-compat.c for weak symbols with parlib

This commit requires a rebuild of glibc (XCC)

Historically, parlib and glibc have been 2 separate entities. In spirit,
however, they both serve to provide low level functionalitity required
by higher level libraries. In theory, all of the functionality we
provide in parlib could (and arguably should) eventually be pushed down
into the akaros port of glibc. However, for now, we have opted to keep
parlib and glibc separate to maintain a faster turn-around time with
building parlib vs. glibc.

Unfortunately, keeping parlib and glibc separate is not very clean when
it comes to building glibc. Glibc is designed to be the lowest level
library on the system, and as such, doesn't like it when it has
unresolved symbols from parlib at link time. Since all executables
eventually link with parlib, this is not a problem (in theory), but
glibc doesn't like it nonetheless, and we have problems building our
cross compiler if any parlib symbols are referenced inside our akaros
port of glibc.

To help with this, I've introduced a new file called parlib-compat.c,
to define weak symbols for any parlib symbol that needs to be accessed
internally by glibc. This way, the symbol will exist at the time libc is
linked (to get our cross compiler build to stop complaining), but those
symbols will be overridden by parlib.a in any final executable that
gets linked.

Unfortunately, this trick only works so long as we leave parlib as a
static library. If we ever decide to make parlib a .so, then we will
have to revisit this and use function pointers at runtime or something
similar. Maybe by then we will have pushed all of parlib's functionality
down into glibc, so the point will be moot anyway.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoFix bug in pthread_sigmask() semantics.
Kevin Klues [Tue, 27 Oct 2015 17:12:37 +0000 (10:12 -0700)]
Fix bug in pthread_sigmask() semantics.

Previously, the 'how' parameter was not being ignored correctly if 'set'
was NULL. Moreover, we were not setting the value of 'oset' properly in
cases where 'set' was NULL and 'how' should be ignored. This patch
attempts to fix these semantics to match the specification in:

http://linux.die.net/man/2/sigprocmask

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoTabified file carrying spaces
Davide Libenzi [Sun, 1 Nov 2015 01:31:15 +0000 (18:31 -0700)]
Tabified file carrying spaces

Tabified file carrying spaces.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
3 years agoMigrated user memory copy APIs to use the new exception table guards
Davide Libenzi [Sat, 31 Oct 2015 01:31:15 +0000 (18:31 -0700)]
Migrated user memory copy APIs to use the new exception table guards

Migrated user memory copy APIs to use the new exception table guards.
Added string copy APIs as well.

Signed-off-by: Davide Libenzi <dlibenzi@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>