From patchwork Sun Dec 11 06:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1714554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oR425z1H; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVFrN66k0z23np for ; Sun, 11 Dec 2022 17:55:15 +1100 (AEDT) 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: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:In-Reply-To:References: List-Owner; bh=v21AUj20AA5Av7udlnn9xlSndxhKy9g0Irvcw/7mm2s=; b=oR425z1HPwaQjO /C73YWgWlj6Z18+8svgsfuCb6eJ6gTvas1oOg7ycqoP5yeNAfCXcrNb1LTshCbWe0kkCg/oX2H4ud 1zGul666hp4VEpCg0Rf3ez+Ye3Xz4ju8ErvYS0aqNm8tSsOZSv97FQyxDadRTSG+8CqSnQ3eAaok/ sSC6iU4zJjGldlfDBd/I4lH8bRvupV+Hz+bxWrxxHKZSVUpd+LOcCiVbkKwqWxRjbU5vNorr2oI8r RZHjOusX3ZozD1haqg9cUSEMpMwoBR98Kvzg5sVE9hXJ5K+7sbHqDrZUPIUV5bktBmITyiPjoKue1 MGQjAjkQATTax6GojCrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEg-00DxQs-QW; Sun, 11 Dec 2022 06:54:54 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEY-00DxFN-Ra for opensbi@lists.infradead.org; Sun, 11 Dec 2022 06:54:50 +0000 X-QQ-mid: bizesmtp88t1670741666tbd4fd08 Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 11 Dec 2022 14:54:25 +0800 (CST) X-QQ-SSF: 01200000002000B0C000B00A0000000 X-QQ-FEAT: LE7C6P2vL8RrN6CZ9RRxkxY2wQwmEGU4scE9QP4jBpECEgQc7npbAr/0o4S4r ZQ4sgO1sf7v2hMX60Rj0Odp3BbP3Q6fPR6z/Yiz5xm1p0uHtMhbqamwD/imMO3/9qCFB6ms ycwlG4E/Dy0EwF9atI1kR2XAnIjpHATAZIhYiOp/WpKeHQi23zW0XIdGPP8jbHDkL6G9D2c Wq4yv3mYbdjrgeufg94G5m61zBuVSuCeaIsUgJETHtUtgHrFwN5Ktio9SXqRyzZy9mVIHs1 60BXf0CuR+FMNe10n64Z1GC0Pvfngp50UJxUp0DL0yHtzwEBxIelrfTCGROXUQqBI7OnzBo EMfaKc2T29bvvHGItTjG5Bl+Ee5bG4iTWc+Pq+po+DPPMPk2QI= X-QQ-GoodBg: 0 From: Bin Meng To: opensbi@lists.infradead.org Cc: Anup Patel Subject: [PATCH v3 1/5] lib: utils/irqchip: plic: Fix the off-by-one error in priority save/restore helpers Date: Sun, 11 Dec 2022 14:54:20 +0800 Message-Id: <20221211065424.806478-1-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_225447_262635_35ECE259 X-CRM114-Status: UNSURE ( 7.04 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Interrupt source 0 is reserved. Hence the irq should start from 1. Fixes: 2b79b694a805 ("lib: irqchip/plic: Add priority save/restore helpers") Signed-off-by: Bin Meng Reviewed-by: Anup Patel --- Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.154.221.58 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Interrupt source 0 is reserved. Hence the irq should start from 1. Fixes: 2b79b694a805 ("lib: irqchip/plic: Add priority save/restore helpers") Signed-off-by: Bin Meng Reviewed-by: Anup Patel --- (no changes since v1) lib/utils/irqchip/plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index 73d7788..4df9020 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -38,13 +38,13 @@ static void plic_set_priority(const struct plic_data *plic, u32 source, u32 val) void plic_priority_save(const struct plic_data *plic, u8 *priority) { - for (u32 i = 0; i < plic->num_src; i++) + for (u32 i = 1; i <= plic->num_src; i++) priority[i] = plic_get_priority(plic, i); } void plic_priority_restore(const struct plic_data *plic, const u8 *priority) { - for (u32 i = 0; i < plic->num_src; i++) + for (u32 i = 1; i <= plic->num_src; i++) plic_set_priority(plic, i, priority[i]); } From patchwork Sun Dec 11 06:54:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1714556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gpSpDm4U; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVFrP0Rpwz240J for ; Sun, 11 Dec 2022 17:55:15 +1100 (AEDT) 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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tgpEA94UWLTKILyoe2gDnkP8XXC3WK8jpwyUF1Ppin4=; b=gpSpDm4UdQBr5O T288M+weA71+ejm40ReyCvqCG3jnV6vziYARogghqkhaTs7aDDVTLyhgqbEKctQamtAVxr3A6bM7X MyEOkZ8H0IPvD5crIxIK1tRnkSIu8uLOE3bDqm72s6iEytm/SBCTrHep9Kgl9ckInd6Jt2xV8M56r FGu6EgwbbmS1ochmDgrqDxEwp1enmVlayhEMjWjV0JPimIhZ0WtAUmJ5PHvMmJERQWgNk76NPnUOs sP4i/3ZT1M6uc5n8NcdfiniY5fUsO+sTN05QBcewfHZQrkzQcbhlPMihBSp3V6Mc85xMAcTTZtaeS j9Flj8hJGQ20dJwZVz3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEi-00DxRz-JI; Sun, 11 Dec 2022 06:54:56 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEY-00DxFG-Pr for opensbi@lists.infradead.org; Sun, 11 Dec 2022 06:54:52 +0000 X-QQ-mid: bizesmtp88t1670741668tm7e8ui4 Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with SMTP id 0 for ; Sun, 11 Dec 2022 14:54:27 +0800 (CST) X-QQ-SSF: 01200000002000B0B000B00A0000000 X-QQ-FEAT: lj50s4tNr7r8lvT5q6N/Im+UbsopxFm04kBcIBZ50ahaz9m8sLFa1dJpHRENX zuBRDoyCMc/8+p1vVaYvk6U1fwclVyQa3sJcnN3LZKM5gxwQhvQGP/Cej3jkqEuB5Lqh1ol Tlfth0i5nOs21dfI+dXT1wYtKQCzdDp5AwXshsb/hZSX1fv0BrMUuDfKGTslF0RzgEQFhQX /HJVJxR9pDqrvZeg5PhpeK+5O8iFWn7CClxfIfEKs20NaYf9V4YCzgudgjYITyl6JkCFCTB JlO9sNmXfj9SsKac2Y8GFo5gqOIW/HWL30OkidkgsKvqvNnGWYOeWdFpetN3FMvcK+hV32o PNN3bFMDs0/Zny+BdGJ9m2VJGIPONvwXkMzPKMk6Xz+PtxuXsA= X-QQ-GoodBg: 0 From: Bin Meng To: opensbi@lists.infradead.org Subject: [PATCH v3 2/5] lib: utils/irqchip: plic: Ensure no out-of-bound access in priority save/restore helpers Date: Sun, 11 Dec 2022 14:54:21 +0800 Message-Id: <20221211065424.806478-2-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221211065424.806478-1-bmeng@tinylab.org> References: <20221211065424.806478-1-bmeng@tinylab.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_225447_293444_2E25F28E X-CRM114-Status: GOOD ( 13.48 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently the priority save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.154.221.58 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently the priority save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Signed-off-by: Bin Meng Reviewed-by: Anup Patel --- Changes in v3: - fix the size limit check - move the size limit check to plic_priority_save/restore - add parameter description to fdt_plic_priority_save/restore Changes in v2: - new patch: libs: utils/irqchip: plic: Ensure no out-of-bound access in priority save/restore helpers include/sbi_utils/irqchip/fdt_irqchip_plic.h | 14 ++++++++++++-- include/sbi_utils/irqchip/plic.h | 5 +++-- lib/utils/irqchip/fdt_irqchip_plic.c | 8 ++++---- lib/utils/irqchip/plic.c | 15 +++++++++++---- platform/generic/allwinner/sun20i-d1.c | 4 ++-- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/sbi_utils/irqchip/fdt_irqchip_plic.h b/include/sbi_utils/irqchip/fdt_irqchip_plic.h index 98d4de5..d5b1c60 100644 --- a/include/sbi_utils/irqchip/fdt_irqchip_plic.h +++ b/include/sbi_utils/irqchip/fdt_irqchip_plic.h @@ -9,9 +9,19 @@ #include -void fdt_plic_priority_save(u8 *priority); +/** + * Save the PLIC priority state + * @param priority pointer to the memory region for the saved priority + * @param num size of the memory region including interrupt source 0 + */ +void fdt_plic_priority_save(u8 *priority, u32 num); -void fdt_plic_priority_restore(const u8 *priority); +/** + * Restore the PLIC priority state + * @param priority pointer to the memory region for the saved priority + * @param num size of the memory region including interrupt source 0 + */ +void fdt_plic_priority_restore(const u8 *priority, u32 num); void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold); diff --git a/include/sbi_utils/irqchip/plic.h b/include/sbi_utils/irqchip/plic.h index 48c24f0..38704a1 100644 --- a/include/sbi_utils/irqchip/plic.h +++ b/include/sbi_utils/irqchip/plic.h @@ -18,9 +18,10 @@ struct plic_data { }; /* So far, priorities on all consumers of these functions fit in 8 bits. */ -void plic_priority_save(const struct plic_data *plic, u8 *priority); +void plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num); -void plic_priority_restore(const struct plic_data *plic, const u8 *priority); +void plic_priority_restore(const struct plic_data *plic, const u8 *priority, + u32 num); void plic_context_save(const struct plic_data *plic, int context_id, u32 *enable, u32 *threshold); diff --git a/lib/utils/irqchip/fdt_irqchip_plic.c b/lib/utils/irqchip/fdt_irqchip_plic.c index fe08836..7d76c5b 100644 --- a/lib/utils/irqchip/fdt_irqchip_plic.c +++ b/lib/utils/irqchip/fdt_irqchip_plic.c @@ -24,18 +24,18 @@ static struct plic_data plic[PLIC_MAX_NR]; static struct plic_data *plic_hartid2data[SBI_HARTMASK_MAX_BITS]; static int plic_hartid2context[SBI_HARTMASK_MAX_BITS][2]; -void fdt_plic_priority_save(u8 *priority) +void fdt_plic_priority_save(u8 *priority, u32 num) { struct plic_data *plic = plic_hartid2data[current_hartid()]; - plic_priority_save(plic, priority); + plic_priority_save(plic, priority, num); } -void fdt_plic_priority_restore(const u8 *priority) +void fdt_plic_priority_restore(const u8 *priority, u32 num) { struct plic_data *plic = plic_hartid2data[current_hartid()]; - plic_priority_restore(plic, priority); + plic_priority_restore(plic, priority, num); } void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index 4df9020..dca5678 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -36,15 +36,22 @@ static void plic_set_priority(const struct plic_data *plic, u32 source, u32 val) writel(val, plic_priority); } -void plic_priority_save(const struct plic_data *plic, u8 *priority) +void plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num) { - for (u32 i = 1; i <= plic->num_src; i++) + if (num > plic->num_src) + num = plic->num_src; + + for (u32 i = 1; i <= num; i++) priority[i] = plic_get_priority(plic, i); } -void plic_priority_restore(const struct plic_data *plic, const u8 *priority) +void plic_priority_restore(const struct plic_data *plic, const u8 *priority, + u32 num) { - for (u32 i = 1; i <= plic->num_src; i++) + if (num > plic->num_src) + num = plic->num_src; + + for (u32 i = 1; i <= num; i++) plic_set_priority(plic, i, priority[i]); } diff --git a/platform/generic/allwinner/sun20i-d1.c b/platform/generic/allwinner/sun20i-d1.c index 18d330d..1f27575 100644 --- a/platform/generic/allwinner/sun20i-d1.c +++ b/platform/generic/allwinner/sun20i-d1.c @@ -79,13 +79,13 @@ static u32 plic_threshold; static void sun20i_d1_plic_save(void) { fdt_plic_context_save(true, plic_sie, &plic_threshold); - fdt_plic_priority_save(plic_priority); + fdt_plic_priority_save(plic_priority, PLIC_SOURCES); } static void sun20i_d1_plic_restore(void) { thead_plic_restore(); - fdt_plic_priority_restore(plic_priority); + fdt_plic_priority_restore(plic_priority, PLIC_SOURCES); fdt_plic_context_restore(true, plic_sie, plic_threshold); } From patchwork Sun Dec 11 06:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1714555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=S7tEW6yM; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVFrN6RpQz240G for ; Sun, 11 Dec 2022 17:55:15 +1100 (AEDT) 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=zI+BZGOP7XgyRmmxKBV8JsfunJvzS+Rd1OfF8xEx5RE=; b=S7tEW6yMMfc04y hMXr2qlDjFVG/tVSqxaejMm1eWkNmZmQUAgZpayZx055m+hnKsmx4ZlrB2RSjqm2HEBR0ujwmT+hz 2IlsYQfXRxnXMbO5XVFBewxjrGJH6EXyMpDlyqNQaP/rkTfR6oPmqaosEUY5njNYv8Q/Nhdb2FlA3 ahr20CPA+//VDkfpDnA/sbrwRy8Z/OCcM2zzBAYmsv4bG5jT57agSDr4m75O7QyhsXwOszTca06jR tn/eNpl02FeQCyBinKPU37M+X4foAAeK0SrznO/XePP21WSu8K1ik+ybkdhzJpQ0sgWpfiimWetR7 HwmiLoIgK3/753V6X19Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEf-00DxQC-LY; Sun, 11 Dec 2022 06:54:53 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEY-00DxGw-SO for opensbi@lists.infradead.org; Sun, 11 Dec 2022 06:54:50 +0000 X-QQ-mid: bizesmtp88t1670741670tyolm8i3 Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 11 Dec 2022 14:54:30 +0800 (CST) X-QQ-SSF: 01200000002000B0B000B00A0000000 X-QQ-FEAT: znfcQSa1hKYVMjxw6lcUgPQYAmGybdpIsQrVVWvlBG8yLbx0TbajnupitjkQz 7ONazP0OlDMOsHntQVw3mWSMoTtuj5aElx0SmIf/xAizIbdsmjaL/crhdZ1/wwBE6xkX88N OVTZDeHcoZUSy04WxqpZvCVeCHxGWjssB+NdsZkFZV1AO+CcybEvo/cK8P3asF0Xuq79KPF h82ANUIOS7TczAigYwjwEXmD+jED81ILb8ns5Cor/dD5MhDuJVgmQgx+A1eKc8jaM4IvvA1 TxeRke4xU3FEKJjFpQ6xVG3aznKin3QJXGJyH3MQwzfwZO0ZfZEVIhQBI12hx+82tLJ5aHu lEPXZ/jYB3AoTMCQL9zUF0tzR0Mzmlovk3RTB1enckhK+7kiPg= X-QQ-GoodBg: 0 From: Bin Meng To: opensbi@lists.infradead.org Cc: Anup Patel Subject: [PATCH v3 3/5] lib: utils/irqchip: plic: Fix the off-by-one error in plic_context_init() Date: Sun, 11 Dec 2022 14:54:22 +0800 Message-Id: <20221211065424.806478-3-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221211065424.806478-1-bmeng@tinylab.org> References: <20221211065424.806478-1-bmeng@tinylab.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_225447_302196_34345D3D X-CRM114-Status: UNSURE ( 8.07 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The number of interrupt enable register in words was once correct, but was wrongly changed to have an off-by-one error since commit 8c362e7d065e ("lib: irqchip/plic: Factor out a context init function [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.155.65.254 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The number of interrupt enable register in words was once correct, but was wrongly changed to have an off-by-one error since commit 8c362e7d065e ("lib: irqchip/plic: Factor out a context init function"). Fixes: 8c362e7d065e ("lib: irqchip/plic: Factor out a context init function") Signed-off-by: Bin Meng Reviewed-by: Anup Patel Reviewed-by: Samuel Holland --- (no changes since v2) Changes in v2: - new patch: lib: utils/irqchip: plic: Fix the off-by-one error in plic_context_init() lib/utils/irqchip/plic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index dca5678..568f814 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -127,7 +127,7 @@ int plic_context_init(const struct plic_data *plic, int context_id, if (!plic || context_id < 0) return SBI_EINVAL; - ie_words = (plic->num_src + 31) / 32; + ie_words = plic->num_src / 32 + 1; ie_value = enable ? 0xffffffffU : 0U; for (u32 i = 0; i < ie_words; i++) From patchwork Sun Dec 11 06:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1714553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nqtVlr/I; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVFrN6VDbz240H for ; Sun, 11 Dec 2022 17:55:16 +1100 (AEDT) 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=jcaG3QIE6Pxm5fHRIssSLs9vhG+NSMAvFhf8a+c6NFY=; b=nqtVlr/IFEtOgI Pu24f4HSYRIWaH+Yrk3dp7yQEfIP8lGTM8hJP8imkah601kRGIDi9/gBMStbf3yrwuSrx+vJ1l/Ii wtIMhWkHFWB3I1v3LMI1bnbaPtMMjF8sT4EDNN5hGrrgeCOOAYBqRESerOvmof5yhk3MRbczYr32T d8liYvb0iO/la1h8flWsq6uhhEd3HpEbLZsZq9ewRGQGg94W4A7de/4F9vHNwnVD5W4TDhSH4t8UV VeIceFU4fXfa2aUq7Zf27tQSFbsGMCKTkVuV/TlhACu3Yr5hKm3VpvR14xAe6CZmgGRvcBFFPdlhS CFPcN+D8/us4YE+ROfDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEm-00DxVG-4S; Sun, 11 Dec 2022 06:55:00 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEY-00DxIA-SG for opensbi@lists.infradead.org; Sun, 11 Dec 2022 06:54:52 +0000 X-QQ-mid: bizesmtp88t1670741672tg9ssvb5 Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 11 Dec 2022 14:54:32 +0800 (CST) X-QQ-SSF: 01200000002000B0B000B00A0000000 X-QQ-FEAT: aNSJSRc3qiAHuYxkkLIBggSr2BkRrGGAVqfbqj/WkgQ4q+xvxfCOunjOsGhCm 7Q3+ePp/kBbtaFMeH5yiDn1Xb5cofdSQqgY7kpAfj6EaVoE4Nw0gdHR3GHYA77zmet5IoIH HieAjLobhyRSEFe8O/BjLRmxAKNHX1NxIozryCxMGPeqrrYDAX7tf99JTXdjwMsgNj3PRli hwW2dbWanWJeUeWax1k9DDt+kNUND98CDqqw0W4aAACow743GKhfy2WIVgc5hNl98sY+rHV sgm36EZZkeSkAIGlQEFbnq42PO3pbmyle5wuSXBrLWPHOivuEpKpj3T8yuy7C04slQc8q4K daxCnqxw352wHb/Bu+a4eLTNkQwk4x3iuZmHF5vQImjyndXn50= X-QQ-GoodBg: 0 From: Bin Meng To: opensbi@lists.infradead.org Cc: Anup Patel Subject: [PATCH v3 4/5] lib: utils/irqchip: plic: Fix the off-by-one error in context save/restore helpers Date: Sun, 11 Dec 2022 14:54:23 +0800 Message-Id: <20221211065424.806478-4-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221211065424.806478-1-bmeng@tinylab.org> References: <20221211065424.806478-1-bmeng@tinylab.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_225447_344062_AA83C363 X-CRM114-Status: UNSURE ( 8.92 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: plic->num_src holds the number of interrupt sources without interrupt source 0 but the interrupt enable register includes a bit for the interrupt source 0 in the first word. Fixes: 415ecf28f7ad ("lib: irqchip/plic: Add context save/restore helpers") Signed-off-by: Bin Meng Reviewed-by: Anup Patel Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.154.221.58 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org plic->num_src holds the number of interrupt sources without interrupt source 0 but the interrupt enable register includes a bit for the interrupt source 0 in the first word. Fixes: 415ecf28f7ad ("lib: irqchip/plic: Add context save/restore helpers") Signed-off-by: Bin Meng Reviewed-by: Anup Patel Reviewed-by: Samuel Holland --- (no changes since v2) Changes in v2: - new patch: lib: utils/irqchip: plic: Fix the off-by-one error in context save/restore helpers lib/utils/irqchip/plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index 568f814..b152bb7 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -100,7 +100,7 @@ static void plic_set_ie(const struct plic_data *plic, u32 cntxid, void plic_context_save(const struct plic_data *plic, int context_id, u32 *enable, u32 *threshold) { - u32 ie_words = (plic->num_src + 31) / 32; + u32 ie_words = plic->num_src / 32 + 1; for (u32 i = 0; i < ie_words; i++) enable[i] = plic_get_ie(plic, context_id, i); @@ -111,7 +111,7 @@ void plic_context_save(const struct plic_data *plic, int context_id, void plic_context_restore(const struct plic_data *plic, int context_id, const u32 *enable, u32 threshold) { - u32 ie_words = (plic->num_src + 31) / 32; + u32 ie_words = plic->num_src / 32 + 1; for (u32 i = 0; i < ie_words; i++) plic_set_ie(plic, context_id, i, enable[i]); From patchwork Sun Dec 11 06:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1714557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kjWNlFMi; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVFrP2mjHz240K for ; Sun, 11 Dec 2022 17:55:15 +1100 (AEDT) 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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DW1n0vdL36DVTDStJCEvJNI6Uu1r1zogtYb53z+ChrA=; b=kjWNlFMiihiRZu Gz/PLp+pV1Qz7AlnfFdkGp3nNatU8ejjRk9+VnNL/os001quWqxWvDWMcu29hHbRATkY0QrMcnzWT dozNhx/De+Jvv5KxENmCF+rov1PkqYHTAcPrHNchidGE4dwjLHMwL3COVL75ZMjY4rQvhVkiIjCX5 a3ZwFNKCCCFsPGZYYR86Fzx5cO/XY7QvHL40D9zQeHtgP3gpoXBbFIM2tNL5dVVG6pBKlMXrFaa7R rS27SP7HKbxZpgqq0+BoBqAAF6OAQkut5tYVOBispZhn5+WeTECUZJN1Wfuy2Qwm+WmrHl2gc2y9D YAPNbaMXN7rNk0hDNhdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEl-00DxUH-07; Sun, 11 Dec 2022 06:54:59 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4GEY-00DxIS-Qu for opensbi@lists.infradead.org; Sun, 11 Dec 2022 06:54:52 +0000 X-QQ-mid: bizesmtp88t1670741675tkq3zoka Received: from ubuntu.. ( [111.196.135.79]) by bizesmtp.qq.com (ESMTP) with SMTP id 0 for ; Sun, 11 Dec 2022 14:54:34 +0800 (CST) X-QQ-SSF: 01200000002000B0B000B00A0000000 X-QQ-FEAT: FCwU1VixZy/gBKGyc6uIwkn8oXlHXYDSKXZ7aws9s3GTP4lVn/2Ijn6aDjXD8 /G3h6QdRIV+kWn28c7sOg4cEwWCs+G802Rn57KTF+ZGkB8c86g2I9VoG2xDGlkBKSNcr9V7 UkwbSFfpG7Mm6keRLTBcPXnSogyYixJh3/94TRfdbRjKThaZLeq/OLheNGp0q6Jw3SOneFj llrJPNjC2zZz0/0g4ddc5MJf740T2THvEoBPemEMVcGUGdOr+MriokgWFIjVCjQyVTT3qlh Y3p4Jxgo5FRp+Uxsc6BLVCdTZFdd6qJK09beMKjW7B9kTf+yo+as7YeWBq3UZbQrJM1uiib UjGBdJ24W4vgKMlETUTBtFv3C9+RrSGAakbDUv9Rf9hniZ+SaU= X-QQ-GoodBg: 0 From: Bin Meng To: opensbi@lists.infradead.org Subject: [PATCH v3 5/5] lib: utils/irqchip: plic: Ensure no out-of-bound access in context save/restore helpers Date: Sun, 11 Dec 2022 14:54:24 +0800 Message-Id: <20221211065424.806478-5-bmeng@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221211065424.806478-1-bmeng@tinylab.org> References: <20221211065424.806478-1-bmeng@tinylab.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvr:qybglogicsvr3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_225447_322029_84B8F0BB X-CRM114-Status: GOOD ( 10.06 ) X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently the context save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.155.65.254 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently the context save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Signed-off-by: Bin Meng Reviewed-by: Anup Patel --- Changes in v3: - move the size limit check to plic_context_save/restore Changes in v2: - new patch: lib: utils/irqchip: plic: Ensure no out-of-bound access in context save/restore helpers include/sbi_utils/irqchip/fdt_irqchip_plic.h | 5 +++-- include/sbi_utils/irqchip/plic.h | 4 ++-- lib/utils/irqchip/fdt_irqchip_plic.c | 9 +++++---- lib/utils/irqchip/plic.c | 14 ++++++++++---- platform/generic/allwinner/sun20i-d1.c | 5 +++-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/include/sbi_utils/irqchip/fdt_irqchip_plic.h b/include/sbi_utils/irqchip/fdt_irqchip_plic.h index d5b1c60..df645dd 100644 --- a/include/sbi_utils/irqchip/fdt_irqchip_plic.h +++ b/include/sbi_utils/irqchip/fdt_irqchip_plic.h @@ -23,9 +23,10 @@ void fdt_plic_priority_save(u8 *priority, u32 num); */ void fdt_plic_priority_restore(const u8 *priority, u32 num); -void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold); +void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold, u32 num); -void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold); +void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold, + u32 num); void thead_plic_restore(void); diff --git a/include/sbi_utils/irqchip/plic.h b/include/sbi_utils/irqchip/plic.h index 38704a1..112a714 100644 --- a/include/sbi_utils/irqchip/plic.h +++ b/include/sbi_utils/irqchip/plic.h @@ -24,10 +24,10 @@ void plic_priority_restore(const struct plic_data *plic, const u8 *priority, u32 num); void plic_context_save(const struct plic_data *plic, int context_id, - u32 *enable, u32 *threshold); + u32 *enable, u32 *threshold, u32 num); void plic_context_restore(const struct plic_data *plic, int context_id, - const u32 *enable, u32 threshold); + const u32 *enable, u32 threshold, u32 num); int plic_context_init(const struct plic_data *plic, int context_id, bool enable, u32 threshold); diff --git a/lib/utils/irqchip/fdt_irqchip_plic.c b/lib/utils/irqchip/fdt_irqchip_plic.c index 7d76c5b..c54f45c 100644 --- a/lib/utils/irqchip/fdt_irqchip_plic.c +++ b/lib/utils/irqchip/fdt_irqchip_plic.c @@ -38,22 +38,23 @@ void fdt_plic_priority_restore(const u8 *priority, u32 num) plic_priority_restore(plic, priority, num); } -void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold) +void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold, u32 num) { u32 hartid = current_hartid(); plic_context_save(plic_hartid2data[hartid], plic_hartid2context[hartid][smode], - enable, threshold); + enable, threshold, num); } -void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold) +void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold, + u32 num) { u32 hartid = current_hartid(); plic_context_restore(plic_hartid2data[hartid], plic_hartid2context[hartid][smode], - enable, threshold); + enable, threshold, num); } static int irqchip_plic_warm_init(void) diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index b152bb7..8089a0b 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -98,22 +98,28 @@ static void plic_set_ie(const struct plic_data *plic, u32 cntxid, } void plic_context_save(const struct plic_data *plic, int context_id, - u32 *enable, u32 *threshold) + u32 *enable, u32 *threshold, u32 num) { u32 ie_words = plic->num_src / 32 + 1; - for (u32 i = 0; i < ie_words; i++) + if (num > ie_words) + num = ie_words; + + for (u32 i = 0; i < num; i++) enable[i] = plic_get_ie(plic, context_id, i); *threshold = plic_get_thresh(plic, context_id); } void plic_context_restore(const struct plic_data *plic, int context_id, - const u32 *enable, u32 threshold) + const u32 *enable, u32 threshold, u32 num) { u32 ie_words = plic->num_src / 32 + 1; - for (u32 i = 0; i < ie_words; i++) + if (num > ie_words) + num = ie_words; + + for (u32 i = 0; i < num; i++) plic_set_ie(plic, context_id, i, enable[i]); plic_set_thresh(plic, context_id, threshold); diff --git a/platform/generic/allwinner/sun20i-d1.c b/platform/generic/allwinner/sun20i-d1.c index 1f27575..1da9e5b 100644 --- a/platform/generic/allwinner/sun20i-d1.c +++ b/platform/generic/allwinner/sun20i-d1.c @@ -78,7 +78,7 @@ static u32 plic_threshold; static void sun20i_d1_plic_save(void) { - fdt_plic_context_save(true, plic_sie, &plic_threshold); + fdt_plic_context_save(true, plic_sie, &plic_threshold, PLIC_IE_WORDS); fdt_plic_priority_save(plic_priority, PLIC_SOURCES); } @@ -86,7 +86,8 @@ static void sun20i_d1_plic_restore(void) { thead_plic_restore(); fdt_plic_priority_restore(plic_priority, PLIC_SOURCES); - fdt_plic_context_restore(true, plic_sie, plic_threshold); + fdt_plic_context_restore(true, plic_sie, plic_threshold, + PLIC_IE_WORDS); } /*