[ARM] Minor fix ldc and stc instruction emulation.

We were not updating 'index' for ldcstc_xxx() callbacks in
ldc and std instruction emulations hence this patch.

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Fixed a PA increment in VFS load

vfs load command was loading block of data at
the same physical address.

Signed-off-by: Himanshu Chauhan <hschauhan@nulltrace.org>
[DRIVERS] mmc: Fix SD card detection logic.

Currently there were following issues:
1. __mmc_send_if_cond() will generally fails on systems with eMMC
or normal MMC cards. This does not mean we should fail immediately.
2. __sd_send_op_cond() did not validate the OCR value returned by
ACMD41 commands. We should have atleast one valid voltage in OCR
returned ACMD41 after SD card is in powerup state. If the returned
OCR does not have valid voltage bits set then we don't have a valid
SD card.

The above described issues easily manifest on ARM Fast Models
because it emulates:
a. SD card (compliant with MMCv3.4) for image file < 2GB
b. eMMC card (compliant with MMCv4.4) for image file >= 2GB

This patch primarily fixes __mmc_detect_card_inserted() by fixing
above described issues so that we properly distinguish between
SD and MMC cards.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Introduce Boot CPU APIs for SMP host

Currently, we were assuming that Xvisor will be always booted on
CPU0 (i.e. "Boot CPU" is CPU0) which can break our SMP booting in
following use-cases:
1. In AMP system, Xvisor might run on M CPUs out of total N CPUs
and these could be any M CPUs.
2. Faulty HW where CPU0 never boots.

To make our SMP booting independent of underlying CPU number, we
introduce concept of "Boot CPU" and related APIs.

As the name suggest, "Boot CPU" is nothing but the CPU on which
Xvisor starts booting. New added APIs related to Boot CPU are:
1. vmm_smp_bootcpu_id() - SMP processor ID of Boot CPU
2. vmm_smp_set_bootcpu() - Mark current CPU as Boot CPU. This
API will only work once for CPU who first calls it.
3. vmm_smp_is_bootcpu() - Check whether current CPU is Boot CPU.

We also depericate vmm_init_secondary() API and make vmm_init()
intelligent to handle Boot CPU and Non-Boot CPUs differently.

Signed-off-by: Anup Patel <anup@brainfault.org>
[DRIVERS] mmc: Reduce delays in SD and MMC card detections

Currently, __sd_send_op_cond() and __mmc_send_op_cond() are used by
__mmc_detect_card_inserted() to detect SD and MMC cards respectively.

These functions have huge trial counts (or "timeout" counts) hence on
some ARM host (such as Raspberry Pi) we might spend lot of time trying
to detect card when no card is present.

This patch make trial counts (or "timeout" counts) in these functions
to more realistic value.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32: Don't access FPSID before enabling CP10 & CP11 in CPACR

Currently, cpu_init() function used cpu_supports_fpu() before enabling
CP10 & CP11 in CPACR. This is architecturally wrong and does not work
on real HW becasue cpu_supports_fpu() reads FPSID which can only be
accessed if CP10 & CP10 is enabled in CPACR.

This patch fixes above described issue for arm32 port.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32: Cleanups and consmetic changes.

Large part of cpu_vcpu_cp15.c was violating 80 col text limit
and "arm_priv(vcpu)->cp15" was extensively used. Also cp15
register save/restore was in one unified switch function which
results in duplicate checks on "vcpu->is_normal".

The cpu_vcpu_vfp.c has issues similar to cpu_vcpu_cp15.c as
described above.

This patch does cleanups to fix the above.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32ve: Factor-out VFP switching and simplify CP15 switching

This patch primarily factors-out VFP switching into separate sources
cpu_vcpu_vfp.c and cpu_vcpu_vfp.h. We also introduce separate struct
arch_priv_vfp for maintaining VFP state.

The CP15 switching needed to be simplified so that we have clear
distinction between save and restore routines.

Signed-off-by: Sting Cheng <sting.cheng@gmail.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32ve: Improve failure cleanups in arch_vcpu_init()

If we fail when doing arch_vcpu_init() for first time (i.e. at
guest creation time) then we need to explicity cleanup resources
in arch_vcpu_init().

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_manager: Improve cleanups in vmm_manager_guest_create()

Currently, we did not do anything to cleanup VCPU if guest creation
failed while setting up VCPU.

This patch improves cleanups of Guest VCPU creation failures.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm64: Reorganize and modularize code

This patch make arm64 more modular by adding new modules
such as:
cpu_vcpu_vfp     - VCPU VFP emulation
cpu_vcpu_excep   - VCPU exception handling
cpu_vcpu_inject  - VCPU exception injection
cpu_vcpu_sysregs - VCPU sysreg, cp15, and cp14 emulation

The old cpu_vcpu_spr has been depricated from arm64 because
"spr" does not mean anything for arm64 hence cpu_vcpu_sysregs
replaces cpu_vcpu_spr.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32: Improve failure cleanups in arch_vcpu_init()

If we fail when doing arch_vcpu_init() for first time (i.e. at
guest creation time) then we need to explicity cleanup resources
in arch_vcpu_init().

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32ve: Reorganize and modularize code

This patch make arm32ve more modular by adding new modules
such as:
cpu_vcpu_excep   - VCPU exception handling
cpu_vcpu_inject  - VCPU exception injection

The above added modules are factored-out from cpu_vcpu_cp15
and cpu_vcpu_helper respectively.

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