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: 10529489 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 EFFE9600F4 for ; Tue, 17 Jul 2018 13:50:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6DF628D8A for ; Tue, 17 Jul 2018 13:50:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB1BA29203; Tue, 17 Jul 2018 13:50:38 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74E0628D8A for ; Tue, 17 Jul 2018 13:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731429AbeGQOXX (ORCPT ); Tue, 17 Jul 2018 10:23:23 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:38368 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbeGQOXX (ORCPT ); Tue, 17 Jul 2018 10:23:23 -0400 Received: by mail-qk0-f196.google.com with SMTP id y4-v6so516437qka.5; Tue, 17 Jul 2018 06:50:37 -0700 (PDT) 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-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=cb/n276Xxe2U8txtUJ8tHphmr2TB1hqLIHEdC9jJtzc=; b=qC0WzWXGawy+MUA2o6FPmCsOdPwu655osJZMNDj3ByGA4JMmXLjClosejbgsGDfH6N RuWmIrjsI1tCmgkNuzdYyggSUeIAmkW54JiZtBqSBc182DN65INaXFM6hIdMNVdfwk+g lk6hi0n66cpghlCpR//IXkU9GR4t7ifbBzMz+H2QApaPAG3dEvNLivhWqQv5DhhDgghR OWrKkRQzLtFK9p1b4r+BlD/QUS+bq6mK7v8bsqD3viWmU/78y6+tQBDZ8iBNcmcowwOi r73EkorPinazsX2iBU5PBx+AvD8Hiu/kf7fyNUiFyT2cG76e/snrdZg3QTgzXrtJ5roX mzUw== X-Gm-Message-State: AOUpUlGcvvQRn4rmLJGa4hwXUQ1e1HzbZcCgiMUN/C5u6YqccowltkbX 4JiXd42zWy+T3YOZ8zKaWlI= 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> Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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]);