# Re: \[PATCH -V3 03/11\] arch/powerpc: Convert virtual address to vpn

- From: Aneesh Kumar K.V \<hidden\>
- Date: 2012-07-10 06:13:26 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2012/07/9470119
- Thread: https://ratatoskr.run/linuxppc-dev/2012/07/9470091/t.md

```text
Stephen Rothwell [ref] writes:

> Hi Aneesh,
>
> On Mon,  9 Jul 2012 18:43:33 +0530 "Aneesh Kumar K.V" [ref] wrote:
>>
>> diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
>> index 1c65a59..1c984a6 100644
>> --- a/arch/powerpc/include/asm/mmu-hash64.h
>> +++ b/arch/powerpc/include/asm/mmu-hash64.h
>> @@ -154,9 +155,25 @@ struct mmu_psize_def
>>  #define MMU_SEGSIZE_256M	0
>>  #define MMU_SEGSIZE_1T		1
>>  
>> +/*
>> + * encode page number shift.
>> + * Inorder to fit the 78 bit va in a 64 bit variable we shift the va by
>> + * 12 bits. This enable us to address upto 76 bit va.
>> + * For hpt hash from a va we can ignore the page size bits of va and for
>> + * hpte encoding we ignore upto 23 bits of va. So ignoring lower 12 bits ensure
>> + * we work in all cases including 4k page size.
>> + */
>> +#define VPN_SHIFT	12
>>  
>> +static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize,
>> +					     int ssize)
>> +{
>> +	unsigned long v;
>> +	/*
>> +	 * The AVA field omits the low-order 23 bits of the 78 bits VA.
>> +	 * These bits are not needed in the PTE, because the
>> +	 * low-order b of these bits are part of the byte offset
>> +	 * into the virtual page and, if b < 23, the high-order
>> +	 * 23-b of these bits are always used in selecting the
>> +	 * PTEGs to be searched
>> +	 */
>> +	BUG_ON(VPN_SHIFT > 23);
>
> Could/should this be BUILD_BUG_ON()?
>

Yes. Will update.

-aneesh
```
