From nobody Tue Nov 18 10:40:12 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1610414859; cv=none; d=zohomail.com; s=zohoarc; b=Ps7o+H1tKyOP+NfKpIzpj8w8NRlJX4i/o5wreTqKHnT0kvGtOn3FKQvBOmX79ukEsWOuXk8vpRBezv0wlK9IlCOyGg3bd1CA9nZzeuEHIZG/NJxm7dFTre2SFPVBABAO1MiOQT+S+jTiTiJG3dmjPVbO6LrYsSXhUTkWuL0c6t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610414859; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=b/0LcBWxGeivY5XSxd1tWLYCCRozE7CkKoA2Pg1+4b8=; b=ZVMZYmGskznK24gLnpr65WaTJbyZrKW7aA9Q6Hy9LqzCyywVPO4WKh6Vtmdf+2wwsCBsF4Gc+GbO/c8UBcOQoorT9ZQ5SiiXYmxjvrhqzp4R5PZ3iYfRs6/aLVc0I8VCx2pOh6qhg0dTUWOtQJn0/KOQo5TBrJwq0sAtkjgvHcc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610414859388779.9255151606868; Mon, 11 Jan 2021 17:27:39 -0800 (PST) Received: from localhost ([::1]:38742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz8TC-0007Ql-43 for importer@patchew.org; Mon, 11 Jan 2021 20:27:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz8RS-0006Lb-K1 for qemu-devel@nongnu.org; Mon, 11 Jan 2021 20:25:50 -0500 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:46755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz8RP-0004Zv-71 for qemu-devel@nongnu.org; Mon, 11 Jan 2021 20:25:48 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 86721580626; Mon, 11 Jan 2021 20:25:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 11 Jan 2021 20:25:46 -0500 Received: from strike.U-LINK.com (unknown [116.228.84.2]) by mail.messagingengine.com (Postfix) with ESMTPA id ECB4E24005B; Mon, 11 Jan 2021 20:25:43 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=b/0LcBWxGeivY5XSxd1tWLYCCR ozE7CkKoA2Pg1+4b8=; b=J60Vwy6AFexgkPi7WVHzDSekXGryJB8+/FxNPHFLjn NUDDICGVisoGDjIjS4MOJMs40Zej8UJdIvy8r+JNGKM8PNUR9Q7X7YaMWjfx+itn gcAUWmlETPKrtX5YNzaL2N0xWKwrNaj+hsbVria+B6vkqywMGFQOm2MkGxlhK9Rq LQLnGzUzvgZmZPnykR3EaMr3Ysc7T0rJG1uisVGnsnjE+5d/IrhlmaLTh+ZeD2w5 uhRXAzggUpOOzYI59aeAVPWLJvFT/I73xSuzan7DDFXKgPb5GcLeHiJfJFYeIvV2 5apl0amMReEcjqtc3wtlprpS8ST40T4kv5Kbia4bj/mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=b/0LcBWxGeivY5XSx d1tWLYCCRozE7CkKoA2Pg1+4b8=; b=JVnpxgvFCPlYbD5hHanZqV52wD57SsjZo 8FvkMRM0dABQZBL6wV3hRSi+mb74vOTzjO6EvZ8QOkiCEkcVv52YsdA1yCv9uaIl XsNDyNsHcG4hBSTX6+dFqhMYniVcMKl55PszFlBRhTgxPbQkpRpZXWpWAOcryJMe DEtsyxa6+MtKlbQBsw7NatXOgJidPjuHjJiPhGOJKsaD2Xy9VuNSt/qwyJKGbtLY Ormm80aOwGDEZRqVDo6Iv0PhtU5//TzeXzKN4G2S/hRx3qWvGA9bm5ykTZyr3vJq NYnNKu0Rn2mftnJjW1HTgVp2SWS6SHeZGqrY3cOyNAsTEMC5QrIwA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehvddgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeflihgrgihunhcu jggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqnecuggftrf grthhtvghrnhephfejtdektdeuhedtieefteekveffteejteefgeekveegffetvddugfel iefhtddunecukfhppeduudeirddvvdekrdekgedrvdenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghho rghtrdgtohhm X-ME-Proxy: From: Jiaxun Yang To: qemu-devel@nongnu.org Subject: [PATCH] hw/intc/loongson_liointc: Fix per core ISR handling Date: Tue, 12 Jan 2021 09:25:27 +0800 Message-Id: <20210112012527.28927-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: permerror client-ip=66.111.4.230; envelope-from=jiaxun.yang@flygoat.com; helo=new4-smtp.messagingengine.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Per core ISR is a set of 32-bit registers spaced by 8 bytes. This patch fixed calculation of it's size and also added check of alignment at reading & writing. Signed-off-by: Jiaxun Yang Reviewed-by: Huacai Chen --- hw/intc/loongson_liointc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/intc/loongson_liointc.c b/hw/intc/loongson_liointc.c index f823d484e0..cc11b544cb 100644 --- a/hw/intc/loongson_liointc.c +++ b/hw/intc/loongson_liointc.c @@ -41,7 +41,7 @@ #define R_IEN_CLR 0x2c #define R_ISR_SIZE 0x8 #define R_START 0x40 -#define R_END 0x64 +#define R_END (R_START + R_ISR_SIZE * NUM_CORES) =20 struct loongson_liointc { SysBusDevice parent_obj; @@ -125,7 +125,12 @@ liointc_read(void *opaque, hwaddr addr, unsigned int s= ize) } =20 if (addr >=3D R_START && addr < R_END) { - int core =3D (addr - R_START) / R_ISR_SIZE; + hwaddr offset =3D addr - R_START; + int core =3D offset / R_ISR_SIZE; + + if (offset % R_ISR_SIZE) { + goto out; + } r =3D p->per_core_isr[core]; goto out; } @@ -169,7 +174,12 @@ liointc_write(void *opaque, hwaddr addr, } =20 if (addr >=3D R_START && addr < R_END) { - int core =3D (addr - R_START) / R_ISR_SIZE; + hwaddr offset =3D addr - R_START; + int core =3D offset / R_ISR_SIZE; + + if (offset % R_ISR_SIZE) { + goto out; + } p->per_core_isr[core] =3D value; goto out; } --=20 2.30.0