From patchwork Tue Jun 16 15:34:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 224511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54C19C433DF for ; Tue, 16 Jun 2020 15:41:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29A40214F1 for ; Tue, 16 Jun 2020 15:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322082; bh=KcBtSG9xpoG4KBKN2wsFVC5ANJ63ngAtb8H3x5Iz6Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cDC/RvOpWRBJI+OfDn/ANqBDoCE0GEjM4+LqdNitWqtLqOFCcpZj9cTANlYJLfzZH Zt6ycOkS4/VaIyWzANu6sGjR3a87n4ZqeKdCsfivfL89p1Hzlh999XRKywRVdbn4Ld eYBmyx1AAxx5SJZS/xXpN8lYo2r/oT8heBJM6Z9A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731406AbgFPPlU (ORCPT ); Tue, 16 Jun 2020 11:41:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:56810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729227AbgFPPlS (ORCPT ); Tue, 16 Jun 2020 11:41:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9FD1D208D5; Tue, 16 Jun 2020 15:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322077; bh=KcBtSG9xpoG4KBKN2wsFVC5ANJ63ngAtb8H3x5Iz6Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=op07wFr9uFiK4u/xPYWyzm5Aa1Z0HBrj4V+6i+3n1yFV63AeFz0A4upGYW0QCNRsL 1zo09ioJIws9sk24J1qM4i0Y2n/TpvQRN6CmE3z0cL+KUHJg2N3jeVBr6wHLilzpDg +vGu0ETVQk9+Qnm7ntjQfi3XxGeB7s88x8A0aZkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Marc Zyngier Subject: [PATCH 5.4 109/134] KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts Date: Tue, 16 Jun 2020 17:34:53 +0200 Message-Id: <20200616153106.007082794@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153100.633279950@linuxfoundation.org> References: <20200616153100.633279950@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 3204be4109ad681523e3461ce64454c79278450a upstream. 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 Tested-by: James Morse Acked-by: James Morse Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/kvm_host.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -392,8 +392,10 @@ void vcpu_write_sys_reg(struct kvm_vcpu * 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;