Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8113243imu; Tue, 4 Dec 2018 03:13:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXLw+5xnuDF8PlGJaCOhb8/t9jdzGHCJszBMLEbA8miYrfOtSt3MU154HWhOYJp0C3bV5P X-Received: by 2002:a62:e704:: with SMTP id s4mr19887906pfh.124.1543922021770; Tue, 04 Dec 2018 03:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922021; cv=none; d=google.com; s=arc-20160816; b=mIQ6Pz1tSjm9ittcED3T545w4Lhj7cLMn58ZkNHfZx5LJyqOUV8+QhUy6xIqacmNeK X50fUVrtZ1pPunjFJRGOOFu9sj5EdGJG8UpyR6gTkGxkLO5o8lrHZnsTblOlOkAVCJan KmhO72wXiL6o5di4hd3/nnLCtjT/8vW0AE013Can+04CFzWj1KavIbNiKrkYHXQ4Z+My pSRTfWE5GO7FZiXNHAqRAifj86FPAnytdcFu7pvm2xOn1q96Jvw3fzBa8XU9ItTKyq34 4HhQ28kr4nwMUIsvNyZ9k5vKaVaHypDDRsEmZpKfYDkBE9/jFmiGggY27XBD/OX3+VFJ Fs7g== 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=phUPZecViY/KxMlwAFzf3IvKwY5bCXzfDmTs014JluA=; b=FWd8KXdbptGs9cv0T1pQjemJ7QC8qMUM3Qq13QZuF7JWKt8UaFswcOpFj11XfP8z+n qGzY+dsO1XtdVaGWxEe02PAE8Z4jcjNrwMFUDbowAzln82F8L4+YVO1moQEHhbgPOndl rmfQXGT9RJUiyMKJjjBj8Km/BYLr0gKPCc6t6ScoHLdBW8sTOVww9uQ3io0NzmBCS6al RMM5pQji+OwpnrgYrYhKJ3f4vehgxOtdyl18CMPqXEh+ZoWz74GIXojl5UnupqAU4v4t mpfi7jpnSApHOPWbu+ZqpsSq6n1r++dnL6eiZGvV5k8OvEitxjKf8NBwQjtdBgVJZAYs u7fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=khZb+RHp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m76si16735299pfj.48.2018.12.04.03.13.27; Tue, 04 Dec 2018 03:13:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=khZb+RHp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbeLDLMh (ORCPT + 99 others); Tue, 4 Dec 2018 06:12:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:57488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728594AbeLDLIM (ORCPT ); Tue, 4 Dec 2018 06:08:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 A40222082D; Tue, 4 Dec 2018 11:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921692; bh=V8VkUU8IcsvfsZnnEnbgZogy/xDSHGCEAekVO0oiq6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=khZb+RHpc0k/ooNXj2Xt81wb3kMeEU38cyeQTusvhf5sr6XXQYZbZa5t6GiFdnBtq /I6OMeWgdraxWtYzEcvMMOg8pXxd2kXcbpIMc7FwWtIBVUPjatA4C/YJ3rGIhSpEJW sV9p+KvGyDOUYcpoQAAqmWNW4G5woamA0sIZPiIk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov Subject: [PATCH 4.9 22/50] xtensa: enable coprocessors that are being flushed Date: Tue, 4 Dec 2018 11:50:17 +0100 Message-Id: <20181204103715.636541101@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103714.485546262@linuxfoundation.org> References: <20181204103714.485546262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Max Filippov commit 2958b66694e018c552be0b60521fec27e8d12988 upstream. coprocessor_flush_all may be called from a context of a thread that is different from the thread being flushed. In that case contents of the cpenable special register may not match ti->cpenable of the target thread, resulting in unhandled coprocessor exception in the kernel context. Set cpenable special register to the ti->cpenable of the target register for the duration of the flush and restore it afterwards. This fixes the following crash caused by coprocessor register inspection in native gdb: (gdb) p/x $w0 Illegal instruction in kernel: sig: 9 [#1] PREEMPT Call Trace: ___might_sleep+0x184/0x1a4 __might_sleep+0x41/0xac exit_signals+0x14/0x218 do_exit+0xc9/0x8b8 die+0x99/0xa0 do_illegal_instruction+0x18/0x6c common_exception+0x77/0x77 coprocessor_flush+0x16/0x3c arch_ptrace+0x46c/0x674 sys_ptrace+0x2ce/0x3b4 system_call+0x54/0x80 common_exception+0x77/0x77 note: gdb[100] exited with preempt_count 1 Killed Cc: stable@vger.kernel.org Signed-off-by: Max Filippov Signed-off-by: Greg Kroah-Hartman --- arch/xtensa/kernel/process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -85,18 +85,21 @@ void coprocessor_release_all(struct thre void coprocessor_flush_all(struct thread_info *ti) { - unsigned long cpenable; + unsigned long cpenable, old_cpenable; int i; preempt_disable(); + RSR_CPENABLE(old_cpenable); cpenable = ti->cpenable; + WSR_CPENABLE(cpenable); for (i = 0; i < XCHAL_CP_MAX; i++) { if ((cpenable & 1) != 0 && coprocessor_owner[i] == ti) coprocessor_flush(ti, i); cpenable >>= 1; } + WSR_CPENABLE(old_cpenable); preempt_enable(); }