Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2890856rwb; Mon, 15 Aug 2022 13:25:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR65FpAA1zlXv3xgWSiYZdBWOut2XXYZw7CxNJj0EkNjZhxJD2oQzzpdi8gBaOrKG4PGFIpl X-Received: by 2002:a17:906:9c82:b0:6df:baa2:9f75 with SMTP id fj2-20020a1709069c8200b006dfbaa29f75mr11561392ejc.762.1660595027616; Mon, 15 Aug 2022 13:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660595027; cv=none; d=google.com; s=arc-20160816; b=XU3QR4ii+R2zNgY/VeW8+HKoUarmMbJFN/t2MHpUa2cTqZNUDl/0OYwYEuP0vXyNqj REKbICh9Cd4hvUJ1g7nxoWdz6bStQCmKxsd/9Qjvge3nfoOlnwLLT3pg9xNEV4vpclss qgN1BVFgdxjhxoTkFq+nsvrMXq8S8Ji11RYSbg/Svs6z9Y2VuefR8cQVkSaP/mRHILcQ +s3624l6UL54rVPkONnHQ2GBDryGDO5GGo2Roby1b+i0kK9pE+ai6q1bPxmNct73HtL8 oK9/5lXZLM+rfxzt0SUwSSaPpPx+ccEeokCCN1XN9cYxvnze40y6zVyxui1ct9icd2pV oD+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I4P97atC+reIWFbcba4C5CTYmQm7je55dWpy0+YGKt4=; b=KZrBY6NJ9s9XwhTbuK39i6oQ1f/2zInt94v95uBMr8c+qbZAJXkVdo0DgJxY3DwU7w AYkA/NAPOBOU9K26Dm83hfLQbidVtGxu4OrHjjafgvcJ2fR6a/MYKbLT7ik1dv7LRlxL qtGVwrbO6QwQ50xiVxLZZnMr2hUBg7dxVmnYnxj1UCWcCLh/jETEwICNt8KJEdBY0ztr gENsRPNbY+fC2Sf9AwBCla2FsFfEeiW6jFQ3MpNpOHyklVWWA63fknvlob+kOeSBGnia oOB4IVbEnsMEXustcg2GuNDOYdB59ZmdJhiU/iFVlrxoNl2iOqTm6xhnLnHPU3rUtkpk Hoyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KHAgyWzU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r26-20020a056402019a00b0043d54ba0a4dsi7567152edv.327.2022.08.15.13.23.17; Mon, 15 Aug 2022 13:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KHAgyWzU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345954AbiHOUPB (ORCPT + 99 others); Mon, 15 Aug 2022 16:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346226AbiHOULE (ORCPT ); Mon, 15 Aug 2022 16:11:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5AAB7F8; Mon, 15 Aug 2022 11:57:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BF030B810A0; Mon, 15 Aug 2022 18:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3360DC43470; Mon, 15 Aug 2022 18:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589829; bh=h2a++vB7rUxdHLPrp5od/YYDptU4FG5vuzzKULCmoS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KHAgyWzUb0eDv+obPCHFY4Kk9AUn1vw3u6iKNZvvxAvAthv7ZHCK3NJLkiELbb7ue w+Ru1AbTMkpSoIDfrtGe1yjABYTF3AA63AAbu/SXJTWn535GP4aNxsHzYGFdOTvUwP 1BubqN/gVZ9ZtMSk2FHfuIlaAF3qjd0G/aqVDgp8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yipeng Zou , Guo Ren , Palmer Dabbelt Subject: [PATCH 5.18 0060/1095] riscv:uprobe fix SR_SPIE set/clear handling Date: Mon, 15 Aug 2022 19:50:59 +0200 Message-Id: <20220815180431.979677244@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yipeng Zou commit 3dbe5829408bc1586f75b4667ef60e5aab0209c7 upstream. In riscv the process of uprobe going to clear spie before exec the origin insn,and set spie after that.But When access the page which origin insn has been placed a page fault may happen and irq was disabled in arch_uprobe_pre_xol function,It cause a WARN as follows. There is no need to clear/set spie in arch_uprobe_pre/post/abort_xol. We can just remove it. [ 31.684157] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1488 [ 31.684677] in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 76, name: work [ 31.684929] preempt_count: 0, expected: 0 [ 31.685969] CPU: 2 PID: 76 Comm: work Tainted: G [ 31.686542] Hardware name: riscv-virtio,qemu (DT) [ 31.686797] Call Trace: [ 31.687053] [] dump_backtrace+0x30/0x38 [ 31.687699] [] show_stack+0x40/0x4c [ 31.688141] [] dump_stack_lvl+0x44/0x5c [ 31.688396] [] dump_stack+0x18/0x20 [ 31.688653] [] __might_resched+0x114/0x122 [ 31.688948] [] __might_sleep+0x50/0x7a [ 31.689435] [] down_read+0x30/0x130 [ 31.689728] [] do_page_fault+0x166/x446 [ 31.689997] [] ret_from_exception+0x0/0xc Fixes: 74784081aac8 ("riscv: Add uprobes supported") Signed-off-by: Yipeng Zou Reviewed-by: Guo Ren Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220721065820.245755-1-zouyipeng@huawei.com Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/probes/uprobes.c | 6 ------ 1 file changed, 6 deletions(-) --- a/arch/riscv/kernel/probes/uprobes.c +++ b/arch/riscv/kernel/probes/uprobes.c @@ -59,8 +59,6 @@ int arch_uprobe_pre_xol(struct arch_upro instruction_pointer_set(regs, utask->xol_vaddr); - regs->status &= ~SR_SPIE; - return 0; } @@ -72,8 +70,6 @@ int arch_uprobe_post_xol(struct arch_upr instruction_pointer_set(regs, utask->vaddr + auprobe->insn_size); - regs->status |= SR_SPIE; - return 0; } @@ -111,8 +107,6 @@ void arch_uprobe_abort_xol(struct arch_u * address. */ instruction_pointer_set(regs, utask->vaddr); - - regs->status &= ~SR_SPIE; } bool arch_uretprobe_is_alive(struct return_instance *ret, enum rp_check ctx,