From patchwork Wed Sep 27 09:09:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13400432 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 083C8E810B5 for ; Wed, 27 Sep 2023 09:10:11 +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: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t5bzohCqNJrRw2JuBPTcdNrwuJSsQ2he5mKDJ9AyT+A=; b=upvfBgSwvhmggz oVwJwY+YTG+MEurQ6Rd7WWF0rcEOaYsczz2z96qtifwFvP5ObHl3xzQ3O0UeTYCdqpotiT/zG0c0l Eul+DZX31DMAX54mQ4tbF3hOlJLsEwAYxL2m7VmyUz2DetcDghyagtP0hVBRqhqva3psTYxmrvMwl jurKpwWHWrkuOp8E5oiZXDNC+eiX9kVJKz8S93LLQJanAML/cI6ZdQx6EDzsy6gy/eEPbAEfonmAC kbE09nVLyvnGf1jETWU1aDaboLVUq77YqNpwN8LoY9D7jhLg+sjeHPN0hsE8oOXtcbV7xL4rNvz1r EXe/EY63C0muzuTKzFZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlQY8-000R26-1k; Wed, 27 Sep 2023 09:09:40 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlQXq-000Qt7-2a for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 09:09:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6EC30CE17DF; Wed, 27 Sep 2023 09:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B578BC433D9; Wed, 27 Sep 2023 09:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695805759; bh=kU23CEv+nBYaQuElLBiPmIVf/MmSLfglEUFHhMry2OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZ+qf0JaaWsBigV0QttbNQRLOaGqMly2id3+fWaRZhxx5e+dJfpnpAOUtK9FZKB2Q adNiindodX1FgdVLvCFCL+ROsssQtqwjmLiIr4ViEGh6zE3BX2L6CBPMGxbGCWU4EQ GFNkp42WOGLK36QRtqMk9F0ANUAsU8ChvzRmtSPXwje3yTg3fdmtLuI1ArsNtIxwp2 fCj77hr0N1hsMdX7HDE4qEqrd5rIRr5m4nSzr1yB41UkGegn2f1x4MzMeo2REa/Uyi 7jqmsuWT9FEjGxHfS8RD2g79vy1RRGoU85bq3ABHK1il6IASjW+lT/+tBKhQw/+TVL twhW9LiC+vXaA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qlQXl-00GaLb-KP; Wed, 27 Sep 2023 10:09:17 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly , Shameerali Kolothum Thodi , Xu Zhao , Eric Auger Subject: [PATCH v3 06/11] KVM: arm64: Use vcpu_idx for invalidation tracking Date: Wed, 27 Sep 2023 10:09:06 +0100 Message-Id: <20230927090911.3355209-7-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927090911.3355209-1-maz@kernel.org> References: <20230927090911.3355209-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: 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, yuzenghui@huawei.com, 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-20230927_020923_085743_0C1276B3 X-CRM114-Status: GOOD ( 13.44 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While vcpu_id isn't necessarily a bad choice as an identifier for the currently running vcpu, it is provided by userspace, and there is close to no guarantee that it would be unique. Switch it to vcpu_idx instead, for which we have much stronger guarantees. Reviewed-by: Zenghui Yu 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 fa21fb15e927..9379a1227501 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;