From patchwork Mon Sep 23 05:21:42 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: 2926091 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 33015BFF05 for ; Mon, 23 Sep 2013 05:22:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 437CC20529 for ; Mon, 23 Sep 2013 05:22:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 607F720527 for ; Mon, 23 Sep 2013 05:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752276Ab3IWFVw (ORCPT ); Mon, 23 Sep 2013 01:21:52 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:60717 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751835Ab3IWFVv (ORCPT ); Mon, 23 Sep 2013 01:21:51 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa1so3096450pad.5 for ; Sun, 22 Sep 2013 22:21:51 -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=wiiPJIURBCZkH0QmuZNF/CtlHbG9OJYyJyLEM95ZIPQ=; b=q6gVQp0DBM9S8eHFBUhUaT8H60dekVsmuV0CNYVrnuLWblyOHKGyqrCkbgZVTySrag b/1fBXS8bnFiGctQ3nTDeXG5vUWPolupm6IQlqJrAJvkMIA7nxNh2HQewDrRlZeUFG/D aSBiKdPUC+12/oWl4hLHU4gBfMOWFMC6AlWzXB0Br8/XxuuHwZoqIVPwpE8SZk3pJBTv RsOnMlDbqb0RHEKeB9mxJgnH4sJ7uDvbpXeOjnwMWfXWOf9S9MASY4oMkHFkiC1g81RI 1l0FKfTaCpKzOYvOD94oXwV6CYtLQzAmw43Mw03boxNngiveOp4KT3N8LQlnOGfXU9z7 3avw== X-Received: by 10.68.197.3 with SMTP id iq3mr21678543pbc.113.1379913711234; Sun, 22 Sep 2013 22:21:51 -0700 (PDT) Received: from Blade1-01.Blade1-01 ([162.105.146.101]) by mx.google.com with ESMTPSA id hx1sm31440619pbb.35.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Sep 2013 22:21:50 -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 v2] kvm-unit-tests: VMX: Comments on the framework and writing test cases Date: Mon, 23 Sep 2013 13:21:42 +0800 Message-Id: <1379913702-18973-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=-9.1 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 | 30 ++++++++++++++++++++++++++++++ x86/vmx_tests.c | 13 +++++++++++++ 2 files changed, 43 insertions(+) diff --git a/x86/vmx.c b/x86/vmx.c index 9db4ef4..d5ae609 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -1,3 +1,33 @@ +/* + * x86/vmx.c : Framework for testing nested virtualization + * This is a framework to test nested VMX for KVM, which + * started as a project of GSoC 2013. All test cases should + * be located in x86/vmx_tests.c and framework related + * functions should be in this file. + * + * How to write test cases? + * Add callbacks of test suite in variant "vmx_tests". You can + * write: + * 1. init function used for initializing test suite + * 2. main function for codes running in L2 guest, + * 3. exit_handler to handle vmexit of L2 to L1 + * 4. syscall handler to handle L2 syscall vmexit + * 5. vmenter fail handler to handle direct failure of vmenter + * 6. guest_regs is loaded when vmenter and saved when + * vmexit, you can read and set it in exit_handler + * If no special function is needed for a test suite, use + * coressponding basic_* functions as callback. More handlers + * can be added to "vmx_tests", see details of "struct vmx_test" + * and function test_run(). + * + * Currently, vmx test framework only set up one VCPU and one + * concurrent guest test environment with same paging for L2 and + * L1. For usage of EPT, only 1:1 mapped paging is used from VFN + * to PFN. + * + * 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},