Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp634198pxm; Fri, 25 Feb 2022 15:46:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyp3A4R5+Ts31KKmjzYUcXKyoGiBCrBtzePU7d2JzAWYGwvgp1Z6+V72duPlyfsvgEnYYD4 X-Received: by 2002:a17:906:2cce:b0:6ce:e203:d207 with SMTP id r14-20020a1709062cce00b006cee203d207mr7924587ejr.242.1645832806193; Fri, 25 Feb 2022 15:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645832806; cv=none; d=google.com; s=arc-20160816; b=WereNpMiLm1F4utPPcaApjXXVQWf9nU6VrpVRbtwFENqbSEApJ/r5Fv/YeKS/V6kXF EXEVTXuf5anMv8oW/QthaaSnUsJvk7DaFDKjIS6pouUXvcWK9SLTbEsfb/SvkbA22VNq Ey/DqYtZy11U09evl2VoTX9U/O9MjXB0eJkiEPBgeh57CzFlYM/PFhbfU+wKkcauHapf e7K9AL78/KHVLiOvCwauqYsmbkFLpX8nJUEsINZ1cPdlho1FyuyBq6KeyZPIrUtAjHKk T+JusznPaOjCET+f6cX0j6QQAjbKWVuCv8xrLfSGWdiF9oixsmarcKsUFKnVi2rLz42e s9xw== 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:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=VKMBlWNx4jK1iDVhpsaRZcvzkSOAxKFhhP9NDDoxkLA=; b=0Wrz/JawvLHdt4nk7vLOT7MMo+kAhnIgqQoXzu9Ov+AANRh8FR3ZgT1g4ezQJfjcck /dsUajLG2jlWlcCuqbJ6vfRek3TA8oBaAD5GTIRxProsyqU1sg/yz1jaVQ/zocx7gzeU zON0i1o9aEJFTeDrb6/aLizQORQf6sbDbmc9FepmigdGeYzZFG73NTTh1jepg0dv7MTg UronIQxTDNE2/VIhgjJzo0CXSsSTXTY7Kk1T97sXYYQEZTTdQiF0rupQ8JgZbosSHrqC eg4Ikt5LS5GhqHA4VeYvuMOszIFZiK51svFYGEMmviki0mCja8fS3jHsQMGqKSsvawS9 YtFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Fdd0ugG9; 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 r1-20020aa7c141000000b00412cab61f15si2309026edp.602.2022.02.25.15.46.23; Fri, 25 Feb 2022 15:46:46 -0800 (PST) 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=20210112 header.b=Fdd0ugG9; 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 S232095AbiBYSXf (ORCPT + 99 others); Fri, 25 Feb 2022 13:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbiBYSX1 (ORCPT ); Fri, 25 Feb 2022 13:23:27 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48555F1EB1 for ; Fri, 25 Feb 2022 10:22:54 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id a12-20020a65640c000000b003756296df5cso3044781pgv.19 for ; Fri, 25 Feb 2022 10:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=VKMBlWNx4jK1iDVhpsaRZcvzkSOAxKFhhP9NDDoxkLA=; b=Fdd0ugG9W3f4EJeeUYsCgb8W9Ynd5MF6AKEcW9LnQwoRU3YEau0D2ZwFmpoNIOuvd1 J6HppSKpX/QYcTmEka6QjbKpAhYpeQgkge2amIHPVjFS9MehVv+XZZd30rcmdCiItSeY 0l6W7scfFbqHQAkX4U1MAUk+AlREKywJdodZSG3B2SIZQTZmBi9wJiPUXWioIjh7j1ya JnMh5Rv9Ap/QzJQDQXG1x8HwsQ92lTRv/4ln8Vo1StPl4s4CSvXq3bZmdHl7jANIHTPt MgOgzVCSzc4MgjTWgS8zkx+e8N0Wo/mApBy98n4knaA8odwbLo7GDc3PWVYrNry/ub6K cg+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=VKMBlWNx4jK1iDVhpsaRZcvzkSOAxKFhhP9NDDoxkLA=; b=f0tdVP1c5p5SHelKJCG/pZYTVCXFZbpZfAzz/bnFYLT+WxKWhUa27+3w1fRwnfaASB 8nLOxv7jF99dOlEf60Ly8497XfwllexW4ysxC5Fk/V6q9jRKgMEGjBv8Hi4fN652z0lH +uKYS4HJwDJdtPGud1VzXijjkz0JlttAhaiIn7FKF3bvgN2vJXTNYs8iFvH5bx01iiEe UAn6qynU/vLi0bL5lbxgY5k/THq7uxUdXSJijUPAfsMgxPd405zHflPwKZHl5ha9nqmP ZIhF/GiE7iKSDMreAgcEvjnEA1grOG7yhpp+ZPK1XQJBlulBKiaf/fGs0SqMcpXVqtRT 2OmQ== X-Gm-Message-State: AOAM533XxKYgKMYRDmNXzFc8OgY51xa5BPnfbeXnKOjWErWL5DuGkHJL 2zQHpGPTxb2AOKMveo7H43zF8zcABOk= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4f43:b0:1bc:7e5c:e024 with SMTP id pj3-20020a17090b4f4300b001bc7e5ce024mr26606pjb.0.1645813373353; Fri, 25 Feb 2022 10:22:53 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 25 Feb 2022 18:22:43 +0000 In-Reply-To: <20220225182248.3812651-1-seanjc@google.com> Message-Id: <20220225182248.3812651-3-seanjc@google.com> Mime-Version: 1.0 References: <20220225182248.3812651-1-seanjc@google.com> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog Subject: [PATCH v2 2/7] KVM: x86: Invoke kvm_mmu_unload() directly on CR4.PCIDE change From: Sean Christopherson To: Paolo Bonzini , Christian Borntraeger , Janosch Frank Cc: David Hildenbrand , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Lai Jiangshan 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=unavailable 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 Replace a KVM_REQ_MMU_RELOAD request with a direct kvm_mmu_unload() call when the guest's CR4.PCIDE changes. This will allow tweaking the logic of KVM_REQ_MMU_RELOAD to free only obsolete/invalid roots, which is the historical intent of KVM_REQ_MMU_RELOAD. The recent PCIDE behavior is the only user of KVM_REQ_MMU_RELOAD that doesn't mark affected roots as obsolete, needs to unconditionally unload the entire MMU, _and_ affects only the current vCPU. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2157284d05b0..579b26ffc124 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1077,7 +1077,7 @@ void kvm_post_set_cr4(struct kvm_vcpu *vcpu, unsigned long old_cr4, unsigned lon */ if (!tdp_enabled && (cr4 & X86_CR4_PCIDE) && !(old_cr4 & X86_CR4_PCIDE)) - kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu); + kvm_mmu_unload(vcpu); /* * The TLB has to be flushed for all PCIDs if any of the following -- 2.35.1.574.g5d30c73bfb-goog