From patchwork Thu Jun 14 00:45:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10463079 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 D69C2603EE for ; Thu, 14 Jun 2018 00:47:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C88DF28988 for ; Thu, 14 Jun 2018 00:47:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCACE28BA8; Thu, 14 Jun 2018 00:47:23 +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 68B2E28988 for ; Thu, 14 Jun 2018 00:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936046AbeFNArX (ORCPT ); Wed, 13 Jun 2018 20:47:23 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34618 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936027AbeFNArU (ORCPT ); Wed, 13 Jun 2018 20:47:20 -0400 Received: by mail-qk0-f194.google.com with SMTP id q70-v6so2713069qke.1; Wed, 13 Jun 2018 17:47:20 -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=tUfxllLURYyxX326N8W78Rjw46owLWjVwnBQm7HyOxg=; b=u3A3zkua/1eBmo0ofCzGXNbUd92jG64W+kPA5OkLJlrQY8MAl64OEg0EgmljVgBRUI IpYIHsvQbfASGql2lNWTup1Sbgs11Z57X4NdnYFp5WfKBr2WzXIhMifwzrcUoH/oEWC+ NuxfUpy/YuyzEZfc8pTRuXZCLLQWlAQ+EACvtVGxktXXIiqY2mF+RDh5Bo2xxcZ5Zfrw +3D1phcV4Hi0kZ7FIOfrkXHGF+ZtNfoMsrdCYko4fGwHwCosyAklnNlJaNlQ09PPqs+r A+miAUyRuQ1DeT6y0jXJ9FVpv3VNK9gqaaT7GhlA4F6/cve3GYJS0UxwzkxKIkdZO1bW eE3g== 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=tUfxllLURYyxX326N8W78Rjw46owLWjVwnBQm7HyOxg=; b=JdrNroyieR8qzalsf9C4IL+YrhxcBdH/hH+La822u/pTSybiV/UJoNYaUfnwoAg0e0 MaG5tTpYCwb6PCWtyL6Hv78enpW+7IG989OSN4eaoOg6beq7zw51nktEWqDGIyjR1+WW IfI/4Tw++xnZBps6KeOLzKIma1AiCsgmtl2jnxymLmstec3DYc1YQRFmvZjTUUV0t7Yc fFUP2s5tUxkbKcJPvdPiOLgLIWfSg9s02HwKG6DB3K0RPVo4anzujmPJK127QVdD1S56 kiZYCWBjXCkkOM8CpbOpc35hKQ1rj93rmOmnoAFwYHDNEV6iLLH1EGuya5chLxM648Rj EDgQ== X-Gm-Message-State: APt69E3HAlHj+b0CuK51zC44CUH4kNK1T7EGT5UGGNV2sUopWXiyfHIK IR0Tm69WyCfOJlHNB6NXQqE= X-Google-Smtp-Source: ADUXVKLlJLtdLsTVXkqhsp8CMX6B/L600rnkiYnMchKfZaFtWIO9KDvRY2OH9eW88olhLugjp2psBQ== X-Received: by 2002:a37:1193:: with SMTP id 19-v6mr341543qkr.379.1528937240286; Wed, 13 Jun 2018 17:47:20 -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 u31-v6sm3225898qtc.28.2018.06.13.17.47.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:19 -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 v13 18/24] selftests/vm: fix an assertion in test_pkey_alloc_exhaust() Date: Wed, 13 Jun 2018 17:45:09 -0700 Message-Id: <1528937115-10132-19-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> References: <1528937115-10132-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 | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index cb81a47..e8ad970 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1175,15 +1175,12 @@ 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. One of which is the default key(0). One can be taken + * up by an execute-only mapping. + * Ensure that we can allocate at least the remaining. */ - 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]);