Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4178123pxf; Tue, 6 Apr 2021 09:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxppQz11fs9HNpZKtSaBeQFrlbFm+Ukh4uq+Ap0HOzOTH2uek1nMGGnRzAEGmuGd/lclevM X-Received: by 2002:a17:906:d7b5:: with SMTP id pk21mr13511974ejb.232.1617727252539; Tue, 06 Apr 2021 09:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617727252; cv=none; d=google.com; s=arc-20160816; b=FksmL2aRm3CoXLFYs9yWtry/qZ0Xr2zjWsegwBS2/GTM02pNDujutI9pat7Le0Kh9h uLzpCcd1DAGFZHFLoH2w6FJXP3HoLNDG/VJIYpp7f6H6pnOC99qwfnD0yqc6G7n6drVz YsSkQyUsTDJ5N88CckGg4hbfR1wg7TmHYkDsS/MDNEJ2qlgWdReULBH/T26caojk9jQ9 FfnnFkenEmHM6uxliB+wbcmUujtEtEnj5VdVbT0CUW/PLZNWmAhqAfX+nQ1NlbIVfTVY ClcBSBEvervk6jEEpiU1ryAI/x8mO7anezgZbzdrtH4tyKsRzQID14Ityl+6l0AYNsDt UkWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=adJFZXXUfBjY+tYAMr2BXVnsAYv5dozcq9tqA6HQSx4=; b=EUWeXqVOaKLeNT4WW+WCFzE/uhJxfWRqPJngEKjFHDi//ZA3C0sqYTfLnl6pjIUesJ Y8JIkYT0QzeFlFr8//sBngrT/tF7x/n1lyQd583o7tNCCzH/FYqI9IS0DwZ6f+PftX8c XHLQL2vs2Hje7RKkz0oRhvOqXBX4mttZ3oXCgBE5rJt0q30Hq0crlqfOo90EMzXzHH4A HNr7CD30nmPfKqqN9q88o199XWg02v2iBP84NwJ0fpMv2PYPfPGY8YYXrJCxwrv4/i0C E+ToRwtjdb/rw+Z4EPWT7Gd8884oWmUZBSt5NvkQQDOuq4RKhV0yTX+ghfUwI+GbjGoB hFnQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si9832574edu.127.2021.04.06.09.40.28; Tue, 06 Apr 2021 09:40:52 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233513AbhDFH2F (ORCPT + 99 others); Tue, 6 Apr 2021 03:28:05 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15606 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbhDFH2E (ORCPT ); Tue, 6 Apr 2021 03:28:04 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FDzZx15dzz19Kn3; Tue, 6 Apr 2021 15:25:45 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Tue, 6 Apr 2021 15:27:51 +0800 Subject: Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception To: Jisheng Zhang CC: Masami Hiramatsu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , , References: <20210330021624.2b776386@xhacker> <20210330183316.942215efe8e6e8455ad14113@kernel.org> <20210331222244.45a5807c@xhacker> <096752a7-21f9-8339-2e76-8c65859fa1d7@huawei.com> <20210402213206.7db93785@xhacker> From: "liaochang (A)" Message-ID: Date: Tue, 6 Apr 2021 15:27:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20210402213206.7db93785@xhacker> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jisheng, 在 2021/4/2 21:32, Jisheng Zhang 写道: > On Thu, 1 Apr 2021 16:49:47 +0800 > "liaochang (A)" wrote: > >> Hi Jisheng, > > Hi, > >> >> 在 2021/3/31 22:22, Jisheng Zhang 写道: >>> On Tue, 30 Mar 2021 18:33:16 +0900 >>> Masami Hiramatsu wrote: >>> >>>> Hi Jisheng, >>> >>> Hi Masami, >>> >>>> >>>> On Tue, 30 Mar 2021 02:16:24 +0800 >>>> Jisheng Zhang wrote: >>>> >>>>> From: Jisheng Zhang >>>>> >>>>> Current riscv's kprobe handlers are run with both preemption and >>>>> interrupt enabled, this violates kprobe requirements. Fix this issue >>>>> by keeping interrupts disabled for BREAKPOINT exception. >>>> >>>> Not only while the breakpoint exception but also until the end of >>>> the single step (maybe you are using __BUG_INSN_32 ??) need to be >>>> disable interrupts. Can this do that? >>>> >>> >>> interrupt is disabled during "single step" by kprobes_save_local_irqflag() >>> and kprobes_restore_local_irqflag(). The code flow looks like: >>> >>> do_trap_break() // for bp >>> kprobe_breakpoint_handler() >>> setup_singlestep() >>> kprobes_restore_local_irqflag() >>> >>> do_trap_break() // for ss >>> kprobe_single_step_handler() >>> kprobes_restore_local_irqflag() >> >> Recently, kernel hit BUG_ON() on QEMU after I install a probe at "sys_read" via kprobe, > > TIPS: Each line should not exceed 80 chars > >> accoriding to my debugging and analysis it looks like caused by the "irq disable" operation for single-stepping. >> >> I present a detailed description about this problem in the mail with title "[PATCH] riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe". >> Looking forward to some feedback,Thanks. >> > > I will comment that patch. Thanks for your reminder. > > thanks > > . >