Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp642356pxu; Fri, 23 Oct 2020 09:37:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw29wTGDKN9t9ONJ3TGaaYctb/NqyTFvP2p65d36tC7k9zHVK8yWFNhlco0HYUBsjMsMbT2 X-Received: by 2002:a17:906:a00d:: with SMTP id p13mr2884683ejy.183.1603471051447; Fri, 23 Oct 2020 09:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603471051; cv=none; d=google.com; s=arc-20160816; b=V6P4yM2m5c0rCIJAMJlQ5viRODbQcuFK1XhmOidbYoJeHOdnu0E5H/8I4TJHAPQ5io 5Pq8COBddueBnHXVASiNHaI0KsWL4sYftyjl/5+KT4JLGcZXuRPM642GXt3w+Cz9TH+Z 1iJ6VUvGo77H59+X5wAqHIl4j4VqwaLYp5rrUDEUWa76+g2KTzDpGSgmK6fErLlfjU/p r8ceA7eAsbu3uy1x9jL6COtBvnmS4C3Ma7zqQbjSwfaAOlKAh+MURjuNuNKx2i4DXdNr MdKJWijT3EP0CgG83gvFFMQNAsBXL+YcvSXoBy9xdejz+STy96n16Yvt5zXq+D3CG0ju JH2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ZrJSzb3WHvQqEKUfz6VHAhcLq9jWnL01O60urGyRQw=; b=t7KNr+IlWz06OaR5IXeTtOF1DRFPPBm6rWHwYter9+FvHf8PrcRFaAV9A5GzWCzvW1 +7CtLgExLLFrVcNxOy+UZK1CerWl0iDIoIBHCKef2O/oGlAKg7ila7w+GwbhRHXimtNn KCitIvxCaGjfCo4pNOhz97c0QjVPKvCkLz6q8MZvKFu4dJuAqsaEH5Jo8Hqiiu6Ky2U7 j9r4SRfmTnZhYP7bCnVfh3PSELv242lo0GS/eCr4nmooHtms/de6O4Wt15gMzarKH/mm ekxwIdSYpFPYRroZAKVZTMdyzAkBEZpRBIVq/K7pVMCG0lflxs+f3IbxpmIaXtzB/Ul6 1HTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=atZVCnAb; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si1161670edn.156.2020.10.23.09.37.09; Fri, 23 Oct 2020 09:37:31 -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=@redhat.com header.s=mimecast20190719 header.b=atZVCnAb; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751628AbgJWQau (ORCPT + 99 others); Fri, 23 Oct 2020 12:30:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29519 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbgJWQar (ORCPT ); Fri, 23 Oct 2020 12:30:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603470646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+ZrJSzb3WHvQqEKUfz6VHAhcLq9jWnL01O60urGyRQw=; b=atZVCnAbdZP0lPfgZqwjsuOGD7UZ4zt0WuZciwjwLtPo06exZzQ7r+YLLw0SXI9/CtPQlC ONY4VnmpQ0h2kXhVM06RwrIjnTWDztfjbUzy8SVd69x8RmJMZaL2KdEVrazaaTNLME8rRI ldtbsW+1NrGkHBeaB2rv14+U/o2UyIo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-ydw-wJqON_uTE5Duqo9dOw-1; Fri, 23 Oct 2020 12:30:43 -0400 X-MC-Unique: ydw-wJqON_uTE5Duqo9dOw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5B83EC11A; Fri, 23 Oct 2020 16:30:42 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 430DA9CBC8; Fri, 23 Oct 2020 16:30:42 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: bgardon@google.com Subject: [PATCH 21/22] kvm: x86/mmu: Don't clear write flooding count for direct roots Date: Fri, 23 Oct 2020 12:30:23 -0400 Message-Id: <20201023163024.2765558-22-pbonzini@redhat.com> In-Reply-To: <20201023163024.2765558-1-pbonzini@redhat.com> References: <20201023163024.2765558-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ben Gardon Direct roots don't have a write flooding count because the guest can't affect that paging structure. Thus there's no need to clear the write flooding count on a fast CR3 switch for direct roots. Tested by running kvm-unit-tests and KVM selftests on an Intel Haswell machine. This series introduced no new failures. This series can be viewed in Gerrit at: https://linux-review.googlesource.com/c/virt/kvm/kvm/+/2538 Signed-off-by: Ben Gardon Message-Id: <20201014182700.2888246-20-bgardon@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6a0941ccac34..7b52fa1f01b0 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3892,7 +3892,13 @@ static void __kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd, */ vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY); - __clear_sp_write_flooding_count(to_shadow_page(vcpu->arch.mmu->root_hpa)); + /* + * If this is a direct root page, it doesn't have a write flooding + * count. Otherwise, clear the write flooding count. + */ + if (!new_role.direct) + __clear_sp_write_flooding_count( + to_shadow_page(vcpu->arch.mmu->root_hpa)); } void kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd, bool skip_tlb_flush, -- 2.26.2