Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6074788rwn; Mon, 12 Sep 2022 20:49:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5habzbhl+JfeFSiAXP4kBmi6m8LRb1W+5lUSXhyPltg8IQDYSIm010CqL2ljw0pWtsgf+w X-Received: by 2002:a17:907:2d2a:b0:77e:def7:65e9 with SMTP id gs42-20020a1709072d2a00b0077edef765e9mr3717586ejc.85.1663040966520; Mon, 12 Sep 2022 20:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663040966; cv=none; d=google.com; s=arc-20160816; b=FPZP5oP1kE9muYoD3h49UsEMuqcJ+9336t9AimhpLTI+Yk4vkQpG61gWZ+pnGvhE2X 3Vb9AyYZ2j6p1Gvn9q/ZoJp2vSNpBs+eZ3gZWK6KdJSairiwi3kPgwllV5l3yUJ1vzqX 9Eib9seS0D0G3ptWRb/4PV9yFniw9NygARfM4zIZwLFfV/AdAwCd7hvfKukUimTOl4Ah kcNj8bZgTxEHUZVTC1f0Gi5Rpl1OGmL5uucsWOvyrdjHu6M8LBjhERmgshe7hAgM8fTw jpdKfSrl4NRmlINgZrT0V90fIWKZwJ3msf/zZksUw2x84j5TvGzPmAge+eWvf0VFG+H/ Vdgw== 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=jgC/tyywlj3itFuaEFvuWR+opnGqQ2RR2Q5T5SHoSHM=; b=yDO9IKtkcfr45tCLMOOanpgS8L9jOG5qY9iC5JlvcReayhq0JUEhWcjObhsCCfCLxZ i5bp0XBTod3pq8ogaiSj2EtQYpCitZR/b/GHjrUXku932T13vO5gD9jxQWiBHgTsO4Fa XOJ3YBiEGpMSD50ukWnDeoneNhBzhM50d3Ir8MQTt3nA0LgBi4H2Z3AWu4bV7/1iLrtH oxqxvfJqHhdgCBZUcEiQyrRemK5Zq7fs4B/s7iiCC7h9osaHvBuBLgV+UgtdD5nknF9f QU55sjXcMjSrvhIu3PKam9YZJGLRpviaLgwOFuMvgOsTh3W0GZFH4DxDYzh130nWg2pn JKRQ== 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 s18-20020a056402521200b0044e85e75120si10358582edd.84.2022.09.12.20.49.02; Mon, 12 Sep 2022 20:49: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 S229816AbiIMDih (ORCPT + 99 others); Mon, 12 Sep 2022 23:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbiIMDib (ORCPT ); Mon, 12 Sep 2022 23:38:31 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4298C54656; Mon, 12 Sep 2022 20:38:29 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MRTc36KtyzmV5w; Tue, 13 Sep 2022 11:34:43 +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.24; Tue, 13 Sep 2022 11:38:26 +0800 From: Liao Chang To: , , , , , , , , , , CC: , , , Subject: [PATCH V2 3/3] arm64/kprobe: Optimize the performance of patching single-step slot Date: Tue, 13 Sep 2022 11:34:54 +0800 Message-ID: <20220913033454.104519-4-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220913033454.104519-1-liaochang1@huawei.com> References: <20220913033454.104519-1-liaochang1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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,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 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. Signed-off-by: Liao Chang --- arch/arm64/kernel/probes/kprobes.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index d1d182320245..5902e33fd3b6 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -44,11 +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); + aarch64_insn_write(addr, p->opcode); + aarch64_insn_write(addr + 1, BRK64_OPCODE_KPROBES_SS); flush_icache_range((uintptr_t)addr, (uintptr_t)(addr + MAX_INSN_SIZE)); -- 2.17.1