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 X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 430B2C433E0 for ; Tue, 9 Mar 2021 13:32:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0FA0650ED for ; Tue, 9 Mar 2021 13:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbhCINbj (ORCPT ); Tue, 9 Mar 2021 08:31:39 -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 >