Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	linux-riscv@lists.infradead.org,
	Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com>
Subject: Re: [PATCH v3] riscv: probes: reject kprobes inside LR/SC sequences
Date: Wed, 26 Aug 2026 15:12:02 +0200	[thread overview]
Message-ID: <87tsoht49p.fsf@yellow.woof> (raw)
In-Reply-To: <20260826100256.1418-1-yuanxiaofeng@eswincomputing.com>

Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com> writes:
> +	while (tmp > scan_end && count < MAX_ATOMIC_CONTEXT_INSN) {
> +		u16 halfword = get_unaligned((u16 *)(tmp - 2));
> +		unsigned int len = (halfword & 0x3) == 0x3 ? 4 : 2;
> +
> +		if (tmp - len < scan_end)
> +			break;
> +
> +		if (len == 4) {
> +			u32 insn = get_unaligned((u32 *)(tmp - 4));
> +
> +			if (riscv_insn_is_lr(insn))
> +				in_atomic = true;
> +			else if (riscv_insn_is_sc(insn))
> +				in_atomic = false;
> +		}
> +
> +		tmp -= len;
> +		count++;
> +	}

This does not look right. If we have

    lr
    another instruction
    sc
    probed instruction

Then riscv_probe_insn_in_atomic() return true, which is clearly wrong.

Have you even tested this patch?

Nam

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2026-08-26 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 10:02 [PATCH v3] riscv: probes: reject kprobes inside LR/SC sequences Xiaofeng Yuan
2026-08-26 13:12 ` Nam Cao [this message]

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=87tsoht49p.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=yuanxiaofeng@eswincomputing.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