Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address alignment issue in VxWorks 7 on 32 bit processor #1271

Closed
skliper opened this issue Jul 20, 2022 · 0 comments · Fixed by #1272
Closed

Address alignment issue in VxWorks 7 on 32 bit processor #1271

skliper opened this issue Jul 20, 2022 · 0 comments · Fixed by #1272
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Jul 20, 2022

Describe the bug
The task control bock (TCB) has an element with a 64 bit alignment requirement on some processors, but the way the OS_impl_task_internal_record_t is defined for VxWorks 7 does not enforce 64 bit alignment on a 32 bit system. This causes taskInitialize to fail.

Note the use of a char array in the structure here:

#if defined(VX_WIND_TCB_SIZE)
/* vxworks >= 7.0 should provide this symbol via taskLib.h. WIND_TCB is an opaque type */
typedef char OS_VxWorks_TCB_t[VX_WIND_TCB_SIZE];
#else
/* older vxworks expose the definition of VX_WIND_TCB_SIZE */
typedef WIND_TCB OS_VxWorks_TCB_t;
#endif /* !defined(VX_WIND_TCB_SIZE) */
/*tasks */
typedef struct
{
OS_VxWorks_TCB_t tcb; /* Must be first */
TASK_ID vxid;
void * heap_block; /* set non-null if the stack was obtained with malloc() */
size_t heap_block_size;
} OS_impl_task_internal_record_t;

Used here:

status = taskInit((WIND_TCB *)&lrec->tcb, /* address of new task's TCB */
(char *)task->task_name, vxpri, /* priority of new task */
vxflags, /* task option word */
(char *)actualstackbase, /* base of new task's stack */
actualsz, /* size (bytes) of stack needed */
(FUNCPTR)OS_VxWorks_TaskEntry, /* entry point of new task */
OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)), /* 1st arg is ID */
0, 0, 0, 0, 0, 0, 0, 0, 0);

To Reproduce
Need to get into a situation where the internal task record (and tcb since it's the first element) is not on a 64 bit boundary, and get's passed into taskInitialize, on a system that errors out if a 64 bit structure element isn't on a boundary. Observed on GR712RC.

Expected behavior
Should initialize tasks successfully. As a quick test a uint64 val; was added to the internal task record, forcing alignment and the task initialization worked.

System observed on:

  • Hardware: GR712RC
  • OS: VxWorks 7
  • Versions: should be observable in Caelum or later

Additional context
None

Reporter Info
Jacob Hageman - NASA/GSFC

@skliper skliper added the bug label Jul 20, 2022
skliper added a commit to skliper/osal that referenced this issue Jul 20, 2022
@skliper skliper added this to the Draco milestone Jul 20, 2022
@skliper skliper self-assigned this Jul 20, 2022
dzbaker added a commit that referenced this issue Jul 28, 2022
Fix #1271, Ensure address alignment of TCB for VxWorks 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant