All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, gleb@redhat.com
Subject: Re: [PATCH 9/9] arm: add vectors support
Date: Sun, 20 Oct 2013 18:35:34 +0200	[thread overview]
Message-ID: <20131020163533.GA2072@hawk.usersys.redhat.com> (raw)
In-Reply-To: <20131017185843.GQ24837@cbox>

On Thu, Oct 17, 2013 at 11:58:43AM -0700, Christoffer Dall wrote:
> On Thu, Oct 17, 2013 at 12:38:59PM +0200, Andrew Jones wrote:
> > On Wed, Oct 16, 2013 at 06:06:42PM -0700, Christoffer Dall wrote:
> > > > +++ b/arm/cstart.S
> > > > @@ -1,5 +1,6 @@
> > > >  
> > > >  #define CR_B	(1 << 7)
> > > > +#define CR_V	(1 << 13)
> > > >  
> > > >  .arm
> > > >  
> > > > @@ -12,6 +13,13 @@ start:
> > > >  	push	{ r0-r3 }		@push r3 too for 8-byte alignment
> > > >  
> > > >  	mrc	p15, 0, r8, c1, c0, 0	@r8 = sctrl
> > > > +
> > > > +	/* set up vector table */
> > > > +	bic	r8, #CR_V		@sctrl.V = 0
> > > > +	mcr	p15, 0, r8, c1, c0, 0
> > > > +	ldr	r0, =vector_table	@vbar = vector_table
> > > > +	mcr     p15, 0, r0, c12, c0, 0
> > > > +
> > > >  	bl	get_endianness
> > > >  	bl	io_init
> > > >  
> > > > @@ -41,6 +49,44 @@ halt:
> > > >  1:	wfi
> > > >  	b	1b
> > > >  
> > > > +vector_common:
> > > > +	add	r2, sp, #(14 * 4)
> > > 
> > > this looks weird, what are you pointing to here?
> > 
> > What sp was at the time of exception. So if you look at ex_regs->sp,
> > then you'll see what sp was when the exception occurred, not that plus
> > what we're pushing on now for the handler.
> > 
> 
> Hmmm, so you're assuming that all exceptions will be taken from SVC
> mode?  I assume we will run tests in more than SVC mode, no?
> 
> Also note that the lr you're pushing here is not the lr at the time the
> exception occurs, but the return address from the exception.  If the SVC
> instruction is executed from SVC mode, the original lr is lost iirc, and
> the caller needs to save it.  If you're from user mode, something like
> 
>     stm sp, {r0-lr}^
> 
> will take care of this for you, and if you're from svc
> mode, you may want consider doing something like
> 
>     push {sp, lr}
>     push {r0-r12}
> 
> instead (assuming this is only ever compiled in ARM mode, not Thumb2, in
> which case the whole thing gets more complicated.

I think the lr pushing should be ok. That part is done in the macro that
all vectors start with.  It got snipped from this mail, so here it is

.macro m_vector, v
	push    { r0-r12,lr }
	mov     r1, \v
	b       vector_common
.endm

I realize it may still not be correct, just as the calculated sp
may not be correct, depending on which mode,vector combo is used,
but I was expecting to have different paths in the C code for
fixing it up. Although that said, I haven't thought about it a
bunch yet, so maybe it won't work that way...

drew

  reply	other threads:[~2013-10-20 16:35 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 16:23 [PATCH 0/9] kvm-unit-tests/arm: initial drop Andrew Jones
2013-10-14 16:23 ` [PATCH 1/9] remove unused files Andrew Jones
2013-10-16 12:52   ` Gleb Natapov
2013-10-16 13:13     ` Alexander Graf
2013-10-16 13:13       ` Alexander Graf
2013-10-16 13:18     ` Andrew Jones
2013-10-14 16:23 ` [PATCH 2/9] makefile and run_tests tweaks Andrew Jones
2013-10-14 16:23 ` [PATCH 3/9] clean root dir of all x86-ness Andrew Jones
2013-10-17  1:06   ` Christoffer Dall
2013-10-17  9:35     ` Andrew Jones
2013-10-17 19:01       ` Christoffer Dall
2013-10-20 16:37         ` Andrew Jones
2013-10-14 16:23 ` [PATCH 4/9] Introduce a simple iomap structure Andrew Jones
2013-10-14 16:23 ` [PATCH 5/9] Add halt() and some error codes Andrew Jones
2013-10-14 16:23 ` [PATCH 6/9] Introduce virtio-testdev Andrew Jones
2013-10-15  8:39   ` Andrew Jones
2013-10-17  1:06   ` Christoffer Dall
2013-10-17  9:51     ` Andrew Jones
2013-10-17 19:01       ` Christoffer Dall
2013-10-17  1:06   ` Christoffer Dall
2013-10-14 16:23 ` [PATCH 7/9] arm: replace arbitrary divisions Andrew Jones
2013-10-17  1:06   ` Christoffer Dall
2013-10-17 10:03     ` Andrew Jones
2013-10-17 18:59       ` Christoffer Dall
2013-10-14 16:23 ` [PATCH 8/9] arm: initial drop Andrew Jones
2013-10-17  1:06   ` Christoffer Dall
2013-10-17 10:16     ` Andrew Jones
2013-10-17 13:28       ` Andrew Jones
2013-10-17 18:39         ` Christoffer Dall
2013-10-14 16:23 ` [PATCH 9/9] arm: add vectors support Andrew Jones
2013-10-17  1:06   ` Christoffer Dall
2013-10-17 10:38     ` Andrew Jones
2013-10-17 18:58       ` Christoffer Dall
2013-10-20 16:35         ` Andrew Jones [this message]
2013-10-21  9:59           ` Christoffer Dall
2013-11-20 23:06 ` [PATCH 0/9] kvm-unit-tests/arm: initial drop María Soler Heredia
2013-11-26 17:23   ` Andrew Jones
2013-12-29  9:24 ` Christoffer Dall
2014-01-02 18:56   ` Andrew Jones

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=20131020163533.GA2072@hawk.usersys.redhat.com \
    --to=drjones@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /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.