blip wrote:
I don't like the idea of depending on the state of something like this to differentiate what is what, it all seems very hacky. It's never a good idea for software to depend on reserved bit values. You never know when or if they'll change.
Yes I have to agree that depending on the reserved bits is just a door to trouble in the future. Theres only one reserved bit that just my hunch that will remain there for a very long time or my guess forever, which is the bit 1 in EFLAGS. For setting AC=1 isn't relying on any reserved bits at all, and really is no harm either way you turn this on or off, and technically I'm not relying on this bit to remain on (it should however), because its merely just a debugging case, if AC happends to be set and identified under a software interrupt generated case, then it happends so it can recover or output information correctly.
JAAman wrote:by reserved interrupts i assume you mean exceptions? soft-ints in exceptions are perfectly valid -- a GPF will trigger on a soft-int only if the IDT descriptor is set to only allow it in a higher ring
Well what I really mean was something in the long the lines of "
intel reserved software interrupting" if that makes it more clear.
JAAman wrote:-a software interrupt in the reserved interrupts ring0 will read as EFLAGS
...
no -- it will read as CS -- as far as i can tell, the only time it will read as eflags, is if it has an errorcode -- which will always be an exception
Thats wrong, if you do the math, specifically when theres no error code (theres always no error code if you software interrupt regardless if its
software intel reserved interrupted), [esp+8h] would point to EFLAGS in stack. To make this clear you can see it like:
When theres an error code..
[esp+Ch] - flage state before interrupt or exception (although not exactly on exceptions, RF may be set in this state)
[esp+8h] - return segment
[esp+4h] - return offset
[esp+0h] - error code
When theres
no error code..
[esp+8h] -
flage state before interrupt or exception
[esp+4h] - return segment
[esp+0h] - return offset
JAAman wrote:this does make it easier for me to do this (though i dont) -- there are only 2 possible CS values (kernel code, and user code)
You can scrap this now.. and yes, it is easy when you have [esp+8h] to be the return segment and identify it to be a software interrupt (because it must be a ring0 segment)
when your expecting [esp+8h] to be a segment. However, in this case we got EFLAGS, which we need to determin if its not a valid EFLAGS which is a completely differnt story.
I've tried anyways, to make a point that in the circumstance only within ring0 the exception handler will find a software interrupted case, (and ofcourse EFLAGS would be the value taken at [esp+8h] not your return segment), in normal cases such as within ring3 code, the handler is not able to identify that its
not an EFLAGS because the return segment would be RPL 3 matching the reserved bit 1 in EFLAGS. This makes things much more trivial then expecting a return segment in [esp+8] under those conditions.. its really hard to explain this which has several factors involved. But its probably because my grammer is just so awful.