[PATCH 2/2] KVM: PPC: Book3E: Get vcpu's last instruction for emulation

Scott Wood scottwood at freescale.com
Wed Jul 10 10:12:31 EST 2013


On 07/09/2013 04:45:10 PM, Alexander Graf wrote:
> 
> On 28.06.2013, at 11:20, Mihai Caraman wrote:
> 
> > +	/* Get page size */
> > +	if (MAS0_GET_TLBSEL(mfspr(SPRN_MAS0)) == 0)
> > +		psize_shift = PAGE_SHIFT;
> > +	else
> > +		psize_shift = MAS1_GET_TSIZE(mas1) + 10;
> > +
> > +	mas7_mas3 = (((u64) mfspr(SPRN_MAS7)) << 32) |
> > +		    mfspr(SPRN_MAS3);
> > +	addr = (mas7_mas3 & (~0ULL << psize_shift)) |
> > +	       (geaddr & ((1ULL << psize_shift) - 1ULL));
> > +
> > +	/* Map a page and get guest's instruction */
> > +	page = pfn_to_page(addr >> PAGE_SHIFT);
> 
> While looking at this I just realized that you're missing a check  
> here. What if our IP is in some PCI BAR? Or can't we execute from  
> those?

We at least need to check pfn_valid() first.  That'll just keep us from  
accessing a bad pointer in the host kernel, though -- it won't make the  
emulation actually work.  If we need that, we'll probably need to  
create a temporary TLB entry manually.

-Scott


More information about the Linuxppc-dev mailing list