* various small fixes and cleanups

* fixes for the ucode revision patch from the previous pull request
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQEcBAABAgAGBQJeRBoQAAoJEL/70l94x66DYOUIAJKM5PDAhOkJpSqoSz2mMVJN
 IOq2YhmbQHSVojUDCUEFnKd2Zja858vsOoAslgce0nbgj+ZNn9WZEVIKeHqkW6cg
 gWybMy1deT5o0U05e6/EIL0id8N5FVMLdUZRdGCFk4qtILFa1kRYJmlwNOMxSVkB
 MSwOy60//+po6lW0WSKD2aTf9qVvZJOQjZozqFrGlIPG/SnqrPZCMRxR/XIrrJuF
 GZZyiAsRXFU1mabr7HafdUj+MYf0DWSvATmihz4wsI/LlXx712uVm9eZ48Rc6PyF
 wEKh17/2bVPoL1g9OeTKYnX9aKt/7C0D98n3W0foG3IpzZzPLX4NaNKPihb5n7I=
 =VlyM
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* various small fixes and cleanups
* fixes for the ucode revision patch from the previous pull request

# gpg: Signature made Wed 12 Feb 2020 15:30:24 GMT
# gpg:                using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream:
  target/i386: enable monitor and ucode revision with -cpu max
  target/i386: check for availability of MSR_IA32_UCODE_REV as an emulated MSR
  target/i386: fix TCG UCODE_REV access
  build: move TARGET_GPROF to config-host.mak
  exec: do not define use_icount for user-mode emulation
  minikconf: accept alnum identifiers
  Remove support for CLOCK_MONOTONIC not being defined
  seqlock: fix seqlock_write_unlock_impl function
  vl: Don't mismatch g_strsplit()/g_free()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-02-13 13:40:59 +00:00
commit 81f49abaaa
14 changed files with 34 additions and 33 deletions

View File

@ -330,7 +330,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
switch(num) { switch(num) {
case TARGET_FREEBSD_NR_exit: case TARGET_FREEBSD_NR_exit:
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
_mcleanup(); _mcleanup();
#endif #endif
gdb_exit(cpu_env, arg1); gdb_exit(cpu_env, arg1);
@ -432,7 +432,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
switch(num) { switch(num) {
case TARGET_NETBSD_NR_exit: case TARGET_NETBSD_NR_exit:
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
_mcleanup(); _mcleanup();
#endif #endif
gdb_exit(cpu_env, arg1); gdb_exit(cpu_env, arg1);
@ -511,7 +511,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
switch(num) { switch(num) {
case TARGET_OPENBSD_NR_exit: case TARGET_OPENBSD_NR_exit:
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
_mcleanup(); _mcleanup();
#endif #endif
gdb_exit(cpu_env, arg1); gdb_exit(cpu_env, arg1);

4
configure vendored
View File

@ -6771,6 +6771,9 @@ fi
if test "$l2tpv3" = "yes" ; then if test "$l2tpv3" = "yes" ; then
echo "CONFIG_L2TPV3=y" >> $config_host_mak echo "CONFIG_L2TPV3=y" >> $config_host_mak
fi fi
if test "$gprof" = "yes" ; then
echo "CONFIG_GPROF=y" >> $config_host_mak
fi
if test "$cap_ng" = "yes" ; then if test "$cap_ng" = "yes" ; then
echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
fi fi
@ -7951,7 +7954,6 @@ alpha)
esac esac
if test "$gprof" = "yes" ; then if test "$gprof" = "yes" ; then
echo "TARGET_GPROF=y" >> $config_target_mak
if test "$target_linux_user" = "yes" ; then if test "$target_linux_user" = "yes" ; then
cflags="-p $cflags" cflags="-p $cflags"
ldflags="-p $ldflags" ldflags="-p $ldflags"

8
exec.c
View File

@ -98,15 +98,15 @@ CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
/* current CPU in the current thread. It is only valid inside /* current CPU in the current thread. It is only valid inside
cpu_exec() */ cpu_exec() */
__thread CPUState *current_cpu; __thread CPUState *current_cpu;
/* 0 = Do not count executed instructions.
1 = Precise instruction counting.
2 = Adaptive rate instruction counting. */
int use_icount;
uintptr_t qemu_host_page_size; uintptr_t qemu_host_page_size;
intptr_t qemu_host_page_mask; intptr_t qemu_host_page_mask;
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
/* 0 = Do not count executed instructions.
1 = Precise instruction counting.
2 = Adaptive rate instruction counting. */
int use_icount;
typedef struct PhysPageEntry PhysPageEntry; typedef struct PhysPageEntry PhysPageEntry;

View File

@ -55,11 +55,11 @@ static inline void seqlock_write_lock_impl(QemuSeqLock *sl, QemuLockable *lock)
#define seqlock_write_lock(sl, lock) \ #define seqlock_write_lock(sl, lock) \
seqlock_write_lock_impl(sl, QEMU_MAKE_LOCKABLE(lock)) seqlock_write_lock_impl(sl, QEMU_MAKE_LOCKABLE(lock))
/* Lock out other writers and update the count. */ /* Update the count and release the lock. */
static inline void seqlock_write_unlock_impl(QemuSeqLock *sl, QemuLockable *lock) static inline void seqlock_write_unlock_impl(QemuSeqLock *sl, QemuLockable *lock)
{ {
seqlock_write_end(sl);
qemu_lockable_unlock(lock); qemu_lockable_unlock(lock);
seqlock_write_begin(sl);
} }
#define seqlock_write_unlock(sl, lock) \ #define seqlock_write_unlock(sl, lock) \
seqlock_write_unlock_impl(sl, QEMU_MAKE_LOCKABLE(lock)) seqlock_write_unlock_impl(sl, QEMU_MAKE_LOCKABLE(lock))

View File

@ -838,14 +838,11 @@ extern int use_rt_clock;
static inline int64_t get_clock(void) static inline int64_t get_clock(void)
{ {
#ifdef CLOCK_MONOTONIC
if (use_rt_clock) { if (use_rt_clock) {
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000LL + ts.tv_nsec; return ts.tv_sec * 1000000000LL + ts.tv_nsec;
} else } else {
#endif
{
/* XXX: using gettimeofday leads to problems if the date /* XXX: using gettimeofday leads to problems if the date
changes, so it should be avoided. */ changes, so it should be avoided. */
return get_clock_realtime(); return get_clock_realtime();

View File

@ -18,7 +18,7 @@
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu.h" #include "qemu.h"
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
#include <sys/gmon.h> #include <sys/gmon.h>
#endif #endif
@ -28,7 +28,7 @@ extern void __gcov_dump(void);
void preexit_cleanup(CPUArchState *env, int code) void preexit_cleanup(CPUArchState *env, int code)
{ {
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
_mcleanup(); _mcleanup();
#endif #endif
#ifdef CONFIG_GCOV #ifdef CONFIG_GCOV

View File

@ -509,7 +509,7 @@ void signal_init(void)
act.sa_flags = SA_SIGINFO; act.sa_flags = SA_SIGINFO;
act.sa_sigaction = host_signal_handler; act.sa_sigaction = host_signal_handler;
for(i = 1; i <= TARGET_NSIG; i++) { for(i = 1; i <= TARGET_NSIG; i++) {
#ifdef TARGET_GPROF #ifdef CONFIG_GPROF
if (i == SIGPROF) { if (i == SIGPROF) {
continue; continue;
} }

View File

@ -645,7 +645,7 @@ class KconfigParser:
self.cursor = self.src.find('\n', self.cursor) self.cursor = self.src.find('\n', self.cursor)
self.val = self.src[start:self.cursor] self.val = self.src[start:self.cursor]
return TOK_SOURCE return TOK_SOURCE
elif self.tok.isalpha(): elif self.tok.isalnum():
# identifier # identifier
while self.src[self.cursor].isalnum() or self.src[self.cursor] == '_': while self.src[self.cursor].isalnum() or self.src[self.cursor] == '_':
self.cursor += 1 self.cursor += 1

View File

@ -6414,7 +6414,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
error_setg(&local_err, "CPU model '%s' requires KVM", name); error_setg(&local_err, "CPU model '%s' requires KVM", name);
goto out; goto out;
} }
}
if (cpu->max_features && accel_uses_host_cpuid()) {
if (enable_cpu_pm) { if (enable_cpu_pm) {
host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx, host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx,
&cpu->mwait.ecx, &cpu->mwait.edx); &cpu->mwait.ecx, &cpu->mwait.edx);

View File

@ -105,6 +105,7 @@ static bool has_msr_smi_count;
static bool has_msr_arch_capabs; static bool has_msr_arch_capabs;
static bool has_msr_core_capabs; static bool has_msr_core_capabs;
static bool has_msr_vmx_vmfunc; static bool has_msr_vmx_vmfunc;
static bool has_msr_ucode_rev;
static uint32_t has_architectural_pmu_version; static uint32_t has_architectural_pmu_version;
static uint32_t num_architectural_pmu_gp_counters; static uint32_t num_architectural_pmu_gp_counters;
@ -2056,6 +2057,9 @@ static int kvm_get_supported_msrs(KVMState *s)
case MSR_IA32_VMX_VMFUNC: case MSR_IA32_VMX_VMFUNC:
has_msr_vmx_vmfunc = true; has_msr_vmx_vmfunc = true;
break; break;
case MSR_IA32_UCODE_REV:
has_msr_ucode_rev = true;
break;
} }
} }
} }
@ -2696,8 +2700,7 @@ static void kvm_init_msrs(X86CPU *cpu)
env->features[FEAT_CORE_CAPABILITY]); env->features[FEAT_CORE_CAPABILITY]);
} }
if (kvm_arch_get_supported_msr_feature(kvm_state, if (has_msr_ucode_rev) {
MSR_IA32_UCODE_REV)) {
kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev); kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev);
} }

View File

@ -229,7 +229,6 @@ void helper_rdmsr(CPUX86State *env)
#else #else
void helper_wrmsr(CPUX86State *env) void helper_wrmsr(CPUX86State *env)
{ {
X86CPU *x86_cpu = env_archcpu(env);
uint64_t val; uint64_t val;
cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1, GETPC()); cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1, GETPC());
@ -372,9 +371,6 @@ void helper_wrmsr(CPUX86State *env)
env->msr_bndcfgs = val; env->msr_bndcfgs = val;
cpu_sync_bndcs_hflags(env); cpu_sync_bndcs_hflags(env);
break; break;
case MSR_IA32_UCODE_REV:
val = x86_cpu->ucode_rev;
break;
default: default:
if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL
&& (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL + && (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL +
@ -393,6 +389,7 @@ void helper_wrmsr(CPUX86State *env)
void helper_rdmsr(CPUX86State *env) void helper_rdmsr(CPUX86State *env)
{ {
X86CPU *x86_cpu = env_archcpu(env);
uint64_t val; uint64_t val;
cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 0, GETPC()); cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 0, GETPC());
@ -526,6 +523,9 @@ void helper_rdmsr(CPUX86State *env)
case MSR_IA32_BNDCFGS: case MSR_IA32_BNDCFGS:
val = env->msr_bndcfgs; val = env->msr_bndcfgs;
break; break;
case MSR_IA32_UCODE_REV:
val = x86_cpu->ucode_rev;
break;
default: default:
if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL
&& (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL + && (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL +

View File

@ -16,7 +16,7 @@ if [ "$#" -ne 0 ]; then
format_list="$@" format_list="$@"
fi fi
if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then
echo "GPROF is enabled ==> Not running the qemu-iotests." echo "GPROF is enabled ==> Not running the qemu-iotests."
exit 0 exit 0
fi fi

View File

@ -48,15 +48,12 @@ static void __attribute__((constructor)) init_get_clock(void)
int use_rt_clock; int use_rt_clock;
static void __attribute__((constructor)) init_get_clock(void) static void __attribute__((constructor)) init_get_clock(void)
{
use_rt_clock = 0;
#ifdef CLOCK_MONOTONIC
{ {
struct timespec ts; struct timespec ts;
use_rt_clock = 0;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
use_rt_clock = 1; use_rt_clock = 1;
} }
} }
#endif #endif
}
#endif

2
vl.c
View File

@ -3510,7 +3510,7 @@ int main(int argc, char **argv, char **envp)
gchar **optname = g_strsplit(typename, gchar **optname = g_strsplit(typename,
ACCEL_CLASS_SUFFIX, 0); ACCEL_CLASS_SUFFIX, 0);
printf("%s\n", optname[0]); printf("%s\n", optname[0]);
g_free(optname); g_strfreev(optname);
} }
g_free(typename); g_free(typename);
} }