From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD4AC4320A for ; Tue, 10 Aug 2021 17:20:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01D2760FC4 for ; Tue, 10 Aug 2021 17:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbhHJRU0 (ORCPT ); Tue, 10 Aug 2021 13:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229474AbhHJRUZ (ORCPT ); Tue, 10 Aug 2021 13:20:25 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA7B0C0613C1 for ; Tue, 10 Aug 2021 10:20:02 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c63-20020a25e5420000b0290580b26e708aso21605787ybh.12 for ; Tue, 10 Aug 2021 10:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=YA3NF9DMKc4I70AnuyD5YSitWTMbp+95cgR2kKH7sPI=; b=UvFYvCNAIwQvbkNWFM3GdZql943uYgfXwguHeOAJ+UsQM8ZY9SGKlpaiNflMIK3bvf HUhTog+Dt5dsbesRt67SUtqUmiHwWrYhAjPueqBfYpgDNYpEJLuNdWRm6UYiMNo63bQb V1uVSSlcjPx22mOMsFORuHQsUL5a0xcV6jqNi9uQyRF9klQk2e5D+7Mm0W9OTA7r1LjU gmikpInhxCnYhVu1ItTPXo9Jpm7xhLpGUUCQLru5N9X3muCjoBLQ+L9c8jleCV7DHMGG T0g1cUS8H1HsiFSmeWqV6z4cyKpt5m7Rv8WkUyU6z8zIyUWqN0pAFIbKmutXSZS1iRL8 1SEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:message-id:mime-version:subject :from:to:cc; bh=YA3NF9DMKc4I70AnuyD5YSitWTMbp+95cgR2kKH7sPI=; b=r3Fmp4OZAJYtX1GdJWX7dGH5aItmMKll9io1kiDl8NKExOaOJIxzYlq8WIZpsFgQPE PCUqcUisGWKK6SqcnUfNpAR2PKVZzoHLoFRb+QHZW4HCGJNWeUms9QO1v3UCF4w6G83u 89/ZoscXXdhGwnQL2uIx2RsMTXuYJdluPGP66YZZIY51uUF+mUdLhaNTGt/NUFEpL2FZ IEDR5GTNJAHbhkXidwu70z5ymuXLv1U2yN6JGxCcxYcT+uUFZnds/tMkorG+6PHuEk29 JpmdhDh/ngQl2xt3U6hQcoMUD9/un62bKdte3Q7Z4XFCPtNa92Gy0kKyweR5Pf+hq7lm g1OQ== X-Gm-Message-State: AOAM530QstqAD35IKk7PRF0ihC6xNg0z14DPL7JKeklw8RMN7QnhqepZ 2+JsoCfDC4IkEj1WVpD0O0MMXtnM7p4= X-Google-Smtp-Source: ABdhPJygJe6rW5Cj2N0CH1AW0Ag2OJztzlMQVaL2LT2y2lLWfiBVxyZiy0tfd7Qo74zvVo95E2Oipv2h3Hg= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:de69:b19a:1af5:866d]) (user=seanjc job=sendgmr) by 2002:a25:dacc:: with SMTP id n195mr21698801ybf.283.1628616002055; Tue, 10 Aug 2021 10:20:02 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 10 Aug 2021 10:19:48 -0700 Message-Id: <20210810171952.2758100-1-seanjc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH 0/4] KVM: nVMX: Use vmcs01 ctrls shadow as basis for vmcs02 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zeng Guang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The goal of this series is to drop the vmx->secondary_exec_control cache without degrading nested VM-Enter performance. The cache is effective, e.g. saves ~1000 cycles on nested VM-Enter, but confusing. The worst of the confusion could be eliminated by returning the computed value from vmx_compute_secondary_exec_control() to make the calls to the "compute" helper more like the other controls. But, the nested VM-Enter path would still have special handling for secondary exec controls, and ideally all controls would benefit from caching, though the benefits are marginal for other controls and thus difficult to justify. Happily, vmcs01 already caches the calculated controls in the controls_shadow. The only issue is that the controls_shadow may have dynamically toggled bits set. However, that is not a fundamental problem, it's simply different than what is expected by the nested VM-Enter code and is easily remedied. TL;DR: Get KVM's (L0's) desires for vmcs02 controls from vmcs01's controls_shadow instead of recalculating the desired controls on every nested VM-Enter, thus eliminating the need to have a dedicated cache for the secondary exec controls calulation. Sean Christopherson (4): KVM: VMX: Use current VMCS to query WAITPKG support for MSR emulation KVM: nVMX: Pull KVM L0's desired controls directly from vmcs01 KVM: VMX: Drop caching of KVM's desired sec exec controls for vmcs01 KVM: VMX: Hide VMCS control calculators in vmx.c arch/x86/kvm/vmx/nested.c | 25 ++++++++++++-------- arch/x86/kvm/vmx/vmx.c | 48 +++++++++++++++++++++++++++------------ arch/x86/kvm/vmx/vmx.h | 35 +++++----------------------- 3 files changed, 56 insertions(+), 52 deletions(-) -- 2.32.0.605.g8dce9f2422-goog