mmu: avoid allocation in allocate_intermediate_level()

An allocation causes recursion with the debug allocator.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
x64: switch stacks in general_protection

If we abort() (which is likely), we'll print a backtrace, which will
call safe_load(), which is likely to generate an exception.  Switch stacks
so it generates the exception on a new stack, preserving the old one
for a developer to examine.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Add defer() utility

Following go, add a way to defer a cleanup function until we exit the scope
in any way (return, exceptio, or break):

  FILE* fp = fopen(...);
  auto cleanup = defer([&] { fclose(fp); });

  ...

  // do things with fp in the knowledge that it will be closed when going
  // out of scope.

A deferred operation can be cancelled:

  if (everything_is_good) {
      cleanup.cancel();
      return fp;
  }

Of course, use RAII types where available in preference to defers.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mempool: protect debug allocator against recursion

Sometimes we need to allocate memory during a free (for example when
we clean up page tables, we use rcu_defer(), which allocates memory).

Prevent this recursion with a flag.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
external: add aarch64 submodules

openjdk.bin
gcc.bin
misc.bin

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: add gcc sysroot for cross builds

Cross-builds of shared objects need a libc to link against (even though it
won't be used at runtime) and startup files.  Provide them in the gcc.bin
external repository for cross builds.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Update gcc.bin for glibc sysroot

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: relax naming of boost libraries

The aarch64 boost libraries have dropped the -mt suffix; so adapt the build
process to accept libraries with or without the suffix.  When the change
also arrives to x64 we can drop this hack.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: define max_align_t

Needed by newer libstdc++.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
runtime: define __stack_chk_guard

Needed by newer libstdc++.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Switch to newer gcc

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>