Message ID | 1319766992-2596-2-git-send-email-david@gibson.dropbear.id.au |
---|---|
State | New |
Headers | show |
On 28.10.2011, at 03:56, David Gibson wrote: > kvmppc_read_int_cpu_dt() returns -1 on errors. However > kvmppc_host_cpu_def() assumes that it can use the return value > directly for setting the corresponding instruction support bits. This > will give invalid results when kvmppc_read_int_cpu_dt() returns -1 > (i.e. 0xffffffff). > > In fact, it gets worse: the common case for -1 return values is when > the properties are simply not present. On some machines this means > the features are not available but in other cases it just means that > the firmware on this platform does not provide this information. So, > when there's an error reading the properties we really can't tell if > vmx or dfp is supported. > > Therefore, this patch checks for -1 return values and falls back to > qemu's built in table of CPU capabilities in that case. > > Reported-by: Nishanth Aravamudan <nacc@us.ibm.com> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au> I already have this patch in my tree, though with different author. I've added Nishanth as Reported-by on it now and you as Acked-by, if you're ok with that. Alex
On Sun, Oct 30, 2011 at 05:53:13PM +0100, Alexander Graf wrote: > > On 28.10.2011, at 03:56, David Gibson wrote: > > > kvmppc_read_int_cpu_dt() returns -1 on errors. However > > kvmppc_host_cpu_def() assumes that it can use the return value > > directly for setting the corresponding instruction support bits. This > > will give invalid results when kvmppc_read_int_cpu_dt() returns -1 > > (i.e. 0xffffffff). > > > > In fact, it gets worse: the common case for -1 return values is when > > the properties are simply not present. On some machines this means > > the features are not available but in other cases it just means that > > the firmware on this platform does not provide this information. So, > > when there's an error reading the properties we really can't tell if > > vmx or dfp is supported. > > > > Therefore, this patch checks for -1 return values and falls back to > > qemu's built in table of CPU capabilities in that case. > > > > Reported-by: Nishanth Aravamudan <nacc@us.ibm.com> > > Signed-off-by: David Gibson <david@gibson.dropbear.id.au> > > I already have this patch in my tree, though with different > author. Yeah, I realised that not long after I sent it. > I've added Nishanth as Reported-by on it now and you as > Acked-by, if you're ok with that. Ok, thanks.
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index a090d79..6b156be 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -912,9 +912,13 @@ const ppc_def_t *kvmppc_host_cpu_def(void) /* Now fix up the spec with information we can query from the host */ - alter_insns(&spec->insns_flags, PPC_ALTIVEC, vmx > 0); - alter_insns(&spec->insns_flags2, PPC2_VSX, vmx > 1); - alter_insns(&spec->insns_flags2, PPC2_DFP, dfp); + if (vmx != -1) { + alter_insns(&spec->insns_flags, PPC_ALTIVEC, vmx > 0); + alter_insns(&spec->insns_flags2, PPC2_VSX, vmx > 1); + } + if (dfp != -1) { + alter_insns(&spec->insns_flags2, PPC2_DFP, dfp); + } return spec; }
kvmppc_read_int_cpu_dt() returns -1 on errors. However kvmppc_host_cpu_def() assumes that it can use the return value directly for setting the corresponding instruction support bits. This will give invalid results when kvmppc_read_int_cpu_dt() returns -1 (i.e. 0xffffffff). In fact, it gets worse: the common case for -1 return values is when the properties are simply not present. On some machines this means the features are not available but in other cases it just means that the firmware on this platform does not provide this information. So, when there's an error reading the properties we really can't tell if vmx or dfp is supported. Therefore, this patch checks for -1 return values and falls back to qemu's built in table of CPU capabilities in that case. Reported-by: Nishanth Aravamudan <nacc@us.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> --- target-ppc/kvm.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)