Re: [PATCH v6 04/12] ARM: KVM: Hypervisor inititalization

Rusty Russell
2012-03-05T01:12:40Z

On Thu, 23 Feb 2012 02:32:39 -0500, Christoffer Dall <c.dall@virtualopensystems.com> wrote:
> From: Christoffer Dall <c.dall@virtualopensystems.com>
>
> +static void cpu_set_vector(void *vector)
> +{
> + unsigned long vector_ptr;
> + unsigned long smc_hyp_nr;
> +
> + vector_ptr = (unsigned long)vector;
> + smc_hyp_nr = SMCHYP_HVBAR_W;
> +
> + /*
> + * Set the HVBAR
> + */
> + asm volatile (
> + "mov r0, %[vector_ptr]\n\t"
> + "mov r7, %[smc_hyp_nr]\n\t"
> + "smc #0\n\t" : :
> + [vector_ptr] "r" (vector_ptr),
> + [smc_hyp_nr] "r" (smc_hyp_nr) :
> + "r0", "r1");

Testing this recently, trying to get a kvm guest to boot. No success
yet, but I did get another issue when I compiled the host non-SMP: you
need to mark r7 as clobbered here (on SMP we didn't clobber anything
important, but on UP it hit init_end_phys_addr and changed it to
0xffffffff and we died horribly in hyp_idmap_del().

Thanks,
Rusty.

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 3772847..146604a 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -585,7 +585,7 @@ static void cpu_set_vector(void *vector)
"smc #0\n\t" : :
[vector_ptr] "r" (vector_ptr),
[smc_hyp_nr] "r" (smc_hyp_nr) :
- "r0", "r1");
+ "r0", "r1", "r7");
}

static void cpu_init_hyp_mode(void *vector)

Cheers,
Rusty.