{"action":"closed","issue":{"url":"https://api.github.com/repos/riscv/riscv-isa-manual/issues/106","repository_url":"https://api.github.com/repos/riscv/riscv-isa-manual","labels_url":"https://api.github.com/repos/riscv/riscv-isa-manual/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/riscv/riscv-isa-manual/issues/106/comments","events_url":"https://api.github.com/repos/riscv/riscv-isa-manual/issues/106/events","html_url":"https://github.com/riscv/riscv-isa-manual/issues/106","id":259258941,"node_id":"MDU6SXNzdWUyNTkyNTg5NDE=","number":106,"title":"Possible clarification for what's written to mepc for ecall/ebreak?","user":{"login":"maikmerten","id":2611432,"node_id":"MDQ6VXNlcjI2MTE0MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/2611432?v=4","gravatar_id":"","url":"https://api.github.com/users/maikmerten","html_url":"https://github.com/maikmerten","followers_url":"https://api.github.com/users/maikmerten/followers","following_url":"https://api.github.com/users/maikmerten/following{/other_user}","gists_url":"https://api.github.com/users/maikmerten/gists{/gist_id}","starred_url":"https://api.github.com/users/maikmerten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maikmerten/subscriptions","organizations_url":"https://api.github.com/users/maikmerten/orgs","repos_url":"https://api.github.com/users/maikmerten/repos","events_url":"https://api.github.com/users/maikmerten/events{/privacy}","received_events_url":"https://api.github.com/users/maikmerten/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-09-20T18:29:36Z","updated_at":"2018-11-19T01:07:25Z","closed_at":"2018-11-19T01:07:25Z","author_association":"NONE","body":"From the privileged spec 1.10, section 3.1.19 (page 34):\r\n\r\n\"When a trap is taken into M-mode, mepc is written with the virtual address of the instruction that\r\nencountered the exception.\"\r\n\r\nAfter reading this I was still unclear about what the content of mepc should be in the case of ecall/ebreak.\r\n - if ecall/ebreak is the instruction that \"encounters\" the exception, then mepc should contain the address of that ecall/ebreak instruction. In this case mepc will *not* denote where execution should resume: instead mepc needs to be loaded, incremented by 4 and updated accordingly before a mret can be executed.\r\n - if ecall/ebreak are merely \"setting up\" the exception, then the succeeding instruction may be the one that \"encounters\" them. In this case mret can be called directly.\r\n\r\nAccording to IRC conversations, it appears that the first case is the intended one. Perhaps it's helpful to some users to clarify this in the manuals.\r\n\r\nFor other types of exceptions (e.g. external interrupts or timers) it appears that mepc will contain the address where execution should resume after exception handling (i.e., a \"proper\" return address for mret to use)."}}
{"actor":{"display_login":"aswaterman"}}