Fix rfe instruction

The rfe instruction has been broken since patch
5a839c0d54fac9db0516904db873a4fe01f50f4b because of a typo.

Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS

Rather than a hand-coded version of the same thing.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
tcg: Remove redundant tcg_target_init checks

We've got a compile-time check for the condition in exec/cpu-defs.h.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
dump: Move stubs into libqemustub.a

This allows us to drop CONFIG_NO_CORE_DUMP with its indirect dependency
on CONFIG_HAVE_CORE_DUMP.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
pc: Fix crash when attempting to hotplug CPU with negative ID

QMP command "{ 'execute': 'cpu-add', 'arguments': { 'id': -1 }}" may cause
QEMU SIGSEGV at:
 piix4_cpu_hotplug_req ()
    ...
    g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
    ...

Since for PC in current implementation id should be in range [0...maxcpus)
and maxcpus is already checked, add check for lower bound and error out
on incorrect value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
pc: Create pc-*-1.6 machine-types

Some CPU model fixes are going to be included and they will require
compatibility properties in the pc-*-1.5 machine-types.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-i386: Update model values on Conroe/Penryn/Nehalem CPU models

The CPUID model values on Conroe, Penryn, and Nehalem are too
conservative and don't reflect the values found on real Conroe, Penryn,
and Nehalem CPUs.

This causes at least one known problems: Windows XP disables sysenter
when (family == 6 && model <= 2), but Skype tries to use the sysenter
instruction anyway because it is reported as available on CPUID, making
it crash.

This patch sets appropriate model values that correspond to real Conroe,
Penryn, and Nehalem CPUs.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-i386: Set level=4 on Conroe/Penryn/Nehalem

The CPUID level value on Conroe, Penryn, and Nehalem are too low. This
causes at least one known problem: the -smp "threads" option doesn't
work as expect if level is < 4, because thread count information is
provided to the guest on CPUID[EAX=4,ECX=2].EAX

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-i386: cpu: Fix potential buffer overrun in get_register_name_32()

Spotted by Coverity,
x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing
x86_reg_info_32[CPU_NB_REGS32] will be one element off array.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Reviewed by: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
monitor: Simplify do_inject_mce() with qemu_get_cpu()

Avoids an open-coded CPU loop.

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Turn cpu_paging_enabled() into a CPUState hook

Relocate assignment of x86 get_arch_id to have all hooks in one place.

Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h

This will avoid issues with hwaddr and ram_addr_t when including
sysemu/memory_mapping.h for CONFIG_USER_ONLY, e.g., from qom/cpu.h.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Turn cpu_get_memory_mapping() into a CPUState hook

Change error reporting from return value to Error argument.

Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
[AF: Fixed cpu_get_memory_mapping() documentation]
Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Drop qemu_get_memory_mapping() stub

dump.c:dump_init() never checked for the return code anyway.
If paging is not enabled, it will fall back to an identity map.
If paging is enabled and getting memory mapping list is not
implemented, qemu_get_guest_memory_mapping() will return an error.

Since the targets not implementing memory mapping also don't implement
dump support, we will not reach this code today and can worry about
changing cpu_paging_enabled() default when the need arises.

This allows us to drop CONFIG_HAVE_GET_MEMORY_SUPPORT.

Signed-off-by: Andreas Färber <afaerber@suse.de>
dump: Drop qmp_dump_guest_memory() stub and build for all targets

qmp_dump_guest_memory() calls dump_init() and returns an Error when
cpu_get_dump_info() returns an error, as done by the stub.
So there is no need to have a stub for qmp_dump_guest_memory().

Enable the documentation of the always-present dump-guest-memory command.

That way we can drop CONFIG_HAVE_CORE_DUMP and leave configure
completely out of the picture for target CPU features.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Change default for CPUClass::get_paging_enabled()

qemu_get_guest_memory_mapping() uses cpu_paging_enabled() to determine
whether to use cpu_get_memory_mapping() to return mappings or whether to
fall back to a simple identity map.

Since by default CPUClass::get_memory_mapping() is not implemented,
change the default to false to use the identity map by default.

Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
dump: Abstract dump_init() with cpu_synchronize_all_states()

Instead of calling cpu_synchronize_state() for each CPU, call the
existing cpu_synchronize_all_states() helper.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Improve qemu_get_guest_memory_mapping() error reporting

Pass any Error out into dump_init() and have it actually stop on errors.
Whether it is unsupported on a certain CPU can be checked by looking for
a NULL CPUClass::get_memory_mapping field.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
[AF: Reverted changes to CPU loops]
Signed-off-by: Andreas Färber <afaerber@suse.de>
qemu-char: remove a few needless #includes

This removes <syslog.h> since we don't use
syslogging, and removes second, solaris-specific,
include of <net/if.h> (which is included in
a common part of the file)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
gitignore: unignore *.patch

This partially reverts:

 commit 082369e62c5bbaba89f173c2b803bc24115bb111
 Author: liguang <lig.fnst@cn.fujitsu.com>
 Date:   Fri Mar 22 16:44:13 2013 +0800

    gitignore: ignore more files

I'm not sure how this went in.  The thing is that
ignoring *.patch, in my opinion, is just wrong.
Especially for downstreams who apply patches for
real.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>