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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6DCFE71068 for ; Thu, 21 Sep 2023 12:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SgvsX14rp9Ck0zjGUjdx7iGicJi4AfqqbxavGOTw3oY=; b=bpA+alC4GHpZJR 6gOSQ1ZqP/zQ07x6DUXD5V702+Me38IrXTIqsDmJXQr57iXjab4702uYMAbVS1lTwpeHmKs2Pu9JX q5ZjDIslz8DzoCP8teykM+jVMuMadCbYAuTmVfn2KG4c+ijyn5pOJLNbhRvGRvIff9ZUieele08gc g6Fee4my+msFdIDTbOh0pQXdIQnzFmr4IQmpg5eRCOx/IZX3Qbuc5EW6fKjc8DoKlXSsWnW+dk+16 sWBkItKkr5FT3Df+pR4bh15XHtdqPGgOm2GEVZilwbLJiHqL2KE8orNkwqjb398OkYhbTbp6wusal sEAzEM7PkwplggZK8/WQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjJGm-0064px-0I; Thu, 21 Sep 2023 12:59:00 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjJGj-0064pN-0C for linux-arm-kernel@lists.infradead.org; Thu, 21 Sep 2023 12:58:58 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 36532CE221D; Thu, 21 Sep 2023 12:58:55 +0000 (UTC) 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230921_055857_450491_16B22979 X-CRM114-Status: GOOD ( 22.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel