From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC84617278D for ; Fri, 21 Jun 2024 12:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718971414; cv=none; b=XFEWZduGN+du7DG1PPBnUbyjTR36PfXNJLNNZ4iBbvy3VPFtzAKjWYd3pFybD6nTOkRSgg1AWSC0E9aQ1eKivEScH9Nhx6qzbmv1bgcwJGn2tHSu3ArWdOiq/3RIhAMrNvrQ5QzVMmcqcBvR/1osHdQnLGDJ/If+i04Cngz+HsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718971414; c=relaxed/simple; bh=UZQ7ofngdkPglX7uUAUMRfKyQGTHYQz14H/4NkfLPRE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fq533dDfGISJ2nM574JlBEl6vPSvAwQLZ4Zpqsb5NOnKZvgJW6GugmoEhI+SJh3rro8qbKbG9jD7dQy3knABqN2wkJrza0HPR9BOqpajGT8QwT1cyPf7Xx6CL/aGAGDGUChoAQq55flbT4HDdmdMssirmIh5dH8+BV8huPLOSZ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Uz7vFDRa; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Uz7vFDRa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718971410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CsSGOB1HODYWe+7tXlzHZdd/rZJ23wX0Crrt14uZIPg=; b=Uz7vFDRam5h6ZjRXnN+zwb3VgcyDJFH146eMfgQR+M7QpvgTI6fO2EdJlUlUo6ellxgO7M pnLpDgq3ipQ1/qKziUBTO6FmXuV93y8tGq4Ytp22QnDK1hd6TSJ7yNAdRN/ulsGG9ysODI C+ZA4DF/UEw3hsxRTDlLPbwmE58HQOw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-pGFMVH7WPjudccqAGfG9Ag-1; Fri, 21 Jun 2024 08:03:28 -0400 X-MC-Unique: pGFMVH7WPjudccqAGfG9Ag-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF22E19560AD; Fri, 21 Jun 2024 12:03:26 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.114]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 146E01956053; Fri, 21 Jun 2024 12:03:22 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 21 Jun 2024 14:01:55 +0200 (CEST) Date: Fri, 21 Jun 2024 14:01:50 +0200 From: Oleg Nesterov To: Andrii Nakryiko Cc: Jiri Olsa , Steven Rostedt , Masami Hiramatsu , Andrii Nakryiko , Nathan Chancellor , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH] uprobe: Do not use UPROBE_SWBP_INSN as static initializer Message-ID: <20240621120149.GB12521@redhat.com> References: <20240618194306.1577022-1-jolsa@kernel.org> <20240620193846.GA7165@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 06/20, Andrii Nakryiko wrote: > > On Thu, Jun 20, 2024 at 12:40 PM Oleg Nesterov wrote: > > > > But I can't understand what does it do, it calls emit_break() and > > git grep -w emit_break finds nothing. > > > > It's DEF_EMIT_REG0I15_FORMAT(break, break_op) in > arch/loongarch/include/asm/inst.h > > A bunch of macro magic, but in the end it produces some constant > value, of course. I see, thanks! Then perhaps something like below? Oleg. --- x/arch/loongarch/include/asm/uprobes.h +++ x/arch/loongarch/include/asm/uprobes.h @@ -9,7 +9,7 @@ typedef u32 uprobe_opcode_t; #define MAX_UINSN_BYTES 8 #define UPROBE_XOL_SLOT_BYTES MAX_UINSN_BYTES -#define UPROBE_SWBP_INSN larch_insn_gen_break(BRK_UPROBE_BP) +#define UPROBE_SWBP_INSN (uprobe_opcode_t)(BRK_UPROBE_BP | (break_op << 15)) #define UPROBE_SWBP_INSN_SIZE LOONGARCH_INSN_SIZE #define UPROBE_XOLBP_INSN larch_insn_gen_break(BRK_UPROBE_XOLBP) --- x/arch/loongarch/kernel/uprobes.c +++ x/arch/loongarch/kernel/uprobes.c @@ -7,6 +7,13 @@ #define UPROBE_TRAP_NR UINT_MAX +static __init int __ck_insn(void) +{ + BUG_ON(UPROBE_SWBP_INSN != larch_insn_gen_break(BRK_UPROBE_BP)); + return 0; +} +late_initcall(__ck_insn); + int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long addr) {