Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp137406lql; Fri, 12 Apr 2024 06:15:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMF4zqjwiuQ4bRHVVWGDDu1n7i7742GpiUopWmb0YAR5XFiS1eQBTGQ7suXTqsGIEtRDkhi/4ijQVhkwFW+zyMu6giO44RBlYdtN+70g== X-Google-Smtp-Source: AGHT+IHpw2VYQB1HzkjxROAOjKZZBqeAGzkiImK82JZ2sAcmhcwS/6epH7fBZqo4Vt2Wo1lJKGv8 X-Received: by 2002:a17:90a:c683:b0:29b:10bc:acaf with SMTP id n3-20020a17090ac68300b0029b10bcacafmr2228823pjt.30.1712927759454; Fri, 12 Apr 2024 06:15:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712927759; cv=pass; d=google.com; s=arc-20160816; b=oFgSVEYSmSf6PM6IS5HxAkFY8ZjxGi1Y2+iKWGBaFg6jmaT9xrX5lJqFurj3UTVb8Y coe/BlvFq1TtZ/YIg+Nk1zH50ZvvW+tmTqpnaatekyWSzQFAoHQjCvht6a4ZZTXZAvXu H1z1aZs6CvsQTs+hZa+XLIiasefe++4r+5rIBFmo9ehmHgAtLl6+mECAODqZHcwTLHbM jbs0bdDWUBG70WjCsK/AmqAd6qAYrJrQUywH2+u5WKwg0GzrxmSSzU4qDBkiAxeNSMXJ /8HS1icsQpV2uv1Ped9Jc76tdB91xUjoz+dWD2rIFgjJWX17XLulAHdA781DZ12EKgzh Ut1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=e4MNLRziR1SYQkKKknooFSOSMFufrQLjxc0dg3vpWhE=; fh=vg0rP54r9LHKasKxKpK3YW6kXXNxXFFWUe/fXEjvOEM=; b=eqep4wZXAAQ0XVAr8HacoEScFHM2Gk1jRw8jnZ2ANw8zWzfLGTAvPaCu1OOTG5PUIB Eel0RKgUl4cej5kMV5CbECUXVUe9/p2Rbg+x3TN/lVNw3rfYvrR0o00ndWz+IIt5WkbE HcvU+ugFbTjvfObO1+L7b84Nb3sf4V3qmTES5CviOgNUAc1BMmomGXfJJSx2xtDyPlx6 dVzQNq4U7E38MiDEeresnd6060s+PpC2VoX8PRREaPECwQlQinaz8QPcYardL2XD3GTc 3rylLzeqqUk9fszUHdw4AnUHMkHNRReqeJXbWp8qqVaT5tPwzpjifp1P7blOYr4TiXc1 jvbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hNXxGfwR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v12-20020a17090a088c00b002a4f0f7a137si5387903pjc.102.2024.04.12.06.15.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 06:15:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hNXxGfwR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 039DF2858EB for ; Fri, 12 Apr 2024 13:15:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D32960ED1; Fri, 12 Apr 2024 13:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hNXxGfwR" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F92B5B209; Fri, 12 Apr 2024 13:15:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927748; cv=none; b=Pyk/sAqWssvItscnvKledmcOV3gKF8651kTc7pKY15t8qqqUhdWDKD9zCvVzFDunvgoEeiA32R76BvB089H30XiYlHB+ioJUd3RMjITJzrd8a3ay2fwP3srPcJUZfBUBgOM2j58GuDajvi0dvrCEQ3de6Sr5XwoWhEQ7zqOSeiE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927748; c=relaxed/simple; bh=FKqbsMvb1Xrvl10w52+WrBW+b+Xl/+V6fjfICrYPU7k=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=bvNCZ/MMgrAJC8psrqKZACqIQ587kqutPI3I3HSospKnBI6VVwYKU+9xn3uAQR2UzedZqsHqwo7rluyv0xlO7yJzrdXI8IZlRxU0I+k+VRDcE+4D1/fk/fIjgDt/qKTfaiRv2Y9YgIwJ6izhKx3gzQAOAzuxC5SYSsZ5oI9rkK0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hNXxGfwR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9713C113CC; Fri, 12 Apr 2024 13:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712927747; bh=FKqbsMvb1Xrvl10w52+WrBW+b+Xl/+V6fjfICrYPU7k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hNXxGfwROQadhM8Bfbt+o+cnTXnED3hgcPxC3tVUCneuZRNBRjyi/d+yoDq4MShLU BzlqesGL+iEiNxIpyPWttOqnp5mN+bQ8esIt4yACop1/8/lN0FkLd+yGn6r9/ph419 5XjJnNDe00k1azgNbQZC7Hi5qn44t5jY3huX6tvwqa7YZLp0Ov44ngjAq5DyWgWus3 SQ2CseSUBen+1DzOq19HixEPvPa4dqaz6G6KEsBrH/yaR3gsq9qX8u/zjaP8xlnCgM eNZYWtBPpVaO64Wx6qlGvkCEc4FRHLTnG38BQZmA/XvqY24QIRJS7MfB/vq96MS5JW 1ho9eqwZ3K5xA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rvGkr-003tYh-Gi; Fri, 12 Apr 2024 14:15:45 +0100 Date: Fri, 12 Apr 2024 14:15:44 +0100 Message-ID: <86jzl2sovz.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Oliver Upton , Tianrui Zhao , Bibo Mao , Thomas Bogendoerfer , Nicholas Piggin , Anup Patel , Atish Patra , Sean Christopherson , Andrew Morton , David Hildenbrand , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback In-Reply-To: <20240412104408.GA27645@willie-the-truck> References: <20240405115815.3226315-1-pbonzini@redhat.com> <20240405115815.3226315-2-pbonzini@redhat.com> <20240412104408.GA27645@willie-the-truck> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: will@kernel.org, pbonzini@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, oliver.upton@linux.dev, zhaotianrui@loongson.cn, maobibo@loongson.cn, tsbogend@alpha.franken.de, npiggin@gmail.com, anup@brainfault.org, atishp@atishpatra.org, seanjc@google.com, akpm@linux-foundation.org, david@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 12 Apr 2024 11:44:09 +0100, Will Deacon wrote: > > On Fri, Apr 05, 2024 at 07:58:12AM -0400, Paolo Bonzini wrote: > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > > index dc04bc767865..ff17849be9f4 100644 > > --- a/arch/arm64/kvm/mmu.c > > +++ b/arch/arm64/kvm/mmu.c > > @@ -1768,40 +1768,6 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) > > return false; > > } > > > > -bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) > > -{ > > - kvm_pfn_t pfn = pte_pfn(range->arg.pte); > > - > > - if (!kvm->arch.mmu.pgt) > > - return false; > > - > > - WARN_ON(range->end - range->start != 1); > > - > > - /* > > - * If the page isn't tagged, defer to user_mem_abort() for sanitising > > - * the MTE tags. The S2 pte should have been unmapped by > > - * mmu_notifier_invalidate_range_end(). > > - */ > > - if (kvm_has_mte(kvm) && !page_mte_tagged(pfn_to_page(pfn))) > > - return false; > > - > > - /* > > - * We've moved a page around, probably through CoW, so let's treat > > - * it just like a translation fault and the map handler will clean > > - * the cache to the PoC. > > - * > > - * The MMU notifiers will have unmapped a huge PMD before calling > > - * ->change_pte() (which in turn calls kvm_set_spte_gfn()) and > > - * therefore we never need to clear out a huge PMD through this > > - * calling path and a memcache is not required. > > - */ > > - kvm_pgtable_stage2_map(kvm->arch.mmu.pgt, range->start << PAGE_SHIFT, > > - PAGE_SIZE, __pfn_to_phys(pfn), > > - KVM_PGTABLE_PROT_R, NULL, 0); > > - > > - return false; > > -} > > - > > bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) > > { > > u64 size = (range->end - range->start) << PAGE_SHIFT; > > Thanks. It's nice to see this code retire: > > Acked-by: Will Deacon > > Also, if you're in the business of hacking the MMU notifier code, it > would be really great to change the .clear_flush_young() callback so > that the architecture could handle the TLB invalidation. At the moment, > the core KVM code invalidates the whole VMID courtesy of 'flush_on_ret' > being set by kvm_handle_hva_range(), whereas we could do a much > lighter-weight and targetted TLBI in the architecture page-table code > when we actually update the ptes for small ranges. Indeed, and I was looking at this earlier this week as it has a pretty devastating effect with NV (it blows the shadow S2 for that VMID, with costly consequences). In general, it feels like the TLB invalidation should stay with the code that deals with the page tables, as it has a pretty good idea of what needs to be invalidated and how -- specially on architectures that have a HW-broadcast facility like arm64. Thanks, M. -- Without deviation from the norm, progress is not possible.