trace: fix tracepoint arguments that are strings in demand paged memory

If a char* tracepoint argument points into demand paged memory, we may
try to access it while it is unmapped, in a non-preemptible context.

Fix by handling the fault gracefully.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: prevent allocation in vdepopulate()

unpopulate<> (used by vdepopulate()) maintains an std::stack<> of pages
to be freed, in order to defer the tlb flush (that must be done after
pages are unlinked from the page table, but before they are actually freed).

However, the debug allocator uses vdepopulate() to ensure freed memory is
made inaccessible (so detecting use-after-free bugs).  This causes endless
recursion.

Fix by using a fixed-size queue of free pages and flushing it if it fills up.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: reclaim intermediate pages in debug allocator

The debug allocator does not recycle virtual addresses in order to
improve detection of use-after-free bugs.  This creates a lot of intermediate
pages as address space is consumed, leading to a very rapid OOM.

Fix by reclaiming intermediate pages that point nowhere.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio-blk: fix use after free

Some tracepoints are called after their arguments are freed.  Reverse the
order.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio: use physically configuous memory for indirect descriptors

Using malloc() fails with the debug allocator, and can fail for the normal
allocator as well since it does not guarantee physical memory.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: convert more files to C++

Easier to add tracepoints, etc.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: don't cache uma allocations if CONF_debug_memory

Caching allocations can hide use-after-free bugs.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
gdb: fix backtrace parsing

BacktraceFormatter expects a string, not a syminfo, as Python was kind enough
not to point out.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>