From patchwork Wed Apr 24 23:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krish Sadhukhan X-Patchwork-Id: 10915907 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 D3BB4922 for ; Wed, 24 Apr 2019 23:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C392828BDE for ; Wed, 24 Apr 2019 23:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7DD028BE1; Wed, 24 Apr 2019 23:43:53 +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 6362B28BDE for ; Wed, 24 Apr 2019 23:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387988AbfDXXnw (ORCPT ); Wed, 24 Apr 2019 19:43:52 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:39038 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387983AbfDXXnw (ORCPT ); Wed, 24 Apr 2019 19:43:52 -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 x3ONctud133686; Wed, 24 Apr 2019 23:43:39 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=R1+QvZo9Yym3fZJAfG6Txwph/nydjdFAvlVj7qlE0Gk=; b=hoiWFdgPhmowyiUx+zWUhamfemMdQQKrdvizAw6NRZ/JVL2a9nBuEUXg91vWLjlBTyJw lxAGWjxCQu2iWbrPXxZrkXX7Frms/EG5AuJsVMenm2ml/KgHfIbnqv/B41S1s2GaFgFb Q/gwVetRVhzDVHISTxJ+tM9CyPKDihFNu01RitTofIb1owcYYoowHbNDy86FBY2ZmScx 1sK+MNf8SpQjr2yunjP1WUbIont6+vb15vyALXaIwEnyJbkpohVVX7hSQmMj0D2osVA2 +lNl+TB9LYGQzNzCtoBKLa5+mBOSNQf0JZjK3r7nCyR26CNh0SEaPMLa4nXPE69/0Skq tA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2ryv2qd7b4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Apr 2019 23:43:38 +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 x3ONgRA5102410; Wed, 24 Apr 2019 23:43:38 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2s0f0wbk84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Apr 2019 23:43:38 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x3ONhbko005306; Wed, 24 Apr 2019 23:43:37 GMT Received: from ban25x6uut29.us.oracle.com (/10.153.73.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Apr 2019 16:43:37 -0700 From: Krish Sadhukhan To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, jmattson@google.com Subject: [PATCH 5/8][KVM nVMX]: Check "load IA32_PERF_GLOBAL_CTRL" VM-entry control on vmentry of nested guests Date: Wed, 24 Apr 2019 19:17:21 -0400 Message-Id: <20190424231724.2014-6-krish.sadhukhan@oracle.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190424231724.2014-1-krish.sadhukhan@oracle.com> References: <20190424231724.2014-1-krish.sadhukhan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9237 signatures=668685 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-1904240162 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9237 signatures=668685 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-1904240162 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to section "CHECKING AND LOADING GUEST STATE" in Intel SDM vol 3C, the following checks are performed on vmentry of nested guests: "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." Signed-off-by: Krish Sadhukhan Reviewed-by: Karl Heubaum Reviewed-by: Jim Mattson --- arch/x86/kvm/vmx/nested.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index d2067370e288..a7bf19eaa70b 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -2691,6 +2691,10 @@ static int nested_vmx_check_vmentry_postreqs(struct kvm_vcpu *vcpu, return 1; } + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL && + !kvm_valid_perf_global_ctrl(vmcs12->guest_ia32_perf_global_ctrl)) + return 1; + /* * If the load IA32_EFER VM-entry control is 1, the following checks * are performed on the field for the IA32_EFER MSR: