mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: linux@armlinux.org.uk, oleg@redhat.com, catalin.marinas@arm.com,
	will.deacon@arm.com, peterz@infradead.org, mingo@redhat.com,
	acme@kernel.org, alexander.shishkin@linux.intel.com,
	jolsa@redhat.com, namhyung@kernel.org, b.zolnierkie@samsung.com,
	m.szyprowski@samsung.com, k.lewandowsk@samsung.com,
	m.slodczyk2@partner.samsung.com
Subject: [PATCH 3/7 RESEND] arm64: introduce get_swbp_insn() instead of static assignment
Date: Fri, 16 Feb 2018 12:23:07 +0100	[thread overview]
Message-ID: <1518780191-31094-4-git-send-email-m.slodczyk2@partner.samsung.com> (raw)
In-Reply-To: <1518780191-31094-1-git-send-email-m.slodczyk2@partner.samsung.com>

In uprobes generic code, an arch specific software breakpoint instruction
is statically assigned with a #define statement. It does not allow to examine
the context and set the proper arch on runtime, which is the case of uprobing
either a 32 or 64 bit app on a 64-bit kernel. Introduce get_swbp_insn() with
weak attribute that will allow to be redefined in ARM64 uprobes code.

Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
---
 include/linux/uprobes.h |  1 +
 kernel/events/uprobes.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index 0a294e9..ef61d79 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -117,6 +117,7 @@ struct uprobes_state {
 
 extern int set_swbp(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
 extern int set_orig_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr);
+extern uprobe_opcode_t get_swbp_insn(void);
 extern bool is_swbp_insn(uprobe_opcode_t *insn);
 extern bool is_trap_insn(uprobe_opcode_t *insn);
 extern unsigned long uprobe_get_swbp_addr(struct pt_regs *regs);
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 267f6ef..cb7a573 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -216,6 +216,16 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
 }
 
 /**
+ * get_swbp_insn - return breakpoint instruction.
+ * Default implementation of get_swbp_insn
+ * Returns architecture-dependent breakpoint instruction opcode
+ */
+uprobe_opcode_t __weak get_swbp_insn(void)
+{
+	return UPROBE_SWBP_INSN;
+}
+
+/**
  * is_swbp_insn - check if instruction is breakpoint instruction.
  * @insn: instruction to be checked.
  * Default implementation of is_swbp_insn
@@ -1178,7 +1188,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
 static struct xol_area *__create_xol_area(unsigned long vaddr)
 {
 	struct mm_struct *mm = current->mm;
-	uprobe_opcode_t insn = UPROBE_SWBP_INSN;
+	uprobe_opcode_t insn = get_swbp_insn();
 	struct xol_area *area;
 
 	area = kmalloc(sizeof(*area), GFP_KERNEL);
-- 
2.7.4

  parent reply	other threads:[~2018-02-16 11:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180216112320eucas1p104a5cca53f8ee7d9b727479b2a362e93@eucas1p1.samsung.com>
2018-02-16 11:23 ` [PATCH 0/7 RESEND] arm64: uprobes - ARM32 instruction probing Maciej Slodczyk
     [not found]   ` <CGME20180216112320eucas1p157eae5e9830028e944f23cad1c81c6eb@eucas1p1.samsung.com>
2018-02-16 11:23     ` [PATCH 1/7 RESEND] arm64: move arm uprobes code to be reused by arm64 Maciej Slodczyk
2018-02-19  1:04       ` kbuild test robot
     [not found]   ` <CGME20180216112321eucas1p1c51df50f06fa2f440fcd4735066d1e61@eucas1p1.samsung.com>
2018-02-16 11:23     ` [PATCH 2/7 RESEND] arm64: uprobes - fix checkpatch.pl issues Maciej Slodczyk
     [not found]   ` <CGME20180216112322eucas1p2b170bbf0687ebbc03110e42ff807342f@eucas1p2.samsung.com>
2018-02-16 11:23     ` Maciej Slodczyk [this message]
     [not found]   ` <CGME20180216112323eucas1p1fd0302348ff3c5f47f0aa8ef52b39401@eucas1p1.samsung.com>
2018-02-16 11:23     ` [PATCH 4/7 RESEND] arm64: change arm64 probes handler prototype Maciej Slodczyk
     [not found]   ` <CGME20180216112324eucas1p2ff53620ec4baec3b89a7d55fc5832c3e@eucas1p2.samsung.com>
2018-02-16 11:23     ` [PATCH 5/7 RESEND] arm64: make arm uprobes code reusable by arm64 Maciej Slodczyk
     [not found]   ` <CGME20180216112325eucas1p1e6c73b9b55db778aac0bbb9ad1b10fae@eucas1p1.samsung.com>
2018-02-16 11:23     ` [PATCH 6/7 RESEND] arm64: change arm_probe_decode_insn() function name Maciej Slodczyk
     [not found]   ` <CGME20180216112326eucas1p10c07384e9a01ab6102b7dba62d9fc315@eucas1p1.samsung.com>
2018-02-16 11:23     ` [PATCH 7/7 RESEND] arm64: uprobes - ARM32 instruction probing Maciej Slodczyk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518780191-31094-4-git-send-email-m.slodczyk2@partner.samsung.com \
    --to=m.slodczyk2@partner.samsung.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=catalin.marinas@arm.com \
    --cc=jolsa@redhat.com \
    --cc=k.lewandowsk@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®