diff mbox

[2/2] ppc: Fix 64K pages support in full emulation

Message ID e8488ee4-396c-02b0-5e28-39513c5f2b37@kaod.org (mailing list archive)
State New, archived
Headers show

Commit Message

Cédric Le Goater June 30, 2016, 4:01 p.m. UTC
On 06/30/2016 12:56 PM, Anton Blanchard wrote:
> Hi,
> 
>> From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>>
>> We were always advertising only 4K & 16M. Additionally the code wasn't
>> properly matching the page size with the PTE content, which meant we
>> could potentially hit an incorrect PTE if the guest used multiple
>> sizes.
>>
>> Finally, honor the CPU capabilities when decoding the size from the
>> SLB so we don't try to use 64K pages on 970.
>>
>> This still doesn't add support for MPSS (Multiple Page Sizes per
>> Segment)
> 
> This is causing issues booting an Ubuntu yakety cloud image. I'm
> running on a ppc64le box (I don't think it reproduces on x86-64).
> 
> cat << EOF > my-user-data
> #cloud-config
> password: password
> chpasswd: { expire: False }
> ssh_pwauth: True
> EOF
> 
> cloud-localds my-seed.img my-user-data
> 
> wget -N https://cloud-images.ubuntu.com/yakkety/current/yakkety-server-cloudimg-ppc64el.img
> 
> qemu-system-ppc64 -M pseries -cpu POWER8 -nographic -vga none -m 4G -drive file=test.img -drive file=my-seed.img -net user -net nic
> 
> The cloud-init scripts never finish, so the ubuntu user's
> password is never updated. With the above cloud config you
> should be able to log in with ubuntu/password.

The code I pushed was a little old. See below for a possible
fix (Ben, David, could you check ?)

With it, I could log in the image : 

	Ubuntu Yakkety Yak (development branch) ubuntu hvc0

	ubuntu login: [  164.177145] cloud-init[1890]: Generating locales (this might take a while)...
		[  175.653454] cloud-init[1890]:   en_US.UTF-8... done
	[  175.664475] cloud-init[1890]: Generation complete.
	[  184.064419] cloud-init[1890]: Cloud-init v. 0.7.7 running 'modules:config' at Thu, 30 Jun 2016 15:47:22 +0000. Up 158.38 seconds.
	ci-info: no authorized ssh keys fingerprints found for user ubuntu.
	<14>Jun 30 15:47:58 ec2: 
	<14>Jun 30 15:47:58 ec2: #############################################################
	<14>Jun 30 15:47:58 ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
	<14>Jun 30 15:47:58 ec2: 1024 SHA256:N8fPX8q8HY2aaIn2r9gf2X+6We3GNcDF+Nb/OO9JIks root@ubuntu (DSA)
	<14>Jun 30 15:47:59 ec2: 256 SHA256:3+9VDWNJ0w4L1RS5jTE3sfYBhMZ/nxS1qJwFZNismbQ root@ubuntu (ECDSA)
	<14>Jun 30 15:47:59 ec2: 256 SHA256:3YDyIYY3M5ThxmeEjn3ZW4GGq0xTony2W0u2pl43pDc root@ubuntu (ED25519)
	<14>Jun 30 15:48:00 ec2: 2048 SHA256:lwcJNspduOE7QOR48X6TudTJ5mj+8i3FhAAD7UzJAG0 root@ubuntu (RSA)
	<14>Jun 30 15:48:00 ec2: -----END SSH HOST KEY FINGERPRINTS-----
	<14>Jun 30 15:48:00 ec2: #############################################################
	-----BEGIN SSH HOST KEY KEYS-----
	ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKxBntCKa5Po0v0eu5Vq6WWCfmTpK7enqvfo7UKZJZz5iXsSBu40yzqUJQVQsqJ4l9toLkaJlYCMlRWDbQ3X76Y= root@ubuntu
	ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO9Y6u+kQCKnX0jb0TyUpkmPOkjGFg8b7EbiHnJPfGBg root@ubuntu
	ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCr75VVowRslg0iDyf3rfJ2crE7H4tzstbmwDzXlJsVVzg4Xysfck6LKlNT8tvQwlocaHaiUYF3pbPCrpYypG2NzlQA9HT+KIdVb5NTeeLy7GdumK3DpWYBSGFdpiGdTCDfeZ9ny5YycAEopsdFJcDazhD/lZCGcYtGYjv+BUIjAtTO0GPHndmnJLZgDMxizTwaxAUb94qj/qyF2yO7fZq9QxgHVzwlwhfD3Wpl9PNH3ZjURMUAH1ExjX4jvkikrvVCW2Q38R6Pal3sgXexq/QdlwhzqCXOeuedo8BHEMmta2QiMoovAtuYLL41k7e2RBY4x8Pq4n4bnY6kPLp1neE3 root@ubuntu
	-----END SSH HOST KEY KEYS-----
	[  196.524382] cloud-init[2058]: Cloud-init v. 0.7.7 running 'modules:final' at Thu, 30 Jun 2016 15:47:55 +0000. Up 191.77 seconds.
	[  196.532336] cloud-init[2058]: ci-info: no authorized ssh keys fingerprints found for user ubuntu.
	[  196.540332] cloud-init[2058]: Cloud-init v. 0.7.7 finished at Thu, 30 Jun 2016 15:48:00 +0000. Datasource DataSourceNoCloud [seed=/dev/sdb][dsmode=net].  Up 196.26 seconds

	Ubuntu Yakkety Yak (development branch) ubuntu hvc0

	ubuntu login: ubuntu
	Password: 
	Welcome to Ubuntu Yakkety Yak (development branch) (GNU/Linux 4.4.0-28-generic ppc64le)
	...

Could you give it a try please ? If you hit this compile bug on ubuntu :

target-ppc/mmu-hash64.c:936:16: error: '*((void *)&slb+16)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     pte_offset = ppc_hash64_htab_lookup(cpu, &slb, addr, &pte);

That needs another fix. working on it. 

Thanks,

C. 


From: Cédric Le Goater <clg@kaod.org>
Subject: [PATCH] ppc: fix regression in large page support
Date: Thu, 30 Jun 2016 17:01:17 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

introduced by commit 53df75a59bcf ('ppc: Fix 64K pages support in full
emulation')

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 target-ppc/mmu-hash64.c |   24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

Comments

Benjamin Herrenschmidt June 30, 2016, 10:13 p.m. UTC | #1
On Thu, 2016-06-30 at 18:01 +0200, Cédric Le Goater wrote:
> +static uint32_t ppc_hash64_pte_size_decode(PowerPCCPU *cpu, uint64_t

> pte0,

> +                                           uint64_t pte1, uint32_t

> slb_pshift)

>  {

> -    switch (slb_pshift) {

> -    case 12:

> -        return 12;

> -    case 16:

> -        if ((pte1 & 0xf000) == 0x1000) {

> -            return 16;

> -        }

> -        return 0;

> -    case 24:

> -        if ((pte1 & 0xff000) == 0) {

> -            return 24;

> -        }

> -        return 0;

> -    }

> -    return 0;

> +    unsigned spshift;

> +

> +    return ppc_hash64_hpte_page_shift_noslb(cpu, pte0, pte1,

> &spshift);

>  }


Why not call ppc_hash64_hpte_page_shift_noslb() directly from the call
site ? That or rename it to ppc_hash64_pte_size_decode :-)

Otherwise yes, your patch looks correct as in what
doesppc_hash64_hpte_page_shift_noslb() is definitely more correct than
what ppc_hash64_pte_size_decode() is doing.

Cheers,
Ben.
David Gibson June 30, 2016, 11:56 p.m. UTC | #2
On Fri, Jul 01, 2016 at 08:13:47AM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2016-06-30 at 18:01 +0200, Cédric Le Goater wrote:
> > +static uint32_t ppc_hash64_pte_size_decode(PowerPCCPU *cpu, uint64_t
> > pte0,
> > +                                           uint64_t pte1, uint32_t
> > slb_pshift)
> >  {
> > -    switch (slb_pshift) {
> > -    case 12:
> > -        return 12;
> > -    case 16:
> > -        if ((pte1 & 0xf000) == 0x1000) {
> > -            return 16;
> > -        }
> > -        return 0;
> > -    case 24:
> > -        if ((pte1 & 0xff000) == 0) {
> > -            return 24;
> > -        }
> > -        return 0;
> > -    }
> > -    return 0;
> > +    unsigned spshift;
> > +
> > +    return ppc_hash64_hpte_page_shift_noslb(cpu, pte0, pte1,
> > &spshift);
> >  }
> 
> Why not call ppc_hash64_hpte_page_shift_noslb() directly from the call
> site ? That or rename it to ppc_hash64_pte_size_decode :-)

Right.. that is the usage that ppc_hash64_hpte_page_shift_noslb() was
intended for.

> Otherwise yes, your patch looks correct as in what
> doesppc_hash64_hpte_page_shift_noslb() is definitely more correct than
> what ppc_hash64_pte_size_decode() is doing.
>
Cédric Le Goater July 1, 2016, 6:06 a.m. UTC | #3
On 07/01/2016 12:13 AM, Benjamin Herrenschmidt wrote:
> On Thu, 2016-06-30 at 18:01 +0200, Cédric Le Goater wrote:
>> +static uint32_t ppc_hash64_pte_size_decode(PowerPCCPU *cpu, uint64_t
>> pte0,
>> +                                           uint64_t pte1, uint32_t
>> slb_pshift)
>>  {
>> -    switch (slb_pshift) {
>> -    case 12:
>> -        return 12;
>> -    case 16:
>> -        if ((pte1 & 0xf000) == 0x1000) {
>> -            return 16;
>> -        }
>> -        return 0;
>> -    case 24:
>> -        if ((pte1 & 0xff000) == 0) {
>> -            return 24;
>> -        }
>> -        return 0;
>> -    }
>> -    return 0;
>> +    unsigned spshift;
>> +
>> +    return ppc_hash64_hpte_page_shift_noslb(cpu, pte0, pte1,
>> &spshift);
>>  }
> 
> Why not call ppc_hash64_hpte_page_shift_noslb() directly from the call
> site ? That or rename it to ppc_hash64_pte_size_decode :-)

yes, clearly :) but that segment page shift is bothering me.  

David, 

Do you think I can remove that parameter as it is never used or do you
have some plans for it ? 

> Otherwise yes, your patch looks correct as in what
> doesppc_hash64_hpte_page_shift_noslb() is definitely more correct than
> what ppc_hash64_pte_size_decode() is doing.

Thanks,

C.
diff mbox

Patch

Index: qemu-dgibson-for-2.7.git/target-ppc/mmu-hash64.c
===================================================================
--- qemu-dgibson-for-2.7.git.orig/target-ppc/mmu-hash64.c
+++ qemu-dgibson-for-2.7.git/target-ppc/mmu-hash64.c
@@ -453,23 +453,12 @@  void ppc_hash64_stop_access(PowerPCCPU *
 /* Returns the effective page shift or 0. MPSS isn't supported yet so
  * this will always be the slb_pshift or 0
  */
-static uint32_t ppc_hash64_pte_size_decode(uint64_t pte1, uint32_t slb_pshift)
+static uint32_t ppc_hash64_pte_size_decode(PowerPCCPU *cpu, uint64_t pte0,
+                                           uint64_t pte1, uint32_t slb_pshift)
 {
-    switch (slb_pshift) {
-    case 12:
-        return 12;
-    case 16:
-        if ((pte1 & 0xf000) == 0x1000) {
-            return 16;
-        }
-        return 0;
-    case 24:
-        if ((pte1 & 0xff000) == 0) {
-            return 24;
-        }
-        return 0;
-    }
-    return 0;
+    unsigned spshift;
+
+    return ppc_hash64_hpte_page_shift_noslb(cpu, pte0, pte1, &spshift);
 }
 
 static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
@@ -494,7 +483,8 @@  static hwaddr ppc_hash64_pteg_search(Pow
         if ((pte0 & HPTE64_V_VALID)
             && (secondary == !!(pte0 & HPTE64_V_SECONDARY))
             && HPTE64_V_COMPARE(pte0, ptem)) {
-            uint32_t pshift = ppc_hash64_pte_size_decode(pte1, slb_pshift);
+            uint32_t pshift = ppc_hash64_pte_size_decode(cpu, pte0, pte1,
+                                                         slb_pshift);
             if (pshift == 0) {
                 continue;
             }