Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2836708rwr; Fri, 21 Apr 2023 15:13:51 -0700 (PDT) X-Google-Smtp-Source: AKy350bbYvocA1wXK2MOQ9t61eeG0uALXJ/oSVyepfYrLz9bFaZ0a6ATAniZ9IlJn2rGZ0ohmIy8 X-Received: by 2002:a17:903:1d1:b0:1a6:93cc:924b with SMTP id e17-20020a17090301d100b001a693cc924bmr8217332plh.3.1682115230910; Fri, 21 Apr 2023 15:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682115230; cv=none; d=google.com; s=arc-20160816; b=k6TaV15B9MWSGSERJIC2KcIBCzF4I9VqRAPaNRWfBdQ+jD7rFqey0mO9sNCVyTq2Gv Y5GPBuuEn7HTFbpempbxjvZBvwHEmp5ln/XavnqRrD1nnQmhSrxCpV/eh5Axrz5ej0Fg lq0jpQHdXRBjIseYH491xAunxdOmQk9pi29lS5laUroEhs0PTe91JW8h6gtMUQaA2e4H /8DbnPiDXFLbrSSPQJW3YVduZeNdiQZwsqdVjAE3ZSNiex44cJgxA7DByjHfY8bTS80d BbnAp5HXfHvOomUM7DW7mwrFFLI/zNzZD3oG/T1POex7+X5oPpuofJ0qv6rtskUCwyaB n51Q== 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=7oTagfDyC4HgrO0yoWB0k9ddYdGP35eHRr7bp/RRLZQ=; b=Wb7GW7GpGHVz/5lhFcZftbAXbgU/LHngzREwV9GZ3Gt9d01XroLSJUQ3A3k9yzhyKb nZYlogLtOvp4DXDOuVvpgUL25BT5ov8bTKcZb07Fw0cbihiN69m22fn3JKdANY70yeg4 kLQF/f8/lO9WmDP8Jdn5PVK9aX+0Y2/M72k17t5SwiDnVLktjjxcAczAf+RJoVgoqhEP DmSpJR9A6b2ggIaUDaRpvqYEWqtxaPqnULCJlTbmasQgBmY6kaba2SA2LTvhiHWZFEqD naupkSRPUKzozuWBh9a8CbK9I0FHAFgPeJuD15u1zwO/pCbuwWEJTzKZE7vwmLKJUV9y RLLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=kuk2qN7K; 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 n3-20020a170902f60300b001a64e866c8csi5745966plg.374.2023.04.21.15.13.38; Fri, 21 Apr 2023 15:13:50 -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=kuk2qN7K; 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 S233603AbjDUV7x (ORCPT + 99 others); Fri, 21 Apr 2023 17:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbjDUV7w (ORCPT ); Fri, 21 Apr 2023 17:59:52 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D45693 for ; Fri, 21 Apr 2023 14:59:51 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-63b79d8043eso14084711b3a.0 for ; Fri, 21 Apr 2023 14:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682114391; x=1684706391; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7oTagfDyC4HgrO0yoWB0k9ddYdGP35eHRr7bp/RRLZQ=; b=kuk2qN7KI93CF2nAuIMxjNhIYpR9YBPe+0c48Da++d12zR2YUrx9tl3VwJBbi7Y2Xa Z6Z9AzRPjuUT/14nCQt/c4Q1qlao51HXmIeAnx0RXAlla8BaOrj7rbAAB4LOLlOdrZEW j1BJ0KjIXppfb66C4IZXyBo92KNrnzZ9IhT4SNTssPwxj4LKewGJQ7SoB5WpbQcY+l2N WlnVlhgQ9YixVyj+cXrnhjcxjORBi+uGTQ6p920VLgiLjcMepLc/NyQP5YIzHZUTwlLg dGEjbkglDyseZpQCcuAmxTfavM+je6lXWwP2GGtYnHK/VJ01RjYa+LR7tfEOBAxedlXY Bq4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682114391; x=1684706391; 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=7oTagfDyC4HgrO0yoWB0k9ddYdGP35eHRr7bp/RRLZQ=; b=jZjXBzOUu7FbF/kiU8MsLL6iJ/xjT7n/fqdDF0v5D2/qlTKGVeOlw46b+WUgT+lBUG KbETOJyJYmqQVt6JOcwaROzFEVych+xFhedRTHxQck1s3SZwshvO37uOtM8lpRedm0mJ OKnK/y9oo61VPy9tg3DXhvBW085dj6f+GMaoPA3brKD9HvUH5IsbLS/fKVKwRV3uiii4 Eh1g0r7AMopqoWIb2560Wj+BBRYOak2wF+UI7BAUyYZGyOUHYagqLxg5vpLNrjAtziQN cM4V+zvUti6IF0JklzOfDjjHb59gw0rZ2dV9qyyx8sBmxFVlVeXjjfB8L5kWhpjyb9WD 3CNg== X-Gm-Message-State: AAQBX9cCSd/O8MJUw+30BnQlsU8HibCFmNyHo/tuEI+nJaPdfnN+UOlu 2boiv46GpKskJLU5VvIEmopWrQAb37k= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:843:0:b0:520:8b35:157d with SMTP id 64-20020a630843000000b005208b35157dmr1507839pgi.4.1682114390748; Fri, 21 Apr 2023 14:59:50 -0700 (PDT) Date: Fri, 21 Apr 2023 14:56:07 -0700 In-Reply-To: <20230421214946.2571580-1-seanjc@google.com> Mime-Version: 1.0 References: <20230421214946.2571580-1-seanjc@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <168211415988.2572634.7887087798476715003.b4-ty@google.com> Subject: Re: [PATCH v2] KVM: x86: Preserve TDP MMU roots until they are explicitly invalidated From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremi Piotrowski , Ben Gardon , David Matlack Content-Type: text/plain; charset="utf-8" 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 Fri, 21 Apr 2023 14:49:46 -0700, Sean Christopherson wrote: > Preserve TDP MMU roots until they are explicitly invalidated by gifting > the TDP MMU itself a reference to a root when it is allocated. Keeping a > reference in the TDP MMU fixes a flaw where the TDP MMU exhibits terrible > performance, and can potentially even soft-hang a vCPU, if a vCPU > frequently unloads its roots, e.g. when KVM is emulating SMI+RSM. > > When KVM emulates something that invalidates _all_ TLB entries, e.g. SMI > and RSM, KVM unloads all of the vCPUs roots (KVM keeps a small per-vCPU > cache of previous roots). Unloading roots is a simple way to ensure KVM > flushes and synchronizes all roots for the vCPU, as KVM flushes and syncs > when allocating a "new" root (from the vCPU's perspective). > > [...] Replaced v1 with this version in kvm-x86 mmu. I'll omit this from the initial pull request for 6.4 and submit it separately later on, assuming syzbot doesn't find more holes in my logic. David (or anyone else), feel free to provide feedback/reviews, I'll squash any trivial changes (tags, comment tweaks, etc.) as needed. I immediately pushed this to -next purely to get testing on the (hopefully) fixed version. [1/1] KVM: x86: Preserve TDP MMU roots until they are explicitly invalidated https://github.com/kvm-x86/linux/commit/bf4166af027e -- https://github.com/kvm-x86/linux/tree/next https://github.com/kvm-x86/linux/tree/fixes