Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp319379pxf; Thu, 1 Apr 2021 01:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxclrjMlY10cpMxhnEYT1iVGwtlQ1uNSN6R0ylgyzetJgiASKMe4ePLV8tKK8XQ8W6Yw6Cd X-Received: by 2002:aa7:da0f:: with SMTP id r15mr8514052eds.111.1617267084529; Thu, 01 Apr 2021 01:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617267084; cv=none; d=google.com; s=arc-20160816; b=N51Ag0eBckYmbqEYDgtM48RZlquSo4ScppczFeTnGErd6Bb2Iq+YPh1wvQOrfLcw+4 u2W/2yszwnhLSxamC/T28f3hrrTNmIEO2+De1Dv5n2LsUQLvwNs2Vym2T1TlIr2cK5zJ 5y9diI3b9hLH2+SvDNuUawz99Sy4xPLz5rTPmFxWLHBVNzpGN2SRx2lh6u3xLNq9tT4U i8aGPoWL3YP2BdHGFOlAQ5Qp8XOrOD+oyNPliFGYQ28fdrb7ZpWEH9tn1Vt2jycXE6+C dqQbDLRsBTiC78Of4MCm6gjOHc+eyvEaHq50i8eRMoSQbgXkb6mNKZxohVNI/vwY/ATY 2iCw== 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:cc:from:references:to :subject; bh=GTJPhdxG8KFRXDVa2QSJn7mwwSfXQ8rsxAkt0ZhCuyU=; b=VPH3hSNVSov/MC9qohN5L1qwP2lHKBNEHUMVW45VC14RuHLewlPsgDNKFechTKr9Yh VnN1dzClYXIXFLu1rWv0nOH2Hq7DBLLj99LY+RXQduCNjaS/6EcXFEDqUMnCcrSFcheQ m4GcWqLXmASQaBUofoRHPAUhagtFPMdfxmk1nXCUpHH4eMUbuKdIoonSGUDpq3qsryuT +15OckECi7a6IiyKfX5RF0OlZFtc0wjIXukI27O+QDe+8RPMiHlXwu97UwTSoXWibyR0 1OAyaM9+pnnneBuWxaTaZqPVO6mekhIj5JzVe74U/HmgHQzuKi+pEzDySU90ILHyLch1 l3lw== 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 gz11si4021884ejc.745.2021.04.01.01.51.01; Thu, 01 Apr 2021 01:51:24 -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 S233677AbhDAIuA (ORCPT + 99 others); Thu, 1 Apr 2021 04:50:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14986 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233714AbhDAItz (ORCPT ); Thu, 1 Apr 2021 04:49:55 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F9xdv3jXCzyNpb; Thu, 1 Apr 2021 16:47:47 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Thu, 1 Apr 2021 16:49:47 +0800 Subject: Re: [PATCH] riscv: keep interrupts disabled for BREAKPOINT exception To: Jisheng Zhang References: <20210330021624.2b776386@xhacker> <20210330183316.942215efe8e6e8455ad14113@kernel.org> <20210331222244.45a5807c@xhacker> From: "liaochang (A)" CC: Masami Hiramatsu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , , Message-ID: <096752a7-21f9-8339-2e76-8c65859fa1d7@huawei.com> Date: Thu, 1 Apr 2021 16:49:47 +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: <20210331222244.45a5807c@xhacker> Content-Type: text/plain; charset="gbk" 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/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, 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. BR, Liao Chang > > Thanks > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv > . >