[DRIVERS] video: Introduce fb_get_smem() and fb_set_smem() API

For implementing "vscreen hard_bind" (i.e. hardware assisted virtual
screen capturing) we will need ability to switch frame buffer shared
memory start address in host frame buffer.

This patch introduces fb_get_smem() and fb_set_smem() frame buffer
APIs for this purpose.

Please note fb_set_smem() will not directly update fix screen info,
instead it will depend on fb_set_smem operation of host frame buffer
because the ability of switching frame buffer shared memory start
address is HW specific and all types of frame buffer HW will not have
this ability.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vio: Add vmm_vdisplay_get_pixeldata() API

For implementing "vscreen hard_bind", we need a vmm_vdisplay API
which will enable us to get format, dimensions, and host address
of guest virtual display. This API will help us to directly point
host frame buffer device to guest frame buffer.

This patch adds vmm_vdisplay_get_pixeldata() API for the above
purpose and also implements gfx_pixeldata() callback for pl110
emulator.

Signed-off-by: Anup Patel <anup@brainfault.org>
[DRIVERS] video: Declare fb_find_mode() in drv/fb.h

We had fb_find_mode() API already implemented and exported in
drivers/video/modedb.c hence we declare in drivers/include/drv/fb.h
so that other part of Xvisor can use this API.

Signed-off-by: Anup Patel <anup@brainfault.org>
[DRIVERS] video: Improve clcdfb_set_sem() callback

We should not update LPBASE and UPBASE register on-the-fly without
disabling CLCD controller hence this patch.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vtemu: Fix typo in comments of vtemu_key_event()

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vscreen: First-cut implementation of virtual screen binding

This patch adds initial implementation of virtual screen binding library.

The library in its current form only provides complete implementation of
vscreen_hard_bind(). The implementation of vscreen_soft_bind() is still
work-in-progress. We also have done limited testing of vscreen_hard_bind()
using "vscreen hard_bind" command on ARM fast models.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vscreen: Improve escape keys detection

Currently, escape keys were detected when pressed in sequence
and released.

Instead of above the correct method of detecting is when all
escape keys are pressed simulatenously (just like QEMU and other
hypervisors) hence this patch.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_manager: Improve use of locks in guest create and destroy

The vmm_manager_guest_create() and vmm_manager_guest_destroy() APIs
depend upon vmm_guest_apace_xxx() APIs which in-turn use sleepable
locks hence we should not call vmm_guest_aspace_xxx() APIs with
"mngr.lock" spinlock held.

This patch fixes above described use of "mngr.lock" in guest create
and destroy APIs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Ensure that irqs are not disabled when acquiring sleepable lock

This improves sanity checks of APIs acquiring sleepable lock so that
we don't accidentally acquire sleepable lock with irqs disabled.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Handle emulated device endianness via device emulation framework

Currently, each device emulator was taking care for endianness of device
to show to guest. This is not wrong but leads to lot of duplicate code
accross device emulators hence this patch makes device endianness as
an attribute of "struct vmm_emulator" and device emulation framework
does appropriate endianness conversion as required.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] vtemu: Erase everything on display for new instance

When new VTEMU instance is created, the framebuffer screen may
contain unknown/garbage data hence for sanity we erase everything
on framebuffer.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32ve: Save/restore MMU context for long descriptor format

In case of long descriptor format (i.e. MMU LPAE), the TTBR0/1 registers
are 64bit and PRRR/NMRR are treated as MAIR0/1 registers.

This patch ensures that we save/restore MMU context for both short &
long descriptor formats.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Use video memory for CLCD framebuffer when possible

ARM boards typically have dedicated video memory for CLCD hence
use this video memory for screen data when possible.

For now only VExpress-A9 and VExpress-A15 have dedicated video
memory.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32: Don't need to save restore TPIDPRW

The TPIDRW registers always traps when accessed from user mode
for ARMv6 and ARMv7 hence no need to save/restore it.

Signed-off-by: Anup Patel <anup@brainfault.org>
[DOCS] Fix boot cpu check for ARMv7 and ARMv8 boot-wrapper

The MPIDR register of ARMv7 and ARMv8 contains more than 8 bits for
multiple affinity levels hence this patch fixes boot cpu checks in
reference boot-wrapper for ARM fast model and ARM foundation v8 model.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Improve arch_smp_id() to handle multiple affinity levels

Currently, arch_smp_id() implementation for arm32, arm32ve, and arm64
only considers one affinity level when computing logical SMP ID from
MPIDR register.

Recently, there has been quite a few ARM CPUs with multiple affinitly
levels (e.g. ARM big.Little and X-Gene) hence it becomes important for
our arch_smp_id() implementation to consider CPU specific affinity levels.

To handle this, at boot time we do CPU specific computation of logical
SMP ID from MPIDR and save it in special register that is only accessible
to Xvisor. The arch_smp_id() only reads the special register where we have
saved logical SMP ID. The special register for arm32 is TPIDPRW, arm32ve is
HTPIDRW, and arm64 is TPIDRW_EL2.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Support cacheable & non-cacheable access in vmm_host_memory_xxx() API

Currently, vmm_host_memory_xxx() and vmm_guest_memory_xxx() APIs only
supported cacheable access but in-real life we might also require
non-cacheable access from this APIs. For example, file contents loaded
by "vfs host_load" and "vfs guest_load" commands should be updated
in RAM directly and should not reside in caches.

This patch extends vmm_host_memory_xxx() and vmm_guest_memory_xxx() APIs
to support both cacheable and non-cacheable access.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_devemu: Associate endianess with both data and device emulator

Currently, we associate endianess with only device emulator which not
the complete story.

In future for ARM32VE and ARM64, we might have Guest VCPU running with
endianess different from Xvisor endianess. In this situation, the data
to/from Guest VCPU has an endiness associated with it.

This patch makes endianess handling in vmm_devemu more generic so that
it is easier for us to implement cross-endian virtualization for any
architecture.

Signed-off-by: Anup Patel <anup@brainfault.org>
[DRIVERS] net: Fix compile warnings in smc91x driver

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_devtree: Return const pointer from vmm_devtree_attrval() API

The vmm_devtree_attrval() API returns pointer to attribute value of
a device tree node. This pointer has to be const to avoid accidental
updates to attribute value thereby reducing potential buggy use of
vmm_devtree_attrval() API.

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