[BACK]Return to procfs_machdep.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / x86 / x86

Annotation of src/sys/arch/x86/x86/procfs_machdep.c, Revision 1.23.2.3

1.23.2.2  martin      1: /*     $NetBSD$ */
1.1       rmind       2:
                      3: /*
                      4:  * Copyright (c) 2001 Wasabi Systems, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * Written by Frank van der Linden and Jason R. Thorpe for
                      8:  * Wasabi Systems, Inc.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *      This product includes software developed for the NetBSD Project by
                     21:  *      Wasabi Systems, Inc.
                     22:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
                     23:  *    or promote products derived from this software without specific prior
                     24:  *    written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: /*
                     40:  * NOTE: We simply use the primary CPU's cpuid_level and tsc_freq
                     41:  * here.  Might want to change this later.
                     42:  */
                     43:
                     44: #include <sys/cdefs.h>
1.23.2.2  martin     45: __KERNEL_RCSID(0, "$NetBSD$");
1.1       rmind      46:
                     47: #include <sys/param.h>
                     48: #include <sys/systm.h>
                     49: #include <sys/mount.h>
                     50: #include <sys/stat.h>
                     51: #include <sys/vnode.h>
                     52:
                     53: #include <miscfs/procfs/procfs.h>
                     54:
                     55: #include <machine/cpu.h>
                     56: #include <machine/reg.h>
                     57: #include <machine/specialreg.h>
1.18      msaitoh    58: #include <x86/cputypes.h>
                     59: #include <x86/cpuvar.h>
1.1       rmind      60:
1.10      msaitoh    61: /*
1.11      msaitoh    62:  *  The feature table. The order is the same as Linux's
1.10      msaitoh    63:  *  x86/include/asm/cpufeatures.h.
                     64:  */
1.8       msaitoh    65: static const char * const x86_features[][32] = {
1.13      msaitoh    66:        { /* (0) Common: 0x0000001 edx */
1.1       rmind      67:        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
                     68:        "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
                     69:        "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
1.8       msaitoh    70:        "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe"},
                     71:
1.13      msaitoh    72:        { /* (1) AMD-defined: 0x80000001 edx */
1.8       msaitoh    73:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     74:        NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
                     75:        NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
                     76:        NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext","3dnow"},
                     77:
1.10      msaitoh    78:        { /* (2) Transmeta-defined */
1.8       msaitoh    79:        "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
                     80:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     81:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     82:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                     83:
1.10      msaitoh    84:        { /* (3) Linux mapping */
1.8       msaitoh    85:        "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
                     86:        "constant_tsc", NULL, NULL,
                     87:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     88:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                     89:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                     90:
1.13      msaitoh    91:        { /* (4) Intel-defined: 0x00000001 ecx */
1.8       msaitoh    92:        "pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
                     93:        "tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "xtpr", "pdcm",
                     94:        NULL, "pcid", "dca", "sse4_1", "sse4_2", "x2apic", "movbe", "popcnt",
                     95:        "tsc_deadline_timer", "aes", "xsave", NULL,
                     96:        "avx", "f16c", "rdrand", "hypervisor"},
                     97:
                     98:        { /* (5) VIA/Cyrix/Centaur-defined */
                     99:        NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
1.13      msaitoh   100:        "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
1.8       msaitoh   101:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    102:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    103:
                    104:        { /* (6) AMD defined 80000001 ecx */
                    105:        "lahf_lm", "cmp_legacy", "svm", "extapic",
                    106:        "cr8_legacy", "abm", "sse4a", "misalignsse",
                    107:        "3dnowprefetch", "osvw", "ibs", "xop", "skinit", "wdt", NULL, "lwp",
                    108:        "fma4", "tce", NULL, "nodeid_msr",
                    109:        NULL, "tbm", "topoext", "perfctr_core",
1.12      msaitoh   110:        "perfctr_nb", NULL, "bpext", "ptsc",
1.17      msaitoh   111:        "perfctr_llc", "mwaitx", NULL, NULL},
1.8       msaitoh   112:
1.10      msaitoh   113:        { /* (7) Linux mapping */
1.12      msaitoh   114:        NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
1.17      msaitoh   115:        "hw_pstate", "proc_feedback", "sme", NULL,
1.21      msaitoh   116:        NULL, NULL, NULL, NULL,
1.8       msaitoh   117:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1.23.2.1  christos  118:        NULL, "ibrs", "ibpb", "stibp", NULL, NULL, NULL, NULL},
1.8       msaitoh   119:
                    120:        { /* (8) Linux mapping */
                    121:        "tpr_shadow", "vnmi", "flexpriority", "ept",
                    122:        "vpid", "npt", "lbrv", "svm_lock",
                    123:        "nrip_save", "tsc_scale", "vmcb_clean", "flushbyasid",
                    124:        "decodeassists", "pausefilter", "pfthreshold", "vmmcall",
1.23.2.1  christos  125:        NULL, "ept_ad", NULL, NULL, NULL, NULL, NULL, NULL,
1.8       msaitoh   126:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    127:
                    128:        { /* (9) Intel-defined: 00000007 ebx */
                    129:        "fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
1.14      msaitoh   130:        "bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
1.12      msaitoh   131:        "avx512f", "avx512dq", "rdseed", "adx",
1.23.2.3! martin    132:        "smap", "avx512ifma", NULL, "clflushopt",
1.21      msaitoh   133:        "clwb", "intel_pt", "avx512pf", "avx512er",
1.12      msaitoh   134:        "avx512cd", "sha_ni", "avx512bw", "avx512vl"},
1.8       msaitoh   135:
1.17      msaitoh   136:        { /* (10) 0x0000000d:1 eax */
1.8       msaitoh   137:        "xsaveopt", "xsavec", "xgetbv1", "xsaves", NULL, NULL, NULL, NULL,
                    138:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    139:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    140:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    141:
1.10      msaitoh   142:        { /* (11) 0x0000000f:0 edx */
1.8       msaitoh   143:        NULL, "cqm_llc", NULL, NULL, NULL, NULL, NULL, NULL,
                    144:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    145:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    146:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    147:
1.10      msaitoh   148:        { /* (12) 0x0000000f:1 edx */
1.23.2.3! martin    149:        "cqm_occup_llc", "cqm_mbm_total", "cqm_mbm_local", NULL,
        !           150:        NULL, NULL, NULL, NULL,
1.8       msaitoh   151:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    152:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    153:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
1.15      msaitoh   154:
1.22      msaitoh   155:        { /* (13) AMD 0x80000008 ebx */
1.23.2.3! martin    156:        "clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
1.23.2.1  christos  157:        NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
1.15      msaitoh   158:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1.23.2.1  christos  159:        NULL, "virt_ssbd", NULL, NULL, NULL, NULL, NULL, NULL},
1.15      msaitoh   160:
                    161:        { /* (14) 0x00000006 eax */
                    162:        "dtherm", "ida", "arat", NULL, "pln", NULL, "pts", "hwp",
                    163:        "hwp_notify", "hwp_act_window", "hwp_epp","hwp_pkg_req",
                    164:        NULL, NULL, NULL, NULL,
                    165:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    166:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    167:
                    168:        { /* (15) 0x8000000a edx */
                    169:        "npt", "lbrv", "svm_lock", "nrip_save",
                    170:        "tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
1.17      msaitoh   171:        NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
                    172:        "v_vmsave_vmload",
                    173:        "vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1.15      msaitoh   174:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
                    175:
                    176:        { /* (16) 0x00000007:0 ecx */
1.22      msaitoh   177:        NULL, "avx512vbmi", "umip", "pku",
1.23.2.3! martin    178:        "ospke", "waitpkg", "avx512_vbmi2", NULL,
1.22      msaitoh   179:        "gfni", "vaes", "vpclmulqdq", "avx512_vnni",
1.23.2.1  christos  180:        "avx512_bitalg", "tme", "avx512_vpopcntdq", NULL,
1.15      msaitoh   181:        "la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
1.23.2.1  christos  182:        NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, NULL, NULL},
1.15      msaitoh   183:
                    184:        { /* (17) 0x80000007 ebx */
1.20      msaitoh   185:        "overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
1.15      msaitoh   186:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    187:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                    188:        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
1.22      msaitoh   189:
                    190:        { /* (18) Intel 0x00000007 edx */
1.23.2.2  martin    191:        NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
                    192:        "vp2intersect", NULL, "md_clear", NULL, NULL, NULL, NULL, NULL,
1.23.2.1  christos  193:        NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
                    194:        NULL, NULL, NULL, NULL,
                    195:        "flush_l1d", "arch_capabilities", NULL, "ssbd"},
1.1       rmind     196: };
                    197:
1.6       christos  198: static int     procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
1.1       rmind     199:
                    200: /*
                    201:  * Linux-style /proc/cpuinfo.
                    202:  * Only used when procfs is mounted with -o linux.
                    203:  *
                    204:  * In the multiprocessor case, this should be a loop over all CPUs.
                    205:  */
                    206: int
1.6       christos  207: procfs_getcpuinfstr(char *bf, size_t *len)
1.1       rmind     208: {
                    209:        struct cpu_info *ci;
                    210:        CPU_INFO_ITERATOR cii;
1.6       christos  211:        size_t i, total, size, used;
1.1       rmind     212:
1.6       christos  213:        i = total = 0;
                    214:        used = size = *len;
1.8       msaitoh   215:
1.1       rmind     216:        for (CPU_INFO_FOREACH(cii, ci)) {
1.6       christos  217:                procfs_getonecpu(i++, ci, bf, &used);
                    218:                total += used + 1;
1.16      msaitoh   219:                if (used + 1 <= size) {
1.1       rmind     220:                        bf += used;
                    221:                        *bf++ = '\n';
1.6       christos  222:                        size -= used + 1;
                    223:                        used = size;
                    224:                } else
                    225:                        used = 0;
1.1       rmind     226:        }
1.6       christos  227:        size = *len;
                    228:        *len = total;
                    229:        return size < *len ? -1 : 0;
1.1       rmind     230: }
                    231:
                    232: static int
1.8       msaitoh   233: procfs_getonefeatreg(uint32_t reg, const char * const *table, char *p,
                    234:     size_t *left)
                    235: {
                    236:        size_t l;
                    237:
                    238:        for (size_t i = 0; i < 32; i++) {
1.23.2.1  christos  239:                if ((reg & (1U << i)) && table[i]) {
1.8       msaitoh   240:                        l = snprintf(p, *left, "%s ", table[i]);
                    241:                        if (l < *left) {
                    242:                                *left -= l;
                    243:                                p += l;
                    244:                        } else
                    245:                                break;
                    246:                }
                    247:        }
                    248:
                    249:        return 0; /* XXX */
                    250: }
                    251:
                    252: /*
1.10      msaitoh   253:  * Print feature bits. The code assume that unused entry of x86_features[]
1.8       msaitoh   254:  * is zero-cleared.
                    255:  *
                    256:  * XXX This function will be rewritten when all of linux entries are
                    257:  * decoded.
                    258:  */
                    259: static int
                    260: procfs_getonecpufeatures(struct cpu_info *ci, char *p, size_t *left)
                    261: {
                    262:        size_t last = *left;
                    263:        size_t diff;
1.17      msaitoh   264:        u_int descs[4];
1.8       msaitoh   265:
                    266:        procfs_getonefeatreg(ci->ci_feat_val[0], x86_features[0], p, left);
                    267:        diff = last - *left;
                    268:
                    269:        procfs_getonefeatreg(ci->ci_feat_val[2], x86_features[1], p + diff,
                    270:            left);
                    271:        diff = last - *left;
                    272:
                    273:        /* x86_features[2] is for Transmeta */
                    274:        /* x86_features[3] is Linux defined mapping */
                    275:
                    276:        procfs_getonefeatreg(ci->ci_feat_val[1], x86_features[4], p + diff,
                    277:            left);
                    278:        diff = last - *left;
                    279:
                    280:        procfs_getonefeatreg(ci->ci_feat_val[4], x86_features[5], p + diff,
                    281:            left);
                    282:        diff = last - *left;
                    283:
                    284:        procfs_getonefeatreg(ci->ci_feat_val[3], x86_features[6], p + diff,
                    285:            left);
                    286:        diff = last - *left;
                    287:
                    288:        /* x86_features[7] is Linux defined mapping */
                    289:        /* x86_features[8] is Linux defined mapping */
                    290:
                    291:        procfs_getonefeatreg(ci->ci_feat_val[5], x86_features[9], p + diff,
                    292:            left);
                    293:        diff = last - *left;
                    294:
1.18      msaitoh   295:        if (ci->ci_max_cpuid >= 0x0d) {
1.17      msaitoh   296:                x86_cpuid2(0x0d, 1, descs);
                    297:                procfs_getonefeatreg(descs[0], x86_features[10], p + diff,
                    298:                    left);
                    299:                diff = last - *left;
                    300:        }
                    301:
1.18      msaitoh   302:        if (ci->ci_max_cpuid >= 0x0f) {
1.17      msaitoh   303:                x86_cpuid2(0x0f, 0, descs);
                    304:                procfs_getonefeatreg(descs[3], x86_features[11], p + diff,
                    305:                    left);
                    306:                diff = last - *left;
                    307:
                    308:                x86_cpuid2(0x0f, 1, descs);
                    309:                procfs_getonefeatreg(descs[3], x86_features[12], p + diff,
                    310:                    left);
                    311:                diff = last - *left;
                    312:        }
                    313:
1.18      msaitoh   314:        if ((cpu_vendor == CPUVENDOR_AMD)
                    315:            && (ci->ci_max_ext_cpuid >= 0x80000008)) {
                    316:                x86_cpuid(0x80000008, descs);
                    317:                procfs_getonefeatreg(descs[1], x86_features[13], p + diff,
                    318:                    left);
                    319:                diff = last - *left;
                    320:        }
1.17      msaitoh   321:
1.18      msaitoh   322:        if (ci->ci_max_cpuid >= 0x06) {
1.17      msaitoh   323:                x86_cpuid(0x06, descs);
                    324:                procfs_getonefeatreg(descs[0], x86_features[14], p + diff,
                    325:                    left);
                    326:                diff = last - *left;
                    327:        }
                    328:
1.18      msaitoh   329:        if ((cpu_vendor == CPUVENDOR_AMD)
                    330:            && (ci->ci_max_ext_cpuid >= 0x8000000a)) {
                    331:                x86_cpuid(0x8000000a, descs);
                    332:                procfs_getonefeatreg(descs[3], x86_features[15], p + diff,
                    333:                    left);
                    334:                diff = last - *left;
                    335:        }
1.15      msaitoh   336:
                    337:        procfs_getonefeatreg(ci->ci_feat_val[6], x86_features[16], p + diff,
                    338:            left);
                    339:        diff = last - *left;
                    340:
1.18      msaitoh   341:        if ((cpu_vendor == CPUVENDOR_AMD)
                    342:            && (ci->ci_max_ext_cpuid >= 0x80000007)) {
                    343:                x86_cpuid(0x80000007, descs);
                    344:                procfs_getonefeatreg(descs[1], x86_features[17], p + diff,
                    345:                    left);
                    346:                diff = last - *left;
                    347:        }
1.10      msaitoh   348:
1.22      msaitoh   349:        if ((cpu_vendor == CPUVENDOR_INTEL)
                    350:            && (ci->ci_max_cpuid >= 0x00000007)) {
                    351:                x86_cpuid(0x00000007, descs);
                    352:                procfs_getonefeatreg(descs[3], x86_features[18], p + diff,
                    353:                    left);
                    354:                diff = last - *left;
                    355:        }
                    356:
1.8       msaitoh   357:        return 0; /* XXX */
                    358: }
                    359:
                    360: static int
1.6       christos  361: procfs_getonecpu(int xcpu, struct cpu_info *ci, char *bf, size_t *len)
1.1       rmind     362: {
1.6       christos  363:        size_t left, l, size;
                    364:        char featurebuf[1024], *p;
1.1       rmind     365:
                    366:        p = featurebuf;
                    367:        left = sizeof(featurebuf);
1.6       christos  368:        size = *len;
1.8       msaitoh   369:        procfs_getonecpufeatures(ci, p, &left);
1.1       rmind     370:
                    371:        p = bf;
                    372:        left = *len;
1.6       christos  373:        size = 0;
1.1       rmind     374:        l = snprintf(p, left,
                    375:            "processor\t: %d\n"
                    376:            "vendor_id\t: %s\n"
                    377:            "cpu family\t: %d\n"
                    378:            "model\t\t: %d\n"
                    379:            "model name\t: %s\n"
                    380:            "stepping\t: ",
                    381:            xcpu,
                    382:            (char *)ci->ci_vendor,
1.9       msaitoh   383:            CPUID_TO_FAMILY(ci->ci_signature),
                    384:            CPUID_TO_MODEL(ci->ci_signature),
1.1       rmind     385:            cpu_brand_string
                    386:        );
1.6       christos  387:        size += l;
                    388:        if (l < left) {
                    389:                left -= l;
                    390:                p += l;
                    391:        } else
                    392:                left = 0;
1.1       rmind     393:
                    394:        if (cpuid_level >= 0)
1.9       msaitoh   395:                l = snprintf(p, left, "%d\n",
                    396:                    CPUID_TO_STEPPING(ci->ci_signature));
1.1       rmind     397:        else
                    398:                l = snprintf(p, left, "unknown\n");
                    399:
1.6       christos  400:        size += l;
                    401:        if (l < left) {
                    402:                left -= l;
                    403:                p += l;
                    404:        } else
                    405:                left = 0;
1.1       rmind     406:
                    407:        if (ci->ci_data.cpu_cc_freq != 0) {
                    408:                uint64_t freq, fraq;
                    409:
                    410:                freq = (ci->ci_data.cpu_cc_freq + 4999) / 1000000;
                    411:                fraq = ((ci->ci_data.cpu_cc_freq + 4999) / 10000) % 100;
1.8       msaitoh   412:                l = snprintf(p, left, "cpu MHz\t\t: %" PRIu64 ".%02" PRIu64
                    413:                    "\n", freq, fraq);
1.1       rmind     414:        } else
                    415:                l = snprintf(p, left, "cpu MHz\t\t: unknown\n");
                    416:
1.6       christos  417:        size += l;
                    418:        if (l < left) {
                    419:                left -= l;
                    420:                p += l;
                    421:        } else
                    422:                left = 0;
1.1       rmind     423:
                    424:        l = snprintf(p, left,
1.23.2.1  christos  425:            "apicid\t\t: %lu\n"
                    426:            "initial apicid\t: %u\n",
                    427:            ci->ci_cpuid,
1.15      msaitoh   428:            ci->ci_initapicid
                    429:        );
                    430:        size += l;
                    431:        if (l < left) {
                    432:                left -= l;
                    433:                p += l;
                    434:        } else
                    435:                left = 0;
                    436:
                    437:        l = snprintf(p, left,
                    438: #ifdef __i386__
1.1       rmind     439:            "fdiv_bug\t: %s\n"
1.15      msaitoh   440: #endif
1.19      maya      441:            "fpu\t\t: yes\n"
1.2       dsl       442:            "fpu_exception\t: yes\n"
1.1       rmind     443:            "cpuid level\t: %d\n"
                    444:            "wp\t\t: %s\n"
1.15      msaitoh   445:            "flags\t\t: %s\n"
                    446:            "clflush size\t: %d\n",
                    447: #ifdef __i386__
1.3       dsl       448:            i386_fpu_fdivbug ? "yes" : "no",    /* an old pentium */
1.15      msaitoh   449: #endif
1.18      msaitoh   450:            ci->ci_max_cpuid,
1.1       rmind     451:            (rcr0() & CR0_WP) ? "yes" : "no",
1.15      msaitoh   452:            featurebuf,
                    453:            ci->ci_cflush_lsize
1.1       rmind     454:        );
1.6       christos  455:        size += l;
1.1       rmind     456:
1.6       christos  457:        left = *len;
                    458:        *len = size;
                    459:        return left < *len ? -1 : 0;
1.1       rmind     460: }
                    461:
                    462: #if defined(__HAVE_PROCFS_MACHDEP) && !defined(__x86_64__)
                    463:
                    464: void
                    465: procfs_machdep_allocvp(struct vnode *vp)
                    466: {
                    467:        struct pfsnode *pfs = vp->v_data;
                    468:
                    469:        switch (pfs->pfs_type) {
                    470:        case Pmachdep_xmmregs:
                    471:                /* /proc/N/xmmregs = -rw------- */
                    472:                pfs->pfs_mode = S_IRUSR|S_IWUSR;
                    473:                vp->v_type = VREG;
                    474:                break;
                    475:        default:
                    476:                KASSERT(false);
                    477:        }
                    478: }
                    479:
                    480: int
                    481: procfs_machdep_rw(struct lwp *curl, struct lwp *l, struct pfsnode *pfs,
                    482:     struct uio *uio)
                    483: {
                    484:
                    485:        switch (pfs->pfs_type) {
                    486:        case Pmachdep_xmmregs:
                    487:                return (procfs_machdep_doxmmregs(curl, l, pfs, uio));
                    488:        default:
                    489:                KASSERT(false);
                    490:        }
                    491:        return EINVAL;
                    492: }
                    493:
                    494: int
                    495: procfs_machdep_getattr(struct vnode *vp, struct vattr *vap, struct proc *procp)
                    496: {
                    497:        struct pfsnode *pfs = VTOPFS(vp);
                    498:
                    499:        switch (pfs->pfs_type) {
                    500:        case Pmachdep_xmmregs:
                    501:                vap->va_bytes = vap->va_size = sizeof(struct xmmregs);
                    502:                break;
                    503:        default:
                    504:                KASSERT(false);
                    505:        }
                    506:        return 0;
                    507: }
                    508:
                    509: int
                    510: procfs_machdep_doxmmregs(struct lwp *curl, struct lwp *l,
                    511:     struct pfsnode *pfs, struct uio *uio)
                    512: {
                    513:
                    514:        return process_machdep_doxmmregs(curl, l, uio);
                    515: }
                    516:
                    517: int
                    518: procfs_machdep_validxmmregs(struct lwp *l, struct mount *mp)
                    519: {
                    520:
                    521:        return process_machdep_validxmmregs(l->l_proc);
                    522: }
                    523:
                    524: #endif

CVSweb <webmaster@jp.NetBSD.org>