From patchwork Sat Jan 4 17:59:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 3434281 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4397F9F2E9 for ; Sat, 4 Jan 2014 18:00:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70FA32015F for ; Sat, 4 Jan 2014 18:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A7272015E for ; Sat, 4 Jan 2014 17:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754893AbaADR7y (ORCPT ); Sat, 4 Jan 2014 12:59:54 -0500 Received: from mout.web.de ([212.227.15.3]:50621 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754773AbaADR7i (ORCPT ); Sat, 4 Jan 2014 12:59:38 -0500 Received: from mchn199C.home ([95.157.58.223]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0MSGXj-1VpIG33Eol-00TS9X for ; Sat, 04 Jan 2014 18:59:36 +0100 From: Jan Kiszka To: Gleb Natapov , Paolo Bonzini , Marcelo Tosatti Cc: kvm Subject: [PATCH 09/13] VMX: Check unconditional I/O exiting Date: Sat, 4 Jan 2014 18:59:15 +0100 Message-Id: <43c381a291fb3f4bad73787f3211df33ec909a06.1388858359.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.8.1.1.298.ge7eed54 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V03:K0:nHxDTtJKL3x2QBhtGjiEMGyq4xyVTTWsZlg6hxhaqiqeWGWpyBp dz3jXZwpyHIMits9yyZc7nkbQUl4aGgvFyv9y8RsXqPCcyRZGFFBpH8xNFiy8JonQoyrqSy rGUI+Wq8P8EoO8++xuXW1FDDH8+7JFhtBVhY2gXYQZ2sAiSwT8j9W2kJwaUdHDibLkJcgR8 49yYuPN9yjQkhjiYDLprg== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 From: Jan Kiszka Test if we ignore "unconditional I/O exiting" as long as "use I/O bitmap" is enabled. Also test if unconditional exiting itself works. Signed-off-by: Jan Kiszka --- x86/vmx_tests.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 0077f3f..2c2d6c4 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -701,13 +701,21 @@ static void iobmp_main() report("I/O bitmap - overrun", 1); else report("I/O bitmap - overrun", 0); + set_stage(9); + vmcall(); + outb(0x0, 0x0); + report("I/O bitmap - ignore unconditional exiting", stage == 9); + set_stage(10); + vmcall(); + outb(0x0, 0x0); + report("I/O bitmap - unconditional exiting", stage == 11); } static int iobmp_exit_handler() { u64 guest_rip; ulong reason, exit_qual; - u32 insn_len; + u32 insn_len, ctrl_cpu0; guest_rip = vmcs_read(GUEST_RIP); reason = vmcs_read(EXI_REASON) & 0xff; @@ -765,6 +773,32 @@ static int iobmp_exit_handler() if (((exit_qual & VMX_IO_PORT_MASK) >> VMX_IO_PORT_SHIFT) == 0xFFFF) set_stage(stage + 1); break; + case 9: + case 10: + ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0); + vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0 & ~CPU_IO); + set_stage(stage + 1); + break; + default: + // Should not reach here + printf("ERROR : unexpected stage, %d\n", get_stage()); + print_vmexit_info(); + return VMX_TEST_VMEXIT; + } + vmcs_write(GUEST_RIP, guest_rip + insn_len); + return VMX_TEST_RESUME; + case VMX_VMCALL: + switch (get_stage()) { + case 9: + ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0); + ctrl_cpu0 |= CPU_IO | CPU_IO_BITMAP; + vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0); + break; + case 10: + ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0); + ctrl_cpu0 = (ctrl_cpu0 & ~CPU_IO_BITMAP) | CPU_IO; + vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0); + break; default: // Should not reach here printf("ERROR : unexpected stage, %d\n", get_stage());