Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp753919rdb; Sun, 18 Feb 2024 10:05:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOpb3fGdGMNruG6Xz8iv2aXbV9ZuQWjAJ2QtmUKEpErautsjrqJ5kX+NISHxDI2MFg+uMcn8szsPFfExdRMYUZbOzHlgSlX52+ZufsGw== X-Google-Smtp-Source: AGHT+IH6sWlheACXuHLkm3IX36yNENW5/dZqfPekIsJYF99RtDyjchwIZSLsTyiwHzYJg/w9l5tQ X-Received: by 2002:a17:906:e089:b0:a3c:f531:4514 with SMTP id gh9-20020a170906e08900b00a3cf5314514mr6852740ejb.62.1708279559366; Sun, 18 Feb 2024 10:05:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708279559; cv=pass; d=google.com; s=arc-20160816; b=b1U8OOr71eJNDeWVw8+DURpFjMWRWCdSawzLtt25akxgO7a3A84bUw1JAfXDQKk3rk a6WQSkOB7R+7rHEZq94XJsnoSY1/3OtxiGIijec/VK8S/Whi3hQGcMShuAM0sdl8oEla Cv1e57JSmfVMXTIU1kGg7NGAeW3Tw5cHh/x1tdC55L15AmPRmyUok/LhSkzLMiof8X6A wJTfcqeNXai3W2ILHzjAxFV+gt2rKyVUN6F+jcgOFZaBYmpoTPlpxDMc4GGZINqtYFNO y9Gc+6dltScShneNjDeYCyYarpfepF1XD5V8moHuWwllaAU0vW52ob4+/EnLdd8G+mms 2Lig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=+NFOvyN6tcyqft/QfMQHusxypN7esItJ9glpfGKgmoY=; fh=csFJ1+HrNkGMBMkPDqu77Qy+euPXJ+WNh9qFaY2EzSg=; b=E4yvtR0VQ2uNooi+KepsWXjkQDqC3E0UGv2rLbMPsmF036FzS2676YkuKimDfV8Gh7 8pEo7P/OSlxqnv495eq+Ki55ZYXGcS3PuhKtEJU7VtPwc/j8wLKBHMJe8lTKc6i7Znbc MVcWhiAhS6opH/XKLL+DxYEGRyEApkfKUYMp8vZai7d63dW6c3no9SlsTZ4DUwjMhaFn 27LISwXDpoO/0N1HipTzYwk03fXYvNfeWcdY+c+tLOgluYgsHqTABrWbFo8mmqpYBcEO s2BStKzQ/+K0fIJmS+DY7oQ5gF1ioMd0NsephyUz6EkkhA3dhi/iqYw6mu105BoFl5hh LQ5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xs7qHF3e; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-70474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70474-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k4-20020a170906680400b00a3e894ffff8si318913ejr.736.2024.02.18.10.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:05:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xs7qHF3e; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-70474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70474-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id F1E231F21A3A for ; Sun, 18 Feb 2024 18:05:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 413EA6F080; Sun, 18 Feb 2024 18:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xs7qHF3e" Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (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 1CDAA6BB4B for ; Sun, 18 Feb 2024 18:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708279547; cv=none; b=VCJqVPL/VqPaxxc8xf6DYlVVBrEwXXdy8hBm/bYW7Zlj7cPFbVqhXk7UwxFycAXjOIdYiu/bIRaS5Wc5IxbUqmkEevz+HjKmBkixlW0uVt//qAJ6nSZuifaR4xuaOisja7/elCiRt1kUliGBuuqnDmpUy7AeQYr9ZM48sWtG/g0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708279547; c=relaxed/simple; bh=vWVIcKnpvzocSjV2NV3m3GpLSmyp7ylR5NPlCRCJaZY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mPvz3Q5hCLM1yZ4Rn6zg/E82/eEIEY46/PmjlPqKWqYsF74ai+rzlQ+9LVy19GkApN+PAKkHH6cnS2CgLD1A+J+mXCkXdIrvgIN0pN20cDvt0c4B7dJNpxTERdrLlukdiF7ufih5OqA/tvsE5N2bhbukCkipTacwuXExRIs9XJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xs7qHF3e; arc=none smtp.client-ip=95.215.58.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Sun, 18 Feb 2024 10:05:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708279543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+NFOvyN6tcyqft/QfMQHusxypN7esItJ9glpfGKgmoY=; b=xs7qHF3exFPWwEGGZCKaakY0hjM+4cJ+uaKTQw5SkevF4h4GyYFP2wyvW5KmX1YzN8yq+b MKzjBUabBpGzC60uFsdnSptqMXgR3OGjle0P1LR2IQAbvdoMyoUHmxpG2tWXdkgxxaeikN zhNDYy7z2s0dz7qt1IKRUMEJv0DzjHg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/10] KVM: arm64: vgic-its: Walk the LPI xarray in vgic_copy_lpi_list() Message-ID: References: <20240216184153.2714504-1-oliver.upton@linux.dev> <20240216184153.2714504-5-oliver.upton@linux.dev> <86frxq3w3g.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86frxq3w3g.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT On Sun, Feb 18, 2024 at 10:28:19AM +0000, Marc Zyngier wrote: > On Sun, 18 Feb 2024 08:46:53 +0000, > Zenghui Yu wrote: > > > > On 2024/2/17 2:41, Oliver Upton wrote: > > > Start iterating the LPI xarray in anticipation of removing the LPI > > > linked-list. > > > > > > Signed-off-by: Oliver Upton > > > --- > > > arch/arm64/kvm/vgic/vgic-its.c | 7 ++++++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c > > > index fb2d3c356984..9ce2edfadd11 100644 > > > --- a/arch/arm64/kvm/vgic/vgic-its.c > > > +++ b/arch/arm64/kvm/vgic/vgic-its.c > > > @@ -335,6 +335,7 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, > > > int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) > > > { > > > struct vgic_dist *dist = &kvm->arch.vgic; > > > + XA_STATE(xas, &dist->lpi_xa, GIC_LPI_OFFSET); > > > struct vgic_irq *irq; > > > unsigned long flags; > > > u32 *intids; > > > @@ -353,7 +354,9 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) > > > return -ENOMEM; > > > raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); > > > - list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { > > > + rcu_read_lock(); > > > + > > > + xas_for_each(&xas, irq, INTERRUPT_ID_BITS_ITS) { > > > > We should use '1 << INTERRUPT_ID_BITS_ITS - 1' to represent the maximum > > LPI interrupt ID. /facepalm Thanks Zenghui! > Huh, well caught! I'm not even sure how it works, as that's way > smaller than the start of the walk (8192). Probably doesn't. > > An alternative would be to use max_lpis_propbaser(), but I'm not sure > we always have a valid PROPBASER value set when we start using this > function. Worth investigating though. Given the plans to eventually replace this with xarray marks, I'd vote for doing the lazy thing and deciding this at compile time. I can squash this in when I apply the series if the rest of it isn't offensive, otherwise respin with the change. -- Thanks, Oliver diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index d84cb7618c59..f6025886071c 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -316,6 +316,8 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, return 0; } +#define GIC_LPI_MAX_INTID ((1 << INTERRUPT_ID_BITS_ITS) - 1) + /* * Create a snapshot of the current LPIs targeting @vcpu, so that we can * enumerate those LPIs without holding any lock. @@ -345,7 +347,7 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); rcu_read_lock(); - xas_for_each(&xas, irq, INTERRUPT_ID_BITS_ITS) { + xas_for_each(&xas, irq, GIC_LPI_MAX_INTID) { if (i == irq_count) break; /* We don't need to "get" the IRQ, as we hold the list lock. */