public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
* [patch][rfa]: SID mapper component - wordsize
@ 2003-02-13 23:58 Dave Brolley
  2003-02-14  2:52 ` Ben Elliston
  2003-02-14 19:09 ` Frank Ch. Eigler
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Brolley @ 2003-02-13 23:58 UTC (permalink / raw)
  To: sid

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Hi,

I ran across a problem with the scaling of the upper bound of a mapped 
range when the wordsize feature is used. The specification

[4*1000-1010]

should allow access to the range 4000-4043, however, the upper bound is 
simply being multiplied by the wordsize, resulting in an upper bound of 
4040. If the mapper is accessed using wordsized elements, the problem 
goes unnoticed, since the mapper does not check the ending address of 
the range being accessed. However, if the mapper is accessed one byte at 
a time (as GDB often does), the final 3 bytes are considered unmapped.

Attached is the patch which corrects this. OK to commit?

Dave

[-- Attachment #2: mapper-wordsize.patch.txt --]
[-- Type: text/plain, Size: 1511 bytes --]

Index: component/mapper/compMapper.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/mapper/compMapper.cxx,v
retrieving revision 1.12
diff -c -p -r1.12 compMapper.cxx
*** component/mapper/compMapper.cxx	11 Nov 2002 22:28:28 -0000	1.12
--- component/mapper/compMapper.cxx	13 Feb 2003 23:49:05 -0000
***************
*** 1,6 ****
  // compMapper.cxx - a bus mapper component.  -*- C++ -*-
  
! // Copyright (C) 1999-2002 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,6 ----
  // compMapper.cxx - a bus mapper component.  -*- C++ -*-
  
! // Copyright (C) 1999-2003 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** generic_mapper::make_name_mapping (const
*** 774,780 ****
    // scale all values by the word width
    record.mapped_base *= record.bytes_per_word;
    record.low    *= record.bytes_per_word;
!   record.high   *= record.bytes_per_word;
    record.stride *= record.bytes_per_word;
    record.width  *= record.bytes_per_word;
  
--- 774,780 ----
    // scale all values by the word width
    record.mapped_base *= record.bytes_per_word;
    record.low    *= record.bytes_per_word;
!   record.high   = (record.high + 1) * record.bytes_per_word - 1;
    record.stride *= record.bytes_per_word;
    record.width  *= record.bytes_per_word;
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa]: SID mapper component - wordsize
  2003-02-13 23:58 [patch][rfa]: SID mapper component - wordsize Dave Brolley
@ 2003-02-14  2:52 ` Ben Elliston
  2003-02-14 19:09 ` Frank Ch. Eigler
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Elliston @ 2003-02-14  2:52 UTC (permalink / raw)
  To: sid

>>>>> "Dave" == Dave Brolley <brolley@redhat.com> writes:

  Dave> Attached is the patch which corrects this. OK to commit?

Fine.  Please make sure that the documentation documents the right
behaviour (it probably does).

Ben

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa]: SID mapper component - wordsize
  2003-02-13 23:58 [patch][rfa]: SID mapper component - wordsize Dave Brolley
  2003-02-14  2:52 ` Ben Elliston
@ 2003-02-14 19:09 ` Frank Ch. Eigler
  2003-02-14 19:38   ` Dave Brolley
  1 sibling, 1 reply; 4+ messages in thread
From: Frank Ch. Eigler @ 2003-02-14 19:09 UTC (permalink / raw)
  To: Dave Brolley; +Cc: sid


brolley wrote:

> [...] The specification
> [4*1000-1010]
> should allow access to the range 4000-4043, however, the upper bound
> is simply being multiplied by the wordsize, resulting in an upper
> bound of 4040.

Actually, addresses in the mapper specs are inclusive, not exclusive.
That's why one often sees ranges ending with ...ffff.  Plain raw
scaling such inclusive limits doesn't make sense though, so a special
case calculation like yours would make sense.  However, care should be
taken not to confuse exclusive vs inclusive bounds.

> If the mapper is accessed using wordsized elements, the problem goes
> unnoticed, since the mapper does not check the ending address of the
> range being accessed.

That's a peculiar other bug.  To be consistent with the byte-oriented
addressing across sid::bus, the size of the access would need to be
included in the checks.


- FChE

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][rfa]: SID mapper component - wordsize
  2003-02-14 19:09 ` Frank Ch. Eigler
@ 2003-02-14 19:38   ` Dave Brolley
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Brolley @ 2003-02-14 19:38 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: sid



Frank Ch. Eigler wrote:

>brolley wrote:
>
>  
>
>>[...] The specification
>>[4*1000-1010]
>>should allow access to the range 4000-4043, however, the upper bound
>>is simply being multiplied by the wordsize, resulting in an upper
>>bound of 4040.
>>    
>>
>
>Actually, addresses in the mapper specs are inclusive, not exclusive.
>That's why one often sees ranges ending with ...ffff.  Plain raw
>scaling such inclusive limits doesn't make sense though, so a special
>case calculation like yours would make sense.  However, care should be
>taken not to confuse exclusive vs inclusive bounds.
>
Right. That's precisely what the patch does. It computes the intended 
inclusive bounds.

>>If the mapper is accessed using wordsized elements, the problem goes
>>unnoticed, since the mapper does not check the ending address of the
>>range being accessed.
>>    
>>
>
>That's a peculiar other bug.  To be consistent with the byte-oriented
>addressing across sid::bus, the size of the access would need to be
>included in the checks.
>  
>
That's a separate bug (wasn't sure if it was intentional or not) and an 
exercise for someone's copious spare time :-)

Dave


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-14 19:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 23:58 [patch][rfa]: SID mapper component - wordsize Dave Brolley
2003-02-14  2:52 ` Ben Elliston
2003-02-14 19:09 ` Frank Ch. Eigler
2003-02-14 19:38   ` Dave Brolley

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 read-only IMAP folder(s) and NNTP newsgroup(s).