[PATCH] spec/cpukit: Omit Cortex-M from libdebugger build

2023-08-16 Thread Kinsey Moore
The current ARM support in libdebugger does not cover Cortex-M series
cores since it requires support for CP14 system register accessor
instructions. Cortex-M series cores support debug monitor mode, but its
configuration is accessed by memory mapped registers instead of using
CP14. This omits building libdebugger from BSPs that use a cortex-m ABI
flag.
---
 spec/build/cpukit/optlibdebugger.yml | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/spec/build/cpukit/optlibdebugger.yml 
b/spec/build/cpukit/optlibdebugger.yml
index 4cee9809f6..5ff67d6bd8 100644
--- a/spec/build/cpukit/optlibdebugger.yml
+++ b/spec/build/cpukit/optlibdebugger.yml
@@ -9,7 +9,15 @@ default: []
 description: ''
 enabled-by:
 - aarch64
-- arm
+- and:
+  - arm
+  - not: bsps/arm/atsam
+  - not: bsps/arm/imxrt
+  - not: bsps/arm/lm3s69xx
+  - not: bsps/arm/lpc176x
+  - not: bsps/arm/lpc24xx
+  - not: bsps/arm/stm32h7
+  - not: bsps/arm/stm32f4
 - i386
 - microblaze
 links: []
-- 
2.39.2

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


Re: libdl support for base image TLS variables

2023-08-16 Thread Gedare Bloom
On Mon, Aug 14, 2023 at 10:05 PM  wrote:
>
> These patches add support to rtems.git and rtems-tools.git to
> provide access to TLS variables in the base from loaded code.
> The changes contain the ground work to resolving #4920 which is
> a blocker for the release of 6.
>
> This change is required due to the regression in libdl due to the
> change in newlib to use TLS variables for reneterant data.
>
> The rtems.git patch can be applied before the rtems-tools.git
> patch. If the tools are updated and the libdl code is not present
> the tests fail with linker errors. If the tools change is
> not present the test will link but it will continue to fail.
>
> The currently supported archs that build are:
>
>  - aarch64
>  - arm
>  - powerpc
>  - sparc
>
> The follow are to be completed and do not build:
>
>  - bfin
>  - i386
>  - lm32
>  - m68k
>  - mips
>  - moxie
>  - riscv
>  - v850
>
> We need to add support for these architectures if they support TLS.
>
We are deprecating v850. It might be worth considering whether some of
these other architectures should also be deprecated, especially if no
one is able/willing to add TLS for them.

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

Re: [PATCH] libdl: Add support to import base image TLS symbols

2023-08-16 Thread Gedare Bloom
On Mon, Aug 14, 2023 at 10:05 PM  wrote:
>
> From: Chris Johns 
>
> This change requires an rtems-tools update for symbol generation.
>
> Working architectures:
>  - aarch64
>  - arm
>  - powerpc
>  - sparc
>
> Updates #4920
> ---
>  cpukit/include/rtems/rtl/rtl-sym.h |  23 -
>  cpukit/include/rtems/rtl/rtl.h |   6 +-
>  cpukit/libdl/rtl-elf.c |  20 +++-
>  cpukit/libdl/rtl-mdreloc-aarch64.c |   6 +-
>  cpukit/libdl/rtl-mdreloc-arm.c |   3 +-
>  cpukit/libdl/rtl-mdreloc-powerpc.c |  18 +++-
>  cpukit/libdl/rtl-mdreloc-sparc.c   | 152 -
>  cpukit/libdl/rtl-sym.c |  36 ++-
>  cpukit/libdl/rtl-tls.c | 111 +
>  cpukit/libdl/rtl-tls.h |  51 ++
>  cpukit/libdl/rtl.c |   6 +-
>  spec/build/cpukit/objdl.yml|   1 +
>  testsuites/libtests/dl11/dl-load.c |  27 -
>  13 files changed, 408 insertions(+), 52 deletions(-)
>  create mode 100644 cpukit/libdl/rtl-tls.c
>  create mode 100644 cpukit/libdl/rtl-tls.h
>
> diff --git a/cpukit/include/rtems/rtl/rtl-sym.h 
> b/cpukit/include/rtems/rtl/rtl-sym.h
> index 0d29a6ae40..9eef9a1b7b 100644
> --- a/cpukit/include/rtems/rtl/rtl-sym.h
> +++ b/cpukit/include/rtems/rtl/rtl-sym.h
> @@ -62,6 +62,22 @@ typedef struct rtems_rtl_symbols
>size_t   nbuckets;
>  } rtems_rtl_symbols;
>
> +/**
> + * A TLS variable offset call. There is one per base image TLS
> + * variable.
> + */
> +typedef size_t (*rtems_tls_offset_func)(void);
> +
rtems_tls_xxx is a new naming prefix. Is this stuff only specific to
rtl? should be rtems_rtl_tls_...?

or, do we need to add a new tls header file and interface for this
stuff, in case it would be needed outside of the rtl?

> +/**
> + * A TLS symbol offset entry. It is used with an exported symbol table
> + * to find a TSL table offset for a variable at runtime.
s/TSL/TLS

> + */
> +typedef struct rtems_tls_offset
> +{
> +  size_tindex;  /** exported symbol table index */
> +  rtems_tls_offset_func offset; /** TLS offset function */
> +} rtems_tls_offset;
> +
>  /**
>   * Open a symbol table with the specified number of buckets.
>   *
> @@ -101,10 +117,15 @@ void rtems_rtl_symbol_table_close (rtems_rtl_symbols* 
> symbols);
>   * @param obj The object table the symbols are for.
>   * @param esyms The exported symbol table.
>   * @param size The size of the table in bytes.
> + * @param tls_offsets The TLS offsets table. If NULL none provided.
> + * @param tls_size The number TLS offset entries in the table..
two periods, "number of"

> +
extra blank line

>   */
>  bool rtems_rtl_symbol_global_add (rtems_rtl_obj*   obj,
>const unsigned char* esyms,
> -  unsigned int size);
> +  unsigned int size,
> +  rtems_tls_offset*tls_offsets,
> +  unsigned int tls_size);
>
>  /**
>   * Find a symbol given the symbol label in the global symbol table.
> diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h
> index 0fd4e74cdf..aaaeb7b592 100644
> --- a/cpukit/include/rtems/rtl/rtl.h
> +++ b/cpukit/include/rtems/rtl/rtl.h
> @@ -393,9 +393,13 @@ bool rtems_rtl_path_prepend (const char* path);
>   *
>   * @param esyms The exported symbol table.
>   * @param count The size of the exported symbol table.
> + * @param tls_offsets The TLS offsets table. If NULL none provided.
> + * @param tls_size The number TLS offset entries in the table..
two periods

>   */
>  void rtems_rtl_base_sym_global_add (const unsigned char* esyms,
> -unsigned int count);
> +unsigned int count,
> +rtems_tls_offset*tls_offsets,
> +unsigned int tls_size);
>
>  /**
>   * Return the object file descriptor for the base image. The object file
> diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c
> index 5754070518..b46d2ac3a0 100644
> --- a/cpukit/libdl/rtl-elf.c
> +++ b/cpukit/libdl/rtl-elf.c
> @@ -178,12 +178,19 @@ rtems_rtl_elf_find_symbol (rtems_rtl_obj*  obj,
>
>/*
> * If the symbol type is STT_NOTYPE the symbol references a global
> -   * symbol. The gobal symbol table is searched to find it and that value
> +   * symbol. The global symbol table is searched to find it and that value
> * returned. If the symbol is local to the object module the section for 
> the
> * symbol is located and it's base added to the symbol's value giving an
> * absolute location.
> +   *
> +   * If the symbols type of TLS return the symbols value. It is the
> +   * offset from the thread's TLS area base. The offset is set by the
> +   * linker for the base image and by the TLS allocator for loaded
> +   * modules. There is no sectio

[PATCH rtems-tools] tester/report: Apply test excludes to fatal-error

2023-08-16 Thread Kinsey Moore
Before the fatal-error test result type was introduced, minimum.exe was
classified as an invalid test since it lacked a proper test header and
trailer. This applies the test exclusions to all test states to avoid
this happening again in the future.
---
 tester/rt/report.py | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tester/rt/report.py b/tester/rt/report.py
index a688dc8..5c369e6 100644
--- a/tester/rt/report.py
+++ b/tester/rt/report.py
@@ -192,7 +192,11 @@ class report(object):
 if tools != self.config['tools']:
 state = 'WRONG_TOOLS'
 if state is None or state == 'EXPECTED_PASS':
-if start and end:
+exe_name = path.basename(name).split('.')[0]
+if exe_name in test_fail_excludes:
+status = 'passed'
+self.passed += 1
+elif start and end:
 if state is None or state == 'EXPECTED_PASS':
 status = 'passed'
 self.passed += 1
@@ -210,13 +214,8 @@ class report(object):
 status = 'failed'
 self.failed += 1
 else:
-exe_name = path.basename(name).split('.')[0]
-if exe_name in test_fail_excludes:
-status = 'passed'
-self.passed += 1
-else:
-status = 'invalid'
-self.invalids += 1
+status = 'invalid'
+self.invalids += 1
 else:
 if state == 'EXPECTED_FAIL':
 if start and end:
-- 
2.39.2

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


Re: [PATCH 0/2 v3] Refactor the aarch64/raspberryp4b BSP

2023-08-16 Thread Utkarsh Verma
A gentle reminder for this patch.

On Thu, Aug 10, 2023 at 11:45 AM Utkarsh Verma 
wrote:

> A gentle reminder for this. Please let me know which changes are required
> so that I can send the next set of patches as well.
>
> On Wed, Aug 9, 2023 at 9:20 AM Utkarsh Verma 
> wrote:
>
>> Changes can also be seen on my fork:
>> https://github.com/UtkarshVerma/rtems/tree/refactor
>>
>> On Wed, Aug 9, 2023 at 9:18 AM Utkarsh Verma 
>> wrote:
>>
>>> This patch series refactors the BSP and build spec for Raspberry Pi 4B
>>> with the following goals in mind:
>>>
>>> - IWYU(include what you use) includes
>>> - Modularity in BSP and the build spec
>>> - Strict MMU mapping
>>>
>>> This is my first code contribution to RTEMS, therefore suggestions of
>>> any kind would be highly appreciated.
>>>
>>> Regards,
>>> Utkarsh
>>>
>>> Utkarsh Verma (2):
>>>   bsps/aarch64/raspberrypi: Refactor the BSP
>>>   build: Modularize the aarch64/raspberrypi spec
>>>
>>>  bsps/aarch64/raspberrypi/console/console.c|  39 +-
>>>  bsps/aarch64/raspberrypi/include/bsp.h|  37 +-
>>>  .../aarch64/raspberrypi/include/bsp/bcm2711.h |  96 
>>>  bsps/aarch64/raspberrypi/include/bsp/irq.h| 102 ++--
>>>  .../raspberrypi/include/bsp/raspberrypi.h | 471 --
>>>  .../include/bsp/start/bspstartmmu.h   |  45 ++
>>>  bsps/aarch64/raspberrypi/include/tm27.h   |   5 +-
>>>  bsps/aarch64/raspberrypi/start/bspstart.c |  16 +-
>>>  .../aarch64/raspberrypi/start/bspstarthooks.c |  26 +-
>>>  bsps/aarch64/raspberrypi/start/bspstartmmu.c  |  66 +--
>>>  spec/build/bsps/aarch64/raspberrypi/abi.yml   |  39 +-
>>>  spec/build/bsps/aarch64/raspberrypi/bsp4b.yml |  23 +
>>>  .../aarch64/raspberrypi/bspraspberrypi4.yml   |  72 ---
>>>  spec/build/bsps/aarch64/raspberrypi/grp.yml   |  25 +
>>>  spec/build/bsps/aarch64/raspberrypi/grp4b.yml |  26 +
>>>  .../{linkercmds.yml => linkcmds.yml}  |  27 +-
>>>  spec/build/bsps/aarch64/raspberrypi/obj.yml   |  40 ++
>>>  .../bsps/aarch64/raspberrypi/objcache.yml |  23 +
>>>  .../bsps/aarch64/raspberrypi/objclock.yml |  24 +
>>>  .../bsps/aarch64/raspberrypi/objconsole.yml   |  20 +
>>>  .../build/bsps/aarch64/raspberrypi/objirq.yml |  27 +
>>>  .../bsps/aarch64/raspberrypi/objstart.yml |  35 ++
>>>  22 files changed, 553 insertions(+), 731 deletions(-)
>>>  create mode 100644 bsps/aarch64/raspberrypi/include/bsp/bcm2711.h
>>>  delete mode 100644 bsps/aarch64/raspberrypi/include/bsp/raspberrypi.h
>>>  create mode 100644
>>> bsps/aarch64/raspberrypi/include/bsp/start/bspstartmmu.h
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/bsp4b.yml
>>>  delete mode 100644
>>> spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/grp.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/grp4b.yml
>>>  rename spec/build/bsps/aarch64/raspberrypi/{linkercmds.yml =>
>>> linkcmds.yml} (88%)
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/obj.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/objcache.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/objclock.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/objconsole.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/objirq.yml
>>>  create mode 100644 spec/build/bsps/aarch64/raspberrypi/objstart.yml
>>>
>>> --
>>> 2.41.0
>>>
>>>
>>>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] libdl: Add support to import base image TLS symbols

2023-08-16 Thread Chris Johns
Thanks for the detailed review. It is so nice to have this happen.

I will post v2 soon.

On 17/8/2023 6:55 am, Gedare Bloom wrote:
> On Mon, Aug 14, 2023 at 10:05 PM  wrote:
>>
>> From: Chris Johns 
>>
>> This change requires an rtems-tools update for symbol generation.
>>
>> Working architectures:
>>  - aarch64
>>  - arm
>>  - powerpc
>>  - sparc
>>
>> Updates #4920
>> ---
>>  cpukit/include/rtems/rtl/rtl-sym.h |  23 -
>>  cpukit/include/rtems/rtl/rtl.h |   6 +-
>>  cpukit/libdl/rtl-elf.c |  20 +++-
>>  cpukit/libdl/rtl-mdreloc-aarch64.c |   6 +-
>>  cpukit/libdl/rtl-mdreloc-arm.c |   3 +-
>>  cpukit/libdl/rtl-mdreloc-powerpc.c |  18 +++-
>>  cpukit/libdl/rtl-mdreloc-sparc.c   | 152 -
>>  cpukit/libdl/rtl-sym.c |  36 ++-
>>  cpukit/libdl/rtl-tls.c | 111 +
>>  cpukit/libdl/rtl-tls.h |  51 ++
>>  cpukit/libdl/rtl.c |   6 +-
>>  spec/build/cpukit/objdl.yml|   1 +
>>  testsuites/libtests/dl11/dl-load.c |  27 -
>>  13 files changed, 408 insertions(+), 52 deletions(-)
>>  create mode 100644 cpukit/libdl/rtl-tls.c
>>  create mode 100644 cpukit/libdl/rtl-tls.h
>>
>> diff --git a/cpukit/include/rtems/rtl/rtl-sym.h 
>> b/cpukit/include/rtems/rtl/rtl-sym.h
>> index 0d29a6ae40..9eef9a1b7b 100644
>> --- a/cpukit/include/rtems/rtl/rtl-sym.h
>> +++ b/cpukit/include/rtems/rtl/rtl-sym.h
>> @@ -62,6 +62,22 @@ typedef struct rtems_rtl_symbols
>>size_t   nbuckets;
>>  } rtems_rtl_symbols;
>>
>> +/**
>> + * A TLS variable offset call. There is one per base image TLS
>> + * variable.
>> + */
>> +typedef size_t (*rtems_tls_offset_func)(void);
>> +
> rtems_tls_xxx is a new naming prefix. Is this stuff only specific to
> rtl? should be rtems_rtl_tls_...?
> 
> or, do we need to add a new tls header file and interface for this
> stuff, in case it would be needed outside of the rtl?

I will change the function call to rtems_rtl_tls_.

Yes an score way to provide the base would be welcome but that is out of scope
for this change. I am sorry but I have no time to invest in adding something new
the score like this.

>> +/**
>> + * A TLS symbol offset entry. It is used with an exported symbol table
>> + * to find a TSL table offset for a variable at runtime.
> s/TSL/TLS
> 
>> + */
>> +typedef struct rtems_tls_offset

I have fixed this as well.

>> +{
>> +  size_tindex;  /** exported symbol table index */
>> +  rtems_tls_offset_func offset; /** TLS offset function */
>> +} rtems_tls_offset;
>> +
>>  /**
>>   * Open a symbol table with the specified number of buckets.
>>   *
>> @@ -101,10 +117,15 @@ void rtems_rtl_symbol_table_close (rtems_rtl_symbols* 
>> symbols);
>>   * @param obj The object table the symbols are for.
>>   * @param esyms The exported symbol table.
>>   * @param size The size of the table in bytes.
>> + * @param tls_offsets The TLS offsets table. If NULL none provided.
>> + * @param tls_size The number TLS offset entries in the table..
> two periods, "number of"

Fixed

> 
>> +
> extra blank line

Fixed

> 
>>   */
>>  bool rtems_rtl_symbol_global_add (rtems_rtl_obj*   obj,
>>const unsigned char* esyms,
>> -  unsigned int size);
>> +  unsigned int size,
>> +  rtems_tls_offset*tls_offsets,
>> +  unsigned int tls_size);
>>
>>  /**
>>   * Find a symbol given the symbol label in the global symbol table.
>> diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h
>> index 0fd4e74cdf..aaaeb7b592 100644
>> --- a/cpukit/include/rtems/rtl/rtl.h
>> +++ b/cpukit/include/rtems/rtl/rtl.h
>> @@ -393,9 +393,13 @@ bool rtems_rtl_path_prepend (const char* path);
>>   *
>>   * @param esyms The exported symbol table.
>>   * @param count The size of the exported symbol table.
>> + * @param tls_offsets The TLS offsets table. If NULL none provided.
>> + * @param tls_size The number TLS offset entries in the table..
> two periods

Fixed

> 
>>   */
>>  void rtems_rtl_base_sym_global_add (const unsigned char* esyms,
>> -unsigned int count);
>> +unsigned int count,
>> +rtems_tls_offset*tls_offsets,
>> +unsigned int tls_size);
>>
>>  /**
>>   * Return the object file descriptor for the base image. The object file
>> diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c
>> index 5754070518..b46d2ac3a0 100644
>> --- a/cpukit/libdl/rtl-elf.c
>> +++ b/cpukit/libdl/rtl-elf.c
>> @@ -178,12 +178,19 @@ rtems_rtl_elf_find_symbol (rtems_rtl_obj*  obj,
>>
>>/*
>> * If the symbol type is STT_NOTYPE the symbol references a global
>> -   * symbol. The gobal symbol table is searched 

Re: libdl support for base image TLS variables

2023-08-16 Thread Chris Johns
On 17/8/2023 6:34 am, Gedare Bloom wrote:
> On Mon, Aug 14, 2023 at 10:05 PM  wrote:
>>
>> These patches add support to rtems.git and rtems-tools.git to
>> provide access to TLS variables in the base from loaded code.
>> The changes contain the ground work to resolving #4920 which is
>> a blocker for the release of 6.
>>
>> This change is required due to the regression in libdl due to the
>> change in newlib to use TLS variables for reneterant data.
>>
>> The rtems.git patch can be applied before the rtems-tools.git
>> patch. If the tools are updated and the libdl code is not present
>> the tests fail with linker errors. If the tools change is
>> not present the test will link but it will continue to fail.
>>
>> The currently supported archs that build are:
>>
>>  - aarch64
>>  - arm
>>  - powerpc
>>  - sparc
>>
>> The follow are to be completed and do not build:
>>
>>  - bfin
>>  - i386
>>  - lm32
>>  - m68k
>>  - mips
>>  - moxie
>>  - riscv
>>  - v850
>>
>> We need to add support for these architectures if they support TLS.
>>
> We are deprecating v850. It might be worth considering whether some of
> these other architectures should also be deprecated, especially if no
> one is able/willing to add TLS for them.

From Joel's comments on #4920 some have TLS but the newlib support has not been
updated. Newlib TLS support for reent is a nice and welcomed feature but not
having newlib TLS support means the arch is performing as before.

The other TSL issue is gdb is broken. If you attempt to print errno you will be
told TLS is not supported by gdb for this OS.

A review of archs should happen before 6 is released so we can indicate which we
will remove for 7. What have we indicated is to be removed in 7?

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

Re: libdl support for base image TLS variables

2023-08-16 Thread Joel Sherrill
On Wed, Aug 16, 2023, 8:30 PM Chris Johns  wrote:

> On 17/8/2023 6:34 am, Gedare Bloom wrote:
> > On Mon, Aug 14, 2023 at 10:05 PM  wrote:
> >>
> >> These patches add support to rtems.git and rtems-tools.git to
> >> provide access to TLS variables in the base from loaded code.
> >> The changes contain the ground work to resolving #4920 which is
> >> a blocker for the release of 6.
> >>
> >> This change is required due to the regression in libdl due to the
> >> change in newlib to use TLS variables for reneterant data.
> >>
> >> The rtems.git patch can be applied before the rtems-tools.git
> >> patch. If the tools are updated and the libdl code is not present
> >> the tests fail with linker errors. If the tools change is
> >> not present the test will link but it will continue to fail.
> >>
> >> The currently supported archs that build are:
> >>
> >>  - aarch64
> >>  - arm
> >>  - powerpc
> >>  - sparc
> >>
> >> The follow are to be completed and do not build:
> >>
> >>  - bfin
> >>  - i386
> >>  - lm32
> >>  - m68k
> >>  - mips
> >>  - moxie
> >>  - riscv
> >>  - v850
> >>
> >> We need to add support for these architectures if they support TLS.
> >>
> > We are deprecating v850. It might be worth considering whether some of
> > these other architectures should also be deprecated, especially if no
> > one is able/willing to add TLS for them.
>
> From Joel's comments on #4920 some have TLS but the newlib support has not
> been
> updated. Newlib TLS support for reent is a nice and welcomed feature but
> not
> having newlib TLS support means the arch is performing as before.
>

Is TLS off on some architectures?

Is that a column missing in the table I added?


> The other TSL issue is gdb is broken. If you attempt to print errno you
> will be
> told TLS is not supported by gdb for this OS.
>

That seems harder.

>
> A review of archs should happen before 6 is released so we can indicate
> which we
> will remove for 7. What have we indicated is to be removed in 7?
>

 SH, v850, and sparc64.


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

Re: libdl support for base image TLS variables

2023-08-16 Thread Chris Johns
On 17/8/2023 11:57 am, Joel Sherrill wrote:
> On Wed, Aug 16, 2023, 8:30 PM Chris Johns  > wrote:
> 
> On 17/8/2023 6:34 am, Gedare Bloom wrote:
> > On Mon, Aug 14, 2023 at 10:05 PM  > wrote:
> >>
> >> These patches add support to rtems.git and rtems-tools.git to
> >> provide access to TLS variables in the base from loaded code.
> >> The changes contain the ground work to resolving #4920 which is
> >> a blocker for the release of 6.
> >>
> >> This change is required due to the regression in libdl due to the
> >> change in newlib to use TLS variables for reneterant data.
> >>
> >> The rtems.git patch can be applied before the rtems-tools.git
> >> patch. If the tools are updated and the libdl code is not present
> >> the tests fail with linker errors. If the tools change is
> >> not present the test will link but it will continue to fail.
> >>
> >> The currently supported archs that build are:
> >>
> >>  - aarch64
> >>  - arm
> >>  - powerpc
> >>  - sparc
> >>
> >> The follow are to be completed and do not build:
> >>
> >>  - bfin
> >>  - i386
> >>  - lm32
> >>  - m68k
> >>  - mips
> >>  - moxie
> >>  - riscv
> >>  - v850
> >>
> >> We need to add support for these architectures if they support TLS.
> >>
> > We are deprecating v850. It might be worth considering whether some of
> > these other architectures should also be deprecated, especially if no
> > one is able/willing to add TLS for them.
> 
> From Joel's comments on #4920 some have TLS but the newlib support has 
> not been
> updated. Newlib TLS support for reent is a nice and welcomed feature but 
> not
> having newlib TLS support means the arch is performing as before.
> 
> Is TLS off on some architectures?

I do not know.

> Is that a column missing in the table I added?

I suggest that becomes a different thread so the topic is not lost here.

> The other TSL issue is gdb is broken. If you attempt to print errno you 
> will be
> told TLS is not supported by gdb for this OS.
> 
> That seems harder. 

I do not know how this fixed. It only showed up after the newlib switch
happened. That was July 2022 so we have to fix gdb to have it resolved as
winding back the newlib change is now not possible.

> A review of archs should happen before 6 is released so we can indicate 
> which we
> will remove for 7. What have we indicated is to be removed in 7?
> 
>  SH, v850, and sparc64.
> 

I suggest new thread so this is not lost in this one.

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

Re: [PATCH] spec/cpukit: Omit Cortex-M from libdebugger build

2023-08-16 Thread Chris Johns
On 17/8/2023 6:30 am, Kinsey Moore wrote:
> The current ARM support in libdebugger does not cover Cortex-M series
> cores since it requires support for CP14 system register accessor
> instructions. Cortex-M series cores support debug monitor mode, but its
> configuration is accessed by memory mapped registers instead of using
> CP14. This omits building libdebugger from BSPs that use a cortex-m ABI
> flag.

The ARM libdebugger has support to use memory mapped registers. It is determined
 by the ROM and then rtems_debugger_arm_debug_registers. I think the code
currently assume CP14 instructions but I think that could be made conditional
where needed?

Are these builds of Cortex-M processors able to support libdebugger?

I have been rejecting changes like this unless there is a reason it cannot be
made to work. Are there reasons it cannot be made to work?

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


Re: [PATCH rtems-tools] tester/report: Apply test excludes to fatal-error

2023-08-16 Thread Chris Johns
On 17/8/2023 7:36 am, Kinsey Moore wrote:
> Before the fatal-error test result type was introduced, minimum.exe was
> classified as an invalid test since it lacked a proper test header and
> trailer. This applies the test exclusions to all test states to avoid
> this happening again in the future.

I do not think this right. What state are you seeing?

While we cannot determine the pass state because there is no end message we can
determine if the test has timed out or is too long and they should be a fail.

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


[PATCH v2] libdl: Add support to import base image TLS symbols

2023-08-16 Thread chrisj
From: Chris Johns 

This change requires an rtems-tools update for symbol generation.

Working architectures:
 - aarch64
 - arm
 - powerpc
 - sparc

No newlib TLS support but checked:
 - i386
 - m69k

Updates #4920
---
 cpukit/include/rtems/rtl/rtl-sym.h |  26 -
 cpukit/include/rtems/rtl/rtl.h |   8 +-
 cpukit/libdl/rtl-elf.c |  20 +++-
 cpukit/libdl/rtl-mdreloc-aarch64.c |   6 +-
 cpukit/libdl/rtl-mdreloc-arm.c |   3 +-
 cpukit/libdl/rtl-mdreloc-powerpc.c |  18 +++-
 cpukit/libdl/rtl-mdreloc-sparc.c   | 154 -
 cpukit/libdl/rtl-sym.c |  40 ++--
 cpukit/libdl/rtl-tls.c | 114 +
 cpukit/libdl/rtl-tls.h |  51 ++
 cpukit/libdl/rtl.c |   8 +-
 spec/build/cpukit/objdl.yml|   1 +
 testsuites/libtests/dl11/dl-load.c |  27 -
 13 files changed, 418 insertions(+), 58 deletions(-)
 create mode 100644 cpukit/libdl/rtl-tls.c
 create mode 100644 cpukit/libdl/rtl-tls.h

diff --git a/cpukit/include/rtems/rtl/rtl-sym.h 
b/cpukit/include/rtems/rtl/rtl-sym.h
index 0d29a6ae40..3502b303b8 100644
--- a/cpukit/include/rtems/rtl/rtl-sym.h
+++ b/cpukit/include/rtems/rtl/rtl-sym.h
@@ -62,6 +62,22 @@ typedef struct rtems_rtl_symbols
   size_t   nbuckets;
 } rtems_rtl_symbols;
 
+/**
+ * A TLS variable offset call. There is one per base image TLS
+ * variable.
+ */
+typedef size_t (*rtems_rtl_tls_offset_func)(void);
+
+/**
+ * A TLS symbol offset entry. It is used with an exported symbol table
+ * to find a TSL table offset for a variable at runtime.
+ */
+typedef struct rtems_rtl_tls_offset
+{
+  size_tindex;  /** exported symbol table index */
+  rtems_rtl_tls_offset_func offset; /** TLS offset function */
+} rtems_rtl_tls_offset;
+
 /**
  * Open a symbol table with the specified number of buckets.
  *
@@ -101,10 +117,14 @@ void rtems_rtl_symbol_table_close (rtems_rtl_symbols* 
symbols);
  * @param obj The object table the symbols are for.
  * @param esyms The exported symbol table.
  * @param size The size of the table in bytes.
+ * @param tls_offsets The TLS offsets table. If NULL none provided.
+ * @param tls_size The number TLS offset entries in the table.
  */
-bool rtems_rtl_symbol_global_add (rtems_rtl_obj*   obj,
-  const unsigned char* esyms,
-  unsigned int size);
+bool rtems_rtl_symbol_global_add (rtems_rtl_obj*obj,
+  const unsigned char*  esyms,
+  unsigned int  size,
+  rtems_rtl_tls_offset* tls_offsets,
+  unsigned int  tls_size);
 
 /**
  * Find a symbol given the symbol label in the global symbol table.
diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h
index 0fd4e74cdf..bd3dce588a 100644
--- a/cpukit/include/rtems/rtl/rtl.h
+++ b/cpukit/include/rtems/rtl/rtl.h
@@ -393,9 +393,13 @@ bool rtems_rtl_path_prepend (const char* path);
  *
  * @param esyms The exported symbol table.
  * @param count The size of the exported symbol table.
+ * @param tls_offsets The TLS offsets table. If NULL none provided.
+ * @param tls_size The number TLS offset entries in the table.
  */
-void rtems_rtl_base_sym_global_add (const unsigned char* esyms,
-unsigned int count);
+void rtems_rtl_base_sym_global_add (const unsigned char*  esyms,
+unsigned int  count,
+rtems_rtl_tls_offset* tls_offsets,
+unsigned int  tls_size);
 
 /**
  * Return the object file descriptor for the base image. The object file
diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c
index 5754070518..b46d2ac3a0 100644
--- a/cpukit/libdl/rtl-elf.c
+++ b/cpukit/libdl/rtl-elf.c
@@ -178,12 +178,19 @@ rtems_rtl_elf_find_symbol (rtems_rtl_obj*  obj,
 
   /*
* If the symbol type is STT_NOTYPE the symbol references a global
-   * symbol. The gobal symbol table is searched to find it and that value
+   * symbol. The global symbol table is searched to find it and that value
* returned. If the symbol is local to the object module the section for the
* symbol is located and it's base added to the symbol's value giving an
* absolute location.
+   *
+   * If the symbols type of TLS return the symbols value. It is the
+   * offset from the thread's TLS area base. The offset is set by the
+   * linker for the base image and by the TLS allocator for loaded
+   * modules. There is no section and no absolute base.
*/
-  if (ELF_ST_TYPE(sym->st_info) == STT_NOTYPE || sym->st_shndx == SHN_COMMON)
+  if (ELF_ST_TYPE (sym->st_info) == STT_NOTYPE ||
+  sym->st_shndx == SHN_COMMON ||
+  ELF_ST_TYPE (sym->st_info) == STT_TLS)
   {
 /*
  * Search the object f

v2 libdl support for base image TLS variables

2023-08-16 Thread chrisj
These patches add support to rtems.git and rtems-tools.git to 
provide access to TLS variables in the base from loaded code.
The changes contain the ground work to resolving #4920 which is 
a blocker for the release of 6.

This change is required due to the regression in libdl due to the
change in newlib to use TLS variables for reenterant data.

The rtems.git patch can be applied before the rtems-tools.git
patch. If the tools are updated and the libdl code is not present
the tests fail with linker errors. If the tools change is
not present the test will link but it will continue to fail.

The currently supported archs that build are:

 - aarch64
 - arm
 - powerpc
 - sparc

Test results are in #4920. The following do not have newlib TLS
support so are OK:

 - i386
 - m68k

The follow are to be completed and do not build:

 - bfin
 - lm32
 - mips
 - moxie
 - riscv

These are to be removed and so not tested or built:

 - v850  

We need to add support for these architectures if they support TLS or 
list them as not needing support like the m68k.

v2:
 - Review commment updates

Chris


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


[rtems-tools PATCH v2] linker: Add TLS support to the symbol table generator

2023-08-16 Thread chrisj
From: Chris Johns 

Updates #4920
---
 linkers/rtems-syms.cpp | 179 ++---
 1 file changed, 134 insertions(+), 45 deletions(-)

diff --git a/linkers/rtems-syms.cpp b/linkers/rtems-syms.cpp
index e5170e1..c72ee55 100644
--- a/linkers/rtems-syms.cpp
+++ b/linkers/rtems-syms.cpp
@@ -60,10 +60,22 @@ static const char* c_header[] =
   " *  Automatically generated. Do not edit..",
   " */",
   "",
+  "#include ",
+  "#include ",
+  "",
+  "extern void* rtems_rtl_tls_get_base (void);",
+  "",
   "extern const unsigned char rtems__rtl_base_globals[];",
   "extern const unsigned int rtems__rtl_base_globals_size[];",
   "",
-  "void rtems_rtl_base_sym_global_add (const unsigned char* , unsigned int );",
+  "typedef size_t (*rtems_rtl_tls_offset_func)(void);",
+  "typedef struct rtems_rtl_tls_offset {",
+  "  size_t index;",
+  "  rtems_rtl_tls_offset_func offset;",
+  "} rtems_rtl_tls_offset;",
+  "",
+  "void rtems_rtl_base_sym_global_add (const unsigned char* , unsigned int,",
+  "rtems_rtl_tls_offset*, size_t );",
   "",
   "asm(\".section \\\".rodata\\\"\");",
   "",
@@ -78,35 +90,60 @@ static const char* c_header[] =
   0
 };
 
-static const char* c_trailer[] =
+static const char* c_sym_table_end[] =
 {
   "asm(\"  .byte0\");",
   "asm(\"  .ascii   \\\"\\xde\\xad\\xbe\\xef\\\"\");",
-#if BROKEN_ON_SOME_ASSEMBLERS
-  "asm(\"  .typertems__rtl_base_globals, #object\");",
-  "asm(\"  .sizertems__rtl_base_globals, . - rtems__rtl_base_globals\");",
-#endif
   "",
+  0
+};
+
+static const char* c_tls_call_table_start[] =
+{
+  "rtems_rtl_tls_offset rtems_rtl_tls_offsets[] = {",
+  0
+};
+
+static const char* c_tls_call_table_end[] =
+{
+  "};",
+  "#define RTEMS_RTL_TLS_OFFSETS_NUM " \
+  "(sizeof(rtems_rtl_tls_offsets) / (sizeof(rtems_rtl_tls_offsets[0])))",
+  "",
+  0
+};
+
+static const char* c_trailer[] =
+{
   "/*",
   " * Symbol table size.",
   " */",
   "asm(\"  .align   4\");",
   "asm(\"  .local   rtems__rtl_base_globals_size\");",
-#if BROKEN_ON_SOME_ASSEMBLERS
-  "asm(\"  .typertems__rtl_base_globals_size, #object\");",
-  "asm(\"  .sizertems__rtl_base_globals_size, 4\");",
-#endif
   "asm(\"rtems__rtl_base_globals_size:\");",
   "asm(\"  .long rtems__rtl_base_globals_size - rtems__rtl_base_globals\");",
   "",
   0
 };
 
+static const char* c_rtl_call_body_embeded[] =
+{
+  "{",
+  "  rtems_rtl_base_sym_global_add (&rtems__rtl_base_globals[0],",
+  " rtems__rtl_base_globals_size[0],",
+  " &rtems_rtl_tls_offsets[0],",
+  " RTEMS_RTL_TLS_OFFSETS_NUM);",
+  "}",
+  0
+};
+
 static const char* c_rtl_call_body[] =
 {
   "{",
   "  rtems_rtl_base_sym_global_add (&rtems__rtl_base_globals[0],",
-  " rtems__rtl_base_globals_size[0]);",
+  " rtems__rtl_base_globals_size[0],",
+  " NULL",
+  " 0);",
   "}",
   0
 };
@@ -140,7 +177,7 @@ c_embedded_trailer (rld::process::tempfile& c)
 {
   c.write_line ("void rtems_rtl_base_global_syms_init(void);");
   c.write_line ("void rtems_rtl_base_global_syms_init(void)");
-  temporary_file_paint (c, c_rtl_call_body);
+  temporary_file_paint (c, c_rtl_call_body_embeded);
 }
 
 /**
@@ -214,16 +251,27 @@ symbol_filter::filter (const rld::symbols::symtab& 
symbols,
 
 struct output_sym
 {
+  enum struct output_mode {
+symbol,
+tls_func,
+tls_call_table
+  };
   rld::process::tempfile& c;
   const bool  embed;
   const bool  weak;
-
-  output_sym(rld::process::tempfile& c,
- boolembed,
- boolweak)
-: c (c),
-  embed (embed),
-  weak (weak) {
+  const output_mode   mode;
+  size_t& index;
+
+  output_sym(rld::process::tempfile& c_,
+ boolembed_,
+ boolweak_,
+ output_mode mode_,
+ size_t& index_)
+: c (c_),
+  embed (embed_),
+  weak (weak_),
+  mode (mode_),
+  index (index_) {
   }
 
   void operator ()(const rld::symbols::symtab::value_type& value);
@@ -240,34 +288,56 @@ output_sym::operator ()(const 
rld::symbols::symtab::value_type& value)
   if (weak && sym.value () == 0)
 return;
 
-  c.write_line ("asm(\"  .asciz \\\"" + sym.name () + "\\\"\");");
-
-  if (sym.type() == STT_TLS)
-  {
-c.write_line ("asm(\"  .type \\\"" + sym.name () + "\\\", 
%tls_object\");");
-  }
-
-  if (embed)
-  {
-c.write_line ("#if __SIZEOF_POINTER__ == 8");
-c.write_line ("asm(\"  .quad " + sym.name () + "\");");
-c.write_line ("#else");
-c.write_line ("asm(\"  .long " + sym.name () + "\");");
-c.write_line ("#endif");
-  }
-  else
-  {
-std::stringstream oss;
-oss << std::hex << std::setfi

[rtems-tools PATCH] tester/sis: Use the RTEMS SIS command

2023-08-16 Thread chrisj
From: Chris Johns 

Make sis and sis-run the same as there is no SIS support in
gdb anymore.

Closes #4945
---
 tester/rtems/testing/bsps/sis-run.ini | 2 +-
 tester/rtems/testing/bsps/sis.ini | 6 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/tester/rtems/testing/bsps/sis-run.ini 
b/tester/rtems/testing/bsps/sis-run.ini
index c34eae4..4861231 100644
--- a/tester/rtems/testing/bsps/sis-run.ini
+++ b/tester/rtems/testing/bsps/sis-run.ini
@@ -35,4 +35,4 @@
 bsp  = sis
 arch = sparc
 tester   = %{_rtscripts}/sis.cfg
-bsp_run_opts = -a
+bsp_run_opts =
diff --git a/tester/rtems/testing/bsps/sis.ini 
b/tester/rtems/testing/bsps/sis.ini
index b5d700f..086cb45 100644
--- a/tester/rtems/testing/bsps/sis.ini
+++ b/tester/rtems/testing/bsps/sis.ini
@@ -34,8 +34,6 @@
 [sis]
 bsp= sis
 arch   = sparc
-tester = %{_rtscripts}/gdb.cfg
+tester = %{_rtscripts}/sis.cfg
 gdb_script = bsp_gdb_script
-bsp_gdb_script = target sim -a -nouartrx
- load
- run
+bsp_run_opts =
-- 
2.37.1

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