On Mon, Mar 5, 2018 at 11:44 AM, Joerg Roedel <j...@8bytes.org> wrote:
> On Mon, Mar 05, 2018 at 09:51:29AM -0500, Brian Gerst wrote:
>> For the IRET fault case you will still need to catch it in the
>> exception code.  See the 64-bit code (.Lerror_bad_iret) for example.
>> For 32-bit, you could just expand that check to cover the whole exit
>> prologue after the CR3 switch, including the data segment loads.
>
> I had a look at the 64 bit code and the exception-in-kernel case seems
> to be handled differently than on 32 bit. The 64 bit entry code has
> checks for certain kinds of errors like iret exceptions.
>
> On 32 bit this is implemented via the standard exception tables which
> get an entry for every EIP that might fault (usually segment loading
> operations, but also iret).
>
> So, unless I am missing something, all the exception entry code has to
> do is to remember the stack and the cr3 with which it was entered (if
> entered from kernel mode) and restore those before iret. And this is
> what I implemented in v3 of this patch-set.

I also noticed that 32-bit will raise SIGILL for all IRET faults,
while 64-bit will raise SIGBUS (#NP/#SS) or SIGSEGV (#GP).  The 64-bit
code is better since it doesn't lose the original fault type, whereas
SIGILL is wrong for this case (illegal opcode).

--
Brian Gerst

Reply via email to