Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp655541rwb; Fri, 23 Sep 2022 02:14:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QTP4ROZjPssGoyIbJA2EBqYQagfq0sjbGxAtzSbdYEazrl6NTKiAJ3TTESquejwXT42YS X-Received: by 2002:a05:6402:1e96:b0:451:129e:1a2c with SMTP id f22-20020a0564021e9600b00451129e1a2cmr7578371edf.60.1663924466623; Fri, 23 Sep 2022 02:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663924466; cv=none; d=google.com; s=arc-20160816; b=ws8mV7MF58pG22Red/vNx3Sm86Yf8SWO5bTwSll0kbPvF/KWaTRhOSklz+NlU5fPol B9gqNrt19/NIK3V+Gl8aW/oxJyUNVaix6i2i5mHbymfpPgw4SpmZMsfzS2YZZUD/wwTd eYKGILBg4lLWPErlJRCFutVseKZ2y2UmgNis6DD6N8GGrD0I5KDBcv3bY9v9+BVG1Kwp 7BoAXSI8uI7k0bNADi+0FQEhVCv7a81DGFpu/YIzSlkfCoGyxsQJ/EM+Jb9wggtZqzmK /dKcCbSdonXHa4FPUqbDXPNYCgF+mScaB+BM8TKuD+EtWsx0IjkfAQX1j1IxyKVr3p8w CSKA== 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=s2p+nORVMOX81irsecQQO5jvA2x6GLg9ZNeSNIOa/n8PMr4j152vY32z1myho0pa3Y EJTVJt0jKgxkVNHvmefzL0vuKL6wFixu5xpvBqB1g+LBHvnjbjOs5Wj1RKtWcgxVrwrh QFJwBBXLBaW8M3petug+NyR25+r2lxsgfQPKkJzXEonFkR/oRc4iAUbyKz/Sel+69yiB BimFIDPKqZy6srLRKDT7ZqLeY5SKRicFb9YlhmHepMquB0YPEOGnIw58t+S3iNjAYxvb ZITe6+I+N2jI6zCe4Tk5nbwinjAorYNp8RX3iXTnAba5acx5gxZVRNLndqWsTRO0ul0f UMZA== 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 j21-20020a508a95000000b0044eb862958esi7846100edj.401.2022.09.23.02.14.01; Fri, 23 Sep 2022 02:14:26 -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 S231187AbiIWIvC (ORCPT + 99 others); Fri, 23 Sep 2022 04:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbiIWIu4 (ORCPT ); Fri, 23 Sep 2022 04:50:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBDEC126B49; Fri, 23 Sep 2022 01:50:54 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MYm3Q04rLzWgpB; Fri, 23 Sep 2022 16:46:41 +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; Fri, 23 Sep 2022 16:50:39 +0800 From: Liao Chang To: , , , , , , , , , , , CC: , , , Subject: [PATCH 2/3] csky/kprobe: Optimize the performance of patching single-step slot Date: Fri, 23 Sep 2022 16:46:57 +0800 Message-ID: <20220923084658.99304-3-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220923084658.99304-1-liaochang1@huawei.com> References: <20220923084658.99304-1-liaochang1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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