From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 7B2121A0B99 for ; Fri, 4 Mar 2016 21:28:00 +1100 (AEDT) Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 Mar 2016 20:27:59 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 4A58F3578053 for ; Fri, 4 Mar 2016 21:27:56 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u24ARlWa6160888 for ; Fri, 4 Mar 2016 21:27:56 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u24ARN54026400 for ; Fri, 4 Mar 2016 21:27:23 +1100 Message-ID: <56D962F9.9020503@linux.vnet.ibm.com> Date: Fri, 04 Mar 2016 15:57:05 +0530 From: Anshuman Khandual MIME-Version: 1.0 To: linuxppc-dev@lists.ozlabs.org CC: aneesh.kumar@linux.vnet.ibm.com Subject: Re: [PATCH] powerpc/mm: Add validation for platform reserved memory ranges References: <1457085039-27656-1-git-send-email-khandual@linux.vnet.ibm.com> In-Reply-To: <1457085039-27656-1-git-send-email-khandual@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 03/04/2016 03:20 PM, Anshuman Khandual wrote: > For partition running on PHYP, there can be a adjunct partition > which shares the virtual address range with the operating system. > Virtual address ranges which can be used by the adjunct partition > are communicated with virtual device node of the device tree with > a property known as "ibm,reserved-virtual-addresses". This patch > introduces a new function named 'validate_reserved_va_range' which > is called during initialization to validate that these reserved > virtual address ranges do not overlap with the address ranges used > by the kernel for all supported memory contexts. This helps prevent > the possibility of getting return codes similar to H_RESOURCE for > H_PROTECT hcalls for conflicting HPTE entries. > > Signed-off-by: Anshuman Khandual > --- > - It has been tested on both LE and BE POWER8 platforms > > arch/powerpc/mm/hash_utils_64.c | 77 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 77 insertions(+) > > diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c > index ba59d59..ee14df7 100644 > --- a/arch/powerpc/mm/hash_utils_64.c > +++ b/arch/powerpc/mm/hash_utils_64.c > @@ -1564,3 +1564,80 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base, > /* Finally limit subsequent allocations */ > memblock_set_current_limit(ppc64_rma_size); > } > + > +/* > + * PAPR says that each reserved virtual address range record > + * contains three be32 elements which is of toal 12 bytes. > + * First two be32 elements contain the abbreviated virtual > + * address (high order 32 bits and low order 32 bits that > + * generate the abbreviated virtual address of 64 bits which > + * need to be concatenated with 24 bits of 0 at the end) and > + * the third be32 element contains the size of the reserved > + * virtual address range as number of consecutive 4K pages. > + */ > +struct reserved_va_record { > + __be32 high_addr; > + __be32 low_addr; > + __be32 nr_pages_4K; > +}; > + > +/* > + * Linux uses 65 bits (CONTEXT_BITS + ESID_BITS + SID_SHIFT) > + * of virtual address. As reserved virtual address comes in > + * as an abbreviated form (64 bits) from the device tree, we > + * will use a partial address bit mask (65 >> 24) to match it > + * for simplicity. > + */ > +#define RVA_LESS_BITS 24 > +#define LINUX_VA_BITS CONTEXT_BITS + ESID_BITS + SID_SHIFT > +#define PARTIAL_LINUX_VA_MASK ((1ULL << (LINUX_VA_BITS - RVA_LESS_BITS)) - 1) Oops, the indentation should have been similar here. Will fix it.