linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: KVM: avoid add/sub on vcpu pointer
Date: Tue, 15 Jan 2013 11:20:29 +0000	[thread overview]
Message-ID: <1358248829-13764-1-git-send-email-marc.zyngier@arm.com> (raw)

Doing arithmetic on the vcpu pointer can be avoided by using
another register as a base. Saves a few instructions on the
switch path.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm/kvm/interrupts_head.S | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/arch/arm/kvm/interrupts_head.S b/arch/arm/kvm/interrupts_head.S
index 0e423be..d2442f9 100644
--- a/arch/arm/kvm/interrupts_head.S
+++ b/arch/arm/kvm/interrupts_head.S
@@ -264,11 +264,10 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 	str	r3, [vcpu, #CP15_OFFSET(c1_CPACR)]
 	str	r4, [vcpu, #CP15_OFFSET(c2_TTBCR)]
 	str	r5, [vcpu, #CP15_OFFSET(c3_DACR)]
-	add	vcpu, vcpu, #CP15_OFFSET(c2_TTBR0)
-	strd	r6, r7, [vcpu]
-	add	vcpu, vcpu, #CP15_OFFSET(c2_TTBR1) - CP15_OFFSET(c2_TTBR0)
-	strd	r8, r9, [vcpu]
-	sub	vcpu, vcpu, #CP15_OFFSET(c2_TTBR1)
+	add	r2, vcpu, #CP15_OFFSET(c2_TTBR0)
+	strd	r6, r7, [r2]
+	add	r2, vcpu, #CP15_OFFSET(c2_TTBR1)
+	strd	r8, r9, [r2]
 	str	r10, [vcpu, #CP15_OFFSET(c10_PRRR)]
 	str	r11, [vcpu, #CP15_OFFSET(c10_NMRR)]
 	str	r12, [vcpu, #CP15_OFFSET(c0_CSSELR)]
@@ -362,11 +361,10 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 	ldr	r3, [vcpu, #CP15_OFFSET(c1_CPACR)]
 	ldr	r4, [vcpu, #CP15_OFFSET(c2_TTBCR)]
 	ldr	r5, [vcpu, #CP15_OFFSET(c3_DACR)]
-	add	vcpu, vcpu, #CP15_OFFSET(c2_TTBR0)
-	ldrd	r6, r7, [vcpu]
-	add	vcpu, vcpu, #CP15_OFFSET(c2_TTBR1) - CP15_OFFSET(c2_TTBR0)
-	ldrd	r8, r9, [vcpu]
-	sub	vcpu, vcpu, #CP15_OFFSET(c2_TTBR1)
+	add	r12, vcpu, #CP15_OFFSET(c2_TTBR0)
+	ldrd	r6, r7, [r12]
+	add	r12, vcpu, #CP15_OFFSET(c2_TTBR1)
+	ldrd	r8, r9, [r12]
 	ldr	r10, [vcpu, #CP15_OFFSET(c10_PRRR)]
 	ldr	r11, [vcpu, #CP15_OFFSET(c10_NMRR)]
 	ldr	r12, [vcpu, #CP15_OFFSET(c0_CSSELR)]
@@ -479,7 +477,7 @@ vcpu	.req	r0		@ vcpu pointer always in r0
  * for the host.
  *
  * Assumes vcpu pointer in vcpu reg
- * Clobbers r2-r4
+ * Clobbers r2-r5
  */
 .macro save_timer_state
 #ifdef CONFIG_KVM_ARM_TIMER
@@ -496,9 +494,8 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 
 	mrrc	p15, 3, r2, r3, c14	@ CNTV_CVAL
 	ldr	r4, =VCPU_TIMER_CNTV_CVAL
-	add	vcpu, vcpu, r4
-	strd	r2, r3, [vcpu]
-	sub	vcpu, vcpu, r4
+	add	r5, vcpu, r4
+	strd	r2, r3, [r5]
 
 1:
 #endif
@@ -513,7 +510,7 @@ vcpu	.req	r0		@ vcpu pointer always in r0
  * for the host.
  *
  * Assumes vcpu pointer in vcpu reg
- * Clobbers r2-r4
+ * Clobbers r2-r5
  */
 .macro restore_timer_state
 	@ Disallow physical timer access for the guest
@@ -534,9 +531,8 @@ vcpu	.req	r0		@ vcpu pointer always in r0
 	mcrr	p15, 4, r2, r3, c14	@ CNTVOFF
 
 	ldr	r4, =VCPU_TIMER_CNTV_CVAL
-	add	vcpu, vcpu, r4
-	ldrd	r2, r3, [vcpu]
-	sub	vcpu, vcpu, r4
+	add	r5, vcpu, r4
+	ldrd	r2, r3, [r5]
 	mcrr	p15, 3, r2, r3, c14	@ CNTV_CVAL
 	isb
 
-- 
1.8.1

             reply	other threads:[~2013-01-15 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 11:20 Marc Zyngier [this message]
2013-01-15 14:35 ` [PATCH] ARM: KVM: avoid add/sub on vcpu pointer 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=1358248829-13764-1-git-send-email-marc.zyngier@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).