All of lore.kernel.org
 help / color / mirror / Atom feed
From: kirill@shutemov.name (Kirill A. Shutemov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct
Date: Tue, 26 Jul 2011 23:18:58 +0300	[thread overview]
Message-ID: <20110726201858.GA6322@shutemov.name> (raw)
In-Reply-To: <1311689686-7451-1-git-send-email-dave.martin@linaro.org>

On Tue, Jul 26, 2011 at 03:14:46PM +0100, Dave Martin wrote:
> With the UM_SIGNAL alignment fault mode, no siginfo structure is
> passed to userspace.
> 
> POSIX specifies how siginfo_t should be populated for alignment
> faults, so this patch does just that:
> 
>   * si_signo = SIGBUS
>   * si_code = BUS_ADRALN
>   * si_addr = address of the faulted instruction
> 
> Signed-off-by: Dave Martin <dave.martin@linaro.org>

Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name>

> ---
>  arch/arm/mm/alignment.c |   14 +++++++++++---
>  1 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
> index 724ba3b..9a65aaf 100644
> --- a/arch/arm/mm/alignment.c
> +++ b/arch/arm/mm/alignment.c
> @@ -22,6 +22,7 @@
>  #include <linux/sched.h>
>  #include <linux/uaccess.h>
>  
> +#include <asm/system.h>
>  #include <asm/unaligned.h>
>  
>  #include "fault.h"
> @@ -883,9 +884,16 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>  	if (ai_usermode & UM_FIXUP)
>  		goto fixup;
>  
> -	if (ai_usermode & UM_SIGNAL)
> -		force_sig(SIGBUS, current);
> -	else {
> +	if (ai_usermode & UM_SIGNAL) {
> +		siginfo_t si;
> +
> +		si.si_signo = SIGBUS;
> +		si.si_errno = 0;
> +		si.si_code = BUS_ADRALN;
> +		si.si_addr = (void __user *)instruction_pointer(regs);
> +
> +		force_sig_info(si.si_signo, &si, current);
> +	} else {
>  		/*
>  		 * We're about to disable the alignment trap and return to
>  		 * user space.  But if an interrupt occurs before actually
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
 Kirill A. Shutemov

  parent reply	other threads:[~2011-07-26 20:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26 14:14 [PATCH 1/2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Dave Martin
2011-07-26 14:16 ` Dave Martin
2011-07-26 16:29 ` Kirill A. Shutemov
2011-07-26 17:16   ` Dave Martin
2011-07-26 17:48     ` Kirill A. Shutemov
2011-07-26 20:18 ` Kirill A. Shutemov [this message]
2011-07-26 20:34 ` Nicolas Pitre

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=20110726201858.GA6322@shutemov.name \
    --to=kirill@shutemov.name \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.