Bug 93498 - Request for implementing SIDT instruction
Summary: Request for implementing SIDT instruction
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 230085 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-18 13:26 UTC by Dennis Lubert
Modified: 2010-04-13 11:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
A patch for the SIDT and SGDT support in VEX on x86 and amd64 (5.88 KB, patch)
2010-04-06 15:58 UTC, Alexander Potapenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Lubert 2004-11-18 13:26:20 UTC
As stated on http://invisiblethings.org/papers/redpill.html the SIDT instruction
can be used by programs to detect if they run on a vm or not. It would be nice
if valgrind could implement it such that a program is not able to distingiush
between real and valgrind, so one can create a skin for analysing such tools.
Comment 1 Alexander Potapenko 2010-04-06 13:21:04 UTC
*** Bug 230085 has been marked as a duplicate of this bug. ***
Comment 2 Alexander Potapenko 2010-04-06 15:58:06 UTC
Created attachment 42530 [details]
A patch for the SIDT and SGDT support in VEX on x86 and amd64

This patch implements the SIDT and SGDT instructions support via a dirty helper that invokes native (x86/amd64) S{I,G}DT instructions. The approach is transparent for the client applications, so the redpill method is not able to distinguish between a native run and a Valgrind run.
Comment 3 Tom Hughes 2010-04-06 16:21:06 UTC
Can you provide some rationale as to why simply passing these instructions through is valid? Given that, as I understand it, the descriptor tables affect the interpretation of segment registers I would have though valgrind would need to be aware of any changes made to the descriptor tables?
Comment 4 Alexander Potapenko 2010-04-06 17:17:07 UTC
(In reply to comment #3)
> Can you provide some rationale as to why simply passing these instructions
> through is valid? Given that, as I understand it, the descriptor tables affect
> the interpretation of segment registers I would have though valgrind would need
> to be aware of any changes made to the descriptor tables?

IIUC, the SIDT and SGDT instructions do not modify the descriptor tables, only LIDT/LGDT do (which are harder to implement). Reading the descriptor tables shouldn't affect the segment registers. Am I missing something?
Comment 5 Tom Hughes 2010-04-06 17:45:20 UTC
Ah OK I had my load/store ideas the wrong way round. That should be fine then. Obviously as it's a VEX issue Julian will need to deal with it anyway.
Comment 6 Julian Seward 2010-04-12 23:29:57 UTC
Alexander, can you explain why you want to use this instruction?
According to the Intel documentation "SIDT is only useful in
operating-system software; however it can be used in application
programs without causing an exception to be generated."
Comment 7 Alexander Potapenko 2010-04-13 11:08:02 UTC
(In reply to comment #6)
The SIDT instruction is for some strange reason used by the client code in Mac OS 10.6 (see https://bugs.kde.org/show_bug.cgi?id=205241#c36), so Valgrind can't work on Snow Leopard without having it implemented.

> Alexander, can you explain why you want to use this instruction?
> According to the Intel documentation "SIDT is only useful in
> operating-system software; however it can be used in application
> programs without causing an exception to be generated."