Chuck Silvers | 2 Jul 2008 17:09
Favicon

Re: [ARM32] panic when sshd responding

On Thu, Jun 19, 2008 at 10:08:25AM -0700, Matt Thomas wrote:
> On Jun 19, 2008, at 9:55 AM, Chris Gilbert wrote:
>> On Thu, June 19, 2008 10:49 am, Andy Shevchenko wrote:
>>> The last patch is wrong. There is some kind of lucky.
>>
>> Yes, it is :)  I discussed this with Matt, and we think the issue is that
>> pmap_kenter_pa is being a bit too paranoid in trying to avoid cache alias
>> issues.  And that's what the KASSERT is trying to detect.
>>
>> We think the right thing to do is assert there are no managed writeable
>> mappings (which there shouldn't be as the loan switches the pages to read
>> only, and so flushes the data & write back cache)
>
> Upon further thought, I think the socket loan code should use
> pmap_enter/pmap_remove instead pmap_kenter_pa/pmap_kremove.

I think the thinking already moved away from this idea, but just in case...

pages loaned to the kernel must be mapped with pmap_kenter_pa()
so that if the page is freed from its original object or anon,
the pmap_page_protect(VM_PROT_NONE) call that happens in that path
doesn't remove the kernel's mapping of the page.

-Chuck

Chris Gilbert | 2 Jul 2008 23:43
Picon

converting SWIs to pass swi number in a register.

Hi,

I was wondering if anyone had an opinion on switching to passing the SWI 
  number into syscall.  I know Linux did this a while back.

I think it particularly makes sense for processors with seperate 
instruction and data caches, as it save taking a data cache miss for 
every SWI call.

Looking at the current code and our current ABI, I'm thinking we could 
use ip (r12) to pass the SWI to the kernel, eg SYSTRAP becomes similar 
to this:
#define SYSTRAP(x)      \
                         mov r12, # ((SYS_ ## x) & 0xff) ;\
                         add r12, r12, #((SYS_ ## x) & 0xff00) ;\
                         swi SWI_OS_NETBSD | SYS_ ## x

Note I thinking we can probably a bit of tweaking to remove an 
instruction count if the swi is < 256

This would allow a post 5.0 kernel to only need to look at the r12/ip to 
work out the SWI call.

Thoughts?

Thanks,
Chris

Matt Thomas | 3 Jul 2008 07:41

Re: converting SWIs to pass swi number in a register.


On Jul 2, 2008, at 2:43 PM, Chris Gilbert wrote:

> Hi,
>
> I was wondering if anyone had an opinion on switching to passing  
> the SWI  number into syscall.  I know Linux did this a while back.
>
> I think it particularly makes sense for processors with seperate  
> instruction and data caches, as it save taking a data cache miss  
> for every SWI call.
>
> Looking at the current code and our current ABI, I'm thinking we  
> could use ip (r12) to pass the SWI to the kernel, eg SYSTRAP  
> becomes similar to this:
> #define SYSTRAP(x)      \
>                         mov r12, # ((SYS_ ## x) & 0xff) ;\
>                         add r12, r12, #((SYS_ ## x) & 0xff00) ;\
>                         swi SWI_OS_NETBSD | SYS_ ## x
>
> Note I thinking we can probably a bit of tweaking to remove an  
> instruction count if the swi is < 256
>
> This would allow a post 5.0 kernel to only need to look at the r12/ 
> ip to work out the SWI call.

I'm already doing that for the THUMB SWI where syscall # > 255.
One question is how do we know we are using ip?  Think binary
compat with older binaries...

(Continue reading)

Chris Gilbert | 3 Jul 2008 08:35
Picon

Re: converting SWIs to pass swi number in a register.

Matt Thomas wrote:
> 
> On Jul 2, 2008, at 2:43 PM, Chris Gilbert wrote:
> 
>> Hi,
>>
>> I was wondering if anyone had an opinion on switching to passing the
>> SWI  number into syscall.  I know Linux did this a while back.
>>
>> I think it particularly makes sense for processors with seperate
>> instruction and data caches, as it save taking a data cache miss for
>> every SWI call.
>>
>> Looking at the current code and our current ABI, I'm thinking we could
>> use ip (r12) to pass the SWI to the kernel, eg SYSTRAP becomes similar
>> to this:
>> #define SYSTRAP(x)      \
>>                         mov r12, # ((SYS_ ## x) & 0xff) ;\
>>                         add r12, r12, #((SYS_ ## x) & 0xff00) ;\
>>                         swi SWI_OS_NETBSD | SYS_ ## x
>>
>> Note I thinking we can probably a bit of tweaking to remove an
>> instruction count if the swi is < 256
>>
>> This would allow a post 5.0 kernel to only need to look at the r12/ip
>> to work out the SWI call.
> 
> I'm already doing that for the THUMB SWI where syscall # > 255.
> One question is how do we know we are using ip?  Think binary
> compat with older binaries...
(Continue reading)

Chris Gilbert | 3 Jul 2008 11:15
Picon

Re: converting SWIs to pass swi number in a register.

Richard Earnshaw wrote:
> On Wed, 2008-07-02 at 22:41 -0700, Matt Thomas wrote:
>> On Jul 2, 2008, at 2:43 PM, Chris Gilbert wrote:
>>> This would allow a post 5.0 kernel to only need to look at the r12/ 
>>> ip to work out the SWI call.
>> I'm already doing that for the THUMB SWI where syscall # > 255.
>> One question is how do we know we are using ip?  Think binary
>> compat with older binaries...
>>
> 
> Use 0 in the SWI # field (as linux does).  You only need to look in the
> SWI field if you have a relevant COMPAT_.. enabled.

And if we find 0 look at the register?  I had hoped to cheat for now and
not do the kernel side change, just setup userland to do the right
thing, but that's just laziness on my part :)  But then the kernel work
is quite small really.

> Overall I think this would be a good move (with potential performance
> boost), but probably should be combined with a move to the AEABI as
> well...

That was something I suggested doing when we do a libc major (which is
expected when time_t becomes 64bit.)  I was hoping to sneak this in so
that come the release after 5.0 we can make use of this...

> BTW, AFAICT linux uses r7 for the syscall number, since Thumb finds it
> very hard to set up r12.

Yes it does, I was thinking about how to avoid stacking r7, and r12
(Continue reading)

Martin Guy | 3 Jul 2008 11:22
Picon
Favicon

Re: converting SWIs to pass swi number in a register.

On 7/2/08, Chris Gilbert <chris <at> dokein.co.uk> wrote:
>  I was wondering if anyone had an opinion on switching to passing the SWI
> number into syscall.  I know Linux did this a while back.

Sort of. It was slipped in with the recent binary-incompatible change
from old-ABI to EABI, but most systems still use the old mechanism.
For details see wiki.debian.org/ArmEabiPort at the second half of
section "System Call Interface".

>  I think it particularly makes sense for processors with seperate
> instruction and data caches, as it save taking a data cache miss for every
> SWI call.

indeed. Another option is to make a new BSD arm port and change to use
EABI, now that most of the GCC, binutils, glibc etc work is stable.
That also allows you to link soft-float and hard-float code, allowing
you to distribute one set of generic soft-float libraries as binary
packages but also allowing people to compile their own code using the
various different FPUs that their ARM boards may have. However, it is
a lot of work - the amount of earth-moving is roughly equivalent to a
new machine port. (I know, I moved a lot of that earth in 2006 and
this year...)

    M

Richard Earnshaw | 3 Jul 2008 11:45
Favicon

Re: converting SWIs to pass swi number in a register.

On Thu, 2008-07-03 at 10:15 +0100, Chris Gilbert wrote:
> Richard Earnshaw wrote:
> > On Wed, 2008-07-02 at 22:41 -0700, Matt Thomas wrote:
> >> On Jul 2, 2008, at 2:43 PM, Chris Gilbert wrote:
> >>> This would allow a post 5.0 kernel to only need to look at the r12/ 
> >>> ip to work out the SWI call.
> >> I'm already doing that for the THUMB SWI where syscall # > 255.
> >> One question is how do we know we are using ip?  Think binary
> >> compat with older binaries...
> >>
> > 
> > Use 0 in the SWI # field (as linux does).  You only need to look in the
> > SWI field if you have a relevant COMPAT_.. enabled.
> 
> And if we find 0 look at the register? 

Yes.

>  I had hoped to cheat for now and
> not do the kernel side change, just setup userland to do the right
> thing, but that's just laziness on my part :)  But then the kernel work
> is quite small really.
> 
> > Overall I think this would be a good move (with potential performance
> > boost), but probably should be combined with a move to the AEABI as
> > well...
> 
> That was something I suggested doing when we do a libc major (which is
> expected when time_t becomes 64bit.)  I was hoping to sneak this in so
> that come the release after 5.0 we can make use of this...
(Continue reading)

Martin Guy | 3 Jul 2008 11:54
Picon
Favicon

Re: converting SWIs to pass swi number in a register.

On 7/3/08, Chris Gilbert <chris <at> dokein.co.uk> wrote:
> Richard Earnshaw wrote:
>  > On Wed, 2008-07-02 at 22:41 -0700, Matt Thomas wrote:
>  >> One question is how do we know we are using ip?  Think binary
>  >> compat with older binaries...
>  >
>  > Use 0 in the SWI # field (as linux does).  You only need to look in the
>  > SWI field if you have a relevant COMPAT_.. enabled.
>
>  And if we find 0 look at the register?

But if you always have to check for SWI  0 before looking in the
register, then you have to inspect the instruction stream with a data
access for every SWI anyway and lose the whole point of doing this!
  Linux does this for "old-abi compatability under EABI mode", but you
lose the syscall speed advantage - which seems to be the only reason
for making this change in BSD.

   M

    M

Richard Earnshaw | 3 Jul 2008 10:39
Favicon

Re: converting SWIs to pass swi number in a register.

On Wed, 2008-07-02 at 22:41 -0700, Matt Thomas wrote:
> On Jul 2, 2008, at 2:43 PM, Chris Gilbert wrote:
> 
> > Hi,
> >
> > I was wondering if anyone had an opinion on switching to passing  
> > the SWI  number into syscall.  I know Linux did this a while back.
> >
> > I think it particularly makes sense for processors with seperate  
> > instruction and data caches, as it save taking a data cache miss  
> > for every SWI call.
> >
> > Looking at the current code and our current ABI, I'm thinking we  
> > could use ip (r12) to pass the SWI to the kernel, eg SYSTRAP  
> > becomes similar to this:
> > #define SYSTRAP(x)      \
> >                         mov r12, # ((SYS_ ## x) & 0xff) ;\
> >                         add r12, r12, #((SYS_ ## x) & 0xff00) ;\
> >                         swi SWI_OS_NETBSD | SYS_ ## x
> >
> > Note I thinking we can probably a bit of tweaking to remove an  
> > instruction count if the swi is < 256
> >
> > This would allow a post 5.0 kernel to only need to look at the r12/ 
> > ip to work out the SWI call.
> 
> I'm already doing that for the THUMB SWI where syscall # > 255.
> One question is how do we know we are using ip?  Think binary
> compat with older binaries...
> 
(Continue reading)

Martin Guy | 3 Jul 2008 12:02
Picon
Favicon

Re: converting SWIs to pass swi number in a register.

On 7/3/08, Richard Earnshaw <rearnsha <at> arm.com> wrote:
>  Use 0 in the SWI # field (as linux does).  You only need to look in the
>  SWI field if you have a relevant COMPAT_.. enabled.

Der. Of course you are right

   M


Gmane