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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E6E1E7D0AA for ; Thu, 21 Sep 2023 18:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbjIUSKq (ORCPT ); Thu, 21 Sep 2023 14:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjIUSKj (ORCPT ); Thu, 21 Sep 2023 14:10:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E5B385D27 for ; Thu, 21 Sep 2023 10:37:51 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FE28C4E67D; Thu, 21 Sep 2023 12:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695301133; bh=p2rPYJ8v79QRC92u+uM0OQjzvCP0vWiWuVvNHsnIUIo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f56Y7ss8vs0xfKopqna+GBC5d3tnP62h96mx1Txvw7J4ViS6OW85LGQ6N6UumyNIV w9Q01TNsxORKGTin6dQvy9JSbbU7Wr4s0fHitvr8VYdQuowHgjLKIRUQuWXOrXJcll IQ9JgkdGpAouv8rNxtiLroD03Jd3X374270Fh5p166RJFYgp0wAGr60fczcZoWgIHW gXJl6AVG47LxvrAKlDIiNhEByEBnYSTBsLISlkLpR9eEG7oStYKrHvqShr2Y9DTwDk aTERQpxObwxM9jzVe1QP13bwNko2epPG+JV8ry3THbCsqUfre5/p+MQ9LczJZNDg/M JjGZko2GFJufA== 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 1qjJGd-00EvBD-0R; Thu, 21 Sep 2023 13:58:51 +0100 Date: Thu, 21 Sep 2023 13:58:49 +0100 Message-ID: <86zg1fof7a.wl-maz@kernel.org> From: Marc Zyngier To: Zenghui Yu Cc: , , , James Morse , Suzuki K Poulose , Oliver Upton , Joey Gouly , Shameerali Kolothum Thodi , Xu Zhao , Eric Auger Subject: Re: [PATCH v2 06/11] KVM: arm64: Use vcpu_idx for invalidation tracking In-Reply-To: References: <20230920181731.2232453-1-maz@kernel.org> <20230920181731.2232453-7-maz@kernel.org> 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.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) 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: yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, joey.gouly@arm.com, shameerali.kolothum.thodi@huawei.com, zhaoxu.35@bytedance.com, eric.auger@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, 21 Sep 2023 10:16:42 +0100, Zenghui Yu wrote: > > On 2023/9/21 2:17, Marc Zyngier wrote: > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kvm/arm.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index 872679a0cbd7..23c22dbd1969 100644 > > --- a/arch/arm64/kvm/arm.c > > +++ b/arch/arm64/kvm/arm.c > > @@ -438,9 +438,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > > * We might get preempted before the vCPU actually runs, but > > * over-invalidation doesn't affect correctness. > > */ > > - if (*last_ran != vcpu->vcpu_id) { > > + if (*last_ran != vcpu->vcpu_idx) { > > kvm_call_hyp(__kvm_flush_cpu_context, mmu); > > - *last_ran = vcpu->vcpu_id; > > + *last_ran = vcpu->vcpu_idx; > > } > > vcpu->cpu = cpu; > > Isn't the original code (using vcpu_id) enough to detect a different > previously run VCPU? What am I missing? It is in theory enough. However, I couldn't convince myself of the *unicity* of the vcpu_id field. It really feels like something as crucial as the TLB invalidation shouldn't rely on something that is controlled by userspace. And I really should write a commit message to capture this. Thanks, M. -- Without deviation from the norm, progress is not possible.