From patchwork Tue Jul 17 13:49:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10529523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2CE1D6020A for ; Tue, 17 Jul 2018 13:51:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2C829203 for ; Tue, 17 Jul 2018 13:51:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 030F129221; Tue, 17 Jul 2018 13:51:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 973CF29203 for ; Tue, 17 Jul 2018 13:51:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B7276B0276; Tue, 17 Jul 2018 09:50:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2404E6B0277; Tue, 17 Jul 2018 09:50:38 -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 042CE6B0278; Tue, 17 Jul 2018 09:50:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by kanga.kvack.org (Postfix) with ESMTP id C76DF6B0276 for ; Tue, 17 Jul 2018 09:50:37 -0400 (EDT) Received: by mail-qt0-f199.google.com with SMTP id d25-v6so746572qtp.10 for ; Tue, 17 Jul 2018 06:50:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=cb/n276Xxe2U8txtUJ8tHphmr2TB1hqLIHEdC9jJtzc=; b=dnTtHy1w5nFtIa9oDDDn+Vwe7nPn27csN8dExG0jPfDOkKyNWX+9E34R0NAWwbOiuw wCuw2wppgMKAiJdQFA5p1DEdjzbj+/R3wHRkmSYkuEWyHbywfkqxbmcPiKDZQBfWH5pt CDmiszt94/ad9TiA3n7JI1N74fZw2gqzvmTpSErA9AX3NPMSIZXyctl6nJXlHxZUbqs2 ls+g0z5EfgiOdekoGGsdpVmZq7/T1Ac0rrV/V4fBWfmx8GaOl5z5Li+BVBZhubEql55T ppmNzHT8vqKfPhArtyGGhw9dhoRL4mx+qmVM4xxGWY52tlKucg0TB0sYwVAQjQpRKG/T 7XAA== X-Gm-Message-State: AOUpUlFORo4uN6d1ljVab0mm7gaBsYifBBJrQGRIkh/n9g+7p+g8lyxV Lc8RYNOcoYkqtoUh4Oa/BSlyC34IA7rOgoNroLGpejLu1sbzDaT7YTapN+DKCOCcYptZcC1168S Ee9c/wWAxuuQcCOHSmavWFwzRWxoLAzYCsPVql37zVy1EE1N7ZTjArgiJbKpak1YIdoUmQQiEg9 ShxxkQA0474nLUcMEW8/Jr7ypIIB0WOk9AQJYO59tiEvc49+P+ldjZ7I5W9X551e9e/R3ZzG7RM Be7I7tIFcKHXHEweNDfH04pXDBGxVG6I+r1f/Rhw4BFTc145p3SWkqAuurxONxBIPGJXaoGVyWz 2zBPW8x1nkQ3gaUG1M5AyAHJ0ah0d9QziGYnBMJp2m/+kZEqgtzQ8JRRfIK68TGNh3YC2EXJ3Q= = X-Received: by 2002:ac8:720f:: with SMTP id a15-v6mr1506243qtp.243.1531835437614; Tue, 17 Jul 2018 06:50:37 -0700 (PDT) X-Received: by 2002:ac8:720f:: with SMTP id a15-v6mr1506211qtp.243.1531835437145; Tue, 17 Jul 2018 06:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531835437; cv=none; d=google.com; s=arc-20160816; b=mnprQLlgOs94h9AwqJZH/GjySzEMTbiBF6Z3oYGqMOUEbfXOy2ssLD1T3R/YGLxaNP zlZ8OrZiWo43Zv4xxEphY5K/XTo56753ZMGl5mf7X83EVMyx0lC50uo2JhuL8WCA6AMA AnBLwfbg5pktycW0GX5z5bOgpq+FsLkqc+X4NZCN/sfjdx2FpENohQLgmxz/QeQhSwSQ VMyV7I2OK9jFiVrRngmiQmiZqblVHfgqZ6ZM6pQc2EDWSy+zJsKbDhVU5h+TBWTKMzez BsMa0IvK+Ezw0umEL9jbrAX0CIn2zn2IPMCBDNvFfBCoIDqvs9CTN+AmKFVp7ygRcutr z/JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature:arc-authentication-results; bh=cb/n276Xxe2U8txtUJ8tHphmr2TB1hqLIHEdC9jJtzc=; b=v/M+iY1GhxEUnfHmArTjEXSjCf0xQ0RLOCyx3Z4PFsOyvdZmykQvDzwFMDbgBlYb6f 8+e2ZR/ApS0Rw/QWmpuvroC0v4eTlSmzGYf6cUfaicx9fuuqpP+0Y3+j1AIe9vtRujQr aXjG4TiIO0BejVJuNxQ20ch3xsNg/xmRA9p02lp/QvXJNhoTPaF9IAYCurUGBhXO+DFK WxXMaRVlizTI3urpjO21WkkUN1rxMbddyLEjIXJ9dNfI8PlTsAqHo2D2j0omTfDJd+cY +u8Gcz7cLTuuIpyWXuuU4m6KeVdOg2I7QpW1zxssBuBk1Vqq52jShZ79bZ3ihZ9YIWTG Kprw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cnjQzVcc; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t129-v6sor398007qkc.79.2018.07.17.06.50.37 for (Google Transport Security); Tue, 17 Jul 2018 06:50:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cnjQzVcc; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com 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=cb/n276Xxe2U8txtUJ8tHphmr2TB1hqLIHEdC9jJtzc=; b=cnjQzVccnZsI3MxcWqgv7wu8Gyw9XSWjFqpBT5cy6rE9mcaP3uVzRh706+Leq8hkAk Q4SqbnvgKqX8dKdn+ehW+q+F1JLircRshYGI9DNo8hmZ9rKWccZthDlHdMa7gc6kTlcD +FsBxuwTDo0nEi8EnHag24YcPr0irtVdro1kED/oagEq6RKi+LNnU04Rju6uskCuPyv8 CjvUb50LGp9MI9cymubyUPmui9FO4jlctp2scbda/BGMeR2USVpp9dUwLQ7074fqnfhm uzCRr7SlyYaWs7zetImG/X5LBiGLSdpJTNvle7YQrvEBUIN3kmYbA7a89kdY3gkwBnnI trvw== X-Google-Smtp-Source: AAOMgpfbt/T+9epouC5j+lm5WX16FKDuPtgJ38fd+LUHkNOdwYaV0KrFxaAds7J5w/qMucXlcdeiHA== X-Received: by 2002:a37:8346:: with SMTP id f67-v6mr1437903qkd.18.1531835436903; Tue, 17 Jul 2018 06:50:36 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id s83-v6sm640937qki.20.2018.07.17.06.50.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 06:50:36 -0700 (PDT) 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, mingo@redhat.com, dave.hansen@intel.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, linuxram@us.ibm.com, fweimer@redhat.com, msuchanek@suse.de, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v14 16/22] selftests/vm: fix an assertion in test_pkey_alloc_exhaust() Date: Tue, 17 Jul 2018 06:49:19 -0700 Message-Id: <1531835365-32387-17-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1531835365-32387-1-git-send-email-linuxram@us.ibm.com> References: <1531835365-32387-1-git-send-email-linuxram@us.ibm.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP The maximum number of keys that can be allocated has to take into consideration, that some keys are reserved by the architecture for specific purpose. Hence cannot be allocated. Fix the assertion in test_pkey_alloc_exhaust() cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index d27fa5e..67d841e 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1171,15 +1171,11 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) pkey_assert(i < NR_PKEYS*2); /* - * There are 16 pkeys supported in hardware. Three are - * allocated by the time we get here: - * 1. The default key (0) - * 2. One possibly consumed by an execute-only mapping. - * 3. One allocated by the test code and passed in via - * 'pkey' to this function. - * Ensure that we can allocate at least another 13 (16-3). + * There are NR_PKEYS pkeys supported in hardware. arch_reserved_keys() + * are reserved. And one key is allocated by the test code and passed + * in via 'pkey' to this function. */ - pkey_assert(i >= NR_PKEYS-3); + pkey_assert(i >= (NR_PKEYS-arch_reserved_keys()-1)); for (i = 0; i < nr_allocated_pkeys; i++) { err = sys_pkey_free(allocated_pkeys[i]);