From patchwork Thu May 9 21:20:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10937905 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 914621390 for ; Thu, 9 May 2019 21:47:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83230289EC for ; Thu, 9 May 2019 21:47:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7725728A5B; Thu, 9 May 2019 21:47:24 +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 0953028A16 for ; Thu, 9 May 2019 21:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbfEIVrU (ORCPT ); Thu, 9 May 2019 17:47:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48968 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726989AbfEIVrT (ORCPT ); Thu, 9 May 2019 17:47:19 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LihxY185862; Thu, 9 May 2019 21:46:58 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 : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=ILnW0wsBivAJkm1XbUoPFgltWm+r7j/kZDMAfDd4L/Y=; b=miM7XTI63VOOmlnSechjN9cAWV2t/f0lXkAgxEg3Thyw4I5ebUNbH7f4pb0aPeMpfh4Y i3beZSLA4iDaQMh1bCxm/zfcO/KsrLeSA8PEncjhvvIruHkkpvGOfGc1NzFCYziuiqL2 xsKu6oMgIdTseljXLz3K2Z9W6WlOpr5H4P9EOO+bIlxcygVWwU2kCIPl4g7yOBwi9NqJ lOZdPiLPxtFK2Z8kFhQ0pta+PHmLKdml+ZoFcIuH1Jkgq877aXorZB4Dd7pTUeVFKHUP qafDZPBayDIYuTesi9ja/BJLSyDnOwT++Bbd/86RCylIda/oThC6Js/7kmOZHlT3klee Eg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2s94b15nka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LjC9r191548; Thu, 9 May 2019 21:46:57 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2schw032jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:57 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x49Lkv1Z032089; Thu, 9 May 2019 21:46:57 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 May 2019 14:46:57 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: rkrcmar@redhat.com, pbonzini@redhat.com, jmattson@google.com Subject: [PATCH 1/4][kvm-unit-test nVMX]: Rename guest_pat_main to guest_state_test_main Date: Thu, 9 May 2019 17:20:52 -0400 Message-Id: <20190509212055.29933-2-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190509212055.29933-1-krish.sadhukhan@oracle.com> References: <20190509212055.29933-1-krish.sadhukhan@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ...so that it can be re-used by other tests. Signed-off-by: Krish Sadhukhan Reviewed-by: Karl Heubaum --- x86/vmx_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index c01fa9d..ee96596 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -4995,7 +4995,7 @@ static void test_sysenter_field(u32 field, const char *name) vmcs_write(field, addr_saved); } -static void guest_pat_main(void) +static void guest_state_test_main(void) { while (1) { if (vmx_get_test_stage() != 2) @@ -5097,7 +5097,7 @@ static void test_pat(u32 fld, const char * fld_name, u32 ctrl_fld, u64 ctrl_bit) vmcs_clear_bits(ctrl_fld, ctrl_bit); if (fld == GUEST_PAT) { vmx_set_test_stage(1); - test_set_guest(guest_pat_main); + test_set_guest(guest_state_test_main); } for (i = 0; i < 256; i = (i < PAT_VAL_LIMIT) ? i + 1 : i * 2) { From patchwork Thu May 9 21:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10937897 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 83752112C for ; Thu, 9 May 2019 21:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 705D428A16 for ; Thu, 9 May 2019 21:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C38428A5B; Thu, 9 May 2019 21:47:17 +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 F3B2F289EC for ; Thu, 9 May 2019 21:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbfEIVrP (ORCPT ); Thu, 9 May 2019 17:47:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55152 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfEIVrP (ORCPT ); Thu, 9 May 2019 17:47:15 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LiP2Q167641; Thu, 9 May 2019 21:46:59 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 : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=hd70tYlMcjdgM84KL5FEKIqbP+hq+PffgStFpNuCJwI=; b=43Xi/4JMWWTUUV02XhV/Mk3Xnmbug4lCcDcBH9wfLMAd91yLIWMvsUYvQ0qCZqCt+GWW dOQOc9EAg2DZE+TeJypJibVj4jfFUykqN8yP2BokejrWEt+Kg/noJWuQIHao/35I04fN FsPFVLzPPUNQN9ZY8lex6kIdzrfUfuOTUjPW5A/CvrltRccZ0mQUnm6tKu9jxH0nmZC6 1zkFV7B2+WpC22V0RvS/40ocLEq1zBp4OiEI4hVxG4mPerQkBS1yIbvFcIsjRrCqOp7y YRtGI2hcGyjbjoLDG2xFcRAbn/jhFsKS8QZq/70YoBMmWQXsr5WucqY5DcNOjtfp/emI rg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2s94bgdp0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:58 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49Lj6YZ159159; Thu, 9 May 2019 21:46:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2scpy5wvjk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:57 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x49LkvOd032092; Thu, 9 May 2019 21:46:57 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 May 2019 14:46:57 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: rkrcmar@redhat.com, pbonzini@redhat.com, jmattson@google.com Subject: [PATCH 2/4][kvm-unit-test nVMX]: Rename report_guest_pat_test to report_guest_state_test Date: Thu, 9 May 2019 17:20:53 -0400 Message-Id: <20190509212055.29933-3-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190509212055.29933-1-krish.sadhukhan@oracle.com> References: <20190509212055.29933-1-krish.sadhukhan@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ...so that it can be re-used by other tests. Signed-off-by: Krish Sadhukhan Reviewed-by: Karl Heubaum --- x86/vmx_tests.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index ee96596..a339bb3 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -5007,13 +5007,14 @@ static void guest_state_test_main(void) asm volatile("fnop"); } -static void report_guest_pat_test(const char *test, u32 xreason, u64 guest_pat) +static void report_guest_state_test(const char *test, u32 xreason, + u64 field, const char * field_name) { u32 reason = vmcs_read(EXI_REASON); u64 guest_rip; u32 insn_len; - report("%s, GUEST_PAT %lx", reason == xreason, test, guest_pat); + report("%s, %s %lx", reason == xreason, test, field_name, field); guest_rip = vmcs_read(GUEST_RIP); insn_len = vmcs_read(EXI_INST_LEN); @@ -5112,8 +5113,9 @@ static void test_pat(u32 fld, const char * fld_name, u32 ctrl_fld, u64 ctrl_bit) } else { // GUEST_PAT __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT enabled", - VMX_VMCALL, val); + report_guest_state_test("ENT_LOAD_PAT enabled", + VMX_VMCALL, val, + "GUEST_PAT"); } } } @@ -5139,17 +5141,19 @@ static void test_pat(u32 fld, const char * fld_name, u32 ctrl_fld, u64 ctrl_bit) } else { // GUEST_PAT if (i == 0x2 || i == 0x3 || i == 0x8) { __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT " - "enabled", + report_guest_state_test("ENT_LOAD_PAT " + "enabled", VMX_FAIL_STATE | VMX_ENTRY_FAILURE, - val); + val, + "GUEST_PAT"); } else { __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT " + report_guest_state_test("ENT_LOAD_PAT " "enabled", VMX_VMCALL, - val); + val, + "GUEST_PAT"); } } From patchwork Thu May 9 21:20:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10937899 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 E609E15A6 for ; Thu, 9 May 2019 21:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3855289EC for ; Thu, 9 May 2019 21:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C472E28A5B; Thu, 9 May 2019 21:47:17 +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 6AF7B289EC for ; Thu, 9 May 2019 21:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbfEIVrQ (ORCPT ); Thu, 9 May 2019 17:47:16 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:34870 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfEIVrP (ORCPT ); Thu, 9 May 2019 17:47:15 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LiQpf179132; Thu, 9 May 2019 21:46:59 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 : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=TZBt4pA7NKxXTWaITFJcnks62kgz7q+5yunnkc9Z6qU=; b=VPLibSP8J9BPeRVtDfyyig1qQ/CNbefew03fAEkiKOsCkfS3qSH6Ad1vxaZja0SB/wER AAHmylYeS+SckcEtEUKbpkIvJC5pZhB4wEw2c7M2wDt+XpdxEw4QK7HvudgsJ/gF7D0B rVN+QVwRM32ovVxhsFTH2FkNMDKSKC7utU/+/zZig5XcYa35f0e5LNDDw6JSGfQynsOQ T8Wz7B4bCwCsFsa2AF8PzfmYRBDXi29l/pSQpnSiODnxEII8PPxhJq2dWX9gxJw1at/6 h1U27aaZEeg5+lHVG/uR3N9kYNcT6HMAfO0a87Mg035DzTBOcree0wTp9eDwSkVgk1j0 Ug== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2s94b6dpv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:59 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49Lk7oh152467; Thu, 9 May 2019 21:46:58 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2sagyvgagt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:58 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x49LkwZf012695; Thu, 9 May 2019 21:46:58 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 May 2019 14:46:57 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: rkrcmar@redhat.com, pbonzini@redhat.com, jmattson@google.com Subject: [PATCH 3/4][kvm-unit-test nVMX]: Add #define for "load IA32_PERF_GLOBAL_CONTROL" bit Date: Thu, 9 May 2019 17:20:54 -0400 Message-Id: <20190509212055.29933-4-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190509212055.29933-1-krish.sadhukhan@oracle.com> References: <20190509212055.29933-1-krish.sadhukhan@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Krish Sadhukhan Reviewed-by: Karl Heubaum --- x86/vmx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/x86/vmx.h b/x86/vmx.h index eefd5dc..a4ceac3 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -370,6 +370,7 @@ enum Ctrl_exi { enum Ctrl_ent { ENT_LOAD_DBGCTLS = 1UL << 2, ENT_GUEST_64 = 1UL << 9, + ENT_LOAD_PERF = 1UL << 13, ENT_LOAD_PAT = 1UL << 14, ENT_LOAD_EFER = 1UL << 15, }; From patchwork Thu May 9 21:20:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10937903 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 741E1112C for ; Thu, 9 May 2019 21:47:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65156289EC for ; Thu, 9 May 2019 21:47:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 597DB28AFA; Thu, 9 May 2019 21:47:23 +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 D191D289EC for ; Thu, 9 May 2019 21:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727018AbfEIVrV (ORCPT ); Thu, 9 May 2019 17:47:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48982 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727026AbfEIVrV (ORCPT ); Thu, 9 May 2019 17:47:21 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LiW4C185806; Thu, 9 May 2019 21:46:59 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 : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=+F+FCY9mN8hViyTt7kvXJOtNkLlGIXGm8si6xkeP1zA=; b=ReTgKLgFpmX+OvSXavDz8rtvGoJzU0PvKiFyFYgz0qwtyNXuo3/WZRug9GSSXOKui9kS +eDeWx0IXd945mVTOggfMKnqIgxUBcjuaf+HhFQJmIA6wLVTj0sClVEELg7GKXYxJTeO +Z4YHTxLu+8uvvyciiTCTyAUrd91SZDjgwCiLwP2S7QFmmlrO938aPDAOtHU4wSRnZmB nKBd0x08q1mV1Kc0oNrUEdCp42hutMpd6vvLS5YY2Q3CA8HWw6pSGvFxehapuXhpfKHo Qpeay/TmP16UimMoIOHUrTN5cgNYLuyEZ3xy5PuMEjMNeuVOVkLRiTW0766wW6KJcULP aA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2s94b15nkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:59 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x49LjPYw124632; Thu, 9 May 2019 21:46:59 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2s94ah1nm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 May 2019 21:46:59 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x49Lkw3x012754; Thu, 9 May 2019 21:46:58 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 May 2019 14:46:58 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: rkrcmar@redhat.com, pbonzini@redhat.com, jmattson@google.com Subject: [PATCH 4/4][kvm-unit-test nVMX]: Test "load IA32_PERF_GLOBAL_CONTROL" VM-entry control on vmentry of nested guests Date: Thu, 9 May 2019 17:20:55 -0400 Message-Id: <20190509212055.29933-5-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190509212055.29933-1-krish.sadhukhan@oracle.com> References: <20190509212055.29933-1-krish.sadhukhan@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9252 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090123 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ..to verify KVM performs the appropriate consistency checks for loading IA32_PERF_GLOBAL_CONTROL as part of running a nested guest. According to section "Checking and Loading Guest State" in Intel SDM vol 3C, the following check is performed on vmentry: If the "load IA32_PERF_GLOBAL_CTRL" VM-exit control is 1, bits reserved in the IA32_PERF_GLOBAL_CTRL MSR must be 0 in the field for that register. Signed-off-by: Krish Sadhukhan Reviewed-by: Karl Heubaum --- x86/vmx_tests.c | 82 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 11 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index a339bb3..65772ce 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -5031,29 +5031,69 @@ static void test_perf_global_ctl(u32 field, const char * field_name, u64 perf_global_saved = vmcs_read(field); u64 i, val; + if (field == GUEST_PERF_GLOBAL_CTRL) { + vmx_set_test_stage(1); + test_set_guest(guest_state_test_main); + } + vmcs_write(ctrl_field, ctrl_saved & ~ctrl_bit); for (i = 0; i < 64; i++) { val = 1ull << i; vmcs_write(field, val); - report_prefix_pushf("\"load IA32_PERF_GLOBAL_CTRL\" " - "VM-exit control is off, HOST_PERF_GLOBAL_CTRL %lx", val); - test_vmx_vmlaunch(0, false); - report_prefix_pop(); + if (field == HOST_PERF_GLOBAL_CTRL) { + report_prefix_pushf("\"load IA32_PERF_GLOBAL_CTRL\" " + "VM-exit control is off, " + "HOST_PERF_GLOBAL_CTRL %lx", val); + test_vmx_vmlaunch(0, false); + report_prefix_pop(); + } else { // GUEST_PERF_GLOBAL_CTRL + enter_guest(); + report_guest_state_test("ENT_LOAD_PERF disabled", + VMX_VMCALL, val, + "GUEST_PERF_GLOBAL_CTRL"); + } } vmcs_write(ctrl_field, ctrl_saved | ctrl_bit); for (i = 0; i < 64; i++) { val = 1ull << i; vmcs_write(field, val); - report_prefix_pushf("\"load IA32_PERF_GLOBAL_CTRL\" " - "VM-exit control is on, HOST_PERF_GLOBAL_CTRL %lx", val); - if (PERF_GLOBAL_CTRL_VALID_BITS & (1ull << i)) { - test_vmx_vmlaunch(0, false); - } else { - test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD, - false); + if (field == HOST_PERF_GLOBAL_CTRL) { + report_prefix_pushf("\"load IA32_PERF_GLOBAL_CTRL\" " + "VM-exit control is on, HOST_PERF_GLOBAL_CTRL %lx", + val); + if (PERF_GLOBAL_CTRL_VALID_BITS & (1ull << i)) { + test_vmx_vmlaunch(0, false); + } else { + test_vmx_vmlaunch( + VMXERR_ENTRY_INVALID_HOST_STATE_FIELD, + false); } report_prefix_pop(); + } else { // GUEST_PERF_GLOBAL_CTRL + enter_guest(); + if (PERF_GLOBAL_CTRL_VALID_BITS & (1ull << i)) { + report_guest_state_test("ENT_LOAD_PERF enabled", + VMX_FAIL_STATE | + VMX_ENTRY_FAILURE, + val, + "GUEST_PERF_GLOBAL_CTRL"); + } else { + report_guest_state_test("ENT_LOAD_PERF enabled", + VMX_VMCALL, + val, + "GUEST_PERF_GLOBAL_CTRL"); + } + } + } + + if (field == GUEST_PERF_GLOBAL_CTRL) { + /* + * Let the guest finish execution + */ + vmx_set_test_stage(2); + vmcs_write(field, perf_global_saved); + enter_guest(); } vmcs_write(ctrl_field, ctrl_saved); @@ -5079,6 +5119,25 @@ static void test_host_perf_global_ctl(void) EXI_CONTROLS, EXI_LOAD_PERF); } +/* + * If the "load IA32_PERF_GLOBAL_CTRL" VM-entry control is 1, bits reserved + * in the IA32_PERF_GLOBAL_CTRL MSR must be 0 in the field for that + * register. + * + * [Intel SDM] + */ +static void test_guest_perf_global_ctl(void) +{ + if (!(ctrl_exit_rev.clr & ENT_LOAD_PERF)) { + printf("\"load IA32_PERF_GLOBAL_CTRL\" VM-entry control not " + "supported\n"); + return; + } + + test_perf_global_ctl(GUEST_PERF_GLOBAL_CTRL, "GUEST_PERF_GLOBAL_CTRL", + ENT_CONTROLS, ENT_LOAD_PERF); +} + /* * PAT values higher than 8 are uninteresting since they're likely lumped * in with "8". We only test values above 8 one bit at a time, @@ -5243,6 +5302,7 @@ static void test_load_guest_pat(void) */ static void vmx_guest_state_area_test(void) { + test_guest_perf_global_ctl(); test_load_guest_pat(); }