11package hwapi
22
3- //Model specific registers
3+ // Model specific registers
44const (
55 msrSMBase int64 = 0x9e //nolint
66 msrMTRRCap int64 = 0xfe
@@ -18,11 +18,11 @@ type IA32Debug struct {
1818 PCHStrap bool
1919}
2020
21- //HasSMRR returns true if the CPU supports SMRR
21+ // HasSMRR returns true if the CPU supports SMRR
2222func HasSMRR (h LowLevelHardwareInterfaces ) (bool , error ) {
2323 mtrrcap := h .ReadMSR (msrMTRRCap )
2424
25- return (mtrrcap [ 0 ] >> 11 )& 1 != 0 , nil
25+ return (mtrrcap >> 11 )& 1 != 0 , nil
2626}
2727
2828// SMRR for the SMM code.
@@ -40,50 +40,50 @@ func GetSMRRInfo(h LowLevelHardwareInterfaces) (SMRR, error) {
4040
4141 smrrPhysmask := h .ReadMSR (msrSMRRPhysMask )
4242
43- ret .Active = (smrrPhysmask [ 0 ] >> 11 )& 1 != 0
44- ret .PhysBase = (smrrPhysbase [ 0 ] >> 12 ) & 0xfffff
45- ret .PhysMask = (smrrPhysmask [ 0 ] >> 12 ) & 0xfffff
43+ ret .Active = (smrrPhysmask >> 11 )& 1 != 0
44+ ret .PhysBase = (smrrPhysbase >> 12 ) & 0xfffff
45+ ret .PhysMask = (smrrPhysmask >> 12 ) & 0xfffff
4646
4747 return ret , nil
4848}
4949
50- //IA32FeatureControlIsLocked returns true if the IA32_FEATURE_CONTROL msr is locked
50+ // IA32FeatureControlIsLocked returns true if the IA32_FEATURE_CONTROL msr is locked
5151func IA32FeatureControlIsLocked (h LowLevelHardwareInterfaces ) (bool , error ) {
5252 featCtrl := h .ReadMSR (msrFeatureControl )
5353
54- return featCtrl [ 0 ] & 1 != 0 , nil
54+ return featCtrl & 1 != 0 , nil
5555}
5656
57- //IA32PlatformID returns the IA32_PLATFORM_ID msr
57+ // IA32PlatformID returns the IA32_PLATFORM_ID msr
5858func IA32PlatformID (h LowLevelHardwareInterfaces ) (uint64 , error ) {
5959 pltID := h .ReadMSR (msrPlatformID )
6060
61- return pltID [ 0 ] , nil
61+ return pltID , nil
6262}
6363
64- //AllowsVMXInSMX returns true if VMX is allowed in SMX
64+ // AllowsVMXInSMX returns true if VMX is allowed in SMX
6565func AllowsVMXInSMX (h LowLevelHardwareInterfaces ) (bool , error ) {
6666 featCtrl := h .ReadMSR (msrFeatureControl )
6767
6868 var mask uint64 = (1 << 1 ) & (1 << 5 ) & (1 << 6 )
69- return (mask & featCtrl [ 0 ] ) == mask , nil
69+ return (mask & featCtrl ) == mask , nil
7070}
7171
72- //TXTLeavesAreEnabled returns true if all TXT leaves are enabled
72+ // TXTLeavesAreEnabled returns true if all TXT leaves are enabled
7373func TXTLeavesAreEnabled (h LowLevelHardwareInterfaces ) (bool , error ) {
7474 featCtrl := h .ReadMSR (msrFeatureControl )
7575
76- txtBits := (featCtrl [ 0 ] >> 8 ) & 0x1ff
76+ txtBits := (featCtrl >> 8 ) & 0x1ff
7777 return (txtBits & 0xff == 0xff ) || (txtBits & 0x100 == 0x100 ), nil
7878}
7979
80- //IA32DebugInterfaceEnabledOrLocked returns the enabled, locked and pchStrap state of IA32_DEBUG_INTERFACE msr
80+ // IA32DebugInterfaceEnabledOrLocked returns the enabled, locked and pchStrap state of IA32_DEBUG_INTERFACE msr
8181func IA32DebugInterfaceEnabledOrLocked (h LowLevelHardwareInterfaces ) (* IA32Debug , error ) {
8282 var debugMSR IA32Debug
8383 debugInterfaceCtrl := h .ReadMSR (msrIA32DebugInterface )
8484
85- debugMSR .Enabled = (debugInterfaceCtrl [ 0 ] >> 0 )& 1 != 0
86- debugMSR .Locked = (debugInterfaceCtrl [ 0 ] >> 30 )& 1 != 0
87- debugMSR .PCHStrap = (debugInterfaceCtrl [ 0 ] >> 31 )& 1 != 0
85+ debugMSR .Enabled = (debugInterfaceCtrl >> 0 )& 1 != 0
86+ debugMSR .Locked = (debugInterfaceCtrl >> 30 )& 1 != 0
87+ debugMSR .PCHStrap = (debugInterfaceCtrl >> 31 )& 1 != 0
8888 return & debugMSR , nil
8989}
0 commit comments