lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory mana


From: Noam Weissman
Subject: Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.
Date: Thu, 7 Sep 2017 10:51:04 +0000

Hi David,

 

Most of my code is RAW API so I have not seen any issues.

 

BR,

Noam.

 

From: lwip-users [mailto:lwip-users-bounces+address@hidden On Behalf Of David Lockyer
Sent: Thursday, September 07, 2017 11:21 AM
To: address@hidden
Subject: Re: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.

 

Hi Noam,
Thanks for the files, they are not too dissimilar to what I have.

My sys_arch_protect / sys_arch_unprotect are slightly different:

sys_prot_t sys_arch_protect(void)
{
    vPortEnterCritical();
    return 1;
}
 
void sys_arch_unprotect(sys_prot_t pval)
{
    ( void ) pval;
    vPortExitCritical();
}

I am using the GCC/ARM_CM4_MPU port:
void vPortEnterCritical( void )
{
BaseType_t xRunningPrivileged = xPortRaisePrivilege();
 
    portDISABLE_INTERRUPTS();
    uxCriticalNesting++;
 
    vPortResetPrivilege( xRunningPrivileged );
}
/*-----------------------------------------------------------*/
 
void vPortExitCritical( void )
{
BaseType_t xRunningPrivileged = xPortRaisePrivilege();
 
    configASSERT( uxCriticalNesting );
    uxCriticalNesting--;
    if( uxCriticalNesting == 0 )
    {
        portENABLE_INTERRUPTS();
    }
    vPortResetPrivilege( xRunningPrivileged );
}

But unless the PortEnterCritical() were to leave privilege raised I don't see how lwip_select() would not trigger the MPU?

I only see this being triggered when I have two separate threads handling different network traffic, i.e. TCP connection and UDP data transfer each handled by a separate thread.

BR,
David

On 07/09/17 07:25, Noam Weissman wrote:

Hi David,

 

Attached please find my own sys_arch files used in STM32F4xx with FreeRTOS.

 

Hope that helps in some way.

 

BR,

Noam.

 

From: lwip-users [mailto:lwip-users-bounces+address@hidden] On Behalf Of David Lockyer
Sent: Wednesday, September 06, 2017 5:13 PM
To: address@hidden
Subject: [lwip-users] LWIP_MPU_COMPATIBLE set to 1, but still get memory management fault in lwip_select.

 

Hi,

I have a project that uses an STM32F MCU running FreeRTOS (cortex mpu port) & lwip, with the MPU enabled.

I'm upgrading to lwip 2.0.2 from lwip 1.4.1, that I had to customize to be compatible with the MPU, in particular in lwip_select().

The motivation was to use the LWIP_MPU_COMPATIBLE define, so a direct modification of the stack source was not required.  However for me it still appears to try to access another threads memory, triggering an exception.

The changes I had to make were:

Index: lib/lwip-2.0.2/src/api/sockets.c
===================================================================
--- lib/lwip-2.0.2/src/api/sockets.c    (revision xxxxx)
+++ lib/lwip-2.0.2/src/api/sockets.c    (working copy)
@@ -1428,7 +1428,9 @@
     /* Put this select_cb on top of list */
     select_cb.next = select_cb_list;
     if (select_cb_list != NULL) {
+      RAISE_PRIVILEGE();
       select_cb_list->prev = &select_cb;
+      RESET_PRIVILEGE();
     }
     select_cb_list = &select_cb;
     /* Increasing this counter tells event_callback that the list has changed. */
@@ -1508,7 +1510,9 @@
     /* Take us off the list */
     SYS_ARCH_PROTECT(lev);
     if (select_cb.next != NULL) {
+      RAISE_PRIVILEGE();
       select_cb.next->prev = select_cb.prev;
+      RESET_PRIVILEGE();
     }
     if (select_cb_list == &select_cb) {
       LWIP_ASSERT("select_cb.prev == NULL", select_cb.prev == NULL);
@@ -1515,7 +1519,9 @@
       select_cb_list = select_cb.next;
     } else {
       LWIP_ASSERT("select_cb.prev != NULL", select_cb.prev != NULL);
+      RAISE_PRIVILEGE();
       select_cb.prev->next = select_cb.next;
+      RESET_PRIVILEGE();
     }
     /* Increasing this counter tells event_callback that the list has changed. */
     select_cb_ctr++;

Is there something else I missed here that would remove the need for this modification?

 

Kind regards,

David Lockyer


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________



_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________


reply via email to

[Prev in Thread] Current Thread [Next in Thread]