KVM: ARM: Remove unnecessary exports from mmu.c

These defines are not used by modules, since KVM as a module is not
supported on ARM, so remove the exports.

Applies to: ARM: Add page table and page defines needed by KVM.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Rework Hyp idmap code

Don't export any external interfaces from the idmap code, instead let
the idmap code allocate the hyp pgd and let KVM clear its own idmaps.

Rename kvm_mmu_exit to kvm_clear_hyp_idmap to clarify what it actually
does.

The exports are no longer needed as KVM/ARM cannot be compiled as a
module and the the #ifdef is not required around a declaration.

Cc: Will Deacon <will.deacon@arm.com>
Cc: Rob Herring <robherring2@gmail.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Update cpu implementer and part number defines

Make these more coherent with a ARM_CPU prefix and shorten them
corespondingly.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fixup KVM/ARM skeleton patch nits

This patch addresses comments from Will Deacon:
 - Make the kvm Makefile inclusion conditional
 - Create register index defines for struct kvm_regs banked regs
 - Support KVM_CAP_MAX_VCPUS and KVM_CAP_NR_VCPUS
 - Use defines for vcpu reg modes offsets

Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fix PGD2 reminiscence

Some kvm-local defines were still named according to the PGD2 naming
scheme, so let's move this to S2_PGD...

Applied to: KVM: ARM: Hypervisor inititalization

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fixup httbr initialization

Use 64 bit value passed to the hyp mode init code which simplifies that
code and allows using a physical address for the HTTBR which is above
the 4G limit.

Applies to: KVM: ARM: Hypervisor inititalization

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Remove page requirements for hyp code

We can allocate over physically non-contigous pages so remove the
alignment and page size requirement from arch/arm/kvm/interrupts.S.

Applies to: KVM: ARM: Hypervisor inititalization

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Revert unnecessary exported mm symbols

We don't support compiling KVM as a module anymore so let's get rid
of these previously introduced exports.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Split create_hyp_pte_mappings in io/non-io versions

create_hyp_pte_mappings basically has all its logic in equally
balanced if-else clauses, so splitting up the function makes things
slightly more clear.

Applies to: KVM: ARM: Hypervisor inititalization

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Remove double documentation entry

The documentation should not be added twice. Clearly a merge error.

Applies to: User space API for getting/setting co-proc registers

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Add missing isb in CSSELR handling

The setting of the CSSELR needs an ISB to be guaranteed to have taken
affect before reading the CCSIDR, so we add that.

Applies to: KVM: ARM: Demux CCSIDR in the userspace API

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fix race condition in update_vttbr

Will Deacon pointed out another funny race in the update_vttbr code,
where two VCPUs belonging to the same VM could end up using different
VMIDs during a roll over of the VMID space.

To preserve the lockless vcpu_run loop in the common case, we re-check
the vmid generation after grabbing the spin lock.

Also use the inner shareable broadcast operations for TLB and ICACHE
invalidation instead of performing the Hyp dance and maintenance
operations on each CPU.

Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Reuse force_vm_exit from copy_current_insn

The VMID management code also needs to force VM exits, so reuse
that functionality from both places.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
ARM: kernel: enhance MPIDR macro definitions

Kernel subsystems other than the topology layer need the MPIDR
mask definitions to access the MPIDR without relying on hardcoded
masks. This patch moves the MPIDR register masks definition to
a header file and defines a macro to simplify access to MPIDR bit fields
representing affinity levels.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
ARM: kernel: update topology to use new MPIDR macros

This patch updates the topology initialization code to use the newly
defined accessors to retrieve the MPIDR affinity levels.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
KVM: ARM: Use MPIDR_LEVEL_MASK for A15 MPIDR

The MPIDR_LEVEL_MASK is more general than the A15 specific define for
bits [1:0] and the upper bits should RAZ, so we can use the more general
define.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Clarify user_mem_abort

Wrap the decoding of the HSR to determine if this was a write fault in a
static inline so the write_fault variable can just be assigned in the
(already complicated) user_mem_abort function.

Also add comments on the icache invalidation details and on the
smp_rmb() for mmu_notifier_seq.

Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Update set_device_addr api text

Update teh set_device_addr api textto specify ARM's use of the 64-bit id
field, specifically that the most significant 32 bits should be zero.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Fixup spelling error

s/Priveleged/Privileged/

Applies to the skeleton patch, uuuhhh.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Default select the ARM KVM Kconfig options

When selecting KVM on an ARM platform, you probably want the whole
thing, and there is only one host KVM CPU type definition so far, so
just select it.

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