From patchwork Thu Aug 6 18:39:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Triplett X-Patchwork-Id: 6962021 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B82F9F39D for ; Thu, 6 Aug 2015 18:40:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D074206F5 for ; Thu, 6 Aug 2015 18:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5471A206EF for ; Thu, 6 Aug 2015 18:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755922AbbHFSkE (ORCPT ); Thu, 6 Aug 2015 14:40:04 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:55337 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755781AbbHFSkC (ORCPT ); Thu, 6 Aug 2015 14:40:02 -0400 Received: from cloud (joshtriplett.org [IPv6:2604:3400:dc1:41:216:3eff:fe9f:2070]) (Authenticated sender: josh@joshtriplett.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id F0CAEA80AC; Thu, 6 Aug 2015 20:40:00 +0200 (CEST) Date: Thu, 6 Aug 2015 11:39:59 -0700 From: Josh Triplett To: kvm@vger.kernel.org Cc: Will Deacon Subject: [PATCH kvmtool] kvm__emulate_io: Don't fall through from IO in to IO out if no handler Message-ID: <20150806183959.GA6740@cloud> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 If an IO port device has no io_in handler, kvm__emulate_io would fall through and call the io_out handler instead. Fix to only call the handler for the appropriate direction. If no handler exists, kvm__emulate_io will automatically treat it as an IO error (due to the default "ret = false"). Signed-off-by: Josh Triplett --- ioport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ioport.c b/ioport.c index 8c55a84..263fe50 100644 --- a/ioport.c +++ b/ioport.c @@ -192,7 +192,7 @@ bool kvm__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, while (count--) { if (direction == KVM_EXIT_IO_IN && ops->io_in) ret = ops->io_in(entry, vcpu, port, ptr, size); - else if (ops->io_out) + else if (direction == KVM_EXIT_IO_OUT && ops->io_out) ret = ops->io_out(entry, vcpu, port, ptr, size); ptr += size;