mmu-hash*: Don't keep looking for PTEs after we find a match
commitf95d7cc7fecbc0e320e83c864ce2d99fee3d9236
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 12 Mar 2013 00:31:27 +0000 (12 00:31 +0000)
committerAlexander Graf <agraf@suse.de>
Fri, 22 Mar 2013 14:28:50 +0000 (22 15:28 +0100)
treee0c61f64c325bb0766b8b5e1859d1178c1118c40
parentbb218042c8b4e4bbcf2ab3c8d961d78876178831
mmu-hash*: Don't keep looking for PTEs after we find a match

BEHAVIOUR CHANGE

The ppc hash mmu hashes each virtual address to a primary and secondary
possible hash bucket (aka PTE group or PTEG) each with 8 PTEs.  Then we
need a linear search through the PTEs to find the correct one for the
virtual address we're translating.

It is a programming error for the guest to insert multiple PTEs mapping the
same virtual address into a PTEG - in this case the ppc architecture says
the MMU can either act as if just one was present, or give a machine check.
Currently our code takes the first matching PTE in a PTEG if it finds a
successful translation.  But if a matching PTE is found, but permission
bits don't allow the access, we keep looking through the PTEG, checking
that any other matching PTEs contain an identical translation.

That behaviour is perhaps not exactly wrong, but it's certainly not useful.
This patch changes it to always just find the first matching PTE in a PTEG.

In addition, if we get a permissions problem on the primary PTEG, we then
search the secondary PTEG.  This is incorrect - a permission denying PTE
in the primary PTEG should not be overwritten by an access granting PTE in
the secondary (although again, it would be a programming error for the
guest to set up such a situation anyway).  So additionally we update the
code to only search the secondary PTEG if no matching PTE is found in the
primary at all.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
target-ppc/mmu-hash32.c
target-ppc/mmu-hash64.c