[libvirt] [PATCH 3/7] x86: Ignore CPUID functions greater than 10

Jiri Denemark jdenemar at redhat.com
Tue Jul 23 16:11:32 UTC 2013


We don't need to store any CPUID data for function we know nothing
about. However, this limit may need to be increased in the future when
libvirt learns features described by a CPUID function greater than 10.
The comparison is done after subtracting high-bits prefix, so currently
functions 0x00000000 to 0x0000000a and 0x80000000 to 0x8000000a are
stored.
---
 src/cpu/cpu_x86.c      | 5 +++++
 src/cpu/cpu_x86_data.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index dbbcfd2..bd3f2b0 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -314,6 +314,11 @@ x86DataAddCpuid(struct cpuX86Data *data,
         cpuids = &data->extended;
     }
 
+    if (pos > CPUX86_MAX_FUNCTION) {
+        VIR_DEBUG("Ignoring unhandled function 0x%x", cpuid->function);
+        return 0;
+    }
+
     if (x86DataExpand(data, basic_by, extended_by) < 0)
         return -1;
 
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index dc972a6..af470e4 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -36,6 +36,7 @@ struct cpuX86cpuid {
 
 # define CPUX86_BASIC    0x0
 # define CPUX86_EXTENDED 0x80000000
+# define CPUX86_MAX_FUNCTION 10
 
 struct cpuX86Data {
     size_t basic_len;
-- 
1.8.3.2




More information about the libvir-list mailing list