Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2168588rdb; Tue, 20 Feb 2024 21:44:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjg1iiWnZsOR+/vVsXxnAsh4vQjKyCBMEzaExzPaOo/hsRLmOaOUxiBy4Yqqck6DMbU45K4KXSQn2xgO6bBkXhmIaFvS5qIiDiWe8ryA== X-Google-Smtp-Source: AGHT+IFGPZzCOMzrxkdQUqU7VLJFPpLZqUnoFpWtOt6+ZotFuJzNp7RTMyk7gJKDAjW+Zt1d917d X-Received: by 2002:a05:620a:17a1:b0:787:8ae4:7a9c with SMTP id ay33-20020a05620a17a100b007878ae47a9cmr592697qkb.30.1708494297912; Tue, 20 Feb 2024 21:44:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708494297; cv=pass; d=google.com; s=arc-20160816; b=uCTD0C5WyRQ8ZEPMAcqA5N+zCRU8LvaXZECRtu63KcqXaoqI1m9nzkKBKcHUGUlPZ4 PiBw6B+0FMN4cqDSbWol7xB+AVKyn0SM4AcnxTkYH15Q6c2rzJCjVW+V8yASIsW55TL5 EO3NR+hplP6GxgYTcWFY9GKDU81j2+zEZXGnnmPbC+Nylek8IlCrnB2sT/qr1Vp26Q0y S6RFg2Idb4gWXldLdJSM5owuET4B7uiiZCQtVCgo8rQtCH2etIQ2YFkchalRmSrn2Ha2 vuoGSADm9JD81iJnUGFSQaC9KLV6YYeMe0VpbLr6R5QfKeDHuGN3nlNi5Z/OSuEriyN/ kQ3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hwGBWvx+wwsJa7xNRdwDH7MJ0Q05E6x3UjwcqNXt4/0=; fh=kCIhDCwfhVa+1moYcBlLNuY7yX/BfELZCoRk1wSf3jY=; b=ZBxy7qiAvq2iNnDVqntunSD7OktYJLoy0ukPtzSwqFn1cUGtLTCkv4jhow3LOO/gat 6U0NhvSiAMSjyzhdnD8q6l/LaIumnmR5gl+dUYQadW8snRjzgl6tO1elg6/fSMskvm3L tLnVvxKcedEUXs34L0mPrKCbMmaT8tQoZplcKNNZRu/oAeoZapqeq8+DgmI0GjSTmW7Z uxISeTJWMnwSl51b35q8k5xrNOmTHb3lFhFFyffLOcVR6kMR66a+88z0vaHkbM/qhSzl 43P6JyycED/cIuj6IJBHtHpsf5XJIM7HVzaWJHEyDowJwsi3PYtR9ELlm+mlxfyIFkSy OOhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MGYDRQmp; 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-74102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v36-20020a05622a18a400b0042dd9493110si11136845qtc.347.2024.02.20.21.44.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 21:44:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MGYDRQmp; 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-74102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74102-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A83AD1C23363 for ; Wed, 21 Feb 2024 05:44:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 879703BB53; Wed, 21 Feb 2024 05:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MGYDRQmp" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (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 17CCA39FC9 for ; Wed, 21 Feb 2024 05:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708494209; cv=none; b=CE3pPC6e7oWRuydgyYrWxt8u0OreFbrDqazgkhcoF18dVTzRwy4UbR/96/Ukqtgr+DzkqeBZ6zVASoqUaLdI635jQFVV9/spFWD5P/bIV1l0gxav7sR1Rxkai/7twZyOFPx2G1m/sOKnCTtDFVjH+2ofXP6YgVKF+E7Vn/YEL/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708494209; c=relaxed/simple; bh=egvxRC64pImQWpYJ5H/66l//0W0vYIRaEzxh49R2ggA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JDXUzHkJbLySEteSPqxuw1cm8XrLhGPDirgTvZrUpUaeWGoZgtaoAAngyUFttoKvE/lcuo9AEK7x8q7l6QIwpc2bfOTun7NJsuJx+KXzkBJvmnv/huXgxt061/Pf6t4Oq5d8ncwhcu2niZ5Js+uZOpgbs50CNFmRhAlQ5khQJpo= 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=MGYDRQmp; arc=none smtp.client-ip=91.218.175.176 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 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708494206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hwGBWvx+wwsJa7xNRdwDH7MJ0Q05E6x3UjwcqNXt4/0=; b=MGYDRQmpErICmMJRKOaSwPhNZwcGWG9i3eBvE7S9eAoTsD13nFyL/UaN2lmj6158Yql47k AE2cr3rXzXv4faz9wb7vFc2SwzJUyIy/dLvzFP+PJ69TdIyorSkUwcQq8Iej9FIRHfuPhI PvHsPUfiiZp1eoJHZjh3RHF+HbDCms4= From: Oliver Upton To: kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org, Eric Auger , Oliver Upton Subject: [PATCH v4 04/10] KVM: arm64: vgic-its: Walk the LPI xarray in vgic_copy_lpi_list() Date: Wed, 21 Feb 2024 05:42:47 +0000 Message-ID: <20240221054253.3848076-5-oliver.upton@linux.dev> In-Reply-To: <20240221054253.3848076-1-oliver.upton@linux.dev> References: <20240221054253.3848076-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index fb2d3c356984..b9874dc04608 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -327,6 +327,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. @@ -335,6 +337,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 +356,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, GIC_LPI_MAX_INTID) { if (i == irq_count) break; /* We don't need to "get" the IRQ, as we hold the list lock. */ @@ -361,6 +366,8 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) continue; intids[i++] = irq->intid; } + + rcu_read_unlock(); raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags); *intid_ptr = intids; -- 2.44.0.rc0.258.g7320e95886-goog