From patchwork Thu Apr 17 14:57:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 4009201 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E1CD9BFF02 for ; Thu, 17 Apr 2014 14:58:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 255C320212 for ; Thu, 17 Apr 2014 14:58:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A7C620394 for ; Thu, 17 Apr 2014 14:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbaDQO57 (ORCPT ); Thu, 17 Apr 2014 10:57:59 -0400 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:51858 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbaDQO54 (ORCPT ); Thu, 17 Apr 2014 10:57:56 -0400 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.157]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s3HEvowo006602; Thu, 17 Apr 2014 15:57:50 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id AECF91AE0621; Thu, 17 Apr 2014 15:57:50 +0100 (BST) From: Will Deacon To: kvm@vger.kernel.org Cc: penberg@kernel.org, Will Deacon Subject: [PATCH 2/2] kvm tools: ARM: allow potential relocation of IO port Date: Thu, 17 Apr 2014 15:57:48 +0100 Message-Id: <1397746668-29060-2-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1397746668-29060-1-git-send-email-will.deacon@arm.com> References: <1397746668-29060-1-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Whilst our IO port is fixed at CPU physical address 0x0, changing ARM_IOPORT_AREA should be all that's necessary to move it around in CPU physical space (it will still be at 0x0 in the bus address space). This patch ensures we subtract KVM_IOPORT_AREA from the faulting CPU physical address when calculating the port for kvm__emulate_io. Reported-by: Arnd Bergmann Signed-off-by: Will Deacon --- tools/kvm/arm/kvm-cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c index b017994f4014..9c9616f307a4 100644 --- a/tools/kvm/arm/kvm-cpu.c +++ b/tools/kvm/arm/kvm-cpu.c @@ -105,7 +105,7 @@ bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, return kvm__emulate_mmio(kvm, phys_addr, data, len, is_write); } else if (arm_addr_in_ioport_region(phys_addr)) { int direction = is_write ? KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN; - u16 port = phys_addr & USHRT_MAX; + u16 port = (phys_addr - KVM_IOPORT_AREA) & USHRT_MAX; return kvm__emulate_io(kvm, port, data, direction, len, 1); } else if (arm_addr_in_pci_region(phys_addr)) { return kvm__emulate_mmio(kvm, phys_addr, data, len, is_write);