From patchwork Tue Sep 27 18:05:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9352519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A6C360757 for ; Tue, 27 Sep 2016 18:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808B829250 for ; Tue, 27 Sep 2016 18:07:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7500929260; Tue, 27 Sep 2016 18:07:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0097F2925B for ; Tue, 27 Sep 2016 18:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936550AbcI0SHg (ORCPT ); Tue, 27 Sep 2016 14:07:36 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:38322 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935669AbcI0SGf (ORCPT ); Tue, 27 Sep 2016 14:06:35 -0400 Received: by mail-wm0-f42.google.com with SMTP id l132so26963009wmf.1 for ; Tue, 27 Sep 2016 11:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l+CxvNrg6SRqJ2SjLqek8C2aNfTBwGn4UYJLD0ihB+E=; b=SMLw9ime0IlyBDxvMxunehBuR6kNOvTASB9CMxOwSI5+sfJ4GhfwNBlJaM61SOFZ0K FkDD4d+ExNkm6gcYBuf9E7OpdSNfvO3EXo07tKFqd6E7rL8FbpnqcP67IpkhCUz+acfp ty6E/WinEYu4nYQcWSCd6O3hHBc+laDEgEwYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l+CxvNrg6SRqJ2SjLqek8C2aNfTBwGn4UYJLD0ihB+E=; b=LXfXCEC5Uv+Nj1ndr1FdUJUMafaGXfzrAo0DGrIRO7sxmqZjZU0HFU2liDfyo06mvF KFke3afGEYSwn25D/xAYksGKccqD+oCcwKTh8F4Vcu5TshLJfgCdktRwe1/JAWbQVhkt Xy5OYDmUabVuCmqY8NcFrRHc8uD2NfzNJxOJvFZz5bMVgDLQzadPjDJVmKh9NvX4LYc7 OJ/bYIzag2wg5EaHsinFETW/TGTw5rWbNz8e6LUU6S+/EUhFTUecmu6Zj9xKcAHRqvq7 kGJNa7Lar2g8DOLTTZFdEmL9i9Q+lZkOb9GjP+eFoZTD65o4LyLqJFWI2XumBffMW/8t Y7fw== X-Gm-Message-State: AE9vXwOohgYVSLS5MF/IC5cb6rxEUghtTtkeWa5sp+Z6qF5oieJjiVdQvrWkM/iDIRqNxZAD X-Received: by 10.194.112.98 with SMTP id ip2mr23055679wjb.95.1474999588727; Tue, 27 Sep 2016 11:06:28 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id k2sm17932539wmg.23.2016.09.27.11.06.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:27 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vladimir Murzin , Christoffer Dall 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 Message-Id: <20160927180558.14699-43-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160927180558.14699-1-christoffer.dall@linaro.org> References: <20160927180558.14699-1-christoffer.dall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vladimir Murzin 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 Signed-off-by: Vladimir Murzin Signed-off-by: Christoffer Dall --- 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,