From patchwork Tue Sep 17 02:29:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Chunqi Li X-Patchwork-Id: 2900421 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 7A0949F1E3 for ; Tue, 17 Sep 2013 02:29:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 881522030B for ; Tue, 17 Sep 2013 02:29:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEAE520303 for ; Tue, 17 Sep 2013 02:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751602Ab3IQC3t (ORCPT ); Mon, 16 Sep 2013 22:29:49 -0400 Received: from mail-pb0-f41.google.com ([209.85.160.41]:58304 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751489Ab3IQC3s (ORCPT ); Mon, 16 Sep 2013 22:29:48 -0400 Received: by mail-pb0-f41.google.com with SMTP id rp2so4873691pbb.14 for ; Mon, 16 Sep 2013 19:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=AFvmFiTX/Sq5INvOD1yrPacSd6aOeMBLh0cSymxMBKc=; b=JT3vMme3q5nBaH2KhDSdOIJv9SuSKCX6u5ioZot97U5bbiXdJlDwnM6BEfUL2n2bHo BCvyieoNnRAlaip61mXm/CxPIUIxlzwaYZ9KTEAoRcifpuHu/wGQfH8CBPXppDDPn1mh azF6tARp6I6zEjuvCoHrZusBaoRAL9DFqJs6YaeKjMhkhxABaM8OhXEcM4b0e+G2WVHK iEMOsOe1CvsVWXT045f3Zt2yf6JkqFUrjTBVxcggEOukUzwHm4WSiTP34nw5VDnVuJbp 1Zr+THEnBmm/osblwexxyQM2J/aI2VrBXmsih1fy59A9AbGQD6OduvOOh2l6u2WN7t2f ClzQ== X-Received: by 10.66.216.193 with SMTP id os1mr34280164pac.29.1379384988292; Mon, 16 Sep 2013 19:29:48 -0700 (PDT) Received: from Blade1-01.Blade1-01 ([162.105.146.101]) by mx.google.com with ESMTPSA id kd1sm42156231pab.20.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 19:29:47 -0700 (PDT) From: Arthur Chunqi Li To: kvm@vger.kernel.org Cc: jan.kiszka@web.de, gleb@redhat.com, pbonzini@redhat.com, Arthur Chunqi Li Subject: [PATCH] kvm-unit-tests: VMX: Comments on the framework and writing test cases Date: Tue, 17 Sep 2013 10:29:16 +0800 Message-Id: <1379384956-11487-1-git-send-email-yzt356@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Add some comments on the framework of nested VMX testing, and guides of how to write new test cases. Signed-off-by: Arthur Chunqi Li --- x86/vmx.c | 25 +++++++++++++++++++++++++ x86/vmx_tests.c | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/x86/vmx.c b/x86/vmx.c index 9db4ef4..3aa8600 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -1,3 +1,28 @@ +/* + * x86/vmx.c : Framework for testing nested virtualization + * This is a framework to test nested VMX for KVM, which is + * a project of GSoC 2013. All test cases are located in + * "vmx_tests", which is defined in x86/vmx_tests.c. All test + * cases should be located in x86/vmx_tests.c and framework + * related functions should be in this file. + * + * How to write test suite? + * Add functions of test suite in variant "vmx_tests". You can + * write: + * init function used for initializing test suite + * main function for codes running in L2 guest, + * exit_handler to handle vmexit of L2 to L1 (framework) + * syscall handler to handle L2 syscall vmexit + * vmenter fail handler to handle direct failure of vmenter + * init registers used to store register value in initialization + * If no special function is needed for a test suite, you can use + * basic_* series of functions. More handlers can be added to + * "vmx_tests", see details of "struct vmx_test" and function + * test_run(). + * + * Author : Arthur Chunqi Li + */ + #include "libcflat.h" #include "processor.h" #include "vm.h" diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 0759e10..5fc16a3 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -1,3 +1,8 @@ +/* + * All test cases of nested virtualization should be in this file + * + * Author : Arthur Chunqi Li + */ #include "vmx.h" #include "msr.h" #include "processor.h" @@ -782,6 +787,14 @@ struct insn_table { u32 test_field; }; +/* + * Add more test cases of instruction intercept here. Elements in this + * table is: + * name/control flag/insn function/type/exit reason/exit qulification/ + * instruction info/field to test + * The last field defines which fields (exit_qual and insn_info) need to be + * tested in exit handler. If set to 0, only "reason" is checked. + */ static struct insn_table insn_table[] = { // Flags for Primary Processor-Based VM-Execution Controls {"HLT", CPU_HLT, insn_hlt, INSN_CPU0, 12, 0, 0, 0},