summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1edaf9d)
raw | patch | inline | side by side (parent: 1edaf9d)
author | Ramsey Harris <ramsey@ti.com> | |
Wed, 20 May 2015 15:08:24 +0000 (08:08 -0700) | ||
committer | Robert Tivy <rtivy@ti.com> | |
Wed, 20 May 2015 23:40:05 +0000 (16:40 -0700) |
The ARM Cortex-A15 processor performs speculative execution on
the instruction stream. This might pull unwanted data into the
cache. The ListMP module expects shared data to be absent from
the cache. However, when running on ARM, we cannot count on the
data to be absent from the cache. A cache invalidate operation
is required.
the instruction stream. This might pull unwanted data into the
cache. The ListMP module expects shared data to be absent from
the cache. However, when running on ARM, we cannot count on the
data to be absent from the cache. A cache invalidate operation
is required.
packages/ti/sdo/ipc/GateMP.c | patch | blob | history | |
packages/ti/sdo/ipc/ListMP.c | patch | blob | history | |
packages/ti/sdo/ipc/transports/TransportShm.c | patch | blob | history |
index a3d90b3176280a0b38aaffe48d89e38f6183c0a0..ba60477bef570b2582359c1738039a0beedb8c49 100644 (file)
ti_sdo_ipc_GateMP_Handle *remoteHandles;
UInt8 *inUseArray;
- UInt numResources;
+ UInt size;
/* Cannot call when numOpen is non-zero. */
Assert_isTrue(obj->numOpens == 0, ti_sdo_ipc_GateMP_A_invalidDelete);
inUseArray = GateMP_module->remoteSystemInUse;
remoteHandles = GateMP_module->remoteSystemGates;
- numResources = GateMP_module->numRemoteSystem;
+ size = GateMP_module->numRemoteSystem * sizeof(UInt8);
break;
case GateMP_RemoteProtect_CUSTOM1:
inUseArray = GateMP_module->remoteCustom1InUse;
remoteHandles = GateMP_module->remoteCustom1Gates;
- numResources = GateMP_module->numRemoteCustom1;
+ size = GateMP_module->numRemoteCustom1 * sizeof(UInt8);
break;
case GateMP_RemoteProtect_CUSTOM2:
inUseArray = GateMP_module->remoteCustom2InUse;
remoteHandles = GateMP_module->remoteCustom2Gates;
- numResources = GateMP_module->numRemoteCustom2;
+ size = GateMP_module->numRemoteCustom2 * sizeof(UInt8);
break;
case GateMP_RemoteProtect_NONE:
/*
systemKey = Hwi_disable();
}
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled array into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(inUseArray, size, Cache_Type_ALL, TRUE);
+ }
+#endif
/* update the GateMP resource tracker */
inUseArray[obj->resourceId] = UNUSED;
if (obj->cacheEnabled) {
- Cache_wbInv(inUseArray,
- numResources * sizeof(UInt8),
- Cache_Type_ALL,
- TRUE);
+ Cache_wbInv(inUseArray, size, Cache_Type_ALL, TRUE);
}
if (GateMP_module->defaultGate != NULL) {
index 80bbafa820755fae69e01653715c82037d720090..4e89cf8e40cfea6d1010ecc758152815804521ec 100644 (file)
/*
- * Copyright (c) 2012-2014 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Bool ListMP_empty(ListMP_Handle handle)
{
ti_sdo_ipc_ListMP_Object *obj = (ti_sdo_ipc_ListMP_Object *)handle;
+ ti_sdo_ipc_ListMP_Attrs *attrs = obj->attrs;
Bool flag = FALSE;
IArg key;
SharedRegion_SRPtr sharedHead;
/* prevent another thread or processor from modifying the ListMP */
key = GateMP_enter((GateMP_Handle)obj->gate);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL, TRUE);
+ }
+#endif
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
/* get the SRPtr for the head */
- sharedHead = (SharedRegion_SRPtr)&(obj->attrs->head);
+ sharedHead = (SharedRegion_SRPtr)&(attrs->head);
}
else {
/* get the SRPtr for the head */
- sharedHead = SharedRegion_getSRPtr(&(obj->attrs->head), obj->regionId);
+ sharedHead = SharedRegion_getSRPtr(&(attrs->head), obj->regionId);
}
/* if 'next' is ourself, then the ListMP must be empty */
- if (obj->attrs->head.next == sharedHead) {
+ if (attrs->head.next == sharedHead) {
flag = TRUE;
}
if (obj->cacheEnabled) {
/* invalidate the head to make sure we are not getting stale data */
- Cache_inv(&(obj->attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL,
- TRUE);
+ Cache_inv(&(attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
/* leave the gate */
Ptr ListMP_getHead(ListMP_Handle handle)
{
ti_sdo_ipc_ListMP_Object *obj = (ti_sdo_ipc_ListMP_Object *)handle;
+ ti_sdo_ipc_ListMP_Attrs *attrs = obj->attrs;
ListMP_Elem *elem;
ListMP_Elem *localHeadNext;
ListMP_Elem *localNext;
/* prevent another thread or processor from modifying the ListMP */
key = GateMP_enter((GateMP_Handle)obj->gate);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL, TRUE);
+ }
+#endif
+
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
- localHeadNext = (ListMP_Elem *)obj->attrs->head.next;
+ localHeadNext = (ListMP_Elem *)attrs->head.next;
}
else {
- localHeadNext = SharedRegion_getPtr(obj->attrs->head.next);
+ localHeadNext = SharedRegion_getPtr(attrs->head.next);
}
/* Assert that pointer is not NULL */
Assert_isTrue(localHeadNext != NULL, ti_sdo_ipc_Ipc_A_nullPointer);
/* See if the ListMP was empty */
- if (localHeadNext == (ListMP_Elem *)(&(obj->attrs->head))) {
+ if (localHeadNext == (ListMP_Elem *)(&(attrs->head))) {
/* Empty, return NULL */
elem = NULL;
}
}
/* Fix the head of the list next pointer */
- obj->attrs->head.next = elem->next;
+ attrs->head.next = elem->next;
/* Fix the prev pointer of the new first elem on the list */
localNext->prev = localHeadNext->prev;
}
if (obj->cacheEnabled) {
- Cache_wbInv(&(obj->attrs->head), sizeof(ListMP_Elem),
- Cache_Type_ALL, TRUE);
+ Cache_wbInv(&(attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
GateMP_leave((GateMP_Handle)obj->gate, key);
Ptr ListMP_getTail(ListMP_Handle handle)
{
ti_sdo_ipc_ListMP_Object *obj = (ti_sdo_ipc_ListMP_Object *)handle;
+ ti_sdo_ipc_ListMP_Attrs *attrs = obj->attrs;
ListMP_Elem *elem;
ListMP_Elem *localHeadPrev;
ListMP_Elem *localPrev;
/* prevent another thread or processor from modifying the ListMP */
key = GateMP_enter((GateMP_Handle)obj->gate);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL, TRUE);
+ }
+#endif
+
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
- localHeadPrev = (ListMP_Elem *)obj->attrs->head.prev;
+ localHeadPrev = (ListMP_Elem *)attrs->head.prev;
}
else {
- localHeadPrev = SharedRegion_getPtr(obj->attrs->head.prev);
+ localHeadPrev = SharedRegion_getPtr(attrs->head.prev);
}
/* Assert that pointer is not NULL */
Assert_isTrue(localHeadPrev != NULL, ti_sdo_ipc_Ipc_A_nullPointer);
/* See if the ListMP was empty */
- if (localHeadPrev == (ListMP_Elem *)(&(obj->attrs->head))) {
+ if (localHeadPrev == (ListMP_Elem *)(&(attrs->head))) {
/* Empty, return NULL */
elem = NULL;
}
}
/* Fix the head of the list prev pointer */
- obj->attrs->head.prev = elem->prev;
+ attrs->head.prev = elem->prev;
/* Fix the next pointer of the new last elem on the list */
localPrev->next = localHeadPrev->next;
}
if (obj->cacheEnabled) {
- Cache_wbInv(&(obj->attrs->head), sizeof(ListMP_Elem),
- Cache_Type_ALL, TRUE);
+ Cache_wbInv(&(attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
GateMP_leave((GateMP_Handle)obj->gate, key);
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
sharedNewElem = (SharedRegion_SRPtr)newElem;
sharedCurElem = (SharedRegion_SRPtr)curElem;
- localPrevElem = (ListMP_Elem *)(curElem->prev);
}
else {
/* get SRPtr for newElem */
/* Keep track of whether an extra Cache_inv is needed */
elemIsCached = obj->cacheEnabled;
elem = (ListMP_Elem *)&(obj->attrs->head);
-
}
else {
elemIsCached = SharedRegion_isCacheEnabled(SharedRegion_getId(elem));
}
if (elemIsCached) {
- /* Invalidate because elem pulled into cache && elem != head. */
+ /* invalidate because elem pulled into cache */
Cache_inv(elem, sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
}
if (elemIsCached) {
- /* Invalidate because elem pulled into cache && elem != head. */
+ /* invalidate because elem pulled into cache */
Cache_inv(elem, sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
Int ListMP_putHead(ListMP_Handle handle, ListMP_Elem *elem)
{
ti_sdo_ipc_ListMP_Object *obj = (ti_sdo_ipc_ListMP_Object *)handle;
+ ti_sdo_ipc_ListMP_Attrs *attrs = obj->attrs;
UInt key;
UInt16 id;
ListMP_Elem *localNextElem;
/* prevent another thread or processor from modifying the ListMP */
key = GateMP_enter((GateMP_Handle)obj->gate);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL, TRUE);
+ }
+#endif
+
id = SharedRegion_getId(elem);
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
sharedElem = (SharedRegion_SRPtr)elem;
- sharedHead = (SharedRegion_SRPtr)&(obj->attrs->head);
- localNextElem = (ListMP_Elem *)obj->attrs->head.next;
+ sharedHead = (SharedRegion_SRPtr)&(attrs->head);
+ localNextElem = (ListMP_Elem *)attrs->head.next;
}
else {
sharedElem = SharedRegion_getSRPtr(elem, id);
- sharedHead = SharedRegion_getSRPtr(&(obj->attrs->head), obj->regionId);
- localNextElem = SharedRegion_getPtr(obj->attrs->head.next);
+ sharedHead = SharedRegion_getSRPtr(&(attrs->head), obj->regionId);
+ localNextElem = SharedRegion_getPtr(attrs->head.next);
}
/* Assert that pointer is not NULL */
}
/* add the new elem into the list */
- elem->next = obj->attrs->head.next;
+ elem->next = attrs->head.next;
elem->prev = sharedHead;
localNextElem->prev = sharedElem;
- obj->attrs->head.next = sharedElem;
+ attrs->head.next = sharedElem;
if (localNextElemIsCached) {
/* Write-back because localNextElem->prev changed */
Cache_wbInv(localNextElem, sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
if (obj->cacheEnabled) {
- /* Write-back because obj->attrs->head.next changed */
- Cache_wbInv(&(obj->attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL,
- TRUE);
+ /* Write-back because attrs->head.next changed */
+ Cache_wbInv(&(attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
if (SharedRegion_isCacheEnabled(id)) {
/* Write-back because elem->next & elem->prev changed */
Int ListMP_putTail(ListMP_Handle handle, ListMP_Elem *elem)
{
ti_sdo_ipc_ListMP_Object *obj = (ti_sdo_ipc_ListMP_Object *)handle;
+ ti_sdo_ipc_ListMP_Attrs *attrs = obj->attrs;
UInt key;
UInt16 id;
ListMP_Elem *localPrevElem;
/* prevent another thread or processor from modifying the ListMP */
key = GateMP_enter((GateMP_Handle)obj->gate);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL, TRUE);
+ }
+#endif
+
id = SharedRegion_getId(elem);
if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
sharedElem = (SharedRegion_SRPtr)elem;
- sharedHead = (SharedRegion_SRPtr)&(obj->attrs->head);
- localPrevElem = (ListMP_Elem *)obj->attrs->head.prev;
+ sharedHead = (SharedRegion_SRPtr)&(attrs->head);
+ localPrevElem = (ListMP_Elem *)attrs->head.prev;
}
else {
sharedElem = SharedRegion_getSRPtr(elem, id);
- sharedHead = SharedRegion_getSRPtr(&(obj->attrs->head), obj->regionId);
- localPrevElem = SharedRegion_getPtr(obj->attrs->head.prev);
+ sharedHead = SharedRegion_getSRPtr(&(attrs->head), obj->regionId);
+ localPrevElem = SharedRegion_getPtr(attrs->head.prev);
}
/* Assert that pointer is not NULL */
/* add the new elem into the list */
elem->next = sharedHead;
- elem->prev = obj->attrs->head.prev;
+ elem->prev = attrs->head.prev;
localPrevElem->next = sharedElem;
- obj->attrs->head.prev = sharedElem;
+ attrs->head.prev = sharedElem;
if (localPrevElemIsCached) {
/* Write-back because localPrevElem->next changed */
Cache_wbInv(localPrevElem, sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
if (obj->cacheEnabled) {
- /* Write-back because obj->attrs->head.prev changed */
- Cache_wbInv(&(obj->attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL,
- TRUE);
+ /* Write-back because attrs->head.prev changed */
+ Cache_wbInv(&(attrs->head), sizeof(ListMP_Elem), Cache_Type_ALL, TRUE);
}
if (SharedRegion_isCacheEnabled(id)) {
/* Write-back because elem->next & elem->prev changed */
obj->cacheEnabled = SharedRegion_isCacheEnabled(obj->regionId);
obj->cacheLineSize = SharedRegion_getCacheLineSize(obj->regionId);
+#ifdef xdc_target__isaCompatible_v7A
+ /* ARM speculative execution might have pulled attrs into cache */
+ if (obj->cacheEnabled) {
+ Cache_inv(obj->attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL,
+ TRUE);
+ }
+#endif
/* get the local address of the SRPtr */
localAddr = SharedRegion_getPtr(obj->attrs->gateMPAddr);
diff --git a/packages/ti/sdo/ipc/transports/TransportShm.c b/packages/ti/sdo/ipc/transports/TransportShm.c
index b53b1b977b2e8814be27804bc4f2c7091ca6815d..75d3ad41dc5c4b63d6284ef10cc01eede1871f46 100644 (file)
/* put the message to the destination queue */
MessageQ_put(queueId, msg);
-#if defined(gnu_targets_STD_) && defined (xdc_target__isaCompatible_v7A)
- __asm__ __volatile__ (
- "dmb"
- ::: "memory"
- );
-#endif
-
/* check to see if there are more messages */
msg = (MessageQ_Msg)ListMP_getHead((ListMP_Handle)obj->localList);
}