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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77CA0C433EF for ; Thu, 17 Feb 2022 21:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244973AbiBQVEd (ORCPT ); Thu, 17 Feb 2022 16:04:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243990AbiBQVEF (ORCPT ); Thu, 17 Feb 2022 16:04:05 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C963F1017EF for ; Thu, 17 Feb 2022 13:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645131830; 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=kbg+OqZri34BoKCLL1H4Wwzp/4I4YJYM0faw8mk1Jng=; b=icxNAzZRATbf/2YWGXsk3hwd/+HSKt1Bev+d2zDtQupZ34h2UWe7qlita67HfgZ/JClnd5 b8uf96FUYwD6zwK5bLQjo4wNkdYkDPJKoigltHFXcyPCQ78s4QQ02/l+/Pkr1irzwgFW/p bBh0+dW2sgeo42lPtbwhwX03ODyL/sM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-qvdlAysIMd-OoGmt1adXEg-1; Thu, 17 Feb 2022 16:03:48 -0500 X-MC-Unique: qvdlAysIMd-OoGmt1adXEg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5400C814245; Thu, 17 Feb 2022 21:03:47 +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 0492C6AB95; Thu, 17 Feb 2022 21:03:46 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com Subject: [PATCH v2 12/18] KVM: x86/mmu: clear MMIO cache when unloading the MMU Date: Thu, 17 Feb 2022 16:03:34 -0500 Message-Id: <20220217210340.312449-13-pbonzini@redhat.com> In-Reply-To: <20220217210340.312449-1-pbonzini@redhat.com> References: <20220217210340.312449-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For cleanliness, do not leave a stale GVA in the cache after all the roots are cleared. In practice, kvm_mmu_load will go through kvm_mmu_sync_roots if paging is on, and will not use vcpu_match_mmio_gva at all if paging is off. However, leaving data in the cache might cause bugs in the future. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index b01160716c6a..4e8e3e9530ca 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5111,6 +5111,7 @@ void kvm_mmu_unload(struct kvm_vcpu *vcpu) { __kvm_mmu_unload(vcpu->kvm, &vcpu->arch.root_mmu); __kvm_mmu_unload(vcpu->kvm, &vcpu->arch.guest_mmu); + vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY); } static bool need_remote_flush(u64 old, u64 new) -- 2.31.1