From nobody Sun Feb 8 13:45:15 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 CE3352FE595 for ; Tue, 23 Dec 2025 14:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766500594; cv=none; b=X52bH6+iesWPvgAiOApSE5AKRX+qKuu9B6xo3tGtTh8fEkuwVcQ1ASu/EH8zJebmnK9d21h1vgVm6w2dnLxpUuOIhsRwFGqhtw+n6BRUt1ucl7ziZ4RsZmUYZbHLJR1ka+qFSUZKDPLLBSM2SKxzR4vE0CFHcKL+ltSaJAZddx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766500594; c=relaxed/simple; bh=K/IE/Ug2OjHeTtwcx0bKNSKz7TLZt6ej1bZqYEY11So=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UBMIwIJAikhxcsmwU/34/zf3o48HQTkyKcF0DuGaGpoDUQTVeR/Uh4UMTF5StSTBLXAKvCDk93puBQNtZNbWMtLVyA5+m5l2QntvQAAk0nNa7da7GvFVL7ZOE+YI6RHl9WBfClpgSrZT/+obwk/dM+4sIwz4YT8Q0/EdKnQH+qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=fVWIMTcC; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="fVWIMTcC" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BN78U6T4044542; Tue, 23 Dec 2025 14:35:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=CsSg3raa755P7fEcUVN611Vs8+I2n7jTezy 9VwgkJA8=; b=fVWIMTcCbYsE969JUBB5OyUUBzwfwhPKt4SFgfZoCHJZPFZ9y3H DxyOC6b1FoWe2FLdOKvGBKzxpy73HTybQLeyz44BVPeDx/5Dh4nFBQAqV0WmFQDc 8k3oTJ6EREh0x04ox9OX/CeEJ+aKGFmojRnex9inXaAdv6Sx9zLfrOdiZjb5xm3j smeN8G+itS7RW90RN5ArotUZcT1R0tkKDurLndoNr8I2mguTPQ2q5KMrLata4SIT DybrEYkwW0dXfD6R7KJKQfUrSf5qF/9wLon7TVZjAcBSI3GKaAcb1KQc6xFn4Bh5 b8caUWN2/dA4r6+bqAIdgqYFIZAngUfspOw== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4b7cuhaxct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Dec 2025 14:35:49 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 5BNEZkhi009619; Tue, 23 Dec 2025 14:35:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 4b5mvm95g5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Dec 2025 14:35:46 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5BNEZkrh009611; Tue, 23 Dec 2025 14:35:46 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 5BNEZkph009609 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Dec 2025 14:35:46 +0000 Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id 3143F21A30; Tue, 23 Dec 2025 20:05:45 +0530 (+0530) From: Anup Patel To: Thomas Gleixner , Palmer Dabbelt , Paul Walmsley Cc: Alexandre Ghiti , Sunil V L , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv" Date: Tue, 23 Dec 2025 20:05:44 +0530 Message-ID: <20251223143544.1504217-1-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 9iaSLzjfDeb7f_OHe9U_zVa0CjGOGmEw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjIzMDEyMCBTYWx0ZWRfXwybHLAjqO3ld hP9i2fNduP5HUOGMmogbIThUiZf8APudf3k87/nfL24q8DUCMHYB8ewAcfSbE02RAgpZWokSsoN 3yOasC/nevVUSAY1V4LVpXoJjuLwh9jS9QXoBJftM8mSreHQ+yIh9iXKIMlpyOdd81frJre0lfG 1QatefbEaN8+9YmR3Sit00Xc67jiSQ1UOBEfkoCGIkjV2L+C46DnxGRitRgui9KEA5iNDniDaIq 89KFJGyjAM0N7E1yqllNFZhhxXKPAzOM/PMvfN8rd6RiGJ41fnaNIBHmp0fLmrdMWmwmgXbWKeS jxvaXCfDYG5vaHhCnTiTzAAy/dHIvcfsONvresAUfXuKGAOg4gfFDu0RRGBl5qA/YA8X3gI9JaC mTiscJ1rQqCdhhB9NYS30YvFcKiNKKdINc5AtsQiI8pzIEbE4dYQLzHEsuo3b1J2tztFo9PISlm kaM9G+kYQpcGou1YJ+A== X-Proofpoint-GUID: 9iaSLzjfDeb7f_OHe9U_zVa0CjGOGmEw X-Authority-Analysis: v=2.4 cv=NZDrFmD4 c=1 sm=1 tr=0 ts=694aa8c5 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=ZCMddYN6k4-7DcXjQ1QA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-23_03,2025-12-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 clxscore=1011 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512230120 Content-Type: text/plain; charset="utf-8" The __alloc_percpu() fails when the number of IDs are greater than 959 because size parameter of __alloc_percpu() must be less than 32768 (aka PCPU_MIN_UNIT_SIZE). This failure is observed with KVMTOOL when AIA is trap-n-emulated by in-kernel KVM because in this case KVM guest has 2047 interrupt IDs. To address this issue, don't embed vector array in struct imsic_local_priv until __alloc_percpu() support size parameter greater than 32768. This reverts commit 79eaabc61dfb ("irqchip/riscv-imsic: Embed the vector array in lpriv"). Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-state.c | 10 ++++++++-- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-= riscv-imsic-state.c index 385368052d5c..b6cebfee9461 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -477,6 +477,7 @@ static void __init imsic_local_cleanup(void) lpriv =3D per_cpu_ptr(imsic->lpriv, cpu); =20 bitmap_free(lpriv->dirty_bitmap); + kfree(lpriv->vectors); } =20 free_percpu(imsic->lpriv); @@ -490,8 +491,7 @@ static int __init imsic_local_init(void) int cpu, i; =20 /* Allocate per-CPU private state */ - imsic->lpriv =3D __alloc_percpu(struct_size(imsic->lpriv, vectors, global= ->nr_ids + 1), - __alignof__(*imsic->lpriv)); + imsic->lpriv =3D alloc_percpu(typeof(*imsic->lpriv)); if (!imsic->lpriv) return -ENOMEM; =20 @@ -511,6 +511,12 @@ static int __init imsic_local_init(void) timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED); #endif =20 + /* Allocate vector array */ + lpriv->vectors =3D kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors), + GFP_KERNEL); + if (!lpriv->vectors) + goto fail_local_cleanup; + /* Setup vector array */ for (i =3D 0; i <=3D global->nr_ids; i++) { vec =3D &lpriv->vectors[i]; diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-= riscv-imsic-state.h index 6332501dcbd8..c42ee180b305 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -40,7 +40,7 @@ struct imsic_local_priv { #endif =20 /* Local vector table */ - struct imsic_vector vectors[]; + struct imsic_vector *vectors; }; =20 struct imsic_priv { --=20 2.43.0