* [Qemu-devel] [PATCH 1/6] kvmclock: Fix feature detection
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 2/6] kvm: Drop obsolete KVM_IOEVENTFD #ifdefs Marcelo Tosatti
` (5 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm
From: Jan Kiszka <jan.kiszka@siemens.com>
Bit-wise or the feature flags and drop the obsolete #ifdef.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hw/kvmclock.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index 692ad18..b73aec4 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -101,11 +101,8 @@ static SysBusDeviceInfo kvmclock_info = {
void kvmclock_create(void)
{
if (kvm_enabled() &&
- first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE)
-#ifdef KVM_FEATURE_CLOCKSOURCE2
- || (1ULL << KVM_FEATURE_CLOCKSOURCE2)
-#endif
- )) {
+ first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
+ (1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
sysbus_create_simple("kvmclock", -1, NULL);
}
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 2/6] kvm: Drop obsolete KVM_IOEVENTFD #ifdefs
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 1/6] kvmclock: Fix feature detection Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 3/6] qemu: Add strtosz_suffix_unit function Marcelo Tosatti
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm
From: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
kvm-all.c | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index cbc2532..b9c172b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1328,7 +1328,6 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool assign)
{
-#ifdef KVM_IOEVENTFD
int ret;
struct kvm_ioeventfd iofd;
@@ -1353,14 +1352,10 @@ int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool assign
}
return 0;
-#else
- return -ENOSYS;
-#endif
}
int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)
{
-#ifdef KVM_IOEVENTFD
struct kvm_ioeventfd kick = {
.datamatch = val,
.addr = addr,
@@ -1380,9 +1375,6 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)
return r;
}
return 0;
-#else
- return -ENOSYS;
-#endif
}
int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 3/6] qemu: Add strtosz_suffix_unit function
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 1/6] kvmclock: Fix feature detection Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 2/6] kvm: Drop obsolete KVM_IOEVENTFD #ifdefs Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 4/6] qemu-x86: Add tsc_freq option to -cpu Marcelo Tosatti
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm
From: Joerg Roedel <joerg.roedel@amd.com>
This function does the same as the strtosz_suffix function
except that it allows to specify the unit to which the
k/M/B/T suffixes apply. This function will be used later to
parse the tsc-frequency from the command-line.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
cutils.c | 16 +++++++++++-----
qemu-common.h | 2 ++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/cutils.c b/cutils.c
index f9a7e36..28049e0 100644
--- a/cutils.c
+++ b/cutils.c
@@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
* value must be terminated by whitespace, ',' or '\0'. Return -1 on
* error.
*/
-int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+ const char default_suffix, int64_t unit)
{
int64_t retval = -1;
char *endptr;
@@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
}
break;
case STRTOSZ_DEFSUFFIX_KB:
- mul = 1 << 10;
+ mul = unit;
break;
case 0:
if (mul_required) {
goto fail;
}
case STRTOSZ_DEFSUFFIX_MB:
- mul = 1ULL << 20;
+ mul = unit * unit;
break;
case STRTOSZ_DEFSUFFIX_GB:
- mul = 1ULL << 30;
+ mul = unit * unit * unit;
break;
case STRTOSZ_DEFSUFFIX_TB:
- mul = 1ULL << 40;
+ mul = unit * unit * unit * unit;
break;
default:
goto fail;
@@ -405,6 +406,11 @@ fail:
return retval;
}
+int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+{
+ return strtosz_suffix_unit(nptr, end, default_suffix, 1024);
+}
+
int64_t strtosz(const char *nptr, char **end)
{
return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB);
diff --git a/qemu-common.h b/qemu-common.h
index afbd04d..389f4d2 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -157,6 +157,8 @@ int fcntl_setfl(int fd, int flag);
#define STRTOSZ_DEFSUFFIX_B 'B'
int64_t strtosz(const char *nptr, char **end);
int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix);
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+ const char default_suffix, int64_t unit);
/* path.c */
void init_paths(const char *prefix);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 4/6] qemu-x86: Add tsc_freq option to -cpu
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (2 preceding siblings ...)
2011-08-05 20:55 ` [Qemu-devel] [PATCH 3/6] qemu: Add strtosz_suffix_unit function Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-05 20:55 ` [Qemu-devel] [PATCH 5/6] qemu-x86: Set tsc_khz in kvm when supported Marcelo Tosatti
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm
From: Joerg Roedel <joerg.roedel@amd.com>
To let the user configure the desired tsc frequency for the
guest if running in KVM.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target-i386/cpu.h | 1 +
target-i386/cpuid.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index dd6c5fa..dcdd95f 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -743,6 +743,7 @@ typedef struct CPUX86State {
uint32_t cpuid_kvm_features;
uint32_t cpuid_svm_features;
bool tsc_valid;
+ int tsc_khz;
/* in order to simplify APIC support, we leave this pointer to the
user */
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index e1ae3af..89e9623 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -224,6 +224,7 @@ typedef struct x86_def_t {
int family;
int model;
int stepping;
+ int tsc_khz;
uint32_t features, ext_features, ext2_features, ext3_features;
uint32_t kvm_features, svm_features;
uint32_t xlevel;
@@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
} else if (!strcmp(featurestr, "model_id")) {
pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
val);
+ } else if (!strcmp(featurestr, "tsc_freq")) {
+ int64_t tsc_freq;
+ char *err;
+
+ tsc_freq = strtosz_suffix_unit(val, &err,
+ STRTOSZ_DEFSUFFIX_B, 1000);
+ if (!*val || *err) {
+ fprintf(stderr, "bad numerical value %s\n", val);
+ goto error;
+ }
+ x86_cpu_def->tsc_khz = tsc_freq / 1000;
} else {
fprintf(stderr, "unrecognized feature %s\n", featurestr);
goto error;
@@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
env->cpuid_svm_features = def->svm_features;
env->cpuid_ext4_features = def->ext4_features;
env->cpuid_xlevel2 = def->xlevel2;
+ env->tsc_khz = def->tsc_khz;
if (!kvm_enabled()) {
env->cpuid_features &= TCG_FEATURES;
env->cpuid_ext_features &= TCG_EXT_FEATURES;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 5/6] qemu-x86: Set tsc_khz in kvm when supported
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (3 preceding siblings ...)
2011-08-05 20:55 ` [Qemu-devel] [PATCH 4/6] qemu-x86: Add tsc_freq option to -cpu Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-05 21:28 ` Jan Kiszka
2011-08-05 20:55 ` [Qemu-devel] [PATCH 6/6] Remove #ifdef KVM_CAP_TSC_CONTROL Marcelo Tosatti
2011-08-08 20:07 ` [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
6 siblings, 1 reply; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm
From: Joerg Roedel <joerg.roedel@amd.com>
Make use of the KVM_TSC_CONTROL feature if available.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target-i386/kvm.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 10fb2c4..923d2d5 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
uint32_t unused;
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
+ int r;
env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
@@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
qemu_add_vm_change_state_handler(cpu_update_state, env);
- return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+ r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+ if (r)
+ return r;
+
+#ifdef KVM_CAP_TSC_CONTROL
+ r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
+ if (r && env->tsc_khz) {
+ r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
+ if (r < 0) {
+ fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
+ return r;
+ }
+ }
+#endif
+
+ return 0;
}
void kvm_arch_reset_vcpu(CPUState *env)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 5/6] qemu-x86: Set tsc_khz in kvm when supported
2011-08-05 20:55 ` [Qemu-devel] [PATCH 5/6] qemu-x86: Set tsc_khz in kvm when supported Marcelo Tosatti
@ 2011-08-05 21:28 ` Jan Kiszka
0 siblings, 0 replies; 15+ messages in thread
From: Jan Kiszka @ 2011-08-05 21:28 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Joerg Roedel, Anthony Liguori, qemu-devel, kvm
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
On 2011-08-05 22:55, Marcelo Tosatti wrote:
> From: Joerg Roedel <joerg.roedel@amd.com>
>
> Make use of the KVM_TSC_CONTROL feature if available.
>
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> ---
> target-i386/kvm.c | 18 +++++++++++++++++-
> 1 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 10fb2c4..923d2d5 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
> uint32_t unused;
> struct kvm_cpuid_entry2 *c;
> uint32_t signature[3];
> + int r;
>
> env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
>
> @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
>
> qemu_add_vm_change_state_handler(cpu_update_state, env);
>
> - return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> + r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> + if (r)
> + return r;
Coding style...
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 6/6] Remove #ifdef KVM_CAP_TSC_CONTROL
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (4 preceding siblings ...)
2011-08-05 20:55 ` [Qemu-devel] [PATCH 5/6] qemu-x86: Set tsc_khz in kvm when supported Marcelo Tosatti
@ 2011-08-05 20:55 ` Marcelo Tosatti
2011-08-08 20:07 ` [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
6 siblings, 0 replies; 15+ messages in thread
From: Marcelo Tosatti @ 2011-08-05 20:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Marcelo Tosatti, qemu-devel, kvm
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target-i386/kvm.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 923d2d5..31b88b7 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -504,7 +504,6 @@ int kvm_arch_init_vcpu(CPUState *env)
if (r)
return r;
-#ifdef KVM_CAP_TSC_CONTROL
r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
if (r && env->tsc_khz) {
r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
@@ -513,7 +512,6 @@ int kvm_arch_init_vcpu(CPUState *env)
return r;
}
}
-#endif
return 0;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue
2011-08-05 20:55 [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (5 preceding siblings ...)
2011-08-05 20:55 ` [Qemu-devel] [PATCH 6/6] Remove #ifdef KVM_CAP_TSC_CONTROL Marcelo Tosatti
@ 2011-08-08 20:07 ` Anthony Liguori
6 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2011-08-08 20:07 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, kvm
On 08/05/2011 03:55 PM, Marcelo Tosatti wrote:
> The following changes since commit 35d7ace74bd07e3d6983c1fd7cbfab4e11175689:
>
> qcow2: Fix L1 table size after bdrv_snapshot_goto (2011-08-05 07:15:47 -0500)
>
> are available in the git repository at:
> git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
Pulled. Thanks.
Regards,
Anthony Liguori
>
> Jan Kiszka (2):
> kvmclock: Fix feature detection
> kvm: Drop obsolete KVM_IOEVENTFD #ifdefs
>
> Joerg Roedel (3):
> qemu: Add strtosz_suffix_unit function
> qemu-x86: Add tsc_freq option to -cpu
> qemu-x86: Set tsc_khz in kvm when supported
>
> Marcelo Tosatti (1):
> Remove #ifdef KVM_CAP_TSC_CONTROL
>
> cutils.c | 16 +++++++++++-----
> hw/kvmclock.c | 7 ++-----
> kvm-all.c | 8 --------
> qemu-common.h | 2 ++
> target-i386/cpu.h | 1 +
> target-i386/cpuid.c | 13 +++++++++++++
> target-i386/kvm.c | 16 +++++++++++++++-
> 7 files changed, 44 insertions(+), 19 deletions(-)
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread