Received: by 10.223.185.116 with SMTP id b49csp1379477wrg; Wed, 21 Feb 2018 17:58:53 -0800 (PST) X-Google-Smtp-Source: AH8x227vihyaV89NkuvLcCBQzOHAquB4Xw+Rn/gw7Ce7vjwlHi8ny5jUdXlm8ZRG4ACbVMdnUJAP X-Received: by 10.99.60.8 with SMTP id j8mr4303459pga.209.1519264732981; Wed, 21 Feb 2018 17:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519264732; cv=none; d=google.com; s=arc-20160816; b=KOy42LsoGnYMWESjcRu4BzgxK5kbsa+ORcJQGvBoqhw9TpbBtCX6ylbcmmm5G9ybt8 CGykBxA7ZueSSmZ/VNE21mmKwL8Y3cAT+41cuqnollxDXpU8Xr9xOuS0WOCmElG3OAoG gAq8I+cAwh+vrnKeQWxrslNzPeVuaH4UJVlKR0xk2soD5grJusIl2n76Sf4yqWCke12s Al8Jv00EZgmE7HqkHGhn7VkgTCuA8jEvDaYQxGnKvYFq1dMJS61tPJkORIkDdy5/FpaH HvtbDwgIGR28mIeiXx6F8OHGDl7G+nD3AQBzYPoPmciZTCe8IYIH8qbLu9YFjbtP2IBZ pUdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Xbi2MBYUPIS8r6VXXWuy1pJ8fT0X514qrV5rejhl31Q=; b=GsDnqpMFPVIaHp7IgaH9Uj2eU+hQ9sumxlwMlH23YnWESt2EgMN3ULFKsCDHlB5T5v MDjjc+Sk1s6s7zQBTN9kVzCuJXjATe4o5pTfKVt8X/YXRLDN3qF+UEWsYMd3dvqw4ear xfgNNlc2ESlmahEsTPvO4tR/XGItWYNQ6uJwuVj4WKIRaxhHpc8ynZO2Am3BOn1DQBW8 HRfSBTUngDh+zg06ujAT27zGgh4+BLlH/5sa9Hr9mKGSrz/yTjQYH7BJ9KbTxrnVSVdF fnuVnRdWgKBo0QK3e48RloFSijqBGbxsE5mmW75WCUheSNHZJJUY8dAk4mXTQd4cXzTS 981w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cjh8G9CQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si488581pfb.355.2018.02.21.17.58.38; Wed, 21 Feb 2018 17:58:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cjh8G9CQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752225AbeBVB5c (ORCPT + 99 others); Wed, 21 Feb 2018 20:57:32 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34436 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbeBVB53 (ORCPT ); Wed, 21 Feb 2018 20:57:29 -0500 Received: by mail-qt0-f196.google.com with SMTP id d14so4521702qtg.1; Wed, 21 Feb 2018 17:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xbi2MBYUPIS8r6VXXWuy1pJ8fT0X514qrV5rejhl31Q=; b=cjh8G9CQBxgnrkblJH8y+CUjl1UgKsyMLZpUoG/2HCms1zyh9FXP+lk8edoipUBUnZ 4AemMYz54o/W9OtaoqJs7PmEkNwQ1c8BsI/6PJIHZwEd9iNPxVdJ1mfAOxal51yZoEVR z4mR8VTglsy8t/gi/GH+MO+kZ6Q4Is2WD9I8poV8YM8tG4XtIlXdVlhTMGG2WH7lMCW/ cTCRRY1aO7Yz0+VqqYMIWqJLiJnh4WZRYrHviopynKDKUcVyG4ZdqmSfCoktQwsYCA3R houxTXhjBMaNbYbIgIRi8Tet/b2JlQQddsxrjykuAaXCsaHs2hl+mg1SLU6D3VMrasOG oaeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Xbi2MBYUPIS8r6VXXWuy1pJ8fT0X514qrV5rejhl31Q=; b=YHFq6xifR17c9mnHwWjFZ6dDH7fL43oJMhBAu6QZmKYQgQ7LBn+yH6PMvKN3JQ3pHK cPbWkB41tlnTnKtsHtNPCPNMXLiwAS9n8kIVsFY9xXey9DZRoEhiwihHXyq/xpjfjO3J lZnKFXBFXXd3jio0hXhaTQfBAswTSfDwowbwEyWJzVipeFXqBw25KS8dretaUh/lTeIb /pqTGT7yabj2sc/kq4yBzzBVoW9IH1PuBP4l21AYmq1k+PWrQRAbCh+PIkz3BrzxoLZ7 1VeNjzjcWn9MqXkW3ZhlMun1cpRlMYLUIzMYiKGCMN+VYKGLZ49/SBrcAGyGVgTUgTwM A5Ww== X-Gm-Message-State: APf1xPBux1f1EoGblwgkuEv31GbCxsC3SQ5wA1obliWzaSNk4dBve2sP fYjPe5/we/jq4X2aZJC6uN4= X-Received: by 10.200.40.129 with SMTP id i1mr8227470qti.176.1519264648413; Wed, 21 Feb 2018 17:57:28 -0800 (PST) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id n29sm14182630qtf.18.2018.02.21.17.57.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 17:57:27 -0800 (PST) From: Ram Pai To: shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, akpm@linux-foundation.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com, arnd@arndb.de Subject: [PATCH v12 21/22] selftests/vm: sub-page allocator Date: Wed, 21 Feb 2018 17:55:40 -0800 Message-Id: <1519264541-7621-22-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org introduce a new allocator that allocates 4k hardware-pages to back 64k linux-page. This allocator is only applicable on powerpc. cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 30 ++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 42c068a..1b06e59 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -766,6 +766,35 @@ void free_pkey_malloc(void *ptr) return ptr; } +void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +{ +#ifdef __powerpc64__ + void *ptr; + int ret; + + dprintf1("doing %s(size=%ld, prot=0x%x, pkey=%d)\n", __func__, + size, prot, pkey); + pkey_assert(pkey < NR_PKEYS); + ptr = mmap(NULL, size, prot, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + pkey_assert(ptr != (void *)-1); + + ret = syscall(__NR_subpage_prot, ptr, size, NULL); + if (ret) { + perror("subpage_perm"); + return PTR_ERR_ENOTSUP; + } + + ret = mprotect_pkey((void *)ptr, PAGE_SIZE, prot, pkey); + pkey_assert(!ret); + record_pkey_malloc(ptr, size); + + dprintf1("%s() for pkey %d @ %p\n", __func__, pkey, ptr); + return ptr; +#else /* __powerpc64__ */ + return PTR_ERR_ENOTSUP; +#endif /* __powerpc64__ */ +} + void *malloc_pkey_anon_huge(long size, int prot, u16 pkey) { int ret; @@ -888,6 +917,7 @@ void setup_hugetlbfs(void) void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { malloc_pkey_with_mprotect, + malloc_pkey_with_mprotect_subpage, malloc_pkey_anon_huge, malloc_pkey_hugetlb /* can not do direct with the pkey_mprotect() API: -- 1.7.1