Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2550283pxb; Tue, 9 Mar 2021 05:33:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP2Z4jxZoPMlVvbliYLYu4gJxq9C04hFKaCTH5WIPYIgueO/4n57F6Oi0Q9tcZBnADwQtd X-Received: by 2002:a17:906:1712:: with SMTP id c18mr20680647eje.417.1615296783249; Tue, 09 Mar 2021 05:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615296783; cv=none; d=google.com; s=arc-20160816; b=ALw/WkZ41cZ8Zj2xSOOIZCt1b1ogLB/rUDAqDh61jbCk+/el1cZpiA9tAbPqI2SCP4 czJaf+eZMUyixCa8RSRr+NrRHvLgcBLI1rqwzWoE8YGSUsMTjlSFqgwEafPuUuf3StJG k0lXx5w7SS2XT5X3lu1nl0VvnJkmMjVphm/ZB+mBSImK+SFk06idzMVyNzmh0bgpAQfL yHh1WS43VB6oO7ZIICt2HsULI3VTOkTEdgi9SZd07iOF4i4cTlbDgUsUI9/3Vrov0S8E EM1U/iR4ZLbQCkP8AKP9wjf3dIsBh8oougPap0clRh4BORuhFpskXI4idRoMaqvP6rbX ENqg== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=EpvaiT9lNridqnyvnBIVcNFfk1XSrEn77fD74rsW3bg=; b=dsoGIXVt5SrLwMbtaAVwZlJWxvffUFk57vxe5dY/dlFhvzOvfO/XkU5y/QhMxy9oBO IYgXNp5YYH1z2ROWGg8XkTmsZbvOeHXwUtJE03UGEXIISqlLLVdqulUDIOqSsFpFxeFP u9LVLeKR+7KRn7gzGZt8TsVn40QVvu7jSTzl4aWuCLHrf/feJxcsPt7YA7G2TmHmyZNV Wq90B5JzgAnxmpHnHazy62zZ15O01zf+V2oJAClGUlwDZ1GaEwdmH2f8OF4y2MAi0cMx H78pLelRzKnbFM+Ffe5YgZsH9aLSGDEmQ1+UI8WgMm1vQwXYAlx/705U0lccm+R4+Plh waPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GqhJTLtR; 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 bi7si9204460ejb.754.2021.03.09.05.32.40; Tue, 09 Mar 2021 05:33:03 -0800 (PST) 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=GqhJTLtR; 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 S230414AbhCINbi (ORCPT + 99 others); Tue, 9 Mar 2021 08:31:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58111 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCINb2 (ORCPT ); Tue, 9 Mar 2021 08:31:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615296688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EpvaiT9lNridqnyvnBIVcNFfk1XSrEn77fD74rsW3bg=; b=GqhJTLtR7XC7p4NWBwZqyqK5m8nFQyrAcFujvruDJ2Zu9x40hCopqogVJSLPO/cDOVuXWo 1yyqbJBPnW/+J2rkEPfNclyQbVpMFAckeqluHJ1rws7m1P0JjJhMrZdVrAhgh9bj2fSbdn BckPDEmpXZF2n9t0ZWR6tyLrJawy4/M= 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-76-yuDpp31vNJ2ZcgeLvMHd8A-1; Tue, 09 Mar 2021 08:31:26 -0500 X-MC-Unique: yuDpp31vNJ2ZcgeLvMHd8A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 218F71005D4A; Tue, 9 Mar 2021 13:31:25 +0000 (UTC) Received: from starship (unknown [10.35.206.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7600319D7C; Tue, 9 Mar 2021 13:31:22 +0000 (UTC) Message-ID: Subject: Re: [PATCH 2/2] KVM: x86/mmu: Exclude the MMU_PRESENT bit from MMIO SPTE's generation From: Maxim Levitsky To: Paolo Bonzini , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky Date: Tue, 09 Mar 2021 15:31:21 +0200 In-Reply-To: References: <20210309021900.1001843-1-seanjc@google.com> <20210309021900.1001843-3-seanjc@google.com> <785c17c307e66b9d7b422cc577499d284cfb6e7b.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-03-09 at 14:12 +0100, Paolo Bonzini wrote: > On 09/03/21 11:09, Maxim Levitsky wrote: > > What happens if mmio generation overflows (e.g if userspace keeps on updating the memslots)? > > In theory if we have a SPTE with a stale generation, it can became valid, no? > > > > I think that we should in the case of the overflow zap all mmio sptes. > > What do you think? > > Zapping all MMIO SPTEs is done by updating the generation count. When > it overflows, all SPs are zapped: > > /* > * The very rare case: if the MMIO generation number has wrapped, > * zap all shadow pages. > */ > if (unlikely(gen == 0)) { > kvm_debug_ratelimited("kvm: zapping shadow pages for > mmio generation wraparound\n"); > kvm_mmu_zap_all_fast(kvm); > } > > So giving it more bits make this more rare, at the same time having to > remove one or two bits is not the end of the world. This is exactly what I expected to happen, I just didn't find that code. Thanks for explanation, and it shows that I didn't study the mmio spte code much. Best regards, Maxim Levitsky > > Paolo >