From patchwork Tue Aug 13 12:43:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 266789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (unknown [IPv6:2001:4830:134:3::12]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF9EB2C010B for ; Tue, 13 Aug 2013 22:44:30 +1000 (EST) Received: from localhost ([::1]:34295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9Dxc-0002Y0-1Y for incoming@patchwork.ozlabs.org; Tue, 13 Aug 2013 08:44:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9DxH-0002Uw-0J for qemu-devel@nongnu.org; Tue, 13 Aug 2013 08:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9DxB-0005IZ-1E for qemu-devel@nongnu.org; Tue, 13 Aug 2013 08:44:06 -0400 Received: from thoth.sbs.de ([192.35.17.2]:34180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9DxA-0005H5-NT for qemu-devel@nongnu.org; Tue, 13 Aug 2013 08:44:00 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id r7DChvKI016013; Tue, 13 Aug 2013 14:43:58 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.40.156]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id r7DChviA014047; Tue, 13 Aug 2013 14:43:57 +0200 Message-ID: <520A2A0D.4010600@siemens.com> Date: Tue, 13 Aug 2013 14:43:57 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Paolo Bonzini , Gleb Natapov X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 192.35.17.2 Cc: qemu-devel , kvm Subject: [Qemu-devel] [PATCH uq/master] kvm: Simplify kvm_handle_io X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that cpu_in/out is just a wrapper around address_space_rw, we can also call the latter directly. As host endianness == guest endianness, there is no need for the memory access helpers st*_p/ld*_p as well. Signed-off-by: Jan Kiszka Reviewed-by: Andreas Färber --- kvm-all.c | 28 ++-------------------------- 1 files changed, 2 insertions(+), 26 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 716860f..c861354 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1499,32 +1499,8 @@ static void kvm_handle_io(uint16_t port, void *data, int direction, int size, uint8_t *ptr = data; for (i = 0; i < count; i++) { - if (direction == KVM_EXIT_IO_IN) { - switch (size) { - case 1: - stb_p(ptr, cpu_inb(port)); - break; - case 2: - stw_p(ptr, cpu_inw(port)); - break; - case 4: - stl_p(ptr, cpu_inl(port)); - break; - } - } else { - switch (size) { - case 1: - cpu_outb(port, ldub_p(ptr)); - break; - case 2: - cpu_outw(port, lduw_p(ptr)); - break; - case 4: - cpu_outl(port, ldl_p(ptr)); - break; - } - } - + address_space_rw(&address_space_io, port, ptr, size, + direction == KVM_EXIT_IO_OUT); ptr += size; } }