Revert "ARM: KVM: move usr regs to struct pt_regs"

This reverts commit f7c6882646ebd12ee0daab1055cd38c23f47c610.

The kvm_regs struct is part of the user space ABI to provide an index
for which registers are get/set using the corresponding ioctl's and
should really be explicitly typed in line with the remaining KVM code.

If we want to move away from that we should provide fixed indices for
the registers, but I've never been a fan of hiding the pc and cpsr under
the usr_regs field in the first place.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
ARM: KVM: move MMIO handling to its own files

MMIO handling is currently tangled between mmu.c and emulate.c.

Move HSR based handling to mmio.c, and anything related to emulation
(including the readback from memory) into emulate.c.

In the end:
- mmu.c: only deals with page tables and defers to mmio.c for anything
  else
- mmio.c: only deals with valid HSR faults, and defers to emulate.c
  for anything else
- emulate.c only cares about instruction emulation

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Introduce KVM_INIT_IRQCHIP ioctl

Used to initialize the in-kernel interrupt controller. On ARM we need to
map the virtual generic interrupt controller (vGIC) into Hyp the guest's
physicall address space so the guest can access the virtual cpu
interface. This must be done after the IRQ chips is create and after a
base address has been provided for the emulated platform (patch is
following), but before the CPU is initally run.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl

On ARM (and possibly other architectures) some bits are specific to the
model being emulated for the guest and user space needs a way to tell
the kernel about those bits.  An example is mmio device base addresses,
where KVM must know the base address for a given device to properly
emulate mmio accesses within a certain address range or directly map a
device with virtualiation extensions into the guest address space.

We try to make this API slightly more generic than for our specific use,
but so far only the VGIC uses this feature.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Split KVM_CREATE_IRQCHIP and KVM_INIT_IRQCHIP

We need this two factor initialization step to support a sane user space
initialization of the emulated model.  We simply follow the names of the
ioctls for the internal vgic implementation steps and check if we have
everything we need on the host side when we create the vgic and set up
the rest on init.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
fixup! KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fix the set device addr api

Don't use the KVM_INIT_IRQCHIP ioctl anymore as this can happen
transparently upon executing the CPU.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Set kvm->arch.vgic.vctrl_base in kvm_vgic_create

This value needs to be set before calling kvm_vgic_vcpu_init, which is
now called before kvm_vgic_init - confusing? Yes, but the entire vgic
thing is super confusing, so we will have to live with it.

Also use the IS_VGIC_ADDR_UNDEF() macro to avoid type warnings when
comparing to the VGIC_ADDR_UNDEF constant; it's unlikely that a device
will sit on address 0, but since this is a part of main kernel boot
procedure if this stuff is enabled in the config, I'm being paranoid.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Update documentation for KVM_SET_DEVICE_ADDR

Explain how this works and is expected to be used with the GIC on ARM.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>