summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorKarel Zak2010-01-07 17:34:03 +0100
committerKarel Zak2010-01-07 17:34:03 +0100
commit79e8b41a4a17763ac8d2dffbe72504783d002ddc (patch)
tree76e7f4ebfe8f810cbee8b0ae74ea0fb14ed3e1dc /sys-utils/lscpu.c
parentfdisk: sleep-after-sync and fsync usage (diff)
downloadkernel-qcow2-util-linux-79e8b41a4a17763ac8d2dffbe72504783d002ddc.tar.gz
kernel-qcow2-util-linux-79e8b41a4a17763ac8d2dffbe72504783d002ddc.tar.xz
kernel-qcow2-util-linux-79e8b41a4a17763ac8d2dffbe72504783d002ddc.zip
lscpu: add {32,64}-bit CPU modes detection
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>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 6b6082fbf..c200fb32f 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -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) {