Message ID | 1418663515-16839-1-git-send-email-chris.j.arges@canonical.com |
---|---|
State | New |
Headers | show |
On Mon, Dec 15, 2014 at 11:11:55AM -0600, Chris J Arges wrote: > From: Greg Kurz <gkurz@linux.vnet.ibm.com> > > BugLink: http://bugs.launchpad.net/bugs/1401150 > > The associativity domain numbers are obtained from the hypervisor through > registers and written into memory by the guest: the packed array passed to > vphn_unpack_associativity() is then native-endian, unlike what was assumed > in the following commit: > > commit b08a2a12e44eaec5024b2b969f4fcb98169d1ca3 > Author: Alistair Popple <alistair@popple.id.au> > Date: Wed Aug 7 02:01:44 2013 +1000 > > powerpc: Make NUMA device node code endian safe > > This issue fills the topology with bogus data and makes it unusable. It may > lead to severe performance breakdowns. > > We should ideally patch the vphn_unpack_associativity() function to do the > 64-bit loads, but this requires some more brain storming. > > In the meantime, let's go for a suboptimal and temporary bug fix: this patch > converts each 64-bit value of the packed array to big endian, as expected by > the current parsing code in vphn_unpack_associativity(). > > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> > (cherry picked from commit 5c9fb1899400096c6818181c525897a31d57e488) > Signed-off-by: Chris J Arges <chris.j.arges@canonical.com> > --- > arch/powerpc/mm/numa.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c > index c752d50..a115c56 100644 > --- a/arch/powerpc/mm/numa.c > +++ b/arch/powerpc/mm/numa.c > @@ -1417,8 +1417,11 @@ static long hcall_vphn(unsigned long cpu, __be32 *associativity) > long retbuf[PLPAR_HCALL9_BUFSIZE] = {0}; > u64 flags = 1; > int hwcpu = get_hard_smp_processor_id(cpu); > + int i; > > rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu); > + for (i = 0; i < 6; i++) > + retbuf[i] = cpu_to_be64(retbuf[i]); > vphn_unpack_associativity(retbuf, associativity); > > return rc; Uggg. I assume that as this is "temporary" that someone will make this 6 go away upstream. Nasty. Acked-by: Andy Whitcroft <apw@canonical.com> -apw
Applied to Trusty and Utopic. -apw
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index c752d50..a115c56 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1417,8 +1417,11 @@ static long hcall_vphn(unsigned long cpu, __be32 *associativity) long retbuf[PLPAR_HCALL9_BUFSIZE] = {0}; u64 flags = 1; int hwcpu = get_hard_smp_processor_id(cpu); + int i; rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu); + for (i = 0; i < 6; i++) + retbuf[i] = cpu_to_be64(retbuf[i]); vphn_unpack_associativity(retbuf, associativity); return rc;