From patchwork Fri Jun 22 23:35:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10483323 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 9E95460388 for ; Fri, 22 Jun 2018 23:36:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E36228FAF for ; Fri, 22 Jun 2018 23:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8303B29065; Fri, 22 Jun 2018 23:36:46 +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 2F8BF28FAF for ; Fri, 22 Jun 2018 23:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934334AbeFVXgo (ORCPT ); Fri, 22 Jun 2018 19:36:44 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52348 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934067AbeFVXgQ (ORCPT ); Fri, 22 Jun 2018 19:36:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5MNZ3X9093333; Fri, 22 Jun 2018 23:36:03 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-2017-10-26; bh=jS++mVypMAwgJrOuEn+S7hniPEJXctwbFXPa5Skpx+8=; b=Gxfh/w1Bbim9T2iaXZjt8HuvhB31jqT2UaV0iOqvdzggs1ZhgEp4otcip1hMoIIX/pH5 pM0YnXa8Vk9qFCmwZ3/fUERKetc08tuQzOdyqcIJsUF6MMxyC3tQPKe0wuslpGSSVn0R QNFTN0SNy/vbDdZy+A1sci4CGZAAP1GWIHibyMZFu4Gm//BQVT8kJiAVeExXEwEKpggV qfPKgugLfknoojHonO8ek6FFauN24ZzaVWa8GpkrhXevrKgTpx8SXwqenZpPA0uvihYt 4m0Zwq8iHdin4mBOBXbfPu80qelR8J1405uK8NnQluUX/80zV8FtvcOTfBULebtuBg6J YA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2jrp8hupwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:02 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5MNa2mL010019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:02 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5MNa2g3020794; Fri, 22 Jun 2018 23:36:02 GMT Received: from liran-pc.mynet (/79.183.72.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Jun 2018 16:36:01 -0700 From: Liran Alon To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: jmattson@google.com, idan.brown@oracle.com, Liran Alon Subject: [PATCH 14/22] KVM: nVMX: Allocate a vmcs02 shadow VMCS when virtualizing VMCS shadowing Date: Sat, 23 Jun 2018 02:35:14 +0300 Message-Id: <1529710522-28315-15-git-send-email-liran.alon@oracle.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529710522-28315-1-git-send-email-liran.alon@oracle.com> References: <1529710522-28315-1-git-send-email-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8932 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=663 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806220260 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When L1 activates VMCS shadowing for L2, associate an L0 shadow VMCS with vmcs02. It's not yet linked to vmcs02, since we don't have the appropriate VMREAD and VMWRITE bitmaps for it. Signed-off-by: Liran Alon Signed-off-by: Jim Mattson --- arch/x86/kvm/vmx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index db9bb24ffc23..99576c2fa65a 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4441,7 +4441,10 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) loaded_vmcs->vmcs = NULL; if (loaded_vmcs->msr_bitmap) free_page((unsigned long)loaded_vmcs->msr_bitmap); - WARN_ON(loaded_vmcs->shadow_vmcs != NULL); + if (loaded_vmcs->shadow_vmcs) { + free_vmcs(loaded_vmcs->shadow_vmcs); + loaded_vmcs->shadow_vmcs = NULL; + } } static struct vmcs *alloc_vmcs(bool shadow) @@ -11354,6 +11357,11 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) if (nested_cpu_has_xsaves(vmcs12)) vmcs_write64(XSS_EXIT_BITMAP, vmcs12->xss_exit_bitmap); + + if (nested_cpu_has2(vmcs12, SECONDARY_EXEC_SHADOW_VMCS) && + enable_shadow_vmcs && alloc_shadow_vmcs(vcpu)) { + /* TODO: IMPLEMENT */ + } vmcs_write64(VMCS_LINK_POINTER, -1ull); if (cpu_has_vmx_posted_intr())