Re: [PATCH v2 2/2] libbsp/arm: Fix the local interrupt mask disable/enable calls.

2016-08-16 Thread Pavel Pisa
Hello Chris and Sebastian,

On Tuesday 16 of August 2016 07:55:57 Sebastian Huber wrote:
> On 16/08/16 07:45, Chris Johns wrote:
> > ---
> >   c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c
> > b/c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c index
> > f650009..cfad45f 100644
> > --- a/c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c
> > +++ b/c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c
> > @@ -88,10 +88,10 @@ uint32_t arm_cp15_set_translation_table_entries(
> > rtems_interrupt_level level;
> > uint32_t section_flags_of_first_entry;
> >
> > -  rtems_interrupt_disable(level);
> > +  rtems_interrupt_local_disable(level);
> > section_flags_of_first_entry =
> >   set_translation_table_entries(begin, end, section_flags);
> > -  rtems_interrupt_enable(level);
> > +  rtems_interrupt_local_enable(level);
> >
> > return section_flags_of_first_entry;
> >   }
>
> We should only change this if this is known to work on SMP.

My analysis for this concrete case,

1) RTEMS uses same MMU table for all CPUs.
2) inner set_translation_table_entries() ensures that change
   is visible to all CPUs
3) when arm_cp15_set_translation_table_entries() is called for range
   which is not (yet) accessed by other CPU(s) then the function should
   not cause any breakage
4) when change is requested for same range in parallel/twice from multiple
   threads or even CPUs then  it is indication of some more serious problem
   in upper layers
5) if the update of mapping is requested for some range from cached to
   uncached for example then it is not enough to protect
   arm_cp15_set_translation_table_entries() alone. Protection
   of necessary cache flush and invalidation is required in addition.


So generally, there is almost no difference between case when there is
no protection or weak protection by rtems_interrupt_local_disable().
May it be that there can be some difference if operation
ttb [i] = addr | section_flags;
is translated by multiple memory accesses by C compiler (highly improbable).

If the dynamic MMU operations/virtual space allocations are needed
like in multiprocess OS then MMU table changes needs to be protected
by spinlock or better semaphore (to not cause block of other tasks).

So I agree that simple change of rtems_interrupt_disable(level)
to rtems_interrupt_local_disable(level) is not perfect but on the other
hand real situation is not changed. In the fact, it would worth
to change protection to MMU context semaphore.

So generally, I am unsure what is preferred solution for now.

By the way, is there some defined function/way to check if RTEMS
executive reached switch to multitasking mode?
I would like to protect VideoCore operations with mutex/semaphore
but these operations has to be accessible even from bsp_start_hook_0 or 1
before core is ready. So I would like to skip mutex/semaphore operations
if functions are called during early initialization.

May it be that same concept should be used for MMU operations
serialization.

Best wishes,

  Pavel



___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


undefined left-shift of negative integer

2016-08-16 Thread Gedare Bloom
I stumbled across some lurking undefined behavior. In score/status.h:81 we have
STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD )
where PTHREAD_BARRIER_SERIAL_THREAD is defined to -1. This causes ( -1
) << 8 which is undefined behavior.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 0/3] POSIX Shared Memory Objects

2016-08-16 Thread Gedare Bloom
These patches start to add support for POSIX Shared Memory Objects, see
http://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html
This support aims to improve POSIX compliance.

The approach taken is to use the existing score Object as the basis
for each shm object, where the Object.Name field directly relates to
the name provided to shm_open(). So far the support for shm_open and
ftruncate have been included.

Support is needed for close() and shm_unlink().

A test is added based on some example code from an OS text book. This
test also uses mmap() and munmap() which should be added to support
mapping shared memory objects.

Gedare Bloom (3):
  posix: add test case for shared memory objects
  posix: shared memory support
  posix: implement shm_ftruncate with workspace

 cpukit/posix/Makefile.am  |   3 +
 cpukit/posix/include/rtems/posix/config.h |   5 +
 cpukit/posix/include/rtems/posix/shm.h|  66 
 cpukit/posix/include/rtems/posix/shmimpl.h|  90 ++
 cpukit/posix/preinstall.am|   8 +
 cpukit/posix/src/shm.c|  48 ++
 cpukit/posix/src/shmopen.c| 230 +-
 cpukit/rtems/src/rtemsobjectgetapiclassname.c |   1 +
 cpukit/sapi/include/confdefs.h|  28 
 cpukit/score/include/rtems/score/objectimpl.h |   5 +-
 cpukit/score/include/rtems/sysinit.h  |   1 +
 testsuites/psxtests/Makefile.am   |   4 +-
 testsuites/psxtests/configure.ac  |   1 +
 testsuites/psxtests/psxshm01/Makefile.am  |  22 +++
 testsuites/psxtests/psxshm01/init.c   |  91 ++
 testsuites/psxtests/psxshm01/psxshm01.scn |   0
 testsuites/psxtests/psxshm01/system.h |  29 
 testsuites/sptests/spsysinit01/init.c |  17 ++
 18 files changed, 641 insertions(+), 8 deletions(-)
 create mode 100644 cpukit/posix/include/rtems/posix/shm.h
 create mode 100644 cpukit/posix/include/rtems/posix/shmimpl.h
 create mode 100644 cpukit/posix/src/shm.c
 create mode 100644 testsuites/psxtests/psxshm01/Makefile.am
 create mode 100644 testsuites/psxtests/psxshm01/init.c
 create mode 100644 testsuites/psxtests/psxshm01/psxshm01.scn
 create mode 100644 testsuites/psxtests/psxshm01/system.h

-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 0/3] POSIX Shared Memory Objects

2016-08-16 Thread Chris Johns

On 17/08/2016 06:48, Gedare Bloom wrote:

These patches start to add support for POSIX Shared Memory Objects, see
http://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html
This support aims to improve POSIX compliance.


I cannot see any patches.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel