From patchwork Mon Sep 16 09:55:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 11146669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4E0A1747 for ; Mon, 16 Sep 2019 09:57:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A24AC214D9 for ; Mon, 16 Sep 2019 09:57:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A24AC214D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8DDA26B0006; Mon, 16 Sep 2019 05:57:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 866F46B0007; Mon, 16 Sep 2019 05:57:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72EA36B0008; Mon, 16 Sep 2019 05:57:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 51CEC6B0007 for ; Mon, 16 Sep 2019 05:57:26 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 05013180AD802 for ; Mon, 16 Sep 2019 09:57:26 +0000 (UTC) X-FDA: 75940331292.29.love87_7b0e69517a037 X-Spam-Summary: 2,0,0,860aeb201de0920c,d41d8cd98f00b204,ldufour@linux.ibm.com,:mpe@ellerman.id.au:benh@kernel.crashing.org:paulus@samba.org:aneesh.kumar@linux.ibm.com:npiggin@gmail.com:linuxppc-dev@lists.ozlabs.org::linux-kernel@vger.kernel.org,RULES_HIT:1:2:41:69:355:379:541:800:960:968:973:988:989:1260:1261:1311:1314:1345:1359:1381:1437:1515:1605:1730:1747:1777:1792:2393:2559:2562:2900:2903:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3874:4050:4250:4321:4605:5007:6119:6120:6261:7875:7901:7903:7904:8603:10004:11026:11233:11473:11657:11658:11914:12043:12048:12296:12297:12438:12555:12895:13161:13229:13894:14093:14394:21080:21450:21451:21524:21627:30034:30054:30070,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: love87_7b0e69517a037 X-Filterd-Recvd-Size: 10418 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Sep 2019 09:57:25 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8G9qgZL063204 for ; Mon, 16 Sep 2019 05:57:24 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2v282p09sb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 16 Sep 2019 05:57:24 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Sep 2019 10:57:22 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 16 Sep 2019 10:57:19 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8G9vHV948693316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Sep 2019 09:57:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D775F4C046; Mon, 16 Sep 2019 09:57:17 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 142274C040; Mon, 16 Sep 2019 09:57:17 +0000 (GMT) Received: from pomme.com (unknown [9.145.76.175]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 16 Sep 2019 09:57:16 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, aneesh.kumar@linux.ibm.com, npiggin@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] powperc/mm: read TLB Block Invalidate Characteristics Date: Mon, 16 Sep 2019 11:55:42 +0200 X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190916095543.17496-1-ldufour@linux.ibm.com> References: <20190916095543.17496-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19091609-0016-0000-0000-000002AC848B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091609-0017-0000-0000-0000330D21F2 Message-Id: <20190916095543.17496-2-ldufour@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-16_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909160105 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The PAPR document specifies the TLB Block Invalidate Characteristics which tells for each couple segment base page size, actual page size, the size of the block the hcall H_BLOCK_REMOVE is supporting. These characteristics are loaded at boot time in a new table hblkr_size. The table is appart the mmu_psize_def because this is specific to the pseries architecture. A new init service, pseries_lpar_read_hblkr_characteristics() is added to read the characteristics. In that function, the size of the buffer is set to twice the number of known page size, plus 10 bytes to ensure we have enough place. This new init function is called from pSeries_setup_arch(). Signed-off-by: Laurent Dufour --- .../include/asm/book3s/64/tlbflush-hash.h | 1 + arch/powerpc/platforms/pseries/lpar.c | 138 ++++++++++++++++++ arch/powerpc/platforms/pseries/setup.c | 1 + 3 files changed, 140 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h index 64d02a704bcb..74155cc8cf89 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h @@ -117,4 +117,5 @@ extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start, unsigned long end); extern void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr); +extern void pseries_lpar_read_hblkr_characteristics(void); #endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_HASH_H */ diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c index 36b846f6e74e..98a5c2ff9a0b 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -56,6 +56,15 @@ EXPORT_SYMBOL(plpar_hcall); EXPORT_SYMBOL(plpar_hcall9); EXPORT_SYMBOL(plpar_hcall_norets); +/* + * H_BLOCK_REMOVE supported block size for this page size in segment who's base + * page size is that page size. + * + * The first index is the segment base page size, the second one is the actual + * page size. + */ +static int hblkr_size[MMU_PAGE_COUNT][MMU_PAGE_COUNT]; + #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE static u8 dtl_mask = DTL_LOG_PREEMPT; #else @@ -1311,6 +1320,135 @@ static void do_block_remove(unsigned long number, struct ppc64_tlb_batch *batch, (void)call_block_remove(pix, param, true); } +/* + * TLB Block Invalidate Characteristics These characteristics define the size of + * the block the hcall H_BLOCK_REMOVE is able to process for each couple segment + * base page size, actual page size. + * + * The ibm,get-system-parameter properties is returning a buffer with the + * following layout: + * + * [ 2 bytes size of the RTAS buffer (without these 2 bytes) ] + * ----------------- + * TLB Block Invalidate Specifiers: + * [ 1 byte LOG base 2 of the TLB invalidate block size being specified ] + * [ 1 byte Number of page sizes (N) that are supported for the specified + * TLB invalidate block size ] + * [ 1 byte Encoded segment base page size and actual page size + * MSB=0 means 4k segment base page size and actual page size + * MSB=1 the penc value in mmu_psize_def ] + * ... + * ----------------- + * Next TLB Block Invalidate Specifiers... + * ----------------- + * [ 0 ] + */ +static inline void __init set_hblk_bloc_size(int bpsize, int psize, + unsigned int block_size) +{ + if (block_size > hblkr_size[bpsize][psize]) + hblkr_size[bpsize][psize] = block_size; +} + +/* + * Decode the Encoded segment base page size and actual page size. + * PAPR specifies with bit 0 as MSB: + * - bit 0 is the L bit + * - bits 2-7 are the penc value + * If the L bit is 0, this means 4K segment base page size and actual page size + * otherwise the penc value should be readed. + */ +#define HBLKR_L_BIT_MASK 0x80 +#define HBLKR_PENC_MASK 0x3f +static inline void __init check_lp_set_hblk(unsigned int lp, + unsigned int block_size) +{ + unsigned int bpsize, psize; + + + /* First, check the L bit, if not set, this means 4K */ + if ((lp & HBLKR_L_BIT_MASK) == 0) { + set_hblk_bloc_size(MMU_PAGE_4K, MMU_PAGE_4K, block_size); + return; + } + + lp &= HBLKR_PENC_MASK; + for (bpsize = 0; bpsize < MMU_PAGE_COUNT; bpsize++) { + struct mmu_psize_def *def = &mmu_psize_defs[bpsize]; + + for (psize = 0; psize < MMU_PAGE_COUNT; psize++) { + if (def->penc[psize] == lp) { + set_hblk_bloc_size(bpsize, psize, block_size); + return; + } + } + } +} + +#define SPLPAR_TLB_BIC_TOKEN 50 +#define SPLPAR_TLB_BIC_MAXLENGTH (MMU_PAGE_COUNT*2 + 10) +void __init pseries_lpar_read_hblkr_characteristics(void) +{ + int call_status; + unsigned char local_buffer[SPLPAR_TLB_BIC_MAXLENGTH]; + int len, idx, bpsize; + + if (!firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) { + pr_info("H_BLOCK_REMOVE is not supported"); + return; + } + + memset(local_buffer, 0, SPLPAR_TLB_BIC_MAXLENGTH); + + spin_lock(&rtas_data_buf_lock); + memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE); + call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1, + NULL, + SPLPAR_TLB_BIC_TOKEN, + __pa(rtas_data_buf), + RTAS_DATA_BUF_SIZE); + memcpy(local_buffer, rtas_data_buf, SPLPAR_TLB_BIC_MAXLENGTH); + local_buffer[SPLPAR_TLB_BIC_MAXLENGTH - 1] = '\0'; + spin_unlock(&rtas_data_buf_lock); + + if (call_status != 0) { + pr_warn("%s %s Error calling get-system-parameter (0x%x)\n", + __FILE__, __func__, call_status); + return; + } + + /* + * The first two (2) bytes of the data in the buffer are the length of + * the returned data, not counting these first two (2) bytes. + */ + len = local_buffer[0] * 256 + local_buffer[1] + 2; + if (len >= SPLPAR_TLB_BIC_MAXLENGTH) { + pr_warn("%s too large returned buffer %d", __func__, len); + return; + } + + idx = 2; + while (idx < len) { + unsigned int block_size = local_buffer[idx++]; + unsigned int npsize; + + if (!block_size) + break; + + block_size = 1 << block_size; + + for (npsize = local_buffer[idx++]; npsize > 0; npsize--) + check_lp_set_hblk((unsigned int) local_buffer[idx++], + block_size); + } + + for (bpsize = 0; bpsize < MMU_PAGE_COUNT; bpsize++) + for (idx = 0; idx < MMU_PAGE_COUNT; idx++) + if (hblkr_size[bpsize][idx]) + pr_info("H_BLOCK_REMOVE supports base psize:%d psize:%d block size:%d", + bpsize, idx, hblkr_size[bpsize][idx]); +} + /* * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie * lock. diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index f8adcd0e4589..015b7ba13ee4 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -744,6 +744,7 @@ static void __init pSeries_setup_arch(void) pseries_setup_rfi_flush(); setup_stf_barrier(); + pseries_lpar_read_hblkr_characteristics(); /* By default, only probe PCI (can be overridden by rtas_pci) */ pci_add_flags(PCI_PROBE_ONLY); From patchwork Mon Sep 16 09:55:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 11146671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A0801745 for ; Mon, 16 Sep 2019 09:57:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 241D6214AF for ; Mon, 16 Sep 2019 09:57:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 241D6214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 97CA06B0007; Mon, 16 Sep 2019 05:57:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8B79B6B0008; Mon, 16 Sep 2019 05:57:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5626B000A; Mon, 16 Sep 2019 05:57:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 587556B0007 for ; Mon, 16 Sep 2019 05:57:27 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 0306B181AC9AE for ; Mon, 16 Sep 2019 09:57:26 +0000 (UTC) X-FDA: 75940331334.28.power98_7b2fa1ba64f17 X-Spam-Summary: 2,0,0,6106bc92f69c6e73,d41d8cd98f00b204,ldufour@linux.ibm.com,:mpe@ellerman.id.au:benh@kernel.crashing.org:paulus@samba.org:aneesh.kumar@linux.ibm.com:npiggin@gmail.com:linuxppc-dev@lists.ozlabs.org::linux-kernel@vger.kernel.org,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1311:1314:1345:1359:1381:1437:1515:1535:1544:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2731:2898:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:4118:4250:4321:5007:6119:6261:7903:8603:8660:10004:11026:11473:11657:11658:11914:12043:12048:12291:12297:12438:12555:12895:12986:13095:13148:13221:13229:13230:13894:14181:14394:14721:21080:21212:21433:21450:21451:21627:30012:30034:30054:30070:30090,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:39,LUA_SUMMARY:none X-HE-Tag: power98_7b2fa1ba64f17 X-Filterd-Recvd-Size: 7306 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Sep 2019 09:57:26 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8G9qYhR103649 for ; Mon, 16 Sep 2019 05:57:25 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2v283yr6re-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 16 Sep 2019 05:57:25 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Sep 2019 10:57:24 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 16 Sep 2019 10:57:20 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8G9vItv44040340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Sep 2019 09:57:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C64334C046; Mon, 16 Sep 2019 09:57:18 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 036A64C040; Mon, 16 Sep 2019 09:57:18 +0000 (GMT) Received: from pomme.com (unknown [9.145.76.175]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 16 Sep 2019 09:57:17 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, aneesh.kumar@linux.ibm.com, npiggin@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] powerpc/mm: call H_BLOCK_REMOVE when supported Date: Mon, 16 Sep 2019 11:55:43 +0200 X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190916095543.17496-1-ldufour@linux.ibm.com> References: <20190916095543.17496-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19091609-0012-0000-0000-0000034C8596 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091609-0013-0000-0000-00002186FB01 Message-Id: <20190916095543.17496-3-ldufour@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-16_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909160105 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now we do not call _BLOCK_REMOVE all the time when the feature is exhibited. Depending on the hardware and the hypervisor, the hcall H_BLOCK_REMOVE may not be able to process all the page size for a segment base page size, as reported by the TLB Invalidate Characteristics.o For each couple base segment page size and actual page size, this characteristic is telling the size of the block the hcall is supporting. Due to the involve complexity in do_block_remove() and call_block_remove(), and the fact currently a 8 size block is returned by the hypervisor, we are only supporting 8 size block to the H_BLOCK_REMOVE hcall. Furthermore a warning message is displayed at boot time in the case of an unsupported block size. In order to identify this limitation easily in the code,a local define HBLKR_SUPPORTED_SIZE defining the currently supported block size, and a dedicated checking helper is_supported_hlbkr() are introduced. For regular pages and hugetlb, the assumption is made that the page size is equal to the base page size. For THP the page size is assumed to be 16M. Signed-off-by: Laurent Dufour --- arch/powerpc/platforms/pseries/lpar.c | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c index 98a5c2ff9a0b..e2ad9b3b1097 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -65,6 +65,13 @@ EXPORT_SYMBOL(plpar_hcall_norets); */ static int hblkr_size[MMU_PAGE_COUNT][MMU_PAGE_COUNT]; +/* + * Due to the involved complexity, and that the current hypervisor is only + * returning this value or 0, we are limiting the support of the H_BLOCK_REMOVE + * buffer size to 8 size block. + */ +#define HBLKR_SUPPORTED_BLOCK_SIZE 8 + #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE static u8 dtl_mask = DTL_LOG_PREEMPT; #else @@ -993,6 +1000,15 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, #define HBLKR_CTRL_ERRNOTFOUND 0x8800000000000000UL #define HBLKR_CTRL_ERRBUSY 0xa000000000000000UL +/* + * Returned true if we are supporting this block size for the specified segment + * base page size and actual page size. + */ +static inline bool is_supported_hlbkr(int bpsize, int psize) +{ + return (hblkr_size[bpsize][psize] == HBLKR_SUPPORTED_BLOCK_SIZE); +} + /** * H_BLOCK_REMOVE caller. * @idx should point to the latest @param entry set with a PTEX. @@ -1152,7 +1168,11 @@ static inline void __pSeries_lpar_hugepage_invalidate(unsigned long *slot, if (lock_tlbie) spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags); - if (firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) + /* + * Assuming THP size is 16M, and we only support 8 bytes size buffer + * for the momment. + */ + if (is_supported_hlbkr(psize, MMU_PAGE_16M)) hugepage_block_invalidate(slot, vpn, count, psize, ssize); else hugepage_bulk_invalidate(slot, vpn, count, psize, ssize); @@ -1437,6 +1457,14 @@ void __init pseries_lpar_read_hblkr_characteristics(void) block_size = 1 << block_size; + /* + * If the block size is not supported by the kernel, report it, + * but continue reading the values, and the following blocks. + */ + if (block_size != HBLKR_SUPPORTED_BLOCK_SIZE) + pr_warn("Unsupported H_BLOCK_REMOVE block size : %d\n", + block_size); + for (npsize = local_buffer[idx++]; npsize > 0; npsize--) check_lp_set_hblk((unsigned int) local_buffer[idx++], block_size); @@ -1468,7 +1496,10 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local) if (lock_tlbie) spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags); - if (firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) { + /* + * Currently, we only support 8 bytes size buffer in do_block_remove(). + */ + if (is_supported_hlbkr(batch->psize, batch->psize)) { do_block_remove(number, batch, param); goto out; }