Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp318930rwb; Mon, 26 Sep 2022 19:48:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4gAHdq2rb/C046vj+96d5iRThz4VV+RQkce/wNrfA45oO8LOVx7bRIptl5kvorgXP0Wct6 X-Received: by 2002:a17:906:cc59:b0:779:f094:af3d with SMTP id mm25-20020a170906cc5900b00779f094af3dmr20545566ejb.239.1664246887881; Mon, 26 Sep 2022 19:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664246887; cv=none; d=google.com; s=arc-20160816; b=WS2hEuhElByKKTMzGLEloi+JkKii2754H6vhtMtCGaUszisVvj/DBj4Qoyp5sdD5Ss 05IaIk5LCaVQY5IyjmcYopodsfnJqbwE92U6N7vyiGifr6M7gKRX/APGQLJYiD0bvRLa Jxyw934ffV6EEWDYie8eUX/9TAelza7Sk75sGdMA+3X9fck98BrcgIEap0e7cWsTZwmC N+MAYvAjCm6V7aRXEICjvdA+R0frMwXgXBC7bcF4VLjO1Ukyh/RXR3asx5s0DUQOfTmy LJKG7fOTitGUUSvHZdYMEU5RGMMF4Tmh7fqq+B1mC+eLRRw3msh9bTYBwslYzq1C5C2h S6ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=suP5FFnbVM6PyXwnzX+XsBmM/sUUCSG5Wwj16ju0vyY=; b=QKc44lW71GyuYbqN4CFJt6uy9wDbCTegwd4UFmzjJ3ATNxl/CFsiUc2bKh8q7ck1+o +EUICIdjm3XCIC4ki3kQESE/wYnwPSbRNX/oBnqz2Of9TvIifQthrX1kfk5xD4xAG6xb SazV6BcQbUoEYQD7YMYvk9OLO0n29UA1lUPPNKNmAk8wjjpNhMV1mPpZwkkePkrti8SE 6f0Hc2bKdo2rU+N7lYe2H8TWbWy/qj4MXyKnK0Fd33j223XqWMdIJTxlvydlFFD2Hlpq V7FZ4Po4c8OvnDEpDPI6weV1as+tcmi9OgF+wi3CoNgR0yPP2MdmDj50oOl9ScKDzFsq wNRw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402511100b00451547732e2si417140edd.409.2022.09.26.19.47.40; Mon, 26 Sep 2022 19:48:07 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbiI0C2s (ORCPT + 99 others); Mon, 26 Sep 2022 22:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbiI0C2Y (ORCPT ); Mon, 26 Sep 2022 22:28:24 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD2FA9C01; Mon, 26 Sep 2022 19:28:23 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mc3MV6nRfzHtfM; Tue, 27 Sep 2022 10:23:34 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 10:28:20 +0800 From: Liao Chang To: , , , , , , , , , , CC: , , , Subject: [PATCH 2/3] csky/kprobe: Optimize the performance of patching single-step slot Date: Tue, 27 Sep 2022 10:24:34 +0800 Message-ID: <20220927022435.129965-3-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927022435.129965-1-liaochang1@huawei.com> References: <20220927022435.129965-1-liaochang1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 Single-step slot would not be used until kprobe is enabled, that means no race condition occurs on it under SMP, hence it is safe to pacth ss slot without stopping machine. Acked-by: Masami Hiramatsu (Google) Signed-off-by: Liao Chang --- arch/csky/kernel/probes/kprobes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/csky/kernel/probes/kprobes.c b/arch/csky/kernel/probes/kprobes.c index 3c6e5c725d81..4feb5ce16264 100644 --- a/arch/csky/kernel/probes/kprobes.c +++ b/arch/csky/kernel/probes/kprobes.c @@ -57,7 +57,11 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p) p->ainsn.api.restore = (unsigned long)p->addr + offset; - patch_text(p->ainsn.api.insn, p->opcode); + memcpy(p->ainsn.api.insn, &p->opcode, offset); + dcache_wb_range((unsigned long)p->ainsn.api.insn, + (unsigned long)p->ainsn.api.insn + offset); + icache_inv_range((unsigned long)p->ainsn.api.insn, + (unsigned long)p->ainsn.api.insn + offset); } static void __kprobes arch_prepare_simulate(struct kprobe *p) -- 2.17.1