Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp634226rwb; Fri, 23 Sep 2022 01:54:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71KaraK1RJnSV/vBeN1RHraI4rZhyYtwo0/dfFbAXyNmkcyz/nHXBjDIM/xWHgolDtmXTW X-Received: by 2002:a17:907:d08:b0:72f:b107:c07a with SMTP id gn8-20020a1709070d0800b0072fb107c07amr6224739ejc.340.1663923244347; Fri, 23 Sep 2022 01:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663923244; cv=none; d=google.com; s=arc-20160816; b=rB/y7XDkYtYN9xULSS2F/nIkhmYAug/mK0Jd7t+5lQobBuwTu0iFshKEukLZG1P4gD QS/8CM/HNokqm796G6ztTF371fkM10o5TnsSQJx7QzMW1q+fqSJLPkrNCY43DsdqOfwn wGcwhd5WFtW2mNiOP7E8v4uIP6FNU9MiYdoghkY8bibU2MePsyfrInSSv8rY9b2PiRgz 6pNrLVLGiGJmuJ9eIgV3wT70SOacC54OXKSb1XyvGVzBKR+WgOx/R+V6veyuek2K1iTf VeFHxfMBivs/SShTyYrNydT5O4VRAmgtq7XyFbU3mWdpqn2w6SaGw/SwrfnIDtTfrpYC sLKg== 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=7niafjV8Un6E8E1LVkb9QN4SabuJbcu9QdUOoM3LpG4=; b=U1H76EFHAf+AIeRYUh4I0AwxBkJwELVTpOzU3JpTGqN7FOKLcCFXu+AD8ByWSOX+sY DgaetTJsQyiX2oPJfMKYgLDJjTqK0VhupWMbio0+zGZwVcc6A4lQnOZwI3jr1Ie+7Uj5 GjlTVWOWXtkAL9V59ql1dy0tj8Gy3rUnxLOBvn/LyoYNEqbwA9G8rIaqKXZj+JWe5b75 DWFYNOfXn8X5oUf4MPEzyfOH8iIja/FfAxxnGwK0SLNfo4U6efdsiVfMBR1BI1JOTuJ0 QtIyok7SW94zCJ8BVqelGaiVyjM2aKP9l9yawVu6zS2PAbYUD2wVnJ5KMuj1BkhN3BbQ oziA== 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 l6-20020a170906794600b00781599eb7d9si7372878ejo.542.2022.09.23.01.53.37; Fri, 23 Sep 2022 01:54:04 -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 S231282AbiIWIvJ (ORCPT + 99 others); Fri, 23 Sep 2022 04:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbiIWIu5 (ORCPT ); Fri, 23 Sep 2022 04:50:57 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC36D126B4B; Fri, 23 Sep 2022 01:50:54 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MYm3Q4S2lzWgy5; Fri, 23 Sep 2022 16:46:42 +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:40 +0800 From: Liao Chang To: , , , , , , , , , , , CC: , , , Subject: [PATCH 3/3] arm64/kprobe: Optimize the performance of patching single-step slot Date: Fri, 23 Sep 2022 16:46:58 +0800 Message-ID: <20220923084658.99304-4-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. Since I and D caches are coherent within single-step slot from aarch64_insn_patch_text_nosync(), hence no need to do it again via flush_icache_range(). Acked-by: Masami Hiramatsu (Google) Signed-off-by: Liao Chang --- arch/arm64/kernel/probes/kprobes.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index d1d182320245..29b98bc12833 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -44,13 +44,10 @@ post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *); static void __kprobes arch_prepare_ss_slot(struct kprobe *p) { kprobe_opcode_t *addr = p->ainsn.api.insn; - void *addrs[] = {addr, addr + 1}; - u32 insns[] = {p->opcode, BRK64_OPCODE_KPROBES_SS}; /* prepare insn slot */ - aarch64_insn_patch_text(addrs, insns, 2); - - flush_icache_range((uintptr_t)addr, (uintptr_t)(addr + MAX_INSN_SIZE)); + aarch64_insn_patch_text_nosync(addr, p->opcode); + aarch64_insn_patch_text_nosync(addr + 1, BRK64_OPCODE_KPROBES_SS); /* * Needs restoring of return address after stepping xol. -- 2.17.1