linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	kvm@vger.kernel.org, Suzuki K Poulose <suzuki.poulose@arm.com>,
	stable@vger.kernel.org, James Morse <james.morse@arm.com>,
	Andrew Scull <ascull@google.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/11] KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts
Date: Thu, 11 Jun 2020 10:09:54 +0100	[thread overview]
Message-ID: <20200611090956.1537104-10-maz@kernel.org> (raw)
In-Reply-To: <20200611090956.1537104-1-maz@kernel.org>

AArch32 CP1x registers are overlayed on their AArch64 counterparts
in the vcpu struct. This leads to an interesting problem as they
are stored in their CPU-local format, and thus a CP1x register
doesn't "hit" the lower 32bit portion of the AArch64 register on
a BE host.

To workaround this unfortunate situation, introduce a bias trick
in the vcpu_cp1x() accessors which picks the correct half of the
64bit register.

Cc: stable@vger.kernel.org
Reported-by: James Morse <james.morse@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/include/asm/kvm_host.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 59029e90b557..521eaedfdcc3 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -404,8 +404,10 @@ void vcpu_write_sys_reg(struct kvm_vcpu *vcpu, u64 val, int reg);
  * CP14 and CP15 live in the same array, as they are backed by the
  * same system registers.
  */
-#define vcpu_cp14(v,r)		((v)->arch.ctxt.copro[(r)])
-#define vcpu_cp15(v,r)		((v)->arch.ctxt.copro[(r)])
+#define CPx_BIAS		IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+
+#define vcpu_cp14(v,r)		((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
+#define vcpu_cp15(v,r)		((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
 
 struct kvm_vm_stat {
 	ulong remote_tlb_flush;
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-06-11  9:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11  9:09 [GIT PULL] KVM/arm64 fixes for 5.8, take #1 Marc Zyngier
2020-06-11  9:09 ` [PATCH 01/11] KVM: arm64: Flush the instruction cache if not unmapping the VM on reboot Marc Zyngier
2020-06-11  9:09 ` [PATCH 02/11] KVM: arm64: Stop writing aarch32's CSSELR into ACTLR Marc Zyngier
2020-06-11  9:09 ` [PATCH 03/11] KVM: arm64: Add emulation for 32bit guests accessing ACTLR2 Marc Zyngier
2020-06-11  9:09 ` [PATCH 04/11] KVM: arm64: Stop save/restoring ACTLR_EL1 Marc Zyngier
2020-06-11  9:09 ` [PATCH 05/11] KVM: arm64: Save the host's PtrAuth keys in non-preemptible context Marc Zyngier
2020-06-11  9:09 ` [PATCH 06/11] KVM: arm64: Handle PtrAuth traps early Marc Zyngier
2020-06-11  9:09 ` [PATCH 07/11] KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptr Marc Zyngier
2020-06-11  9:09 ` [PATCH 08/11] KVM: arm64: Remove host_cpu_context member from vcpu structure Marc Zyngier
2020-06-11  9:09 ` Marc Zyngier [this message]
2020-06-11  9:09 ` [PATCH 10/11] KVM: arm64: Synchronize sysreg state on injecting an AArch32 exception Marc Zyngier
2020-06-11  9:09 ` [PATCH 11/11] KVM: arm64: Move hyp_symbol_addr() to kvm_asm.h Marc Zyngier
2020-06-11 18:04 ` [GIT PULL] KVM/arm64 fixes for 5.8, take #1 Paolo Bonzini

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=20200611090956.1537104-10-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=ascull@google.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.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 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).