From patchwork Fri Dec 7 18:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10718725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1ABCB13BF for ; Fri, 7 Dec 2018 18:51:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BD8C2F59B for ; Fri, 7 Dec 2018 18:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE54A2F5A7; Fri, 7 Dec 2018 18:51:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 949382F5A1 for ; Fri, 7 Dec 2018 18:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726158AbeLGSvR (ORCPT ); Fri, 7 Dec 2018 13:51:17 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:42446 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbeLGSvQ (ORCPT ); Fri, 7 Dec 2018 13:51:16 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB7IheoX113589; Fri, 7 Dec 2018 18:51:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=IgVHpkEtIdUBzzxJmjKmpnZ38MM6mSEXOgZTnxUiqqo=; b=n7h3/nwS6OEZ9/GmD1CG8VzBtUH8obiyJ7HyOaj2ULiKU7AWhuRnsZUc84v1wMbEXyqQ QGxPOWdu6l9GmNaXDD7w/TuBp5EeQVd/+WCN1bx1p1CuFDlXnTnK+hGxXQ1EypN0mW8X /Ol6DX7uiXs9InteK9/4yfTFmxl7fp86U5JPjyiIkqxyhvL6eUBryo5SkNcrjm5uBNJR BHYYGtxQwJdVDj4qQjNNcl9PYz18O+vdZo3+YOQKEFUhVXbNcaM5g3JfnFzkqURoPkLv 4DzekaL7gUKqrgWjN+PPjAuRAuYoGrAAQtn/zMdKxhQw+PDQT63DOpcMuniRfuLI9PN+ Kg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2p3ftfkbw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Dec 2018 18:51:10 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB7IpAsM031379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Dec 2018 18:51:10 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB7IpAna006863; Fri, 7 Dec 2018 18:51:10 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Dec 2018 10:51:10 -0800 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, jmattson@google.com Subject: [kvm-unit-test 1/2] nVMX: Move all tests for VM-execution control fields to a separate function Date: Fri, 7 Dec 2018 13:26:36 -0500 Message-Id: <20181207182637.13043-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20181207182637.13043-1-krish.sadhukhan@oracle.com> References: <20181207182637.13043-1-krish.sadhukhan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9099 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=968 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812070152 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ... to improve readability and maintainability, and to align the code as per the layout of the checks in chapter "VM Entries" in Intel SDM vol 3C. Signed-off-by: Krish Sadhukhan Reviewed-by: Mihai Carabas --- x86/vmx_tests.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 7a8d6ce..50806ab 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -4799,18 +4799,10 @@ static void test_vmx_preemption_timer(void) } /* - * Check that the virtual CPU checks all of the VMX controls as - * documented in the Intel SDM. + * Tests for VM-execution control fields */ -static void vmx_controls_test(void) +static void test_vm_execution_ctls(void) { - /* - * Bit 1 of the guest's RFLAGS must be 1, or VM-entry will - * fail due to invalid guest state, should we make it that - * far. - */ - vmcs_write(GUEST_RFLAGS, 0); - test_pin_based_ctls(); test_primary_processor_based_ctls(); test_secondary_processor_based_ctls(); @@ -4821,12 +4813,28 @@ static void vmx_controls_test(void) test_tpr_threshold(); test_nmi_ctrls(); test_pml(); - test_invalid_event_injection(); test_vpid(); test_ept_eptp(); test_vmx_preemption_timer(); } +/* + * Check that the virtual CPU checks all of the VMX controls as + * documented in the Intel SDM. + */ +static void vmx_controls_test(void) +{ + /* + * Bit 1 of the guest's RFLAGS must be 1, or VM-entry will + * fail due to invalid guest state, should we make it that + * far. + */ + vmcs_write(GUEST_RFLAGS, 0); + + test_vm_execution_ctls(); + test_invalid_event_injection(); +} + static bool valid_vmcs_for_vmentry(void) { struct vmcs *current_vmcs = NULL;