From patchwork Sun Feb 11 02:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 10210645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FF6D60594 for ; Sun, 11 Feb 2018 02:04:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FA8C29499 for ; Sun, 11 Feb 2018 02:04:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53ABF2949E; Sun, 11 Feb 2018 02:04:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92E8429499 for ; Sun, 11 Feb 2018 02:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752185AbeBKCEp (ORCPT ); Sat, 10 Feb 2018 21:04:45 -0500 Received: from mga04.intel.com ([192.55.52.120]:46719 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbeBKCEo (ORCPT ); Sat, 10 Feb 2018 21:04:44 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2018 18:04:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,493,1511856000"; d="scan'208";a="17213908" Received: from gao-cwp.sh.intel.com ([10.239.13.104]) by orsmga008.jf.intel.com with ESMTP; 10 Feb 2018 18:04:42 -0800 From: Chao Gao To: kvm@vger.kernel.org Cc: Chao Gao , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini , Liran Alon Subject: [kvm-unit-tests PATCH] kvm-unit-tests: vmx: add a test for injecting events to halted L2 Date: Sun, 11 Feb 2018 10:06:47 +0800 Message-Id: <1518314807-31821-1-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch leverages existing "interrupt" tests. What the patch does is L1 puts L2 in halt state and injects an event to L2. Then check a flag to identify whether event injection succeeds or not. Cc: Liran Alon Signed-off-by: Chao Gao --- x86/vmx_tests.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 0c3b5a7..3c46d3a 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -1584,6 +1584,12 @@ static void interrupt_main(void) for (loops = 0; loops < 10000000 && !timer_fired; loops++) asm volatile ("nop"); report("running a guest with interrupt acknowledgement set", timer_fired); + + apic_write(APIC_TMICT, 0); + irq_enable(); + timer_fired = false; + vmcall(); + report("Inject an event to a halted guest", timer_fired); } static int interrupt_exit_handler(void) @@ -1615,6 +1621,12 @@ static int interrupt_exit_handler(void) case 6: vmcs_write(GUEST_ACTV_STATE, ACTV_HLT); break; + + case 8: + vmcs_write(GUEST_ACTV_STATE, ACTV_HLT); + vmcs_write(ENT_INTR_INFO, + TIMER_VECTOR | INTR_INFO_VALID_MASK); + break; } vmx_inc_test_stage(); vmcs_write(GUEST_RIP, guest_rip + insn_len);