From patchwork Fri Apr 21 00:49:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9691567 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 E57136038D for ; Fri, 21 Apr 2017 00:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D787C2843F for ; Fri, 21 Apr 2017 00:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC78B2847C; Fri, 21 Apr 2017 00:51:40 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, UPPERCASE_50_75 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 73EC92843F for ; Fri, 21 Apr 2017 00:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S948291AbdDUAvi (ORCPT ); Thu, 20 Apr 2017 20:51:38 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:36296 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033694AbdDUAuV (ORCPT ); Thu, 20 Apr 2017 20:50:21 -0400 Received: by mail-oi0-f43.google.com with SMTP id r203so73045034oib.3 for ; Thu, 20 Apr 2017 17:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z8VAf7ploCkZB1IB/BJXvTSrRVIBS4aFQFBJxE2EGxA=; b=Pp+Jvl7YihunWyWiq/QJHgjz5yRdtSx0Srb5+IC5BCDJo1h2R8n83yhCFCdUJ4vvJm 2Z5BHBPLoTZ9d010udNVA6lqOONluZjT/OVQNsSis680jap1zuHd440ekxoYbrE0Yg5k cjGV/61GejtV34OJ8p+ABqMbw4QdvSJk1iW0ahZjPpcbnMZCcYovijrgCbYv+ya22pL1 RKE5LvolXP1b1c9izP5oB3SadNocyu+ABoHzyjOizHqndvqePYn2GZChsfdz+8mnwcS8 PcbapAab7sEETwOKx3UpHU85/2gmkkMjjr9L3lxrnkAIKGLfvYDM2QBppcwyfKmR9Dej zxBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z8VAf7ploCkZB1IB/BJXvTSrRVIBS4aFQFBJxE2EGxA=; b=KHapdqxZPG0LFomlnkaCWWSP40/BPuIdltOThw3BNxBpfBuw20pzjnYU8hIlIGV9Dt 7t7EYYyUR6oW7CJbIg5DM4PDaFEG1FiWx3bP5IoffTBWICQfVIjH8vLvlJrugHxbaUQu geiIknOaEfEKGG9OHs2OXIWLIk60xGR/CLwWbY/+A45ZVcnWPG6XNSQwPhYmweJ99hgA cD5VT8RZYuTd91ohkJNR4wAdvHeKTK+QRSF/ohvZVUkI7MqMbMvov3QqmpsRlvAkYnva oVqggCCm63C/OLx56WfqEai/rr4oytNy7/xwfJq+WUug38wC9HzI8b72evn44KWJRoYJ Bx5g== X-Gm-Message-State: AN3rC/5fU2+dj6wbIDDvFPejDkpkPi3d1YY24HfObzcSY7rSUIqHdPVL wx145d1qQGsltdZr X-Received: by 10.84.140.5 with SMTP id 5mr712304pls.113.1492735815730; Thu, 20 Apr 2017 17:50:15 -0700 (PDT) Received: from dmatlack.sea.corp.google.com ([100.100.206.82]) by smtp.gmail.com with ESMTPSA id e13sm12466486pfb.30.2017.04.20.17.50.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 17:50:14 -0700 (PDT) From: David Matlack To: kvm@vger.kernel.org Cc: GanShun , David Matlack Subject: [kvm-unit-tests PATCH 08/32] x86: Adding gtest to check correct instruction error is returned Date: Thu, 20 Apr 2017 17:49:40 -0700 Message-Id: <20170421005004.137260-9-dmatlack@google.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170421005004.137260-1-dmatlack@google.com> References: <20170421005004.137260-1-dmatlack@google.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: GanShun Added a check in test_vmptrld to verfiy that VMXERR_VMPTRLD_VMXON_POINTER is returned instead of VMXERR_VMCLEAR_VMXON_POINTER. Signed-off-by: GanShun Signed-off-by: David Matlack --- x86/vmx.c | 3 +++ x86/vmx.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/x86/vmx.c b/x86/vmx.c index 651807a76a1e..39a891da4635 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -899,9 +899,12 @@ static void test_vmptrld(void) make_vmcs_current(tmp_root) == 1); /* Pass VMXON region */ + make_vmcs_current(vmcs); tmp_root = (struct vmcs *)vmxon_region; report("test vmptrld with vmxon region", make_vmcs_current(tmp_root) == 1); + report("test vmptrld with vmxon region vm-instruction error", + vmcs_read(VMX_INST_ERROR) == VMXERR_VMPTRLD_VMXON_POINTER); report("test vmptrld with valid vmcs region", make_vmcs_current(vmcs) == 0); } diff --git a/x86/vmx.h b/x86/vmx.h index 290e6bd72b19..52ece1aa53c8 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -396,6 +396,37 @@ enum Intr_type { #define INTR_INFO_INTR_TYPE_SHIFT 8 +/* + * VM-instruction error numbers + */ +enum vm_instruction_error_number { + VMXERR_VMCALL_IN_VMX_ROOT_OPERATION = 1, + VMXERR_VMCLEAR_INVALID_ADDRESS = 2, + VMXERR_VMCLEAR_VMXON_POINTER = 3, + VMXERR_VMLAUNCH_NONCLEAR_VMCS = 4, + VMXERR_VMRESUME_NONLAUNCHED_VMCS = 5, + VMXERR_VMRESUME_AFTER_VMXOFF = 6, + VMXERR_ENTRY_INVALID_CONTROL_FIELD = 7, + VMXERR_ENTRY_INVALID_HOST_STATE_FIELD = 8, + VMXERR_VMPTRLD_INVALID_ADDRESS = 9, + VMXERR_VMPTRLD_VMXON_POINTER = 10, + VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID = 11, + VMXERR_UNSUPPORTED_VMCS_COMPONENT = 12, + VMXERR_VMWRITE_READ_ONLY_VMCS_COMPONENT = 13, + VMXERR_VMXON_IN_VMX_ROOT_OPERATION = 15, + VMXERR_ENTRY_INVALID_EXECUTIVE_VMCS_POINTER = 16, + VMXERR_ENTRY_NONLAUNCHED_EXECUTIVE_VMCS = 17, + VMXERR_ENTRY_EXECUTIVE_VMCS_POINTER_NOT_VMXON_POINTER = 18, + VMXERR_VMCALL_NONCLEAR_VMCS = 19, + VMXERR_VMCALL_INVALID_VM_EXIT_CONTROL_FIELDS = 20, + VMXERR_VMCALL_INCORRECT_MSEG_REVISION_ID = 22, + VMXERR_VMXOFF_UNDER_DUAL_MONITOR_TREATMENT_OF_SMIS_AND_SMM = 23, + VMXERR_VMCALL_INVALID_SMM_MONITOR_FEATURES = 24, + VMXERR_ENTRY_INVALID_VM_EXECUTION_CONTROL_FIELDS_IN_EXECUTIVE_VMCS = 25, + VMXERR_ENTRY_EVENTS_BLOCKED_BY_MOV_SS = 26, + VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID = 28, +}; + #define SAVE_GPR \ "xchg %rax, regs\n\t" \ "xchg %rbx, regs+0x8\n\t" \