xref: /openbmc/linux/arch/powerpc/kvm/book3s_32_mmu.c (revision 4d29bdbf)
101235180SAlexander Graf /*
201235180SAlexander Graf  * This program is free software; you can redistribute it and/or modify
301235180SAlexander Graf  * it under the terms of the GNU General Public License, version 2, as
401235180SAlexander Graf  * published by the Free Software Foundation.
501235180SAlexander Graf  *
601235180SAlexander Graf  * This program is distributed in the hope that it will be useful,
701235180SAlexander Graf  * but WITHOUT ANY WARRANTY; without even the implied warranty of
801235180SAlexander Graf  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
901235180SAlexander Graf  * GNU General Public License for more details.
1001235180SAlexander Graf  *
1101235180SAlexander Graf  * You should have received a copy of the GNU General Public License
1201235180SAlexander Graf  * along with this program; if not, write to the Free Software
1301235180SAlexander Graf  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
1401235180SAlexander Graf  *
1501235180SAlexander Graf  * Copyright SUSE Linux Products GmbH 2009
1601235180SAlexander Graf  *
1701235180SAlexander Graf  * Authors: Alexander Graf <agraf@suse.de>
1801235180SAlexander Graf  */
1901235180SAlexander Graf 
2001235180SAlexander Graf #include <linux/types.h>
2101235180SAlexander Graf #include <linux/string.h>
2201235180SAlexander Graf #include <linux/kvm.h>
2301235180SAlexander Graf #include <linux/kvm_host.h>
2401235180SAlexander Graf #include <linux/highmem.h>
2501235180SAlexander Graf 
2601235180SAlexander Graf #include <asm/tlbflush.h>
2701235180SAlexander Graf #include <asm/kvm_ppc.h>
2801235180SAlexander Graf #include <asm/kvm_book3s.h>
2901235180SAlexander Graf 
3001235180SAlexander Graf /* #define DEBUG_MMU */
3101235180SAlexander Graf /* #define DEBUG_MMU_PTE */
3201235180SAlexander Graf /* #define DEBUG_MMU_PTE_IP 0xfff14c40 */
3301235180SAlexander Graf 
3401235180SAlexander Graf #ifdef DEBUG_MMU
3501235180SAlexander Graf #define dprintk(X...) printk(KERN_INFO X)
3601235180SAlexander Graf #else
3701235180SAlexander Graf #define dprintk(X...) do { } while(0)
3801235180SAlexander Graf #endif
3901235180SAlexander Graf 
40e425a6deSAlexander Graf #ifdef DEBUG_MMU_PTE
4101235180SAlexander Graf #define dprintk_pte(X...) printk(KERN_INFO X)
4201235180SAlexander Graf #else
4301235180SAlexander Graf #define dprintk_pte(X...) do { } while(0)
4401235180SAlexander Graf #endif
4501235180SAlexander Graf 
4601235180SAlexander Graf #define PTEG_FLAG_ACCESSED	0x00000100
4701235180SAlexander Graf #define PTEG_FLAG_DIRTY		0x00000080
4807b0907dSAlexander Graf #ifndef SID_SHIFT
4907b0907dSAlexander Graf #define SID_SHIFT		28
5007b0907dSAlexander Graf #endif
5101235180SAlexander Graf 
5201235180SAlexander Graf static inline bool check_debug_ip(struct kvm_vcpu *vcpu)
5301235180SAlexander Graf {
5401235180SAlexander Graf #ifdef DEBUG_MMU_PTE_IP
5501235180SAlexander Graf 	return vcpu->arch.pc == DEBUG_MMU_PTE_IP;
5601235180SAlexander Graf #else
5701235180SAlexander Graf 	return true;
5801235180SAlexander Graf #endif
5901235180SAlexander Graf }
6001235180SAlexander Graf 
6101235180SAlexander Graf static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
6201235180SAlexander Graf 					  struct kvmppc_pte *pte, bool data);
63af7b4d10SAlexander Graf static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
644b389ca2SAlexander Graf 					     u64 *vsid);
6501235180SAlexander Graf 
6601235180SAlexander Graf static struct kvmppc_sr *find_sr(struct kvmppc_vcpu_book3s *vcpu_book3s, gva_t eaddr)
6701235180SAlexander Graf {
6801235180SAlexander Graf 	return &vcpu_book3s->sr[(eaddr >> 28) & 0xf];
6901235180SAlexander Graf }
7001235180SAlexander Graf 
7101235180SAlexander Graf static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr,
7201235180SAlexander Graf 					 bool data)
7301235180SAlexander Graf {
744b389ca2SAlexander Graf 	u64 vsid;
7501235180SAlexander Graf 	struct kvmppc_pte pte;
7601235180SAlexander Graf 
7701235180SAlexander Graf 	if (!kvmppc_mmu_book3s_32_xlate_bat(vcpu, eaddr, &pte, data))
7801235180SAlexander Graf 		return pte.vpage;
7901235180SAlexander Graf 
804b389ca2SAlexander Graf 	kvmppc_mmu_book3s_32_esid_to_vsid(vcpu, eaddr >> SID_SHIFT, &vsid);
814b389ca2SAlexander Graf 	return (((u64)eaddr >> 12) & 0xffff) | (vsid << 16);
8201235180SAlexander Graf }
8301235180SAlexander Graf 
8401235180SAlexander Graf static void kvmppc_mmu_book3s_32_reset_msr(struct kvm_vcpu *vcpu)
8501235180SAlexander Graf {
8601235180SAlexander Graf 	kvmppc_set_msr(vcpu, 0);
8701235180SAlexander Graf }
8801235180SAlexander Graf 
8901235180SAlexander Graf static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3s,
9001235180SAlexander Graf 				      struct kvmppc_sr *sre, gva_t eaddr,
9101235180SAlexander Graf 				      bool primary)
9201235180SAlexander Graf {
9301235180SAlexander Graf 	u32 page, hash, pteg, htabmask;
9401235180SAlexander Graf 	hva_t r;
9501235180SAlexander Graf 
9601235180SAlexander Graf 	page = (eaddr & 0x0FFFFFFF) >> 12;
9701235180SAlexander Graf 	htabmask = ((vcpu_book3s->sdr1 & 0x1FF) << 16) | 0xFFC0;
9801235180SAlexander Graf 
9901235180SAlexander Graf 	hash = ((sre->vsid ^ page) << 6);
10001235180SAlexander Graf 	if (!primary)
10101235180SAlexander Graf 		hash = ~hash;
10201235180SAlexander Graf 	hash &= htabmask;
10301235180SAlexander Graf 
10401235180SAlexander Graf 	pteg = (vcpu_book3s->sdr1 & 0xffff0000) | hash;
10501235180SAlexander Graf 
10601235180SAlexander Graf 	dprintk("MMU: pc=0x%lx eaddr=0x%lx sdr1=0x%llx pteg=0x%x vsid=0x%x\n",
10701235180SAlexander Graf 		vcpu_book3s->vcpu.arch.pc, eaddr, vcpu_book3s->sdr1, pteg,
10801235180SAlexander Graf 		sre->vsid);
10901235180SAlexander Graf 
11001235180SAlexander Graf 	r = gfn_to_hva(vcpu_book3s->vcpu.kvm, pteg >> PAGE_SHIFT);
11101235180SAlexander Graf 	if (kvm_is_error_hva(r))
11201235180SAlexander Graf 		return r;
11301235180SAlexander Graf 	return r | (pteg & ~PAGE_MASK);
11401235180SAlexander Graf }
11501235180SAlexander Graf 
11601235180SAlexander Graf static u32 kvmppc_mmu_book3s_32_get_ptem(struct kvmppc_sr *sre, gva_t eaddr,
11701235180SAlexander Graf 				    bool primary)
11801235180SAlexander Graf {
11901235180SAlexander Graf 	return ((eaddr & 0x0fffffff) >> 22) | (sre->vsid << 7) |
12001235180SAlexander Graf 	       (primary ? 0 : 0x40) | 0x80000000;
12101235180SAlexander Graf }
12201235180SAlexander Graf 
12301235180SAlexander Graf static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
12401235180SAlexander Graf 					  struct kvmppc_pte *pte, bool data)
12501235180SAlexander Graf {
12601235180SAlexander Graf 	struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
12701235180SAlexander Graf 	struct kvmppc_bat *bat;
12801235180SAlexander Graf 	int i;
12901235180SAlexander Graf 
13001235180SAlexander Graf 	for (i = 0; i < 8; i++) {
13101235180SAlexander Graf 		if (data)
13201235180SAlexander Graf 			bat = &vcpu_book3s->dbat[i];
13301235180SAlexander Graf 		else
13401235180SAlexander Graf 			bat = &vcpu_book3s->ibat[i];
13501235180SAlexander Graf 
13601235180SAlexander Graf 		if (vcpu->arch.msr & MSR_PR) {
13701235180SAlexander Graf 			if (!bat->vp)
13801235180SAlexander Graf 				continue;
13901235180SAlexander Graf 		} else {
14001235180SAlexander Graf 			if (!bat->vs)
14101235180SAlexander Graf 				continue;
14201235180SAlexander Graf 		}
14301235180SAlexander Graf 
14401235180SAlexander Graf 		if (check_debug_ip(vcpu))
14501235180SAlexander Graf 		{
14601235180SAlexander Graf 			dprintk_pte("%cBAT %02d: 0x%lx - 0x%x (0x%x)\n",
14701235180SAlexander Graf 				    data ? 'd' : 'i', i, eaddr, bat->bepi,
14801235180SAlexander Graf 				    bat->bepi_mask);
14901235180SAlexander Graf 		}
15001235180SAlexander Graf 		if ((eaddr & bat->bepi_mask) == bat->bepi) {
1514b389ca2SAlexander Graf 			u64 vsid;
1524b389ca2SAlexander Graf 			kvmppc_mmu_book3s_32_esid_to_vsid(vcpu,
1534b389ca2SAlexander Graf 				eaddr >> SID_SHIFT, &vsid);
1544b389ca2SAlexander Graf 			vsid <<= 16;
1554b389ca2SAlexander Graf 			pte->vpage = (((u64)eaddr >> 12) & 0xffff) | vsid;
1564b389ca2SAlexander Graf 
15701235180SAlexander Graf 			pte->raddr = bat->brpn | (eaddr & ~bat->bepi_mask);
15801235180SAlexander Graf 			pte->may_read = bat->pp;
15901235180SAlexander Graf 			pte->may_write = bat->pp > 1;
16001235180SAlexander Graf 			pte->may_execute = true;
16101235180SAlexander Graf 			if (!pte->may_read) {
16201235180SAlexander Graf 				printk(KERN_INFO "BAT is not readable!\n");
16301235180SAlexander Graf 				continue;
16401235180SAlexander Graf 			}
16501235180SAlexander Graf 			if (!pte->may_write) {
16601235180SAlexander Graf 				/* let's treat r/o BATs as not-readable for now */
16701235180SAlexander Graf 				dprintk_pte("BAT is read-only!\n");
16801235180SAlexander Graf 				continue;
16901235180SAlexander Graf 			}
17001235180SAlexander Graf 
17101235180SAlexander Graf 			return 0;
17201235180SAlexander Graf 		}
17301235180SAlexander Graf 	}
17401235180SAlexander Graf 
17501235180SAlexander Graf 	return -ENOENT;
17601235180SAlexander Graf }
17701235180SAlexander Graf 
17801235180SAlexander Graf static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
17901235180SAlexander Graf 				     struct kvmppc_pte *pte, bool data,
18001235180SAlexander Graf 				     bool primary)
18101235180SAlexander Graf {
18201235180SAlexander Graf 	struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
18301235180SAlexander Graf 	struct kvmppc_sr *sre;
18401235180SAlexander Graf 	hva_t ptegp;
18501235180SAlexander Graf 	u32 pteg[16];
186af7b4d10SAlexander Graf 	u32 ptem = 0;
18701235180SAlexander Graf 	int i;
18801235180SAlexander Graf 	int found = 0;
18901235180SAlexander Graf 
19001235180SAlexander Graf 	sre = find_sr(vcpu_book3s, eaddr);
19101235180SAlexander Graf 
19201235180SAlexander Graf 	dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28,
19301235180SAlexander Graf 		    sre->vsid, sre->raw);
19401235180SAlexander Graf 
19501235180SAlexander Graf 	pte->vpage = kvmppc_mmu_book3s_32_ea_to_vp(vcpu, eaddr, data);
19601235180SAlexander Graf 
19701235180SAlexander Graf 	ptegp = kvmppc_mmu_book3s_32_get_pteg(vcpu_book3s, sre, eaddr, primary);
19801235180SAlexander Graf 	if (kvm_is_error_hva(ptegp)) {
19901235180SAlexander Graf 		printk(KERN_INFO "KVM: Invalid PTEG!\n");
20001235180SAlexander Graf 		goto no_page_found;
20101235180SAlexander Graf 	}
20201235180SAlexander Graf 
20301235180SAlexander Graf 	ptem = kvmppc_mmu_book3s_32_get_ptem(sre, eaddr, primary);
20401235180SAlexander Graf 
20501235180SAlexander Graf 	if(copy_from_user(pteg, (void __user *)ptegp, sizeof(pteg))) {
20601235180SAlexander Graf 		printk(KERN_ERR "KVM: Can't copy data from 0x%lx!\n", ptegp);
20701235180SAlexander Graf 		goto no_page_found;
20801235180SAlexander Graf 	}
20901235180SAlexander Graf 
21001235180SAlexander Graf 	for (i=0; i<16; i+=2) {
21101235180SAlexander Graf 		if (ptem == pteg[i]) {
21201235180SAlexander Graf 			u8 pp;
21301235180SAlexander Graf 
21401235180SAlexander Graf 			pte->raddr = (pteg[i+1] & ~(0xFFFULL)) | (eaddr & 0xFFF);
21501235180SAlexander Graf 			pp = pteg[i+1] & 3;
21601235180SAlexander Graf 
21701235180SAlexander Graf 			if ((sre->Kp &&  (vcpu->arch.msr & MSR_PR)) ||
21801235180SAlexander Graf 			    (sre->Ks && !(vcpu->arch.msr & MSR_PR)))
21901235180SAlexander Graf 				pp |= 4;
22001235180SAlexander Graf 
22101235180SAlexander Graf 			pte->may_write = false;
22201235180SAlexander Graf 			pte->may_read = false;
22301235180SAlexander Graf 			pte->may_execute = true;
22401235180SAlexander Graf 			switch (pp) {
22501235180SAlexander Graf 				case 0:
22601235180SAlexander Graf 				case 1:
22701235180SAlexander Graf 				case 2:
22801235180SAlexander Graf 				case 6:
22901235180SAlexander Graf 					pte->may_write = true;
23001235180SAlexander Graf 				case 3:
23101235180SAlexander Graf 				case 5:
23201235180SAlexander Graf 				case 7:
23301235180SAlexander Graf 					pte->may_read = true;
23401235180SAlexander Graf 					break;
23501235180SAlexander Graf 			}
23601235180SAlexander Graf 
23701235180SAlexander Graf 			if ( !pte->may_read )
23801235180SAlexander Graf 				continue;
23901235180SAlexander Graf 
24001235180SAlexander Graf 			dprintk_pte("MMU: Found PTE -> %x %x - %x\n",
24101235180SAlexander Graf 				    pteg[i], pteg[i+1], pp);
24201235180SAlexander Graf 			found = 1;
24301235180SAlexander Graf 			break;
24401235180SAlexander Graf 		}
24501235180SAlexander Graf 	}
24601235180SAlexander Graf 
24701235180SAlexander Graf 	/* Update PTE C and A bits, so the guest's swapper knows we used the
24801235180SAlexander Graf 	   page */
24901235180SAlexander Graf 	if (found) {
25001235180SAlexander Graf 		u32 oldpte = pteg[i+1];
25101235180SAlexander Graf 
25201235180SAlexander Graf 		if (pte->may_read)
25301235180SAlexander Graf 			pteg[i+1] |= PTEG_FLAG_ACCESSED;
25401235180SAlexander Graf 		if (pte->may_write)
25501235180SAlexander Graf 			pteg[i+1] |= PTEG_FLAG_DIRTY;
25601235180SAlexander Graf 		else
25701235180SAlexander Graf 			dprintk_pte("KVM: Mapping read-only page!\n");
25801235180SAlexander Graf 
25901235180SAlexander Graf 		/* Write back into the PTEG */
26001235180SAlexander Graf 		if (pteg[i+1] != oldpte)
26101235180SAlexander Graf 			copy_to_user((void __user *)ptegp, pteg, sizeof(pteg));
26201235180SAlexander Graf 
26301235180SAlexander Graf 		return 0;
26401235180SAlexander Graf 	}
26501235180SAlexander Graf 
26601235180SAlexander Graf no_page_found:
26701235180SAlexander Graf 
26801235180SAlexander Graf 	if (check_debug_ip(vcpu)) {
26901235180SAlexander Graf 		dprintk_pte("KVM MMU: No PTE found (sdr1=0x%llx ptegp=0x%lx)\n",
27001235180SAlexander Graf 			    to_book3s(vcpu)->sdr1, ptegp);
27101235180SAlexander Graf 		for (i=0; i<16; i+=2) {
27201235180SAlexander Graf 			dprintk_pte("   %02d: 0x%x - 0x%x (0x%llx)\n",
27301235180SAlexander Graf 				    i, pteg[i], pteg[i+1], ptem);
27401235180SAlexander Graf 		}
27501235180SAlexander Graf 	}
27601235180SAlexander Graf 
27701235180SAlexander Graf 	return -ENOENT;
27801235180SAlexander Graf }
27901235180SAlexander Graf 
28001235180SAlexander Graf static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
28101235180SAlexander Graf 				      struct kvmppc_pte *pte, bool data)
28201235180SAlexander Graf {
28301235180SAlexander Graf 	int r;
28401235180SAlexander Graf 
28501235180SAlexander Graf 	pte->eaddr = eaddr;
28601235180SAlexander Graf 	r = kvmppc_mmu_book3s_32_xlate_bat(vcpu, eaddr, pte, data);
28701235180SAlexander Graf 	if (r < 0)
28801235180SAlexander Graf 	       r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte, data, true);
28901235180SAlexander Graf 	if (r < 0)
29001235180SAlexander Graf 	       r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte, data, false);
29101235180SAlexander Graf 
29201235180SAlexander Graf 	return r;
29301235180SAlexander Graf }
29401235180SAlexander Graf 
29501235180SAlexander Graf 
29601235180SAlexander Graf static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum)
29701235180SAlexander Graf {
29801235180SAlexander Graf 	return to_book3s(vcpu)->sr[srnum].raw;
29901235180SAlexander Graf }
30001235180SAlexander Graf 
30101235180SAlexander Graf static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
30201235180SAlexander Graf 					ulong value)
30301235180SAlexander Graf {
30401235180SAlexander Graf 	struct kvmppc_sr *sre;
30501235180SAlexander Graf 
30601235180SAlexander Graf 	sre = &to_book3s(vcpu)->sr[srnum];
30701235180SAlexander Graf 
30801235180SAlexander Graf 	/* Flush any left-over shadows from the previous SR */
30901235180SAlexander Graf 
31001235180SAlexander Graf 	/* XXX Not necessary? */
31101235180SAlexander Graf 	/* kvmppc_mmu_pte_flush(vcpu, ((u64)sre->vsid) << 28, 0xf0000000ULL); */
31201235180SAlexander Graf 
31301235180SAlexander Graf 	/* And then put in the new SR */
31401235180SAlexander Graf 	sre->raw = value;
31501235180SAlexander Graf 	sre->vsid = (value & 0x0fffffff);
3164b389ca2SAlexander Graf 	sre->valid = (value & 0x80000000) ? false : true;
31701235180SAlexander Graf 	sre->Ks = (value & 0x40000000) ? true : false;
31801235180SAlexander Graf 	sre->Kp = (value & 0x20000000) ? true : false;
31901235180SAlexander Graf 	sre->nx = (value & 0x10000000) ? true : false;
32001235180SAlexander Graf 
32101235180SAlexander Graf 	/* Map the new segment */
32201235180SAlexander Graf 	kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT);
32301235180SAlexander Graf }
32401235180SAlexander Graf 
32501235180SAlexander Graf static void kvmppc_mmu_book3s_32_tlbie(struct kvm_vcpu *vcpu, ulong ea, bool large)
32601235180SAlexander Graf {
3274b389ca2SAlexander Graf 	kvmppc_mmu_pte_flush(vcpu, ea, 0x0FFFF000);
32801235180SAlexander Graf }
32901235180SAlexander Graf 
330af7b4d10SAlexander Graf static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
33101235180SAlexander Graf 					     u64 *vsid)
33201235180SAlexander Graf {
333f7bc74e1SAlexander Graf 	ulong ea = esid << SID_SHIFT;
334f7bc74e1SAlexander Graf 	struct kvmppc_sr *sr;
335f7bc74e1SAlexander Graf 	u64 gvsid = esid;
336f7bc74e1SAlexander Graf 
337f7bc74e1SAlexander Graf 	if (vcpu->arch.msr & (MSR_DR|MSR_IR)) {
338f7bc74e1SAlexander Graf 		sr = find_sr(to_book3s(vcpu), ea);
339f7bc74e1SAlexander Graf 		if (sr->valid)
340f7bc74e1SAlexander Graf 			gvsid = sr->vsid;
341f7bc74e1SAlexander Graf 	}
342f7bc74e1SAlexander Graf 
34301235180SAlexander Graf 	/* In case we only have one of MSR_IR or MSR_DR set, let's put
34401235180SAlexander Graf 	   that in the real-mode context (and hope RM doesn't access
34501235180SAlexander Graf 	   high memory) */
34601235180SAlexander Graf 	switch (vcpu->arch.msr & (MSR_DR|MSR_IR)) {
34701235180SAlexander Graf 	case 0:
348f7bc74e1SAlexander Graf 		*vsid = VSID_REAL | esid;
34901235180SAlexander Graf 		break;
35001235180SAlexander Graf 	case MSR_IR:
351f7bc74e1SAlexander Graf 		*vsid = VSID_REAL_IR | gvsid;
35201235180SAlexander Graf 		break;
35301235180SAlexander Graf 	case MSR_DR:
354f7bc74e1SAlexander Graf 		*vsid = VSID_REAL_DR | gvsid;
35501235180SAlexander Graf 		break;
35601235180SAlexander Graf 	case MSR_DR|MSR_IR:
3574d29bdbfSAlexander Graf 		if (sr->valid)
3584b389ca2SAlexander Graf 			*vsid = sr->vsid;
3594d29bdbfSAlexander Graf 		else
3604d29bdbfSAlexander Graf 			*vsid = VSID_BAT | gvsid;
36101235180SAlexander Graf 		break;
36201235180SAlexander Graf 	default:
36301235180SAlexander Graf 		BUG();
36401235180SAlexander Graf 	}
36501235180SAlexander Graf 
3664b389ca2SAlexander Graf 	if (vcpu->arch.msr & MSR_PR)
3674b389ca2SAlexander Graf 		*vsid |= VSID_PR;
3684b389ca2SAlexander Graf 
36901235180SAlexander Graf 	return 0;
37001235180SAlexander Graf }
37101235180SAlexander Graf 
37201235180SAlexander Graf static bool kvmppc_mmu_book3s_32_is_dcbz32(struct kvm_vcpu *vcpu)
37301235180SAlexander Graf {
37401235180SAlexander Graf 	return true;
37501235180SAlexander Graf }
37601235180SAlexander Graf 
37701235180SAlexander Graf 
37801235180SAlexander Graf void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu)
37901235180SAlexander Graf {
38001235180SAlexander Graf 	struct kvmppc_mmu *mmu = &vcpu->arch.mmu;
38101235180SAlexander Graf 
38201235180SAlexander Graf 	mmu->mtsrin = kvmppc_mmu_book3s_32_mtsrin;
38301235180SAlexander Graf 	mmu->mfsrin = kvmppc_mmu_book3s_32_mfsrin;
38401235180SAlexander Graf 	mmu->xlate = kvmppc_mmu_book3s_32_xlate;
38501235180SAlexander Graf 	mmu->reset_msr = kvmppc_mmu_book3s_32_reset_msr;
38601235180SAlexander Graf 	mmu->tlbie = kvmppc_mmu_book3s_32_tlbie;
38701235180SAlexander Graf 	mmu->esid_to_vsid = kvmppc_mmu_book3s_32_esid_to_vsid;
38801235180SAlexander Graf 	mmu->ea_to_vp = kvmppc_mmu_book3s_32_ea_to_vp;
38901235180SAlexander Graf 	mmu->is_dcbz32 = kvmppc_mmu_book3s_32_is_dcbz32;
39001235180SAlexander Graf 
39101235180SAlexander Graf 	mmu->slbmte = NULL;
39201235180SAlexander Graf 	mmu->slbmfee = NULL;
39301235180SAlexander Graf 	mmu->slbmfev = NULL;
39401235180SAlexander Graf 	mmu->slbie = NULL;
39501235180SAlexander Graf 	mmu->slbia = NULL;
39601235180SAlexander Graf }
397