{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/uvisor/issues/87","labels_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/87/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/87/comments","events_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/87/events","html_url":"https://github.com/ARMmbed/uvisor/issues/87","id":113836274,"number":87,"title":"Context switch bug","user":{"login":"meriac","id":408576,"avatar_url":"https://avatars.githubusercontent.com/u/408576?v=3","gravatar_id":"","url":"https://api.github.com/users/meriac","html_url":"https://github.com/meriac","followers_url":"https://api.github.com/users/meriac/followers","following_url":"https://api.github.com/users/meriac/following{/other_user}","gists_url":"https://api.github.com/users/meriac/gists{/gist_id}","starred_url":"https://api.github.com/users/meriac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meriac/subscriptions","organizations_url":"https://api.github.com/users/meriac/orgs","repos_url":"https://api.github.com/users/meriac/repos","events_url":"https://api.github.com/users/meriac/events{/privacy}","received_events_url":"https://api.github.com/users/meriac/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ARMmbed/uvisor/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ARMmbed/uvisor/labels/issue","name":"issue","color":"fbca04"},{"url":"https://api.github.com/repos/ARMmbed/uvisor/labels/mirrored","name":"mirrored","color":"ededed"}],"state":"closed","locked":false,"assignee":{"login":"AlessandroA","id":8617445,"avatar_url":"https://avatars.githubusercontent.com/u/8617445?v=3","gravatar_id":"","url":"https://api.github.com/users/AlessandroA","html_url":"https://github.com/AlessandroA","followers_url":"https://api.github.com/users/AlessandroA/followers","following_url":"https://api.github.com/users/AlessandroA/following{/other_user}","gists_url":"https://api.github.com/users/AlessandroA/gists{/gist_id}","starred_url":"https://api.github.com/users/AlessandroA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlessandroA/subscriptions","organizations_url":"https://api.github.com/users/AlessandroA/orgs","repos_url":"https://api.github.com/users/AlessandroA/repos","events_url":"https://api.github.com/users/AlessandroA/events{/privacy}","received_events_url":"https://api.github.com/users/AlessandroA/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-10-28T14:39:39Z","updated_at":"2015-11-27T19:46:09Z","closed_at":"2015-11-27T19:46:09Z","body":"- Fix the interrupt bug related to tailchained IRQ that happen during a context switch.\r\n- Affects EFM32GG\r\n\r\nAcceptance criteria:\r\n- create test to reproduce the behaviour\r\n- verify the bug if fixed in the context of the test"},"comment":{"url":"https://api.github.com/repos/ARMmbed/uvisor/issues/comments/160195205","html_url":"https://github.com/ARMmbed/uvisor/issues/87#issuecomment-160195205","issue_url":"https://api.github.com/repos/ARMmbed/uvisor/issues/87","id":160195205,"user":{"login":"AlessandroA","id":8617445,"avatar_url":"https://avatars.githubusercontent.com/u/8617445?v=3","gravatar_id":"","url":"https://api.github.com/users/AlessandroA","html_url":"https://github.com/AlessandroA","followers_url":"https://api.github.com/users/AlessandroA/followers","following_url":"https://api.github.com/users/AlessandroA/following{/other_user}","gists_url":"https://api.github.com/users/AlessandroA/gists{/gist_id}","starred_url":"https://api.github.com/users/AlessandroA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlessandroA/subscriptions","organizations_url":"https://api.github.com/users/AlessandroA/orgs","repos_url":"https://api.github.com/users/AlessandroA/repos","events_url":"https://api.github.com/users/AlessandroA/events{/privacy}","received_events_url":"https://api.github.com/users/AlessandroA/received_events","type":"User","site_admin":false},"created_at":"2015-11-27T19:46:09Z","updated_at":"2015-11-27T19:46:09Z","body":"This bug has been addressed with https://github.com/ARMmbed/uvisor/issues/113.\r\n\r\nThe problem was not related to interrupts tailchaining as it was thought at the beginning. Instead, a particular interrupt configuration allowed an IRQ to be enabled (`vIRQ_EnableIRQ`) even before being registered (`vIRQ_SetVector`).\r\n\r\nAlthough this is a pattern that is not recommended for NVIC interrupts, some missing checks in uVisor made it hard to detect and debug. With https://github.com/ARMmbed/uvisor/issues/113 those checks are now in place, and an error is issued when NVIC flags for an IRQ are changed before registering the corresponding ISR.\r\n\r\n@akselsm As for the EFM32GG, the problem was a missing interrupt registration in the GPIO HAL initialization. As described in the `uvisor-lib` [documentation](https://github.com/ARMmbed/uvisor-lib#interrupt-management), interrupts need to be registered before being enabled, as without registration uVisor cannot ensure ownership and protection from other secure boxes.\r\n```C\r\nvIRQ_SetVector(SOME_IRQn, (uint32_t) &SOME_IRQHandler);\r\nvIRQ_EnableIRQ(SOME_IRQn);\r\n```"}}