From patchwork Mon Jun 30 09:07:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 4446811 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 DAFCEBEEAA for ; Mon, 30 Jun 2014 09:07:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B5E2202F8 for ; Mon, 30 Jun 2014 09:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CBA420176 for ; Mon, 30 Jun 2014 09:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754879AbaF3JHT (ORCPT ); Mon, 30 Jun 2014 05:07:19 -0400 Received: from mout.web.de ([212.227.17.12]:60060 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753017AbaF3JHS (ORCPT ); Mon, 30 Jun 2014 05:07:18 -0400 Received: from netbook.home ([95.157.58.223]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MF3jD-1WqnEO1Ajr-00GIMf; Mon, 30 Jun 2014 11:07:07 +0200 Message-ID: <53B128B9.1030205@web.de> Date: Mon, 30 Jun 2014 11:07:05 +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 , kvm CC: Joerg Roedel , Valentine Sinitsyn Subject: [PATCH] KVM: nSVM: Fix IOIO size reported on emulation X-Enigmail-Version: 1.6 X-Provags-ID: V03:K0:6wc8qenAHxa4BxmkvJtE2GSv5r09lyYaJ8Qxjb9+mIrPrrc+vdj M5c1xmvub1qjYMS0kB4yIbmmEUVXGf87ETZhDu+8v7OTOnW8J7spWEvFKLC4NL7F2ud6wH8 pxGG3nRAEKCoMwA5EGDwH4Krfq2xWqWI83ZIkhgnH+/qKLUN756OA+OoKRT7shl4l0g4RWu V9Frw33NvahuLrNF1wiew== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,T_TVD_MIME_EPI,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 From: Jan Kiszka The access size of an in/ins is reported in dst_bytes, and that of out/outs in src_bytes. Signed-off-by: Jan Kiszka --- I'm seeing one more issue now: on emulation of "in (%dx),%eax", we leave to user space several times and check interception also several times after returning. We use dx to calculate the port number for the interception check. But at some point, user space (QEMU) decides to update that register during vmport access - and now we check the wrong port in the bitmap (namely port 0). Ideas? In general, the same interception checks are done multiple times. Once after the exit, then again during emulation. Can't we avoid this somehow? arch/x86/kvm/svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 3483ac9..1824949 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4261,9 +4261,9 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu, if (info->intercept == x86_intercept_in || info->intercept == x86_intercept_ins) { exit_info |= SVM_IOIO_TYPE_MASK; - bytes = info->src_bytes; - } else { bytes = info->dst_bytes; + } else { + bytes = info->src_bytes; } if (info->intercept == x86_intercept_outs ||