qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 6/6] x86: Add sanity checks on phys_bits


From: Dr. David Alan Gilbert (git)
Subject: [Qemu-devel] [PATCH v2 6/6] x86: Add sanity checks on phys_bits
Date: Mon, 4 Jul 2016 20:16:09 +0100

From: "Dr. David Alan Gilbert" <address@hidden>

Add some sanity checks on the phys-bits setting now that
the user can set it.
   a) That it's in a sane range (52..32)
   b) Warn if it mismatches the host and isn't the old default.

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
 target-i386/cpu.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e15abea..5402002 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2985,6 +2985,19 @@ static void x86_cpu_realizefn(DeviceState *dev, Error 
**errp)
             /* The user asked for us to use the host physical bits */
             cpu->phys_bits = host_phys_bits;
 
+        } else if (cpu->phys_bits > 52 || cpu->phys_bits < 32) {
+            error_setg(errp, "phys_bits should be between 32 and 52 or 0 to"
+                             " use host size (but is %u)", cpu->phys_bits);
+            return;
+        }
+        /* Print a warning if the user set it to a value that's not the
+         * host value; ignore the magic value 40 because it may well just
+         * be the old machine type.
+         */
+        if (cpu->phys_bits != host_phys_bits && cpu->phys_bits != 40) {
+            fprintf(stderr, "Warning: Host physical bits (%u)"
+                            " does not match phys_bits (%u)\n",
+                            host_phys_bits, cpu->phys_bits);
         }
     } else {
         /* For 32 bit systems don't use the user set value, but keep
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]