Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21041767rwd; Thu, 29 Jun 2023 10:07:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlGij6w+6ZgJFkWL08vmpDaper3RS5QQ2ATqDzVT6/brQNOGXh/M+FQQWEXMpritxNZPgDqc X-Received: by 2002:a17:903:1c9:b0:1b8:4e69:c8f7 with SMTP id e9-20020a17090301c900b001b84e69c8f7mr3184518plh.23.1688058421482; Thu, 29 Jun 2023 10:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688058421; cv=none; d=google.com; s=arc-20160816; b=hhw6XJ8bbKWFAo983U3upnsnXLlsWcbbdMrO74GwjfCbiCYlRThhaHwIHrbQ8rcZeN mo2sYtU7RWcw58Z1nTd9GkvoOeSMI8x7ONeIcJE8YP5oeQTfHxYsImK92QOAidHgbx+9 L4D3m1CvfyZOgnAL/OKaZd0gX3ldXdxRJAwOW9/oqwOLSb9ObA/2xD0h4UpdNbk1K9vT F8CSaYDWR83ZCo7k5V+RTzV4GYCuVL3NTFMUX9u4olnxDf0AdAo++I0FKQG6EHY2fWsD jzMd5TX3po7wV7KbpC8+p/+Nb94jTfTcwuUuRoX7taMIt4mXvNwsHF3ECQ5pc1Gak72w DGpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=P7X1f1JkCDNqEyBhjNE0NVCYk7dv7XgPQ/wMLYU+XyQ=; fh=7P/LPOK9zhPP0GNid5in865XSIG/4N+ISsOcAJjUokk=; b=v192CJ9sH80YNMxfXnklZmdmMueTGpVRKoFNLLvjBPcyFaYbja4rdwT4pqYA4S+QQg eSPxhim8kbC2HK371YoT6r/KuHKOkx1kLnPv0m9AwJVTr3OugH5faNClqSfBix+zWbaz TKoa0MjaW8sw/MbnBGFW2y2F/cbeUTXRO0ifvtqz3MI8Ze8Y/orFvGdK2HVMjsm6MkFI yj5q3vapdqKFZ6FpcFaR4LQQEoU3maIjUFiLKkZa/M7tdoUDkata0P9P8Ii6/MrFcXzR OYgQ1dVyZd4td2aRihBYdN/028yGLpofcNwYJ0wIEU9WbcsC8uUmsWvB/Cq6cTGKqf2H PFFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a6lSBajW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a636201000000b005439273f2a4si10595356pgb.139.2023.06.29.10.06.43; Thu, 29 Jun 2023 10:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a6lSBajW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231933AbjF2Quk (ORCPT + 99 others); Thu, 29 Jun 2023 12:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbjF2Qui (ORCPT ); Thu, 29 Jun 2023 12:50:38 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C23630F1 for ; Thu, 29 Jun 2023 09:50:37 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5618857518dso6988207b3.2 for ; Thu, 29 Jun 2023 09:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688057436; x=1690649436; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=P7X1f1JkCDNqEyBhjNE0NVCYk7dv7XgPQ/wMLYU+XyQ=; b=a6lSBajW3W02rYZGgR3/o0i9lxzRFVovXoe3Q3JaBs8FdTwqUBneab7VBjiCfUhcLA 0ufpIbSR4EeP/geTQzfXNnnIbTwqIf0t30LMWe6PpIWGthQ/XTooya1lmeGiSvs6YA5S mswOiz4kIhsywRvIn1fanIuT6NZHga1wspana2xVtBxT5giHdB7sN6MIVZl44cmlJnNO 1CGKzS+KzlyEF3Q2aNAESdMDCcdGN0e8CIBhnwCbVpSChU+zztHsa7BZhyNcGQZmHaPF L9/xLJSMfJm4abmW4kcT3CxN4cTptlZaENvbIcJ9kj1ojgO1prkD1YbHNJi4caKPO1dv 6E7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688057436; x=1690649436; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P7X1f1JkCDNqEyBhjNE0NVCYk7dv7XgPQ/wMLYU+XyQ=; b=hb7SIcdl29vp+r73Mz6Yl6TPKv2/yM7XTVXwMKJ4YSR+zrK4fpan2tT3Q/FXXajbqI prpD08J/BcKSQ5SP/RxQA+YE4+xW29Y/htb54HuNkuAu7iEuOcmZkqz9/QpwSFmLwvZL caDvYd/DrsaOhdnDCMXPQBuObcYKBxDxiMhqtJEwNluvxAKDnfE2QmFyBQyps1PqmfOg Y0ivMnWrKQBJdYvyo9PmNjD5JN8Vv10Kq+rIwuz7QwAja5ewYsV5euQPxheJk7PN0DWs tDKEqKym0E5dEUlO6gDeaz4hi3uZXjJIP360dmsEgwTdsRbwMwofbHnURK8Kc5rpfCwX 801g== X-Gm-Message-State: AC+VfDyZFZQlGzNTH7qsCKPq5EeVIRfF7aNtpDo1rGIH1D3PoBr4/RVa ltO+so4cPn9sqqrvuBe0bHexkLVXy5k= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b647:0:b0:56d:3c2b:2471 with SMTP id h7-20020a81b647000000b0056d3c2b2471mr15652904ywk.3.1688057436218; Thu, 29 Jun 2023 09:50:36 -0700 (PDT) Date: Thu, 29 Jun 2023 09:50:34 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230217231022.816138-1-seanjc@google.com> <20230217231022.816138-9-seanjc@google.com> <20230221152349.ulcjtbnvziair7ff@linux.intel.com> <20230221153306.qubx7tfmasnvodeu@linux.intel.com> <20230222064931.ppz6berhfr4edewf@linux.intel.com> Message-ID: Subject: Re: [PATCH 08/12] KVM: nSVM: Use KVM-governed feature framework to track "vVM{SAVE,LOAD} enabled" From: Sean Christopherson To: Yu Zhang Cc: Paolo Bonzini , Vitaly Kuznetsov , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Maxim Levitsky Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 22, 2023, Sean Christopherson wrote: > +Maxim > > On Wed, Feb 22, 2023, Yu Zhang wrote: > I'll opportunistically massage the comment to make it more explicit about why > VMLOAD needs to be intercepted. > > That said, clearing the bits for this seems wrong. That would corrupt the MSRs > for 64-bit Intel guests. The "target" of the fix was 32-bit L2s, i.e. I doubt > anything would notice. > > This patch fixes nested migration of 32 bit nested guests, that was > broken because incorrect cached values of SYSENTER msrs were stored in > the migration stream if L1 changed these msrs with > vmload prior to L2 entry. Aha! Finally figured out what this code is doing. KVM intercepts VMLOAD so that KVM can correctly model the VMLOAD behavior of dropping bits 63:32, i.e. to clear svm->sysenter_eip_hi and svm->sysenter_esp_hi. So the code is correct. I'll add this comment: /* * Intercept VMLOAD if the vCPU mode is Intel in order to emulate that * VMLOAD drops bits 63:32 of SYSENTER (ignoring the fact that exposing * SVM on Intel is bonkers and extremely unlikely to work). */