KVM: ARM: Add KVM_REG_SIZE() helper.

Useful helper for getting length of register given id; it's not
ARM-specific but Avi made it clear that generic KVM patches an x86
implementation to be applied.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: use KVM_SET_ONE_REG/KVM_GET_ONE_REG.

Instead of overloading x86's KVM_GET_MSRS/KVM_SET_MSRS.  The only basic
difference is that the ids are 64 bit.

This means we share the interface with PPC and S/390, though we don't
actually share the code (yet?).

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>

Conflicts:

	arch/arm/kvm/arm.c
KVM: ARM: Add KVM_VCPU_GET_REG_LIST.

Rather than using KVM_VCPU_GET_MSR_INDEX_LIST (a poor clone of x86's
KVM_GET_MSR_INDEX_LIST), we create a more genericly named ONE_REG
discovery mechanism.  Which looks like KVM_GET_MSR_INDEX_LIST,
except:
1) It's a VCPU ioctl, not a KVM ioctl.
2) The array entries are 64 bits, since they're ONE_REG identifiers.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: Access all registers via KVM_GET_ONE_REG/KVM_SET_ONE_REG.

We use the offset within the structure (which, conveniently, is used
internally as well) to supply unique ids for the core registers.

This makes it trivially extensible by appending fields to the struct.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>

Conflicts:

	arch/arm/include/asm/kvm.h
KVM: ARM: Remove last vestage of msr naming.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: Fix walk_msrs()

We need to exhaust both tables we're walking: without this fix, we would
not report all the CP15 registers for KVM_GET_VCPU_MSR_INDEX_LIST.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: Remove misspelled CCSIDR.

The CCSIDR value changes depending on CSSELR, it's not an invariant at
all.  It can't be simply exposed to userspace like this.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: Swap CCSIDR.

We need to save and restore it.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: Demux CCSIDR in the userspace API.

The Cache Size Selection Register (CSSELR) selects the current Cache
Size ID Register (CCSIDR).  You write which cache you are interested
in to CSSELR, and read the information out of CCSIDR.

Which cache numbers are valid is known by reading the Cache Level ID
Register (CLIDR).

To export this state to userspace, we add a KVM_REG_ARM_DEMUX
numberspace (17), which uses 8 bits to represent which register is
being demultiplexed (0 for CCSIDR), and the lower 8 bits to represent
this demultiplexing (in our case, the CSSELR value, which is 4 bits).

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
KVM: ARM: VFP userspace interface.

We use space #18 for floating point regs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tools/testing/selftests/kvm/arm: Import mmiotest from github.
tools/testing/selftests/kvm/arm: update test code to use kvm_vcpu_init.

We need to call KVM_ARM_VCPU_INIT now.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: add to selftests makefile

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: Generalize for different tests.

So we can have other ones than mmio.  The command line is now the name
of the test (ie. 'mmio').

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: Use err() and errx()

This is more convenient than perror and return.  We use exit status 2 if
something went wrong with setting up the test and 1 if it failed.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: Use C code in the tiny guest.

The asm stub just sets up a stack and we jump to 'test'.  We also use
change the mmio so we have well-defined 'fail', 'success' and 'putc'
mmio addresses: everything else gets handed to that test's specific
handler.

We have print() and assert() helpers in guest.h.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: Load an elf guest.

I stole this from my lguest elf-loading code.  It's still small, but
it means we can have a separate section for an exception table (for
cp15 testing) for example.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: Add install target.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: vfp test.

We just check the fp state is as expected, and then we make sure that
the guest and host are seeing independent fp registers.

As expected, this fails without the VFP support patches, and passes
afterwards!

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
tools/testing/selftests/kvm/arm: conditional exectution test.

This tests conditional stores, which are allowed to trap even if they
wouldn't be executed.  I couldn't get the thumb code to assemble, but
I want to test that too.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>