Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1132711ybt; Tue, 7 Jul 2020 08:28:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypC/LXkdSrJDTP/GpctZARFc3AxkOMSiUnd7UKtYXrIm9rRjDXLctLntsfXIaJF5yIaJom X-Received: by 2002:a50:e801:: with SMTP id e1mr60596151edn.251.1594135739426; Tue, 07 Jul 2020 08:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135739; cv=none; d=google.com; s=arc-20160816; b=iIqZ39wS2YzKhD8tZxQ7TR2+t4u+Y7BBiNT2k6SpBPogVc2zeG78yCbtkGu7txddu4 FygJd+9pU5R4zUrszd9EjfymiwJj1grmyK8LuHKCmhd81MQ1KSLNotT9sB+QDhhjVo0i R59NHx6SpYtRnHP41nKl23iM1gfVQ6yVJv97n9R7qGMXCXHcczyB9Zt8uPBVRi0fFOQE ALN9ZtPYdigqqvY5/MaECVphPUWAJd0Xx9IjH13Go94Sa52Jd0npHzFbkh2Kc9b06u4Z lUxOXg1AS0oraMI6BBa0i9fBeyxxtDQtvDWgdujkN8VYTncQptmtwtpgU30cm4CjOgFw n3UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fRXeg82Ux9Zu7tj+N6YJNGnG/aIJkZd5EWwe6z81dSc=; b=XtFVEjkZN911BUeBBucXlsGrS5FDO0JTx/0R7iKZTP3KIakRfcX3iDep7ESlAr6KHV H2KOGqjJo7/KPmGD0I+0gmsgvc28bzNel5CFbtJngeLzwJG32jkN+6oZ0DUKLm1N/eG7 IN3WzP3CEosXUcUELcTo7ChPkbMnU+C72x5E/2TspBtDsqvfsxVtqubFxvT5hT9odyT8 Dk6u0KsjhRARWnBCVxfRJWd2Bk0Sty6xmCyQFnqTYx21iCZMT6FvcLqi+kHQB37xMfg+ PUrsjRF2rgZfcGwLNpyg309qVJ8i1OudmNfHnQtRPkeJPf/Fm1pPE3wEJYwo7x3mKVbi mRCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cXUWnr+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si14990457ejp.681.2020.07.07.08.28.36; Tue, 07 Jul 2020 08:28:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cXUWnr+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729914AbgGGP2F (ORCPT + 99 others); Tue, 7 Jul 2020 11:28:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:40784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730282AbgGGP0a (ORCPT ); Tue, 7 Jul 2020 11:26:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B79B20663; Tue, 7 Jul 2020 15:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135589; bh=118ez3VeKwoGUQFXrk4+dubd44lWo89gVlRGiV64maM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXUWnr+DpJK2goj/t21RHesj3ET8sMGQk8QU+m8K51XRfwwxYE1P2IftwGcT+Fxbr BaWsYrOHIwo3No9uJvD/H2r3W10GwbxK9yCVY5v9wmsTZ10xpC20VFPPWVw/Q75MPm KeAiHc4dDPaAGUQjllafkZs1Gs5eAPP1ZLV+WnDQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hauke Mehrtens , Thomas Bogendoerfer Subject: [PATCH 5.7 101/112] MIPS: Add missing EHB in mtc0 -> mfc0 sequence for DSPen Date: Tue, 7 Jul 2020 17:17:46 +0200 Message-Id: <20200707145805.780237884@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145800.925304888@linuxfoundation.org> References: <20200707145800.925304888@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hauke Mehrtens commit fcec538ef8cca0ad0b84432235dccd9059c8e6f8 upstream. This resolves the hazard between the mtc0 in the change_c0_status() and the mfc0 in configure_exception_vector(). Without resolving this hazard configure_exception_vector() could read an old value and would restore this old value again. This would revert the changes change_c0_status() did. I checked this by printing out the read_c0_status() at the end of per_cpu_trap_init() and the ST0_MX is not set without this patch. The hazard is documented in the MIPS Architecture Reference Manual Vol. III: MIPS32/microMIPS32 Privileged Resource Architecture (MD00088), rev 6.03 table 8.1 which includes: Producer | Consumer | Hazard ----------|----------|---------------------------- mtc0 | mfc0 | any coprocessor 0 register I saw this hazard on an Atheros AR9344 rev 2 SoC with a MIPS 74Kc CPU. There the change_c0_status() function would activate the DSPen by setting ST0_MX in the c0_status register. This was reverted and then the system got a DSP exception when the DSP registers were saved in save_dsp() in the first process switch. The crash looks like this: [ 0.089999] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.097796] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.107070] Kernel panic - not syncing: Unexpected DSP exception [ 0.113470] Rebooting in 1 seconds.. We saw this problem in OpenWrt only on the MIPS 74Kc based Atheros SoCs, not on the 24Kc based SoCs. We only saw it with kernel 5.4 not with kernel 4.19, in addition we had to use GCC 8.4 or 9.X, with GCC 8.3 it did not happen. In the kernel I bisected this problem to commit 9012d011660e ("compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING"), but when this was reverted it also happened after commit 172dcd935c34b ("MIPS: Always allocate exception vector for MIPSr2+"). Commit 0b24cae4d535 ("MIPS: Add missing EHB in mtc0 -> mfc0 sequence.") does similar changes to a different file. I am not sure if there are more places affected by this problem. Signed-off-by: Hauke Mehrtens Cc: Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/traps.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2121,6 +2121,7 @@ static void configure_status(void) change_c0_status(ST0_CU|ST0_MX|ST0_RE|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX, status_set); + back_to_back_c0_hazard(); } unsigned int hwrena;