All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Colin Cross <ccross@android.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ARM: vfp: Fix up exception location in Thumb mode
Date: Fri, 14 Jan 2011 16:23:12 +0000	[thread overview]
Message-ID: <1295022193.7901.56.camel@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <20110114154919.GE15996@n2100.arm.linux.org.uk>

On Fri, 2011-01-14 at 15:49 +0000, Russell King - ARM Linux wrote:
> On Fri, Jan 14, 2011 at 02:10:31PM +0000, Catalin Marinas wrote:
> > On Fri, 2011-01-14 at 12:02 +0000, Russell King - ARM Linux wrote:
> > > I don't think this is correct.  On entry to the undefined instruction
> > > handler, we get the uncorrected PC value, so PC points to the
> > > instruction after the faulting instruction.
> > >
> > > If it was an ARM instruction, that is located at PC-4.  If it was a
> > > Thumb instruction, it is located at PC-2.  This PC value is passed
> > > unmodified to the VFP entry code, and the passed r2 reflect the
> > > value in regs->ARM_pc.
> >
> > The entry-armv.S code adds 2 to the r2 register in case of a 32-bit
> > Thumb instruction, so it is no longer the same as the ARM_pc.
> 
> That's something that should be fixed - the entry conditions should be
> the same irrespective of thumb or arm encoding.

But in this case you have to fix the vfphw.S code to check for Thumb and
subtract 2 rather than 4 from r2.

> > Since the VFP instructions in Thumb mode are always 32-bit, Colin's
> > patch made sense to me.
> 
> I looked up the VADD instruction in the ARM ARM.  It has both a 16-bit
> and 32-bit encoding.

Are you sure? The Thumb encoding is made up of two 16-bit values but it
is still 32-bit in total.

> > > I think that the undefined instruction handling needs reworking for
> > > Thumb entirely as we could be dealing with a 16-bit or 32-bit thumb
> > > instruction, and we have no way of knowing without repeatedly
> > > decoding that instruction.
> >
> > We already handle the r2 for in __und_usr. We don't deal with ARM_pc but
> > we could either do it in __und_usr or let the code handling the undef
> > fix it up.
> 
> At the moment its just confusing as things stand, as some things are
> changed in one place and not the other.  Let's kill the pointless
> addition of 2 in the undefined instruction handler so that in every
> case we enter handlers with r2 == regs->ARM_pc, and regs->ARM_pc
> as per the ARM ARM undefined exception entry LR.
> 
> Undefined instruction exception handlers can then rely on the meaning
> of both of these.

That's an alternative, though we may end up with checking the encoding
twice. The Undef handler already reads the instruction opcode and it
needs to know whether it is a 16 or a 32-bit wide instruction.

But I agree that the current implementation is a bit confusing.

-- 
Catalin



WARNING: multiple messages have this Message-ID (diff)
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: vfp: Fix up exception location in Thumb mode
Date: Fri, 14 Jan 2011 16:23:12 +0000	[thread overview]
Message-ID: <1295022193.7901.56.camel@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <20110114154919.GE15996@n2100.arm.linux.org.uk>

On Fri, 2011-01-14 at 15:49 +0000, Russell King - ARM Linux wrote:
> On Fri, Jan 14, 2011 at 02:10:31PM +0000, Catalin Marinas wrote:
> > On Fri, 2011-01-14 at 12:02 +0000, Russell King - ARM Linux wrote:
> > > I don't think this is correct.  On entry to the undefined instruction
> > > handler, we get the uncorrected PC value, so PC points to the
> > > instruction after the faulting instruction.
> > >
> > > If it was an ARM instruction, that is located at PC-4.  If it was a
> > > Thumb instruction, it is located at PC-2.  This PC value is passed
> > > unmodified to the VFP entry code, and the passed r2 reflect the
> > > value in regs->ARM_pc.
> >
> > The entry-armv.S code adds 2 to the r2 register in case of a 32-bit
> > Thumb instruction, so it is no longer the same as the ARM_pc.
> 
> That's something that should be fixed - the entry conditions should be
> the same irrespective of thumb or arm encoding.

But in this case you have to fix the vfphw.S code to check for Thumb and
subtract 2 rather than 4 from r2.

> > Since the VFP instructions in Thumb mode are always 32-bit, Colin's
> > patch made sense to me.
> 
> I looked up the VADD instruction in the ARM ARM.  It has both a 16-bit
> and 32-bit encoding.

Are you sure? The Thumb encoding is made up of two 16-bit values but it
is still 32-bit in total.

> > > I think that the undefined instruction handling needs reworking for
> > > Thumb entirely as we could be dealing with a 16-bit or 32-bit thumb
> > > instruction, and we have no way of knowing without repeatedly
> > > decoding that instruction.
> >
> > We already handle the r2 for in __und_usr. We don't deal with ARM_pc but
> > we could either do it in __und_usr or let the code handling the undef
> > fix it up.
> 
> At the moment its just confusing as things stand, as some things are
> changed in one place and not the other.  Let's kill the pointless
> addition of 2 in the undefined instruction handler so that in every
> case we enter handlers with r2 == regs->ARM_pc, and regs->ARM_pc
> as per the ARM ARM undefined exception entry LR.
> 
> Undefined instruction exception handlers can then rely on the meaning
> of both of these.

That's an alternative, though we may end up with checking the encoding
twice. The Undef handler already reads the instruction opcode and it
needs to know whether it is a 16 or a 32-bit wide instruction.

But I agree that the current implementation is a bit confusing.

-- 
Catalin

  reply	other threads:[~2011-01-14 16:23 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14  7:42 [PATCH] ARM: vfp: Fix up exception location in Thumb mode Colin Cross
2011-01-14  7:42 ` Colin Cross
2011-01-14 11:43 ` Catalin Marinas
2011-01-14 11:43   ` Catalin Marinas
2011-01-14 12:02   ` Russell King - ARM Linux
2011-01-14 12:02     ` Russell King - ARM Linux
2011-01-14 14:10     ` Catalin Marinas
2011-01-14 14:10       ` Catalin Marinas
2011-01-14 15:49       ` Russell King - ARM Linux
2011-01-14 15:49         ` Russell King - ARM Linux
2011-01-14 16:23         ` Catalin Marinas [this message]
2011-01-14 16:23           ` Catalin Marinas
2011-01-14 16:35           ` Russell King - ARM Linux
2011-01-14 16:35             ` Russell King - ARM Linux
2011-01-14 16:58             ` Catalin Marinas
2011-01-14 16:58               ` Catalin Marinas
2011-01-14 17:30               ` Russell King - ARM Linux
2011-01-14 17:30                 ` Russell King - ARM Linux
2011-01-14 18:47                 ` Russell King - ARM Linux
2011-01-14 18:47                   ` Russell King - ARM Linux
2011-01-14 19:23                   ` Colin Cross
2011-01-14 19:23                     ` Colin Cross
2011-01-14 19:51                     ` Colin Cross
2011-01-14 19:51                       ` Colin Cross
2011-01-14 21:24                       ` Russell King - ARM Linux
2011-01-14 21:24                         ` Russell King - ARM Linux
2011-01-25 23:33                       ` Colin Cross
2011-01-25 23:33                         ` Colin Cross
2011-01-26 11:26                         ` Russell King - ARM Linux
2011-01-26 11:26                           ` Russell King - ARM Linux
2011-01-27  6:11                           ` Colin Cross
2011-01-27  6:11                             ` Colin Cross
2011-01-27  6:35                             ` Colin Cross
2011-01-27  6:35                               ` Colin Cross
2011-01-27  7:30                               ` Colin Cross
2011-01-27  7:30                                 ` Colin Cross
2011-02-09 18:12                                 ` Colin Cross
2011-02-09 18:12                                   ` Colin Cross
2011-01-15 15:38                   ` Catalin Marinas
2011-01-15 15:38                     ` Catalin Marinas
2011-01-15 15:43                     ` Russell King - ARM Linux
2011-01-15 15:43                       ` Russell King - ARM Linux
2011-01-16 11:51                       ` Catalin Marinas
2011-01-16 11:51                         ` Catalin Marinas
2011-01-15 15:31                 ` Catalin Marinas
2011-01-15 15:31                   ` Catalin Marinas
2011-01-15 15:40                   ` Russell King - ARM Linux
2011-01-15 15:40                     ` Russell King - ARM Linux
2011-01-16 11:49                     ` Catalin Marinas
2011-01-16 11:49                       ` Catalin Marinas
2011-01-23 15:51                       ` Russell King - ARM Linux
2011-01-23 15:51                         ` Russell King - ARM Linux
2011-01-25 13:19                         ` Catalin Marinas
2011-01-25 13:19                           ` Catalin Marinas
2011-01-16 21:25                     ` Catalin Marinas
2011-01-16 21:25                       ` Catalin Marinas
2011-01-23 15:46                       ` Russell King - ARM Linux
2011-01-23 15:46                         ` Russell King - ARM Linux
2011-01-25 13:45                         ` Catalin Marinas
2011-01-25 13:45                           ` Catalin Marinas
2011-01-14 16:24       ` Dave Martin
2011-01-14 16:24         ` Dave Martin
2011-01-14 16:52         ` Russell King - ARM Linux
2011-01-14 16:52           ` Russell King - ARM Linux

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=1295022193.7901.56.camel@e102109-lin.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=ccross@android.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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.