aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-06-21 09:25:19 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:47:13 -0400
commit3b249157c03154109d31ec95a3c80203adcf8b70 (patch)
treed6a6f4cbf701136cca9f507dcc4a1b55ba07b1de /arch
parenta576f7a29481438db0fa6f3d9ed6939019c441d3 (diff)
KVM: PPC: Use kernel hash function
The linux kernel already provides a hash function. Let's reuse that instead of reinventing the wheel! Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c10
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_host.c11
2 files changed, 4 insertions, 17 deletions
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 81ca9dba4098..904f5ac78f54 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kvm_host.h> 21#include <linux/kvm_host.h>
22#include <linux/hash.h>
22 23
23#include <asm/kvm_ppc.h> 24#include <asm/kvm_ppc.h>
24#include <asm/kvm_book3s.h> 25#include <asm/kvm_book3s.h>
@@ -162,14 +163,7 @@ static int kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu)
162 * a hash, so we don't waste cycles on looping */ 163 * a hash, so we don't waste cycles on looping */
163static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid) 164static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid)
164{ 165{
165 return (u16)(((gvsid >> (SID_MAP_BITS * 7)) & SID_MAP_MASK) ^ 166 return hash_64(gvsid, SID_MAP_BITS);
166 ((gvsid >> (SID_MAP_BITS * 6)) & SID_MAP_MASK) ^
167 ((gvsid >> (SID_MAP_BITS * 5)) & SID_MAP_MASK) ^
168 ((gvsid >> (SID_MAP_BITS * 4)) & SID_MAP_MASK) ^
169 ((gvsid >> (SID_MAP_BITS * 3)) & SID_MAP_MASK) ^
170 ((gvsid >> (SID_MAP_BITS * 2)) & SID_MAP_MASK) ^
171 ((gvsid >> (SID_MAP_BITS * 1)) & SID_MAP_MASK) ^
172 ((gvsid >> (SID_MAP_BITS * 0)) & SID_MAP_MASK));
173} 167}
174 168
175 169
diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index eb1d26b64714..4ccdde152c37 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/kvm_host.h> 22#include <linux/kvm_host.h>
23#include <linux/hash.h>
23 24
24#include <asm/kvm_ppc.h> 25#include <asm/kvm_ppc.h>
25#include <asm/kvm_book3s.h> 26#include <asm/kvm_book3s.h>
@@ -144,17 +145,9 @@ static int kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu)
144 * a hash, so we don't waste cycles on looping */ 145 * a hash, so we don't waste cycles on looping */
145static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid) 146static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid)
146{ 147{
147 return (u16)(((gvsid >> (SID_MAP_BITS * 7)) & SID_MAP_MASK) ^ 148 return hash_64(gvsid, SID_MAP_BITS);
148 ((gvsid >> (SID_MAP_BITS * 6)) & SID_MAP_MASK) ^
149 ((gvsid >> (SID_MAP_BITS * 5)) & SID_MAP_MASK) ^
150 ((gvsid >> (SID_MAP_BITS * 4)) & SID_MAP_MASK) ^
151 ((gvsid >> (SID_MAP_BITS * 3)) & SID_MAP_MASK) ^
152 ((gvsid >> (SID_MAP_BITS * 2)) & SID_MAP_MASK) ^
153 ((gvsid >> (SID_MAP_BITS * 1)) & SID_MAP_MASK) ^
154 ((gvsid >> (SID_MAP_BITS * 0)) & SID_MAP_MASK));
155} 149}
156 150
157
158static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid) 151static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)
159{ 152{
160 struct kvmppc_sid_map *map; 153 struct kvmppc_sid_map *map;