Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1912471pxb; Mon, 12 Apr 2021 09:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzchg4K6atVkdisLE3a33cxenKxOdIAxjWJC/e3bHSZ/do9uL6OQuD5xKt3EfYEp39Avxh X-Received: by 2002:a17:906:704a:: with SMTP id r10mr28152684ejj.312.1618244959368; Mon, 12 Apr 2021 09:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618244959; cv=none; d=google.com; s=arc-20160816; b=H7es+g7JDuE9PUq5xq1jze4+fYPz4bzUyAMBk4gfhCTdk6LOJKsd+kwB5nF5txdNyT eI0b5mImJ1X5JFFJXv5n9gr7RkHWoGLQNDXxuFrRH5+QCfb4k1bxzSO0Dn1j+vdKXfkn JxsramUK2mlN/+eabvmv22twfEnJjKP1JB5KRVlhinlsoWQii35BggJnDGoo4Z5TLxOA /LEReQkquCqtCi9X2oYvn4KNlNJGzXGbnJoRLiKD4qSeV637ivV7EImqKZ7qOCxhgPk1 q9jHZHEH2ov7zOAaOD/DDHTtmeMmGeyChtNvWL1Bv5YU2L6g3cP058/RkklFSRAtaFy0 trmQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+JWqBqfEhPY4hrU6jUBVKecSMTw69qAjQw6YVxPHI+Y=; b=oUkojrC5ZXerlWLpsT6aOa+ribTmujepXBqO+UszZPO0G7oRbtpMasMI5yl70zUexU h9ivM+AvJ2vgC1sOnkc+NffWn37NvzORWUz2X4ZMYWngNCGOtLLmOn9/hVVfaFK6796A EkviVBi6VitOR0j2DG5yTw81ycdSXIJUCHHUVfpSAX5np94jtp0L/7Bcid8IZawukoZJ hqZh18JAN3mM8fmqXZgBl1Fn1DK5FojFSOVjIRd0HTtmSJydudv+GnX6M0pkqo32L5+W w6MoOUVgarOR5X73Q+NUQhrOV4U8iDpla+qSyQifCUImUzGTWE6jw2eaQGnOdHtTKdOF A7LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=rF+qmraK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw24si7747619ejb.508.2021.04.12.09.28.56; Mon, 12 Apr 2021 09:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=rF+qmraK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244397AbhDLQZy (ORCPT + 99 others); Mon, 12 Apr 2021 12:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243448AbhDLQXv (ORCPT ); Mon, 12 Apr 2021 12:23:51 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3B31C06138E for ; Mon, 12 Apr 2021 09:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=+JWqBqfEhPY4hrU6jUBVKecSMTw69qAjQw 6YVxPHI+Y=; b=rF+qmraKg6WAUwIzBSzo017Eozr5mtqAChwReid5tNhn6oE6hV 85cjYsp5sSVipXpMoHQo0vCyVj25bv6mVqh65YdZnDuM4/YYkidsut+0uvycWIkx 8LssrkDhT8OX85Ej9d/TZEFBnuKU9xrikdmDcuPreCnUvzzbz7q02jiYE= Received: from xhacker (unknown [101.86.20.15]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygB3fkLQc3RgUT_LAA--.48727S2; Tue, 13 Apr 2021 00:22:41 +0800 (CST) Date: Tue, 13 Apr 2021 00:17:38 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang , Anup Patel Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/10] riscv: kprobes: Implement alloc_insn_page() Message-ID: <20210413001738.20c8b2e0@xhacker> In-Reply-To: <20210413001110.7209bae6@xhacker> References: <20210413001110.7209bae6@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygB3fkLQc3RgUT_LAA--.48727S2 X-Coremail-Antispam: 1UD129KBjvdXoW7GFyDGF45XF4kJrWxuw48WFg_yoWDCrg_C3 WxKry3WrWYkrZ7WFyDKr4Sqrsak343KFykWr12yryUtr1DWr13Ka95WF45G3sYqr97JF97 GrnxX3srWF42qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb4AYjsxI4VW3JwAYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Jr 0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVW8JVW3JwCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU8S1v3 UUUUU== X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang Allocate PAGE_KERNEL_READ_EXEC(read only, executable) page for kprobes insn page. This is to prepare for STRICT_MODULE_RWX. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/kernel/probes/kprobes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index 7e2c78e2ca6b..8c1f7a30aeed 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -84,6 +84,14 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return 0; } +void *alloc_insn_page(void) +{ + return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END, + GFP_KERNEL, PAGE_KERNEL_READ_EXEC, + VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, + __builtin_return_address(0)); +} + /* install breakpoint in text */ void __kprobes arch_arm_kprobe(struct kprobe *p) { -- 2.31.0