Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1550820pxa; Thu, 13 Aug 2020 10:54:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4y3FLtnZN8pkW8XOoEkzCxEl5KbXxKNIZkEM7gZjNGdCaa5KRZ+hHmM4WhLi+/g38hqZ5 X-Received: by 2002:a17:906:aed0:: with SMTP id me16mr5856515ejb.288.1597341246578; Thu, 13 Aug 2020 10:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597341246; cv=none; d=google.com; s=arc-20160816; b=iw2nAu3nSW+HRbrgLefo3NDDMEQW58dnimHdMp/chfdJILui3jccfLTKTDYC+/IkxV JTnvKel8PhR4N5a9irfwJAxJ/4/8a/TKHhebDJjzhvGQuHvCydU5eny4tgXwUfiYCJUh 6+XzA5NOc8aa5V/4TqHeBioDMSpuzkooAlAj4zvpQYRTjVnVogkqYf6wFkOLuf37kuV3 UE1P5KAZxdjOgmHhnOeRvFxXZnEjqmF/pJFCNO/i8X9dbD+e/MpGEPTuq0oOiIA87d+R 0kY6MuB0UZ0eeVvZC3A0WKl+SCvLq8Fxtt2eocatfEKqXG2tfmPvqyLnUv0rPshj9/DP XFFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=k8yck4RdxUV1UPISOKBseddHGlGtyaOeMcKpGKtvB5c=; b=kZu6R1nq4CCmWYJ8vaCL2zTSqquVwBfZpA+4pth6lzc57JtNJANWxXEaqa1wDSoY+i gTeSs2+0V8cOQOyu+RAkGNAzUv+J9tfz1NAgkZELYJLqLp4G9Ldrap1meSLhCDHtcajw aQVONIVf3WAQzDUsHXvm7eefeTHsZqNOXahOg+oQ2IZxpK2M962mH7pj8Rvn1w/nXHRm 7ZyFxTlgD630ZsQslnVcR1hOESMl0pP7rcSM0ipRuET7VSeFT3BjomwU77qF05AP+2vb S6LBX+rDrBEMIGUSrml+or4zE2ZhkHMNiMtJuhcRC/1ln1jiZdtd/ctwrTcLz3dajsDq kCqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HHUdhxL4; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si3591571eju.570.2020.08.13.10.53.43; Thu, 13 Aug 2020 10:54:06 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=HHUdhxL4; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbgHMRwY (ORCPT + 99 others); Thu, 13 Aug 2020 13:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgHMRwY (ORCPT ); Thu, 13 Aug 2020 13:52:24 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22BD8C061383 for ; Thu, 13 Aug 2020 10:52:24 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id q9so5504561oth.5 for ; Thu, 13 Aug 2020 10:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k8yck4RdxUV1UPISOKBseddHGlGtyaOeMcKpGKtvB5c=; b=HHUdhxL4MGJXkKRiv5isZeF1DkyMTSw2yBABrfsO4Xva8T2zhq3GQMK3f5sW7YoGHx 23D2UVUUIlyJxdJ9o+ngPoLZFL2OGto96L5+Ip2NErBzR3s56SJDTnDE3I25F+BBDKSv yse8+HTv56nArcjdoR3nUsOhVt9Y/WtgQ7ysCncj6YtFq3Lv2SR5fCloxjrzlmVxNewQ ki1AxnIxj2wq/I6qJUvqVOmFawfFSLrqwta/oi/0Eh6h91Oyhz+5GVyMHarpmpJNGI4q A2m9I7im1yC7QJBtfj/4m+diDBkN5enPS2zyUR8cW/jvYpB3sSt3PLx3EsfP8zLBTlTK vszg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k8yck4RdxUV1UPISOKBseddHGlGtyaOeMcKpGKtvB5c=; b=ukSzLqA8oc8VlV0XKrAR6Ci2rbCgeJBFkKbLcm16QkjFZobWpzy3v19m8fSoPLo5ny +NZG3sGmZuZGjlOJ0oaycPCAMMpT4eAb9gC90M4Ueh1f0J3DrsDZ0CfyT5OPiyP8y11l LmMIgqDbgp+MVlKiNzxbbfSVpMP5RtNuFjn6yrEQvnzCGF3ziQk6udgf4C6qhM1WhXlE vKJbKYb/lIRBBUWPRS09VEJRzq9tE9S/UlTth8Z+myIXRmFSdVp/R8aAuYjX/UJdcCwl SQzpXtzkzhfZenZiEL0/BG6Eve/1uaPVUkuXQ2JyTjI5iZxo2LfEH229Y08ajeXP7Um5 iY+Q== X-Gm-Message-State: AOAM531mgd9pBD8hSQWLX0BuFG+HJZgLuom4CNC2kIG41u855R0OwsnV HsagrE7BXjQfgzH6VKpsVoEb190DYu3LXJhg236fLA== X-Received: by 2002:a9d:22ca:: with SMTP id y68mr5263764ota.56.1597341143209; Thu, 13 Aug 2020 10:52:23 -0700 (PDT) MIME-Version: 1.0 References: <20200807084841.7112-1-chenyi.qiang@intel.com> <20200807084841.7112-8-chenyi.qiang@intel.com> <1481a482-c20b-5531-736c-de0c5d3d611c@intel.com> In-Reply-To: <1481a482-c20b-5531-736c-de0c5d3d611c@intel.com> From: Jim Mattson Date: Thu, 13 Aug 2020 10:52:11 -0700 Message-ID: Subject: Re: [RFC 7/7] KVM: VMX: Enable PKS for nested VM To: Chenyi Qiang Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , Xiaoyao Li , kvm list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.