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; From patchwork Fri Dec 7 18:26:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10718727 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 77E931932 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 68CFF2F548 for ; Fri, 7 Dec 2018 18:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 543FD2F59B; Fri, 7 Dec 2018 18:51:19 +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 EE07F2F5A6 for ; Fri, 7 Dec 2018 18:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbeLGSvS (ORCPT ); Fri, 7 Dec 2018 13:51:18 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:42454 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbeLGSvR (ORCPT ); Fri, 7 Dec 2018 13:51:17 -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 wB7Ihj7O113633; Fri, 7 Dec 2018 18:51:11 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=M0anrnB/VrvE3ObMvWrwPsfzO8sVlXon8ggtdKJPoHI=; b=rRlBg5Vk9TuTQcZAmLdr26Jkmc6L65yu7TFpN466jqVQPm83B2eG/bGRut9q81ZYbHNm VUnCa/r+ggRHWT3b78rX+/kNJGkPWtK6hqvoWMElZ2QEAkYaLZIrRJ5sqpd7a2JXjGz2 suhgIj8D7acMkUPtxaN2V99wQk95sHve2rArEKfpMYu/ZcIroVChS+Lz+5idut15bfmL yHtJWDAfAn282FBLUU34BUo9y+SDJkhgZDcqo/usi0/fr995jvmdjZEis5gguiYPx3pA 1rhANx2OFoo3W5KXKoclZAs92tk9UFP2LSSuKU1ZBCzQicvdhbIGT+KsF1vIGFWHENg6 kA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2p3ftfkbwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Dec 2018 18:51:11 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB7IpBLv023597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Dec 2018 18:51:11 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB7IpAst003208; 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 2/2] nVMX: Move all tests for VM-entry control fields to a separate function Date: Fri, 7 Dec 2018 13:26:37 -0500 Message-Id: <20181207182637.13043-3-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=949 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 50806ab..2ff94e0 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -4819,6 +4819,14 @@ static void test_vm_execution_ctls(void) } /* + * Tests for VM-entry control fields + */ +static void test_vm_entry_ctls(void) +{ + test_invalid_event_injection(); +} + +/* * Check that the virtual CPU checks all of the VMX controls as * documented in the Intel SDM. */ @@ -4832,7 +4840,7 @@ static void vmx_controls_test(void) vmcs_write(GUEST_RFLAGS, 0); test_vm_execution_ctls(); - test_invalid_event_injection(); + test_vm_entry_ctls(); } static bool valid_vmcs_for_vmentry(void)