All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 03/14] ARM: KVM: handle 64bit values passed to mrcc or from mcrr instructions in BE case
Date: Tue, 27 May 2014 15:30:53 +0100	[thread overview]
Message-ID: <5384A19D.1030205@arm.com> (raw)
In-Reply-To: <1399997646-4716-4-git-send-email-victor.kamensky@linaro.org>

On 13/05/14 17:13, Victor Kamensky wrote:
> In some cases the mcrr and mrrc instructions in combination with the ldrd
> and strd instructions need to deal with 64bit value in memory. The ldrd
> and strd instructions already handle endianness within word (register)
> boundaries but to get effect of the whole 64bit value represented correctly,
> rr_lo_hi macro is introduced and is used to swap registers positions when
> the mcrr and mrrc instructions are used. That has the effect of swapping
> two words.
> 
> Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
> ---
>  arch/arm/include/asm/kvm_asm.h | 18 ++++++++++++++++++
>  arch/arm/kvm/init.S            |  4 ++--
>  arch/arm/kvm/interrupts.S      |  4 ++--
>  arch/arm/kvm/interrupts_head.S |  6 +++---
>  4 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h
> index 53b3c4a..3a67bec 100644
> --- a/arch/arm/include/asm/kvm_asm.h
> +++ b/arch/arm/include/asm/kvm_asm.h
> @@ -61,6 +61,24 @@
>  #define ARM_EXCEPTION_FIQ	  6
>  #define ARM_EXCEPTION_HVC	  7
>  
> +/*
> + * The rr_lo_hi macro swaps a pair of registers depending on
> + * current endianness. It is used in conjunction with ldrd and strd
> + * instructions that load/store a 64-bit value from/to memory to/from
> + * a pair of registers which are used with the mrrc and mcrr instructions.
> + * If used with the ldrd/strd instructions, the a1 parameter is the first
> + * source/destination register and the a2 parameter is the second
> + * source/destination register. Note that the ldrd/strd instructions
> + * already swap the bytes within the words correctly according to the
> + * endianness setting, but the order of the registers need to be effectively
> + * swapped when used with the mrrc/mcrr instructions.
> + */
> +#ifdef CONFIG_CPU_ENDIAN_BE8
> +#define rr_lo_hi(a1, a2) a2, a1
> +#else
> +#define rr_lo_hi(a1, a2) a1, a2
> +#endif
> +
>  #ifndef __ASSEMBLY__
>  struct kvm;
>  struct kvm_vcpu;
> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
> index 74f0718..2d10b2d 100644
> --- a/arch/arm/kvm/init.S
> +++ b/arch/arm/kvm/init.S
> @@ -74,7 +74,7 @@ __do_hyp_init:
>  ARM_BE8(setend	be) @ Switch to Big Endian mode if needed
>  
>  	@ Set the HTTBR to point to the hypervisor PGD pointer passed
> -	mcrr	p15, 4, r2, r3, c2
> +	mcrr	p15, 4, rr_lo_hi(r2, r3), c2
>  
>  	@ Set the HTCR and VTCR to the same shareability and cacheability
>  	@ settings as the non-secure TTBCR and with T0SZ == 0.
> @@ -140,7 +140,7 @@ phase2:
>  	mov	pc, r0
>  
>  target:	@ We're now in the trampoline code, switch page tables
> -	mcrr	p15, 4, r2, r3, c2
> +	mcrr	p15, 4, rr_lo_hi(r2, r3), c2
>  	isb
>  
>  	@ Invalidate the old TLBs
> diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S
> index 0d68d40..24d4e65 100644
> --- a/arch/arm/kvm/interrupts.S
> +++ b/arch/arm/kvm/interrupts.S
> @@ -52,7 +52,7 @@ ENTRY(__kvm_tlb_flush_vmid_ipa)
>  	dsb	ishst
>  	add	r0, r0, #KVM_VTTBR
>  	ldrd	r2, r3, [r0]
> -	mcrr	p15, 6, r2, r3, c2	@ Write VTTBR
> +	mcrr	p15, 6, rr_lo_hi(r2, r3), c2	@ Write VTTBR
>  	isb
>  	mcr     p15, 0, r0, c8, c3, 0	@ TLBIALLIS (rt ignored)
>  	dsb	ish
> @@ -135,7 +135,7 @@ ENTRY(__kvm_vcpu_run)
>  	ldr	r1, [vcpu, #VCPU_KVM]
>  	add	r1, r1, #KVM_VTTBR
>  	ldrd	r2, r3, [r1]
> -	mcrr	p15, 6, r2, r3, c2	@ Write VTTBR
> +	mcrr	p15, 6, rr_lo_hi(r2, r3), c2	@ Write VTTBR
>  
>  	@ We're all done, just restore the GPRs and go to the guest
>  	restore_guest_regs
> diff --git a/arch/arm/kvm/interrupts_head.S b/arch/arm/kvm/interrupts_head.S
> index e627858..104977f 100644
> --- a/arch/arm/kvm/interrupts_head.S
> +++ b/arch/arm/kvm/interrupts_head.S
> @@ -520,7 +520,7 @@ ARM_BE8(rev	r6, r6  )
>  	mcr	p15, 0, r2, c14, c3, 1	@ CNTV_CTL
>  	isb
>  
> -	mrrc	p15, 3, r2, r3, c14	@ CNTV_CVAL
> +	mrrc	p15, 3, rr_lo_hi(r2, r3), c14	@ CNTV_CVAL
>  	ldr	r4, =VCPU_TIMER_CNTV_CVAL
>  	add	r5, vcpu, r4
>  	strd	r2, r3, [r5]
> @@ -560,12 +560,12 @@ ARM_BE8(rev	r6, r6  )
>  
>  	ldr	r2, [r4, #KVM_TIMER_CNTVOFF]
>  	ldr	r3, [r4, #(KVM_TIMER_CNTVOFF + 4)]
> -	mcrr	p15, 4, r2, r3, c14	@ CNTVOFF
> +	mcrr	p15, 4, rr_lo_hi(r2, r3), c14	@ CNTVOFF
>  
>  	ldr	r4, =VCPU_TIMER_CNTV_CVAL
>  	add	r5, vcpu, r4
>  	ldrd	r2, r3, [r5]
> -	mcrr	p15, 3, r2, r3, c14	@ CNTV_CVAL
> +	mcrr	p15, 3, rr_lo_hi(r2, r3), c14	@ CNTV_CVAL
>  	isb
>  
>  	ldr	r2, [vcpu, #VCPU_TIMER_CNTV_CTL]
> 

As much as I hate the macro, I can't find a better solution. As such:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
-- 
Jazz is not dead. It just smells funny...

  parent reply	other threads:[~2014-05-27 14:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 16:13 [PATCH v3 00/14] ARM/ARM64: KVM: big endian host support Victor Kamensky
2014-05-13 16:13 ` [PATCH v3 01/14] ARM: KVM: switch hypervisor into BE mode in case of BE host Victor Kamensky
2014-05-27 14:23   ` Marc Zyngier
2014-05-13 16:13 ` [PATCH v3 02/14] ARM: KVM: fix vgic V7 assembler code to work in BE image Victor Kamensky
2014-05-27 14:24   ` Marc Zyngier
2014-05-13 16:13 ` [PATCH v3 03/14] ARM: KVM: handle 64bit values passed to mrcc or from mcrr instructions in BE case Victor Kamensky
2014-05-26 15:28   ` Christoffer Dall
2014-05-28  6:09     ` Victor Kamensky
2014-05-27 14:30   ` Marc Zyngier [this message]
2014-05-13 16:13 ` [PATCH v3 04/14] ARM: KVM: __kvm_vcpu_run function return result fix " Victor Kamensky
2014-05-27 15:02   ` Marc Zyngier
2014-05-28  6:10     ` Victor Kamensky
2014-05-13 16:13 ` [PATCH v3 05/14] ARM: KVM: vgic mmio should hold data as LE bytes array " Victor Kamensky
2014-05-27 15:07   ` Marc Zyngier
2014-05-13 16:13 ` [PATCH v3 06/14] ARM: KVM: MMIO support BE host running LE code Victor Kamensky
2014-05-27 15:49   ` Marc Zyngier
2014-05-13 16:13 ` [PATCH v3 07/14] ARM: KVM: one_reg coproc set and get BE fixes Victor Kamensky
2014-05-25 19:14   ` Christoffer Dall
2014-05-28  6:19     ` Victor Kamensky
2014-05-28  8:03       ` Christoffer Dall
2014-05-27 18:22   ` Marc Zyngier
2014-05-28  6:23     ` Victor Kamensky
2014-05-13 16:14 ` [PATCH v3 08/14] ARM: KVM: enable KVM in Kconfig on big-endian systems Victor Kamensky
2014-05-13 16:14 ` [PATCH v3 09/14] ARM64: KVM: MMIO support BE host running LE code Victor Kamensky
2014-05-27 18:25   ` Marc Zyngier
2014-05-13 16:14 ` [PATCH v3 10/14] ARM64: KVM: store kvm_vcpu_fault_info est_el2 as word Victor Kamensky
2014-05-27 18:34   ` Marc Zyngier
2014-05-13 16:14 ` [PATCH v3 11/14] ARM64: KVM: fix vgic_bitmap_get_reg function for BE 64bit case Victor Kamensky
2014-05-26 15:49   ` Christoffer Dall
2014-05-13 16:14 ` [PATCH v3 12/14] ARM64: KVM: vgic_elrsr and vgic_eisr need to be byteswapped in BE case Victor Kamensky
2014-05-26 17:35   ` Christoffer Dall
2014-05-27 19:11     ` Marc Zyngier
2014-05-13 16:14 ` [PATCH v3 13/14] ARM64: KVM: set and get of sys registers " Victor Kamensky
2014-05-14  8:45   ` Marc Zyngier
2014-05-14 14:18     ` Victor Kamensky
2014-05-25 18:26       ` Christoffer Dall
2014-05-13 16:14 ` [PATCH v3 14/14] ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest Victor Kamensky
2014-05-26 17:52   ` Christoffer Dall
2014-05-28  6:11     ` Victor Kamensky
2014-05-28  9:14       ` Christoffer Dall
2014-05-28 13:56         ` Victor Kamensky
2014-05-28 14:09           ` Christoffer Dall
2014-05-28 14:20             ` Marc Zyngier
2014-05-26 15:49 ` [PATCH v3 00/14] ARM/ARM64: KVM: big endian host support Christoffer Dall
2014-05-28  6:31   ` Victor Kamensky
2014-05-28  8:12     ` Christoffer Dall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5384A19D.1030205@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.