Received: from eggs.gnu.org ([2001:4830:134:3::10]:45444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDzYd-0007tW-22 for qemu-devel@nongnu.org; Thu, 13 Feb 2014 11:54:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDzYS-0003cb-Ha for qemu-devel@nongnu.org; Thu, 13 Feb 2014 11:54:39 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:37993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDzYS-0003cG-8g for qemu-devel@nongnu.org; Thu, 13 Feb 2014 11:54:28 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Feb 2014 16:54:26 -0000 Date: Thu, 13 Feb 2014 17:54:19 +0100 From: Greg Kurz Message-ID: <20140213175419.761da184@bahia.local> In-Reply-To: <7CD7CBCE-A4EB-491C-B12E-6A69102FEE1A@suse.de> References: <20140210172743.00349f59@bahia.local> <20140212152432.32119.34978.stgit@bahia.local> <8738jnu37z.fsf@linux.vnet.ibm.com> <7CD7CBCE-A4EB-491C-B12E-6A69102FEE1A@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] target-ppc: fix 32 bit build break in the page table lookup code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: "list@suse.de:PowerPC" , "Aneesh Kumar K.V" , QEMU Developers On Thu, 13 Feb 2014 15:53:16 +0100 Alexander Graf wrote: >=20 > On 13.02.2014, at 04:00, Aneesh Kumar K.V > wrote: >=20 > > Greg Kurz writes: > >=20 > >> The 396bb9874 commit reworked page table lookup to support kvm. > >> Unfortunately this breaks 32 bit build: > >>=20 > >> target-ppc/mmu-hash64.h: In function =E2=80=98ppc_hash64_load_hpte0=E2= =80=99: > >> target-ppc/mmu-hash64.h:90:23: error: cast to pointer from integer of > >> different size > >>=20 > >> target-ppc/mmu-hash64.h: In function =E2=80=98ppc_hash64_load_hpte1=E2= =80=99: > >> target-ppc/mmu-hash64.h:101:23: error: cast to pointer from integer of > >> different size > >>=20 > >> The problem is that we have two cases to handle here: > >> - the HTAB is external and it is accessed with a pointer > >> - the HTAB is emulated and it is accessed with a hwaddr > >>=20 > >> Depending on the way the HTAB is controlled, we should use the > >> appropriate type: > >> - controlled by kvm, it is copied to an allocated buffer (pointer) > >> - controlled by qemu with an allocated buffer (pointer) > >> - controlled by qemu with soft mmu (hwaddr) > >>=20 > >> This patch introduces an explicit distinction between the two cases in > >> the new page table lookup code. > >=20 > > Reviewed-by: Aneesh Kumar K.V >=20 > I wouldn't mind something slightly lighter weight. How about this one > instead? If you guys think it's better to have an actual type for the > token I'd pull in this patch as is though. >=20 >=20 > Alex >=20 I confess... I consider castings evil and favor explicit typing. :) On the other hand, I have no strong opinions against your patch. The "token" code is quite simple and risks of confusion are low, we can live with it. Please add: Reviewed-by: Greg Kurz Thanks for your time. -- Greg > diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c > index 4e574d9..3240427 100644 > --- a/target-ppc/mmu-hash64.c > +++ b/target-ppc/mmu-hash64.c > @@ -340,7 +340,7 @@ uint64_t ppc_hash64_start_access(PowerPCCPU *cpu, > target_ulong pte_index) > * accessible PTEG. > */ > if (cpu->env.external_htab) { > - token =3D (uint64_t) cpu->env.external_htab + pte_offset; > + token =3D (uint64_t)(uintptr_t) cpu->env.external_htab + > pte_offset; } else if (cpu->env.htab_base) { > token =3D cpu->env.htab_base + pte_offset; > } > diff --git a/target-ppc/mmu-hash64.h b/target-ppc/mmu-hash64.h > index 9c9ca1d..8fb2ae4 100644 > --- a/target-ppc/mmu-hash64.h > +++ b/target-ppc/mmu-hash64.h > @@ -85,22 +85,24 @@ void ppc_hash64_stop_access(uint64_t token); > static inline target_ulong ppc_hash64_load_hpte0(CPUPPCState *env, > uint64_t token, int > index) { > - index *=3D HASH_PTE_SIZE_64; > + uint64_t addr; > + addr =3D token + (index * HASH_PTE_SIZE_64) + HASH_PTE_SIZE_64/2; > if (env->external_htab) { > - return ldq_p((const void *)(token + index)); > + return ldq_p((const void *)(uintptr_t)addr); > } else { > - return ldq_phys(token + index); > + return ldq_phys(addr); > } > } >=20 > static inline target_ulong ppc_hash64_load_hpte1(CPUPPCState *env, > uint64_t token, int > index) { > - index *=3D HASH_PTE_SIZE_64; > + uint64_t addr; > + addr =3D token + (index * HASH_PTE_SIZE_64) + HASH_PTE_SIZE_64/2; > if (env->external_htab) { > - return ldq_p((const void *)(token + index + > HASH_PTE_SIZE_64/2)); > + return ldq_p((const void *)(uintptr_t)addr); > } else { > - return ldq_phys(token + index + HASH_PTE_SIZE_64/2); > + return ldq_phys(addr); > } > } >=20 >=20 --=20 Gregory Kurz kurzgreg@fr.ibm.com gkurz@linux.vnet.ibm.com Software Engineer @ IBM/Meiosys http://www.ibm.com Tel +33 (0)562 165 496 "Anarchy is about taking complete responsibility for yourself." Alan Moore.