From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> 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 <dgilb...@redhat.com> --- 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