Received: by 2002:a25:730a:0:0:0:0:0 with SMTP id o10csp960297ybc; Tue, 24 Sep 2019 17:06:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEOEkv/QbEi6L351CxQiQyRhlS8FHFWqZylU6x7ZkznRAYzB3U5aG8bQWSHenKgJXHP8HI X-Received: by 2002:a05:600c:2246:: with SMTP id a6mr3570044wmm.95.1569370019141; Tue, 24 Sep 2019 17:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569370019; cv=none; d=google.com; s=arc-20160816; b=daXBnLdsPJLUSAGfZ/RUuwFdU8kxrcUZTJbx4PdUedJzZopakuKakPd05Pp3TC15C4 2UlxiapPvJg3cIGajeabJ7jjfu1T2E+JWKzFgNv6wLHPtMU7xvFdhHYTeIoxzLc1vQxt GjGmt9nLEgBLqClHB52Hkq6zb71UU+MaBIqgza19MYv+fMqxDqL8D4rK8IZEVNuvNqZQ JMvB4rmqbInmBhd/YYDVA5zGhdnxxy3IKVu1+7oIu+abAJzZH/ImvlpaBKhwv6eA3X+E Rt2xQnCoHjzjbVuvGlWDEeHazSgHvd58GJRYn1KrkH0FCrhIfTM6wywrWwMZa5N34nOw FoFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=wBHZ7zM9MXX6vAa5xiClSfeozP2w4j+/6pxwIyNuhqc=; b=hqevPs2R//VDAQu369Y9Bx5PK/meOsKvLD3uEz54qu1tgyL7nMua1StD1ST2uzsUyr fACM1Wa3GlFCYPSaA3wlOLv+HCklvOGHIbgmZAQRMj/AMrkn5pRaFWjFuxjLXqlxLp1d apCivww2eyfEARCO/bWKFJ0TZVntRv6fXlPFnc1GWYNOP+XvVqGQhrhKrOzRBXinCkHr nG26pKP4wrRHtohlux2KC1Vr3JQJktunHAG1/N4XdCIgoXAIcWbv1NEkitQtEiITmz1+ C2IHznTAOMM5vLf014HRU10O6vlt6UuKiS8q+qRw9MbApZltA1+0pS336JUVdOohKZQv Cf6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=C7jTYPeF; 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 e22si2188426eda.300.2019.09.24.17.06.35; Tue, 24 Sep 2019 17:06:59 -0700 (PDT) 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=@sifive.com header.s=google header.b=C7jTYPeF; 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 S2389395AbfIWApc (ORCPT + 99 others); Sun, 22 Sep 2019 20:45:32 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46701 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730404AbfIWApc (ORCPT ); Sun, 22 Sep 2019 20:45:32 -0400 Received: by mail-pl1-f195.google.com with SMTP id q24so5720180plr.13 for ; Sun, 22 Sep 2019 17:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=wBHZ7zM9MXX6vAa5xiClSfeozP2w4j+/6pxwIyNuhqc=; b=C7jTYPeFAbIbaL5ADjIqF9fdD2IepbODMzxIU5MuN1WOhRRWcGtS+MbLhqN+eRDK4A onM2qCoHTVwTR3E5SIs75A2NQqB6+EATximTQCQOD3c3VzTIhyRNhkKU+JzVMdLsRLTW 2UzRJopPvdmEJGkXebL7tPxmCxP7ksuVf3q6/PJGcI6zrZvNv9MHzjT/vmMwRGzLZijF 4t0/SentLUt/3pKKAuvB1dCXVy1UIYzThsysj9U8G3B13cWoPciVuwQ3Pe6ZKTZRUGLh e4scPzR6bUJZ6fxsjDBXGRVwVctGrHNQVhrjWORjE2sijRN0KT/ZPBD1r5ITXhmpBtYW 6bKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wBHZ7zM9MXX6vAa5xiClSfeozP2w4j+/6pxwIyNuhqc=; b=EYQ2C/HGoqSZcGKAEdZjNtu98BlS+1k/rR1bPfe/+vzVEJzvng5mXXMKFhAYi4ycVF Sk88xYWxomtvezUFig9mcDzUlKOS3JJQdKW4O78uBldmO4zwAa8fYm2B4+s7tRWNH7FX MDSYSCQ40wI1mt54A1eQUl6R+8/D/OqkOkGFr+NqJF2F11Kks7itAeMhbuKsqkPLxRoW irzeGSY4mqK/ioWftbYPc7MNX3LY8/0ZigEuH6Mu4gYemyM4N5rx6Lr6krhgIWx9T7bI nW2GptX7mAuAPLQaOjg+YVonJZceT5n7OWqQItXrDpkHgVdKtaSGuDxjCN/fN8AbYpMO xxPQ== X-Gm-Message-State: APjAAAXPQAM3qx/XrhjONCjUabvZNplgSRQkg8KrbTOhMs2VoWVg1tdT 1YC5bnY+7wmvRaYeU2LVRNwtvA== X-Received: by 2002:a17:902:ff08:: with SMTP id f8mr29298899plj.309.1569199529599; Sun, 22 Sep 2019 17:45:29 -0700 (PDT) Received: from localhost.localdomain (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id l7sm9139392pjy.12.2019.09.22.17.45.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Sep 2019 17:45:29 -0700 (PDT) From: Vincent Chen To: linux-riscv@lists.infradead.org Cc: paul.walmsley@sifive.com, palmer@sifive.com, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, vincent.chen@sifive.com Subject: [PATCH 0/4] riscv: correct the do_trap_break() Date: Mon, 23 Sep 2019 08:45:13 +0800 Message-Id: <1569199517-5884-1-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following three situations may occur in the current implementation of do_trap_break(). 1. When the CONFIG_GENERIC_BUG is disabled, if a kernel thread is trapped by BUG(), the whole system will be in the loop that infinitely handles the break exception instead of entering the die function. 2. When the kernel runs code on behalf of a user thread, and the kernel executes a WARN() or WARN_ON(), the user thread will be sent a bogus SIGTRAP. 3. Handling the unexpected ebreak instructions is to send a SIGTRAP to the trapped thread. However, if a kernel executes an unexpected ebreak, it may cause the kernel thread to be stuck in the ebreak instruction. This patch set will solve the above problems by adjusting the implementations of the do_trap_break(). Vincent Chen (4): riscv: avoid kernel hangs when trapped in BUG() rsicv: avoid sending a SIGTRAP to a user thread trapped in WARN() riscv: Correct the handling of unexpected ebreak in do_trap_break() riscv: remove the switch statement in do_trap_break() arch/riscv/kernel/traps.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.7.4