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 A9C55C433F5 for ; Wed, 1 Dec 2021 15:48:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351262AbhLAPva (ORCPT ); Wed, 1 Dec 2021 10:51:30 -0500 Received: from vps-vb.mhejs.net ([37.28.154.113]:46438 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351112AbhLAPt2 (ORCPT ); Wed, 1 Dec 2021 10:49:28 -0500 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msRnv-0008Hv-4u; Wed, 01 Dec 2021 16:45:55 +0100 To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Igor Mammedov , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandru Elisei , Atish Patra , Ben Gardon , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <72e1c87ddce1c2836bf8a82962202dc4c34bb53f.1638304316.git.maciej.szmigiero@oracle.com> From: "Maciej S. Szmigiero" Subject: Re: [PATCH v6 25/29] KVM: Call kvm_arch_flush_shadow_memslot() on the old slot in kvm_invalidate_memslot() Message-ID: Date: Wed, 1 Dec 2021 16:45:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.12.2021 04:27, Sean Christopherson wrote: > On Tue, Nov 30, 2021, Maciej S. Szmigiero wrote: >> From: "Maciej S. Szmigiero" >> >> kvm_invalidate_memslot() calls kvm_arch_flush_shadow_memslot() on the >> active, but KVM_MEMSLOT_INVALID slot. >> Do it on the inactive (but valid) old slot instead since arch code really >> should not get passed such invalid slot. > > One other thing that's worth noting in the changelog is that "old->arch" may have > stale data. IMO that's perfectly ok, but it's definitely a quirk. Will add this caveat to this commit message. > Ideally KVM > would disallow touching "arch" for an INVALID slot, but that would require another > arch hook if kvm_prepare_memory_region() failed to refresh old->arch if necessary > before restoring it. :-/ It looks to me that only PPC book3s_hv actually uses the "arch" field in its kvm_arch_flush_shadow_memslot() implementation. But at the same time it does not seem to do lazy allocation for rmaps or similar stuff. However, the code there is complex enough for this change to be of higher-than-usual risk. That's why I have split it out from the main memslots sets rework. Thanks, Maciej