[CORE] Make vmm_host_ram_alloc() more generic

Currently, vmm_host_ram_alloc() allocates RAM aligned to page size or
aligned to request size itself. This is very inflexible because we may
want to allocate XYZ MB of host RAM aligned to ABC boundary.

This patch makes vmm_host_ram_alloc() flexible enough so that we can
allocate host RAM algined to 2^align_order boundary where align_order
is specified as parameter of vmm_host_ram_alloc().

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] vfs: Introduce host_load and guest_load sub-commands

Currently, the "vfs load" sub-command only loaded file contents to a
specific location of host memory but this is not very useful.

In general, we would like to have a vfs sub-commands capable of loading
file contents to specific location of host memory or specific location
of guest memory.

This patch replaces "vfs load" sub-command with two sub-commands namely
"vfs host_load" and "vfs guest_load".

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Minor improvements to vmm_host_ram_alloc()

This patch does minor improvements to sanity checks in vmm_host_ram_alloc().

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Add 'alloced_ram' and 'alloced_rom' regions

Currently, we only have 'ram' and 'rom' regions for specifying
memory and this region types forces us to specify host_physcial_addr
in device tree itself.

The above may be functionally good but users will not like to specify
host_physical_addr for every RAM and ROM regions.

This patch adds 'alloced_ram' and 'alloced_rom' device types so that
user can specify RAM and ROM regions which will have host_physical_addr
alloced from host RAM with given alignment order.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vfs: Fix compile warning for 64-bit systems

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Always print the bootcmds being executed at boot time

Some times boot commands may fail due to several possible reasons
hence we should be verbose about boot commands being executed at
booting time to help debugging.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Improve verbose message of module init

The verbose message "Initialize <module_name>" does not tell us that
we module init function of module <module_name> is called hence this
patch makes this verbose message as "Module Init <module_name>".

Signed-off-by: Anup Patel <anup@brainfault.org>
[DRIVERS] Enrich RBD driver

This patch adds more useful APIs such as rbd_count(), rbd_get(), and
rbd_find() for the RBD (RAM backed block device) driver.

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Add rbd command for managing RBD instances

We introduce 'rbd' command for listing, creating, and destroying
RBD instances from command line.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Enable RBD driver for all ARM host

Gradually we move towards loading guest images from disk. There
would be many ARM host not having disk access hence for such
ARM host we will use RAM backed block device as disk containing
guest images.

Due to above, we enable RBD driver by default for all ARM hosts
via their defconfigs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vfs: Minor bug fix in vfs_fd_alloc()

We have to set bit in fb bitmap after allocating new fd.

This patch fixes this bug in vfs_fd_alloc().

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] vfs: Add 'host_load_list' and 'guest_load_list' sub-commands

Quite often we would frequently load multiple files for host or guest
hence having sub-commands to pick-up list of files to be loaded from
text file can be quite useful.

This patch adds sub-commands 'host_load_list' and 'guest_load_list'
for the above purpose.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_blockdev: Minor fix in submit_request() and abort_request()

We typically clear 'bdev' field of vmm_request upon request completion
or request failure. In other words, 'bdev' field of vmm_request is not
NULL only when vmm_request is queued to some request queue.

Now if we have a block devices (such as RBD block device) that completes
request in make_request() itself then for SMP host current submit_request()
hangs after returning from make_request() because complete_request() clears
'bdev' field of vmm_request.

This patch fixes submit_request() and abort_request() for above described
issue.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Improve sanity checks in vmm_host_ram and vmm_host_vapool APIs

Minor improvements in sanity checks of vmm_host_ram_reserve(),
vmm_host_ram_free(), vmm_host_ram_isfree(), vmm_host_vapool_reserve(),
vmm_host_vapool_free(), and vmm_host_vapool_isfree().

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] vfs: Beautify prints from xxx_load and xxx_load_list sub-commands

Minor beautification of prints from host_load, guest_load, host_load_list,
and guest_load_list sub-commands.

Signed-off-by: Anup Patel <anup@brainfault.org>
[TESTS] Make autoexec command of basic firmware robust

Currently, the 'autoexec' command of basic firmware looks for command
list in Guest NOR flash at offset 0xFF000 terminating with NULL character.

The above approach is flawed because Guest NOR flash can contain garbage
non-ascii (on non-printable) characters which can cause 'autoexec' command
to detect command list with garbage characters.

This patch fixes 'autoexec' command of basic firmware by looking only for
ascii (or printable) characters at 0xFF000 offset of Guest NOR flash.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Load guest images from disk for pre-configured guests

Currently, we depend upon bootloaders to load guest images for all
pre-configured guests created via bootcmd. This approach makes Xvisor
depend too much upon bootloaders to load files and number of files
to be loaded by bootloaders also increases with increasing number of
pre-configured guests.

This patch introduces new approach of loading guest images for all
pre-configured guests from some kind of disk (or block device) and
there-by making our guest image loading more concrete and scalable
to increasing number of guests. For ARM host not having any HW disk
(or HW block device), we use RAM backed block device (i.e. RBD device)
as disk containing guest images.

As per the new approach, Xvisor ARM booting will always require three
things for booting:
1. Xvisor binary (vmm.bin or uvmm.bin)
2. Xvisor host flattened device tree binary (i.e. DTB)
3. Xvisor disk containing guest images (i.e. RBD or SD or MMC or SATA)

Please note Xvisor host flattened device tree can also be compiled and
linked to Xvisor binary itself.

The new approach is not mandatory and folks can still use old method
of depending on bootloaders to load guest images.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Allow vmm_vcpu_irq_wait_timeout only when no irqs are pending

It can happen that someone assert irq to VCPU while the VCPU is trying to
do wait-for-interrupt. If this situation is not handled then a VCPU might
be paused even with irqs pending.

This patch fixes vmm_vcpu_irq_wait_timeout() so that 'execute_pending' is
ensured to zero before VCPU is paused.

Signed-off-by: Anup Patel <anup@brainfault.org>
[EMULATORS] virtio_queue: Add virtio_queue_setup_done() API

Having a mechanism to check whether given VirtIO queue is configured/setup
by Guest or not can be quite useful in developing VirtIO device emulators.

This patch adds virtio_queue_setup_done() for this purpose.

Signed-off-by: Anup Patel <anup@brainfault.org>
[EMULATORS] virtio_blk: Abort all pending block IO requests upon reset

We have to abort all pending block IO requests upon virtio_blk
device reset so that we can free-up resources associated with each
virtio_blk_dev_req hence this patch.

Signed-off-by: Anup Patel <anup@brainfault.org>