Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp292207pxa; Fri, 14 Aug 2020 04:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuksRn/BRiSnJ8uFB2ONXa8dALtcCJ7MHwEIMbkUtfZdYdHZzTiZuzXgiblDH/qQ5DPKyB X-Received: by 2002:a17:906:fad1:: with SMTP id lu17mr1890623ejb.127.1597404740354; Fri, 14 Aug 2020 04:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597404740; cv=none; d=google.com; s=arc-20160816; b=oWk68IWnizwxt+P5drdwLdVlvLPsFOJkcJfUY3p7ODcyfIIu1NQqoDUyTK5v2TcoPa xLjJTuojziiE6lEaPn1S7OiTTFavzHCB7fCuuI8+iZV/NodKDbmhLHc9fl81LpkD7xCS UG94t9FdlCDfk3w+XSC5vuwdjxWYV2ClCBHp8QsYq1u36koYDO0XbhFbaCjQ1VFBmIg5 T3J/b7nBJtf5MNAfhgom7mUbvxLlMOkHbamOQ+yZAAEoOIhzw9KOdjf8RElTTnk7njou h/qf/k2jUQ2pdVeeiz0xRMbQ1scJo/kVEMTon5nMbU/4hcdRwP+tXhtEwkP5HKx6Z/LV KKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=wYyKSMVEF35WS0cpjZV2U0gwOjLy+aP24lnyz9ekVmw=; b=SLTwjvn75L9yYJNRQyTqKBAaPZPT1NqhS4wwcH9edG2uJZ5gJU8Oou2/QHQlCKoWc0 Zw0mBBMrmM8+sZslz/B4aL6JiQvyrC9eKjq08Uqw3wzLQ0MtNTa0C5TNsrZ7kGM66pYe 3uwJxkNeJkXLrtddRXJDBtVH1UiJ/4+X2zzhRIuIdCIpbfwDESzecmoL7KXDjgPiJT1F TjhkzOnUl1XKXVkwBcwWf1mSbuid1WSyors84u3GXQWf19v17EIXPC5oNMSDN4i12VgL Xk2YO4KoNpiiamIRjblBlGvIMWZIyXtnwnsGtaE4YBVM8fbO5XjUn2oEz16MuJheKKDS 8+XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w14si5016251edr.598.2020.08.14.04.31.57; Fri, 14 Aug 2020 04:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726662AbgHNKJl (ORCPT + 99 others); Fri, 14 Aug 2020 06:09:41 -0400 Received: from mga02.intel.com ([134.134.136.20]:39212 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726012AbgHNKJk (ORCPT ); Fri, 14 Aug 2020 06:09:40 -0400 IronPort-SDR: v9olPLzJFE8/D8EMOYiRzvBhLxyrqkWLDiVOc4HoyjvaYaCwpZ9V+Y+NH4RlhBbvm5TiXUaFaJ /W9bzwc20Hyg== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="142225727" X-IronPort-AV: E=Sophos;i="5.76,311,1592895600"; d="scan'208";a="142225727" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 03:09:40 -0700 IronPort-SDR: Ybx8mk0552li0bdHdUB5/dPO86kL96paT7UAUsymjTxWeEEFMaHNyg4TVfG+hdQR/GllgXHLp9 0J1o/mhb1tUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,311,1592895600"; d="scan'208";a="325687704" Received: from cqiang-mobl.ccr.corp.intel.com (HELO [10.238.2.93]) ([10.238.2.93]) by orsmga008.jf.intel.com with ESMTP; 14 Aug 2020 03:09:37 -0700 Subject: Re: [RFC 7/7] KVM: VMX: Enable PKS for nested VM To: Jim Mattson Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , Xiaoyao Li , kvm list , LKML References: <20200807084841.7112-1-chenyi.qiang@intel.com> <20200807084841.7112-8-chenyi.qiang@intel.com> <1481a482-c20b-5531-736c-de0c5d3d611c@intel.com> From: Chenyi Qiang Message-ID: Date: Fri, 14 Aug 2020 18:07:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/14/2020 1:52 AM, Jim Mattson wrote: > On Wed, Aug 12, 2020 at 9:54 PM Chenyi Qiang wrote: >> >> >> >> On 8/11/2020 8:05 AM, Jim Mattson wrote: >>> On Fri, Aug 7, 2020 at 1:47 AM Chenyi Qiang wrote: >>>> >>>> PKS MSR passes through guest directly. Configure the MSR to match the >>>> L0/L1 settings so that nested VM runs PKS properly. >>>> >>>> Signed-off-by: Chenyi Qiang >>>> --- > >>>> + (!vmx->nested.nested_run_pending || >>>> + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PKRS))) >>>> + vmcs_write64(GUEST_IA32_PKRS, vmx->nested.vmcs01_guest_pkrs); >>> >>> This doesn't seem right to me. On the target of a live migration, with >>> L2 active at the time the snapshot was taken (i.e., >>> vmx->nested.nested_run_pending=0), it looks like we're going to try to >>> overwrite the current L2 PKRS value with L1's PKRS value (except that >>> in this situation, vmx->nested.vmcs01_guest_pkrs should actually be >>> 0). Am I missing something? >>> >> >> We overwrite the L2 PKRS with L1's value when L2 doesn't support PKS. >> Because the L1's VM_ENTRY_LOAD_IA32_PKRS is off, we need to migrate L1's >> PKRS to L2. > > I'm thinking of the case where vmx->nested.nested_run_pending is > false, and we are processing a KVM_SET_NESTED_STATE ioctl, yet > VM_ENTRY_LOAD_IA32_PKRS *is* set in the vmcs12. > Oh, I miss this case. What I'm still confused here is that the restoration for GUEST_IA32_DEBUGCTL and GUEST_BNDCFGS have the same issue, right? or I miss something.