This is the mail archive of the
mailing list for the GCC project.
Re: [cfe-dev] RFC: Support x86 interrupt and exception handlers
- From: David Chisnall <David dot Chisnall at cl dot cam dot ac dot uk>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: John Criswell <jtcriswel at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, cfe-dev at lists dot llvm dot org
- Date: Tue, 22 Sep 2015 12:52:20 +0100
- Subject: Re: [cfe-dev] RFC: Support x86 interrupt and exception handlers
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOpKPxK-79pBO-MyiMzGqd=9gxDxJdRnDvdq4UumUTakHQ at mail dot gmail dot com> <CAMe9rOp8hma_3b49oMjWeixLPTeiQFX2MUxSbftMNmfjP4A0-Q at mail dot gmail dot com> <CAMe9rOpOC43+AOBsp8CMdzhCMQrGqzjpj+zTzaZ=SDKmd4GB1w at mail dot gmail dot com> <CAMe9rOpRRuBxHXzEKhSOO67VPkUQnx=gVuMAxq0snyTFxF+gaA at mail dot gmail dot com> <560051EF dot 70405 at gmail dot com> <CAMe9rOpLcvZOLrE+4v-M+CbWs5hw0j4EpfNGuE+myoaFdhpf5Q at mail dot gmail dot com> <9038C99C-408A-4E41-AA9A-6481227BFACB at cl dot cam dot ac dot uk> <CAMe9rOqPTMnrJ+aHVdLp+xvHXXUGONcyyCzmjMmqcLCJ7bduRQ at mail dot gmail dot com>
On 22 Sep 2015, at 12:47, H.J. Lu <email@example.com> wrote:
> since __builtin_exception_error () is the same as
> __builtin_return_address (0) and __builtin_interrupt_data () is
> address of __builtin_exception_error () + size of register.
Except that theyâre *not*. __builtin_return_address(0) is guaranteed to be the same for the duration of the function. __builtin_exception_error() needs to either:
1) Fetch the values early with interrupts disabled, store them in a well-known location, and load them from this place when the intrinsic is called, or
2) Force any function that calls the intrinsic (and wants a meaningful result) to run with interrupts disabled, which is something that the compiler canât verify without knowing the full chain of code from the interrupt handler to the current point (and therefore prone to error).
It is trivial to write a little bit of inline assembly that reads these values from the CPU and expose that for C code. There is a good reason why no one does this.
Without a better programmer model, you are not simplifying things, you are just providing more ways for introducing errors.