aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2011-08-09 18:07:13 +0200
committerAlexander Graf <agraf@suse.de>2011-10-06 09:48:02 +0200
commit0a8b293893051f5c170ae7a2209c12fb92666027 (patch)
treefa7096152276e916ee76bd0d99ac7c61b3d3afa0
parentf61b4bedaf3508b0dffa2e4b277af1f6646c3418 (diff)
PPC: SPAPR: Use KVM function for time info
One of the things we can't fake on PPC is the timer speed. So we need to extract the frequency information from the host and put it back into the guest device tree. Luckily, we already have functions for that from the non-pseries targets, so all we need to do is to connect the dots and the guest suddenly gets to know its real timer speeds. Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r--hw/spapr.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/spapr.c b/hw/spapr.c
index c5c9a95197..760e3231d1 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -140,6 +140,8 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
+ uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
+ uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
fprintf(stderr, "Allocation failure\n");
@@ -158,10 +160,8 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
env->dcache_line_size)));
_FDT((fdt_property_cell(fdt, "icache-block-size",
env->icache_line_size)));
- _FDT((fdt_property_cell(fdt, "timebase-frequency", TIMEBASE_FREQ)));
- /* Hardcode CPU frequency for now. It's kind of arbitrary on
- * full emu, for kvm we should copy it from the host */
- _FDT((fdt_property_cell(fdt, "clock-frequency", 1000000000)));
+ _FDT((fdt_property_cell(fdt, "timebase-frequency", tbfreq)));
+ _FDT((fdt_property_cell(fdt, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(fdt, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(fdt, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));