]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/pc/devarch.c
kernel: cleanup the software mouse cursor mess
[plan9front.git] / sys / src / 9 / pc / devarch.c
index 55d41cdf8d58f47e9222c2e5bc6987a467112e89..2da6f5d556590560a186c954ea46e777f605ab63 100644 (file)
@@ -400,7 +400,7 @@ archread(Chan *c, void *a, long n, vlong offset)
                if((uint)n/8 > -port)
                        error(Ebadarg);
                end = port+(n/8);
-               for(vp = a; port < end; port++)
+               for(vp = a; port != end; port++)
                        if(rdmsr(port, vp++) < 0)
                                error(Ebadarg);
                return n;
@@ -473,7 +473,7 @@ archwrite(Chan *c, void *a, long n, vlong offset)
                if((uint)n/8 > -port)
                        error(Ebadarg);
                end = port+(n/8);
-               for(vp = a; port < end; port++)
+               for(vp = a; port != end; port++)
                        if(wrmsr(port, *vp++) < 0)
                                error(Ebadarg);
                return n;
@@ -684,6 +684,7 @@ static X86type x86amd[] =
        { 6,    -1,     11,     "AMD-Athlon", },/* guesswork */
        { 0xF,  -1,     11,     "AMD-K8", },    /* guesswork */
        { 0x1F, -1,     11,     "AMD-K10", },   /* guesswork */
+       { 23,   1,      13,     "AMD Ryzen" },
 
        { -1,   -1,     11,     "unknown", },   /* total default */
 };
@@ -898,10 +899,26 @@ cpuidentify(void)
        else
                hwrandbuf = nil;
        
-       /* 8-byte watchpoints are supported in Long Mode */
-       if(sizeof(uintptr) == 8)
+       if(sizeof(uintptr) == 8) {
+               /* 8-byte watchpoints are supported in Long Mode */
                m->havewatchpt8 = 1;
-       else if(strcmp(m->cpuidid, "GenuineIntel") == 0){
+
+               /* check and enable NX bit */
+               cpuid(Highextfunc, regs);
+               if(regs[0] >= Procextfeat){
+                       cpuid(Procextfeat, regs);
+                       if((regs[3] & (1<<20)) != 0){
+                               vlong efer;
+
+                               /* enable no-execute feature */
+                               if(rdmsr(Efer, &efer) != -1){
+                                       efer |= 1ull<<11;
+                                       if(wrmsr(Efer, efer) != -1)
+                                               m->havenx = 1;
+                               }
+                       }
+               }
+       } else if(strcmp(m->cpuidid, "GenuineIntel") == 0){
                /* some random CPUs that support 8-byte watchpoints */
                if(family == 15 && (model == 3 || model == 4 || model == 6)
                || family == 6 && (model == 15 || model == 23 || model == 28))