- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to check if the rdtsc instruction is supported by the processor and the operating system. The processor part is easy been done, but I have problem to check if the operation system is supporting this in other privileges than 0.
The general way is to read bit 2 from the control register CR4, but I cannot do this in PL3. Is there any workaround? I don't want to cause a Privileged Instruction exception.
The general way is to read bit 2 from the control register CR4, but I cannot do this in PL3. Is there any workaround? I don't want to cause a Privileged Instruction exception.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are on Linux, you can use something like the following:
#include
#include
bool
is_rdtsc_supported(void)
{
int tsc_supported = PR_TSC_SIGSEGV;
if (prctl(PR_GET_TSC, &tsc_supported) < 0)
return false;
return tsc_supported == PR_TSC_ENABLE;
}
#include
#include
bool
is_rdtsc_supported(void)
{
int tsc_supported = PR_TSC_SIGSEGV;
if (prctl(PR_GET_TSC, &tsc_supported) < 0)
return false;
return tsc_supported == PR_TSC_ENABLE;
}
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page