linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: WANG Xuerui <kernel@xen0n.name>
To: loongarch@lists.linux.dev
Cc: WANG Xuerui <git@xen0n.name>, Huacai Chen <chenhuacai@kernel.org>,
	Xi Ruoyao <xry111@xry111.site>,
	Eric Biederman <ebiederm@xmission.com>,
	Al Viro <viro@zeniv.linux.org.uk>, Arnd Bergmann <arnd@arndb.de>,
	linux-api@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] LoongArch: Relay BCE exceptions to userland as SIGSEGVs with si_code=SEGV_BNDERR
Date: Mon, 17 Apr 2023 01:57:01 +0800	[thread overview]
Message-ID: <ab6e8eeb-576c-436b-abee-fd9bce08ac0c@xen0n.name> (raw)
In-Reply-To: <20230416173326.3995295-3-kernel@xen0n.name>

On 4/17/23 01:33, WANG Xuerui wrote:
> <snip>
> @@ -589,6 +591,110 @@ static void bug_handler(struct pt_regs *regs)
>   	}
>   }
>   
> +asmlinkage void noinstr do_bce(struct pt_regs *regs)
> +{
> +	irqentry_state_t state = irqentry_enter(regs);
> +	bool user = user_mode(regs);
> +	unsigned long era = exception_era(regs);
> +	union loongarch_instruction insn;
> +	u64 badv = 0, lower = 0, upper = ULONG_MAX;
> +
> +	if (regs->csr_prmd & CSR_PRMD_PIE)
> +		local_irq_enable();
> +
> +	current->thread.trap_nr = read_csr_excode();
> +
> +	/*
> +	 * notify the kprobe handlers, if instruction is likely to
> +	 * pertain to them.
> +	 */
> +	if (notify_die(DIE_BOUNDS_CHECK, "Bounds check error", regs, 0,
> +		       current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
> +		goto out;
> +
> +	__show_regs(regs);

Ah, remnant of debug code. Please ignore this line; I'm not resending 
for now because I fully anticipate a v2 (and possibly even more). Lack 
of coffee/tea and presence of beer during weekends aren't going to help...

-- 
WANG "xen0n" Xuerui

Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/


  reply	other threads:[~2023-04-16 17:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 17:33 [PATCH 0/2] LoongArch: Make bounds-checking instructions useful WANG Xuerui
2023-04-16 17:33 ` [PATCH 1/2] LoongArch: Add opcodes of bounds-checking instructions WANG Xuerui
2023-04-16 17:33 ` [PATCH 2/2] LoongArch: Relay BCE exceptions to userland as SIGSEGVs with si_code=SEGV_BNDERR WANG Xuerui
2023-04-16 17:57   ` WANG Xuerui [this message]
2023-04-17  6:47 ` [PATCH 0/2] LoongArch: Make bounds-checking instructions useful Xi Ruoyao
2023-04-17  7:54   ` WANG Xuerui
2023-04-17  9:50     ` Xi Ruoyao
2023-04-20  8:36       ` Huacai Chen
2023-04-20  9:38         ` WANG Xuerui
2023-04-22  8:39           ` Huacai Chen

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=ab6e8eeb-576c-436b-abee-fd9bce08ac0c@xen0n.name \
    --to=kernel@xen0n.name \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=git@xen0n.name \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xry111@xry111.site \
    /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;
as well as URLs for NNTP newsgroup(s).