{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/uvisor/issues/315","repository_url":"https://api.github.com/repos/ARMmbed/uvisor","labels_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/315/comments","events_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/315/events","html_url":"https://github.com/ARMmbed/uvisor/issues/315","id":173274744,"number":315,"title":"uVisor prevents LwIP/Hal from properly using ENET hardware when enabled","user":{"login":"sherrellbc","id":8580880,"avatar_url":"https://avatars.githubusercontent.com/u/8580880?v=3","gravatar_id":"","url":"https://api.github.com/users/sherrellbc","html_url":"https://github.com/sherrellbc","followers_url":"https://api.github.com/users/sherrellbc/followers","following_url":"https://api.github.com/users/sherrellbc/following{/other_user}","gists_url":"https://api.github.com/users/sherrellbc/gists{/gist_id}","starred_url":"https://api.github.com/users/sherrellbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherrellbc/subscriptions","organizations_url":"https://api.github.com/users/sherrellbc/orgs","repos_url":"https://api.github.com/users/sherrellbc/repos","events_url":"https://api.github.com/users/sherrellbc/events{/privacy}","received_events_url":"https://api.github.com/users/sherrellbc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ARMmbed/uvisor/labels/mirrored","name":"mirrored","color":"ededed"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-08-25T18:20:32Z","updated_at":"2016-08-31T17:24:03Z","closed_at":null,"body":"**EDIT:** I changed the issue's name to more appropriately track the purpose of this thread after relevant information has been uncovered surrounding the original problem. \r\n\r\n------\r\n\r\nI have been trying to determine the appropriate uVisor ACL such that I can use the Ethernet hardware on the FRDM K64F development board. After a few hours of debugging and tracing the problem I managed to determine two points of failure when using EthernetInterface.cpp and (a dependency thereof) the LWIP implementation; the root of the corresponding source tree can be found [here](https://github.com/ARMmbed/mbed-os/tree/master/features/net/FEATURE_IPV4/lwip-interface).\r\n\r\nThe first problem I found was that the LWIP implementation was trying to disable the MPU, which I thought might be problematic for uVisor.\r\n\r\n`MPU->CESR &= ~MPU_CESR_VLD_MASK;`\r\n\r\nhttps://github.com/ARMmbed/mbed-os/blob/master/features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_Freescale/hardware_init_MK64F12.c#L41\r\n\r\nI have defined the MPU as an enabled memory range in my ACL, but that does not prevent the system from stopping on that instruction. \r\n\r\n```\r\nconst UvisorBoxAclItem g_main_acl[] = {     \r\n         {SIM,    sizeof(*SIM),    UVISOR_TACLDEF_PERIPH}, \r\n         {OSC,    sizeof(*OSC),    UVISOR_TACLDEF_PERIPH}, \r\n         {MCG,    sizeof(*MCG),    UVISOR_TACLDEF_PERIPH}, \r\n         {PORTA,  sizeof(*PORTA),  UVISOR_TACLDEF_PERIPH}, \r\n         {PORTB,  sizeof(*PORTB),  UVISOR_TACLDEF_PERIPH}, \r\n         {PORTC,  sizeof(*PORTC),  UVISOR_TACLDEF_PERIPH}, \r\n         {PORTD,  sizeof(*PORTD),  UVISOR_TACLDEF_PERIPH}, \r\n         {PORTE,  sizeof(*PORTE),  UVISOR_TACLDEF_PERIPH}, \r\n         {RTC,    sizeof(*RTC),    UVISOR_TACLDEF_PERIPH}, \r\n         {LPTMR0, sizeof(*LPTMR0), UVISOR_TACLDEF_PERIPH}, \r\n         {PIT,    sizeof(*PIT),    UVISOR_TACLDEF_PERIPH}, \r\n         {SMC,    sizeof(*SMC),    UVISOR_TACLDEF_PERIPH}, \r\n         {UART0,  sizeof(*UART0),  UVISOR_TACLDEF_PERIPH}, \r\n         {I2C0,   sizeof(*I2C0),   UVISOR_TACLDEF_PERIPH},\r\n         {SPI0,   sizeof(*SPI0),   UVISOR_TACLDEF_PERIPH},\r\n         {MPU,  sizeof(*MPU), UVISOR_TACLDEF_PERIPH}, \r\n   \r\n         /* EthernetInterface */\r\n         {ENET,   sizeof(*ENET),   UVISOR_TACLDEF_PERIPH}, \r\n         {EWM,    sizeof(*EWM),   UVISOR_TACLDEF_PERIPH}, \r\n};\r\n```\r\n\r\n---------\r\n\r\nThe second problem was related to a call to `EnableIRQ` in `fsl_enet.c`. At the highest level, a call to `EthernetInterface.connect()` will lead to execution of the following. \r\n\r\n```\r\n/* Enables Ethernet interrupt and NVIC. */\r\n    ENET_EnableInterrupts(base, config->interrupt);\r\n    if (config->interrupt & (kENET_RxByteInterrupt | kENET_RxFrameInterrupt))\r\n    {\r\n        EnableIRQ(s_enetRxIrqId[instance]);\r\n    }\r\n    if (config->interrupt & (kENET_TxByteInterrupt | kENET_TxFrameInterrupt))\r\n    {\r\n        EnableIRQ(s_enetTxIrqId[instance]);\r\n    }\r\n    if (config->interrupt & (kENET_BabrInterrupt | kENET_BabtInterrupt | kENET_GraceStopInterrupt | kENET_MiiInterrupt |\r\n                             kENET_EBusERInterrupt | kENET_LateCollisionInterrupt | kENET_RetryLimitInterrupt |\r\n                             kENET_UnderrunInterrupt | kENET_PayloadRxInterrupt | kENET_WakeupInterrupt))\r\n    {\r\n        EnableIRQ(s_enetErrIrqId[instance]);\r\n    }\r\n```\r\n\r\nhttps://github.com/ARMmbed/mbed-os/blob/master/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/drivers/fsl_enet.c#L453\r\n\r\nAs it turns out, `EnableIRQ()` is an inline function defined in `fsl_common.h` as a link to an [NVIC_EnableIRQ](https://www.keil.com/pack/doc/cmsis/Core/html/group___n_v_i_c__gr.html) call:\r\n\r\n```\r\nstatic inline void EnableIRQ(IRQn_Type interrupt)\r\n{\r\n#if defined(FSL_FEATURE_SOC_INTMUX_COUNT) && (FSL_FEATURE_SOC_INTMUX_COUNT > 0)\r\n    if (interrupt < FSL_FEATURE_INTMUX_IRQ_START_INDEX)\r\n#endif\r\n    {\r\n        NVIC_EnableIRQ(interrupt);\r\n    }\r\n}\r\n```\r\n\r\nhttps://github.com/ARMmbed/mbed-os/blob/master/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/drivers/fsl_common.h#L182\r\n\r\nI could not trace the NVIC definition down any further as there were a very large number of them. However, I did check out the generated source code in a disassembler and it seems that `NVIC_EnableIRQ` is being translated to an [SVC](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0179b/ar01s02s07.html) 3 call.\r\n\r\nAre there a special configuration required for this? Does the default SVC_Handler function not handled this case for enabling interrupts? The behavior I am observing is that a call to this function never returns, so I can only guess (since I do not have a debugger) that the uVisor is trapping on this call. \r\n\r\n-----\r\n\r\nAs a side note, I tried using `UVISOR_PERMISSIVE` for my main ACL, but the problem still persists. \r\n\r\nAre there any obvious problems with using `NVIC_EnableIRQ` or writing to the MPU? Are there additional configuration requirements to support either? \r\n\r\nIf I comment out the offending MPU and NVIC_EnableIRQ lines then everything executes without issue -- except the Ethernet hardware does not work, of course. "},"comment":{"url":"https://api.github.com/repos/ARMmbed/uvisor/issues/comments/243837214","html_url":"https://github.com/ARMmbed/uvisor/issues/315#issuecomment-243837214","issue_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/315","id":243837214,"user":{"login":"sherrellbc","id":8580880,"avatar_url":"https://avatars.githubusercontent.com/u/8580880?v=3","gravatar_id":"","url":"https://api.github.com/users/sherrellbc","html_url":"https://github.com/sherrellbc","followers_url":"https://api.github.com/users/sherrellbc/followers","following_url":"https://api.github.com/users/sherrellbc/following{/other_user}","gists_url":"https://api.github.com/users/sherrellbc/gists{/gist_id}","starred_url":"https://api.github.com/users/sherrellbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherrellbc/subscriptions","organizations_url":"https://api.github.com/users/sherrellbc/orgs","repos_url":"https://api.github.com/users/sherrellbc/repos","events_url":"https://api.github.com/users/sherrellbc/events{/privacy}","received_events_url":"https://api.github.com/users/sherrellbc/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T17:24:03Z","updated_at":"2016-08-31T17:24:03Z","body":"@meriac \r\n\r\nI tried making the `MPU->RGDAAC[0] |= 0x007c0000` change in [uVisor](https://github.com/ARMmbed/uvisor/blob/master/core/system/inc/mpu/vmpu_freescale_k64_mem.h#L34) and then manually deploying the generated archives to mbed-os. This change did not seem to work. \r\n\r\n`#define UVISOR_TACL_BACKGROUND 0x000827D0U | 0x007C0000`\r\n\r\nActually, since I already went this far to do a bit of testing I went ahead and gave wide-open privileges for DMA as well:\r\n\r\n`#define UVISOR_TACL_BACKGROUND 0x000827D0U | 0x007C0000 | 0x0001F000`\r\n\r\nNone of that seemed to work, although this was admittedly a bruteforce attempt to just \"see what happens\". "}}
{"actor":{"display_login":"sherrellbc"}}