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=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 CE414C433E0 for ; Fri, 12 Mar 2021 18:13:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8D2664F4E for ; Fri, 12 Mar 2021 18:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232628AbhCLSMb (ORCPT ); Fri, 12 Mar 2021 13:12:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34048 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232697AbhCLSMT (ORCPT ); Fri, 12 Mar 2021 13:12:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615572739; 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=FEwm7dbFA9YEtIy6iLHK/1/1xLzzzQXYHGmPoA51kGY=; b=Z6xWg19dCUVYQWfzWDdNkaNCXeOG2uvNmCX3I9TE3x1c/plBsnqiG3ZkRpfFurUhfVoUUW zGI2vG1CR57vIaus8tfmVuSrtPTozbS0S1wn8MQ7cx9N6cdxPwhTG0opz0iYVNd2sh5KqE JLesZW+lpDg8VFSpNvbrUtZaS78FVUE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-jpXJYB58MXSSVdcSqKzM7A-1; Fri, 12 Mar 2021 13:12:18 -0500 X-MC-Unique: jpXJYB58MXSSVdcSqKzM7A-1 Received: by mail-wr1-f70.google.com with SMTP id n17so11531647wrq.5 for ; Fri, 12 Mar 2021 10:12:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FEwm7dbFA9YEtIy6iLHK/1/1xLzzzQXYHGmPoA51kGY=; b=XUCdkQjNS/jxM2sqvsApaJMT0uFG8mBUoJDvd+8+6LlvB2SKX12grx0n7vb5bQCShi dYEpD+c9SgdpE1KCetJyfof+zDHuNSEZxnOMy6GDzPvVNFvc+IBhec6r1VUBazrXhKzw ZVq/TyD6lDjgB+Gj/mWgCdGHhKXijUnOpQnco+m/Is7Ccmi0okDCJtR3fH0Z68E0nVGP UO3sO6n2n3GvS9iEmgounIGEM30jVeNgQtv7MT855+2KUaDYgI+9b4yI0Kox1bHQRx4q b7x9D4MgNtP6DunEqPyhc4p9vmp53VnrqzVa1wnipCJZ1nZqB5bORuWoT+8vF3K3ZNf9 8XIg== X-Gm-Message-State: AOAM530XwgpJsL3KZx2bzM49x0seXK8F1E/iKMDCpyzeAaGl/++JgC3A c1srb0RoLtZZfrqnIfML9bEL3mBtZZX9U0vx5zjjn/M9KGp+X6CH6U8mmdoRbz9lPnYxFjsBYHh YacBU+w0ufpLbLa1ptHz6NWaYznsngLBNi07jyKKliu7IOTlObgZndZh0gzCVpGk+Ou/D7iV7Tw 0j X-Received: by 2002:a7b:cc84:: with SMTP id p4mr14411450wma.10.1615572736425; Fri, 12 Mar 2021 10:12:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJztaR9pls6kz3Lfs5bJVbE2dnEL9uu98jcGBYdpHNScOrUa5G4QFWGNdLiPxHzLFm5fa/OULw== X-Received: by 2002:a7b:cc84:: with SMTP id p4mr14411425wma.10.1615572736164; Fri, 12 Mar 2021 10:12:16 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id q4sm3154713wma.20.2021.03.12.10.12.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Mar 2021 10:12:15 -0800 (PST) Subject: Re: [PATCH] KVM: x86/mmu: Skip !MMU-present SPTEs when removing SP in exclusive mode To: Ben Gardon , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm , LKML References: <20210310003029.1250571-1-seanjc@google.com> <07cf7833-c74a-9ae0-6895-d74708b97f68@redhat.com> From: Paolo Bonzini Message-ID: Date: Fri, 12 Mar 2021 19:12:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/03/21 23:24, Ben Gardon wrote: > On Wed, Mar 10, 2021 at 1:14 PM Sean Christopherson wrote: >> >> On Wed, Mar 10, 2021, Paolo Bonzini wrote: >>> On 10/03/21 01:30, Sean Christopherson wrote: >>>> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c >>>> index 50ef757c5586..f0c99fa04ef2 100644 >>>> --- a/arch/x86/kvm/mmu/tdp_mmu.c >>>> +++ b/arch/x86/kvm/mmu/tdp_mmu.c >>>> @@ -323,7 +323,18 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, u64 *pt, >>>> cpu_relax(); >>>> } >>>> } else { >>>> + /* >>>> + * If the SPTE is not MMU-present, there is no backing >>>> + * page associated with the SPTE and so no side effects >>>> + * that need to be recorded, and exclusive ownership of >>>> + * mmu_lock ensures the SPTE can't be made present. >>>> + * Note, zapping MMIO SPTEs is also unnecessary as they >>>> + * are guarded by the memslots generation, not by being >>>> + * unreachable. >>>> + */ >>>> old_child_spte = READ_ONCE(*sptep); >>>> + if (!is_shadow_present_pte(old_child_spte)) >>>> + continue; >>>> /* >>>> * Marking the SPTE as a removed SPTE is not > > This optimization also makes me think we could also skip the > __handle_changed_spte call in the read mode case if the SPTE change > was !PRESENT -> REMOVED. > Yes, I think so. It should be a separate patch anyway, so I've queued this one. Paolo