]> err.no Git - util-linux/commitdiff
lscpu: add {32,64}-bit CPU modes detection
authorKarel Zak <kzak@redhat.com>
Thu, 7 Jan 2010 16:34:03 +0000 (17:34 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 7 Jan 2010 16:34:03 +0000 (17:34 +0100)
This patch add "CPU op-mode(s):" field that prints all supported CPU
operation modes. The field is based on CPU flags:

rm (real mode)          16-bit
tm (transparent mode)   32-bit
lm (long mode)          64-bit

Example:

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
CPU(s):                2
Thread(s) per core:    1
Core(s) per socket:    2
CPU socket(s):         1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 15
Stepping:              11
CPU MHz:               1600.000
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu.c

index 6b6082fbfb08d632c9e7cafd53ecc17c052a905e..c200fb32f455a1a04c86a49f738030988ca097ab 100644 (file)
@@ -80,6 +80,12 @@ const char *hv_vendors[] = {
        [HYPER_MSHV]    = "Microsoft"
 };
 
+/* CPU modes (bits) */
+enum {
+       MODE_REAL       = (1 << 1),
+       MODE_TRANSPARENT = (1 << 2),
+       MODE_LONG       = (1 << 3)
+};
 
 /* CPU(s) description */
 struct cpu_desc {
@@ -108,6 +114,8 @@ struct cpu_desc {
        char    *stepping;
        char    *flags;
 
+       int     mode;           /* rm, lm or/and tm */
+
        /* NUMA */
        int     *nodecpu;
 };
@@ -285,6 +293,13 @@ read_basicinfo(struct cpu_desc *cpu)
                        cpu->virtflag = strdup("svm");
                else if (strstr(buf, " vmx "))
                        cpu->virtflag = strdup("vmx");
+
+               if (strstr(buf, " rm "))
+                       cpu->mode |= MODE_REAL;
+               if (strstr(buf, " tm "))
+                       cpu->mode |= MODE_TRANSPARENT;
+               if (strstr(buf, " lm "))
+                       cpu->mode |= MODE_LONG;
        }
 
        fclose(fp);
@@ -584,6 +599,26 @@ static void
 print_readable(struct cpu_desc *cpu)
 {
        print_s("Architecture:", cpu->arch);
+
+       if (cpu->mode & (MODE_REAL | MODE_TRANSPARENT | MODE_LONG)) {
+               char buf[64], *p = buf;
+
+               if (cpu->mode & MODE_REAL) {
+                       strcpy(p, "16-bit, ");
+                       p += 8;
+               }
+               if (cpu->mode & MODE_TRANSPARENT) {
+                       strcpy(p, "32-bit, ");
+                       p += 8;
+               }
+               if (cpu->mode & MODE_LONG) {
+                       strcpy(p, "64-bit, ");
+                       p += 8;
+               }
+               *(p - 2) = '\0';
+               print_s(_("CPU op-mode(s):"), buf);
+       }
+
        print_n("CPU(s):", cpu->ct_cpu);
 
        if (have_topology) {