When setting up paging I decided to utilize the No-eXecute feature if available. To do so I first check if the cpuid instruction is available. If so, I use it to check for the MSR feature (CPUID.01h:EDX[bit 5]). This give me information of whether MSRs are supported at all, but it doesnt give me a specific overview of which registers are available on the current CPU. In order to check if EFER is supported I use cpuid again (CPUID.01h:EDX[bit 20]) this time to see if NX is enabled.
I was wondering, whether there is some way to list the available MSRs of the current CPU or if it is only described in online specifications, therefore making a check with cpuid (like for NX and EFER) needed.
Thanks for the support!
Detecting Model-Specific Registers
- CodePoet2005
- Posts: 1
- Joined: Sat Dec 28, 2024 1:02 pm
- Libera.chat IRC: CodePoet2005
- Location: Always @ Home
- GitHub: https://gitea.com/CodePoet2005
Re: Detecting Model-Specific Registers
Some model specific registers are architectual (see amd64 system programming manual appendix a(msr cross-reference).
Others are model specific, you can use CPUID to get the cpu vendor string, famlily model etc.
If i rembember correctly you can get this values with CPUID EAX = 1.
Also some msrs are pressent if your cpu has certain features (for example apic), you can also detect this with cpuid. As far that i know there is no cpuid function to detect model specific registers. You have to detect the cpu model (and features).
Happy programming
Others are model specific, you can use CPUID to get the cpu vendor string, famlily model etc.
If i rembember correctly you can get this values with CPUID EAX = 1.
Also some msrs are pressent if your cpu has certain features (for example apic), you can also detect this with cpuid. As far that i know there is no cpuid function to detect model specific registers. You have to detect the cpu model (and features).
Happy programming
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Detecting Model-Specific Registers
You always need to check CPUID. A list of available MSRs doesn't tell you what any of those MSRs do.
If you really want a list of MSRs, you could try reading all of them and see which ones don't cause #GP.
If you really want a list of MSRs, you could try reading all of them and see which ones don't cause #GP.