All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <christoffer.dall@linaro.org>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org, Marc Zyngier <marc.zyngier@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu
Subject: [PULL 42/50] KVM: arm: vgic: Support 64-bit data manipulation on 32-bit host systems
Date: Tue, 27 Sep 2016 20:05:50 +0200	[thread overview]
Message-ID: <20160927180558.14699-43-christoffer.dall@linaro.org> (raw)
In-Reply-To: <20160927180558.14699-1-christoffer.dall@linaro.org>

From: Vladimir Murzin <vladimir.murzin@arm.com>

We have couple of 64-bit registers defined in GICv3 architecture, so
unsigned long accesses to these registers will only access a single
32-bit part of that regitser. On the other hand these registers can't
be accessed as 64-bit with a single instruction like ldrd/strd or
ldmia/stmia if we run a 32-bit host because KVM does not support
access to MMIO space done by these instructions.

It means that a 32-bit guest accesses these registers in 32-bit
chunks, so the only thing we need to do is to ensure that
extract_bytes() always takes 64-bit data.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 2 +-
 virt/kvm/arm/vgic/vgic-mmio.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index 6385ed5..0d3c76a 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -23,7 +23,7 @@
 #include "vgic-mmio.h"
 
 /* extract @num bytes at @offset bytes offset in data */
-unsigned long extract_bytes(unsigned long data, unsigned int offset,
+unsigned long extract_bytes(u64 data, unsigned int offset,
 			    unsigned int num)
 {
 	return (data >> (offset * 8)) & GENMASK_ULL(num * 8 - 1, 0);
diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h
index 0b3ecf9..80f92ce 100644
--- a/virt/kvm/arm/vgic/vgic-mmio.h
+++ b/virt/kvm/arm/vgic/vgic-mmio.h
@@ -96,7 +96,7 @@ unsigned long vgic_data_mmio_bus_to_host(const void *val, unsigned int len);
 void vgic_data_host_to_mmio_bus(void *buf, unsigned int len,
 				unsigned long data);
 
-unsigned long extract_bytes(unsigned long data, unsigned int offset,
+unsigned long extract_bytes(u64 data, unsigned int offset,
 			    unsigned int num);
 
 u64 update_64bit_reg(u64 reg, unsigned int offset, unsigned int len,
-- 
2.9.0

WARNING: multiple messages have this Message-ID (diff)
From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PULL 42/50] KVM: arm: vgic: Support 64-bit data manipulation on 32-bit host systems
Date: Tue, 27 Sep 2016 20:05:50 +0200	[thread overview]
Message-ID: <20160927180558.14699-43-christoffer.dall@linaro.org> (raw)
In-Reply-To: <20160927180558.14699-1-christoffer.dall@linaro.org>

From: Vladimir Murzin <vladimir.murzin@arm.com>

We have couple of 64-bit registers defined in GICv3 architecture, so
unsigned long accesses to these registers will only access a single
32-bit part of that regitser. On the other hand these registers can't
be accessed as 64-bit with a single instruction like ldrd/strd or
ldmia/stmia if we run a 32-bit host because KVM does not support
access to MMIO space done by these instructions.

It means that a 32-bit guest accesses these registers in 32-bit
chunks, so the only thing we need to do is to ensure that
extract_bytes() always takes 64-bit data.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 2 +-
 virt/kvm/arm/vgic/vgic-mmio.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index 6385ed5..0d3c76a 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -23,7 +23,7 @@
 #include "vgic-mmio.h"
 
 /* extract @num bytes at @offset bytes offset in data */
-unsigned long extract_bytes(unsigned long data, unsigned int offset,
+unsigned long extract_bytes(u64 data, unsigned int offset,
 			    unsigned int num)
 {
 	return (data >> (offset * 8)) & GENMASK_ULL(num * 8 - 1, 0);
diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h
index 0b3ecf9..80f92ce 100644
--- a/virt/kvm/arm/vgic/vgic-mmio.h
+++ b/virt/kvm/arm/vgic/vgic-mmio.h
@@ -96,7 +96,7 @@ unsigned long vgic_data_mmio_bus_to_host(const void *val, unsigned int len);
 void vgic_data_host_to_mmio_bus(void *buf, unsigned int len,
 				unsigned long data);
 
-unsigned long extract_bytes(unsigned long data, unsigned int offset,
+unsigned long extract_bytes(u64 data, unsigned int offset,
 			    unsigned int num);
 
 u64 update_64bit_reg(u64 reg, unsigned int offset, unsigned int len,
-- 
2.9.0

  parent reply	other threads:[~2016-09-27 18:05 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 18:05 [PULL 00/50] KVM/ARM Changes for v4.9 Christoffer Dall
2016-09-27 18:05 ` Christoffer Dall
2016-09-27 18:05 ` [PULL 01/50] KVM: arm/arm64: Add VGICv3 save/restore API documentation Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 02/50] KVM: arm/arm64: Factor out vgic_attr_regs_access functionality Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 03/50] KVM: arm/arm64: Rename vgic_attr_regs_access to vgic_attr_regs_access_v2 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 04/50] arm64: KVM: Optimize __guest_enter/exit() to save a few instructions Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 05/50] KVM: arm: vgic: Drop build compatibility hack for older kernel versions Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 06/50] arm/kvm: excise redundant cache maintenance Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 07/50] arm64/kvm: remove unused stub functions Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 08/50] KVM: arm/arm64: Get rid of exported aliases to static functions Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 09/50] arm64: KVM: VHE: reset PSTATE.PAN on entry to EL2 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 10/50] arm64: KVM: Move kvm_vcpu_get_condition out of emulate.c Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 11/50] arm64: KVM: Move the AArch32 conditional execution to common code Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 12/50] arm: KVM: Use common AArch32 conditional execution code Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 13/50] arm64: KVM: Make kvm_skip_instr32 available to HYP Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 14/50] arm64: KVM: vgic-v2: Add the GICV emulation infrastructure Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 15/50] arm64: KVM: vgic-v2: Add GICV access from HYP Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 16/50] arm64: KVM: vgic-v2: Enable GICV access from HYP if access from guest is unsafe Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 17/50] arm64: KVM: Rename HCR_VA to HCR_VSE Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 18/50] arm64: KVM: Preserve pending vSError in world switch Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 19/50] arm64: KVM: Add Virtual Abort injection helper Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 20/50] arm64: KVM: Add exception code to report EL1 asynchronous aborts Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 21/50] arm64: KVM: Add EL1 async abort handler Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 22/50] arm64: KVM: Route asynchronous aborts Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 23/50] arm64: KVM: Allow an exit code to be tagged with an SError Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 24/50] arm64: KVM: Inject a Virtual SError if it was pending Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 25/50] arm64: KVM: Handle async aborts delivered while at EL2 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 26/50] arm: KVM: Preserve pending Virtual Abort in world switch Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 27/50] arm: KVM: Add Virtual Abort injection helper Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 28/50] arm: KVM: Add HYP async abort handler Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 29/50] arm: KVM: Allow an exit code to be tagged with a Virtual Abort Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 30/50] arm: KVM: Handle async aborts delivered while at HYP Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 31/50] arm: KVM: Inject a Virtual Abort if it was pending Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 32/50] arm: KVM: Drop unreachable HYP abort handlers Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 33/50] arm/arm64: KVM: Inject virtual abort when guest exits on external abort Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 34/50] arm/arm64: KVM: Remove external abort test from MMIO handling Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 35/50] arm64: KVM: Inject a vSerror if detecting a bad GICV access at EL2 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 36/50] KVM: ARM: cleanup kvm_timer_hyp_init Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 37/50] arm64: KVM: Use static keys for selecting the GIC backend Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 38/50] arm64: KVM: Move GIC accessors to arch_gicv3.h Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 39/50] arm64: KVM: Move vgic-v3 save/restore to virt/kvm/arm/hyp Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 40/50] KVM: arm64: vgic-its: Introduce config option to guard ITS specific code Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 41/50] KVM: arm: vgic: Fix compiler warnings when built for 32-bit Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` Christoffer Dall [this message]
2016-09-27 18:05   ` [PULL 42/50] KVM: arm: vgic: Support 64-bit data manipulation on 32-bit host systems Christoffer Dall
2016-09-27 18:05 ` [PULL 43/50] ARM: Introduce MPIDR_LEVEL_SHIFT macro Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 44/50] ARM: Move system register accessors to asm/cp15.h Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 45/50] ARM: gic-v3: Introduce 32-to-64-bit mappings for GICv3 cpu registers Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 46/50] ARM: KVM: Support vgic-v3 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 47/50] arm64: KVM: Remove duplicating init code for setting VMID Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 48/50] ARM: gic-v3: Work around definition of gic_write_bpr1 Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 49/50] KVM: arm64: Require in-kernel irqchip for PMU support Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-27 18:05 ` [PULL 50/50] KVM: arm/arm64: vgic: Don't flush/sync without a working vgic Christoffer Dall
2016-09-27 18:05   ` Christoffer Dall
2016-09-29 14:46 ` [PULL 00/50] KVM/ARM Changes for v4.9 Radim Krčmář
2016-09-29 14:46   ` Radim Krčmář

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=20160927180558.14699-43-christoffer.dall@linaro.org \
    --to=christoffer.dall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /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.