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: 10463109 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 67832600D0 for ; Thu, 14 Jun 2018 00:47:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57B7728988 for ; Thu, 14 Jun 2018 00:47:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AB3C28BA8; Thu, 14 Jun 2018 00:47:53 +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 D4B8428988 for ; Thu, 14 Jun 2018 00:47:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EAA96B0282; Wed, 13 Jun 2018 20:47:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 69AA96B0284; Wed, 13 Jun 2018 20:47:21 -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 562146B0285; Wed, 13 Jun 2018 20:47:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 2E8F96B0282 for ; Wed, 13 Jun 2018 20:47:21 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id k83-v6so3577617qkl.15 for ; Wed, 13 Jun 2018 17:47:21 -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=tUfxllLURYyxX326N8W78Rjw46owLWjVwnBQm7HyOxg=; b=GyDLgPQDyTbQ3ozpkU5kQHIcEWy/fa3quYxs1LdJ9LB5Yue4yz/jlweaHu105QM8v0 U/wSYXGncT9UkP9e6YTVvof/pDDlJE/cbIxyde2DJn3i66cFeAhRum684+q0aWh13rYi 5IvJWQcALxlpOXSYsLc5lgBlC8yxEJJ0ydAdXR8UFJdyTQsvB3sJetXsgMdnucrOd/3P +Yz+Sqsd8qJzQDq19KNek8+VMaBeKavcFMarEpvQ+Ud9VwauJoBGeB3qEl19ohzF2PBR 9E6K6MwUp2osp1JHeh0eq5qqfnJ7jZjrn9PBZS5g4DbgCEau/weKT7BY9U7BMSjYgDsn 4Vog== X-Gm-Message-State: APt69E2FmRC7LR2Z4huyo8n2gRSbfN5WQcMPp91ZuXZMv469TSCWc/Gl iYdFxn1gNO85p1O8DRiQsVhQ0MOfnShJ4tDpL1MXVC/Dm0Qrw0mbRkycwqQY10gULz53yvRKecb EWUhRFbpNVLu+hne1gy3oC4XQ2hBJu35fnZA2Kvn5esHe50w7bdvYtkSvVwG8iw3syjI/V/dluT WIT3/fkF33HHKYbFqaNvmtuMdzcRfRBF4xBN1pTp/UylCI9KZHuNJxXbRg6iCBreAgv/exiaVla 3uNlEklijYXKVqtGcULSeF9SC5VcDizl6cH6OCyW7dvVceCcErIRvfBnAfEu9SEkyLQ/gZBkC9q AnEm9mGMtEmkTtoOgulfeeigdx41pJPsKTB4kzalW4RpIUWL3mC5WBOB09dbua347NUI6GZRGw= = X-Received: by 2002:ac8:18b9:: with SMTP id s54-v6mr383521qtj.139.1528937240985; Wed, 13 Jun 2018 17:47:20 -0700 (PDT) X-Received: by 2002:ac8:18b9:: with SMTP id s54-v6mr383498qtj.139.1528937240474; Wed, 13 Jun 2018 17:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528937240; cv=none; d=google.com; s=arc-20160816; b=zoAZJE9U8IZX9EDmPi2JqvYq8XQaetpg0fEYY332SsXtu7FWc86cjXkRROEaEokvk9 AQumqu6KrrOKGFNNmfjFs/BfbpC/X5N15Xm0FTZPo4C3cIAL8YmlqdqX4G5hfN7sVQ9s d/ca4cQzKfboyRcsNxCFpjDiog5MQb8YQNjVg6immITg841w4SEJ6gr2Rj0XLTZGnLLC FgS72eXqyJda0UIRzx3hbq0FhalvjTbdkYcARHCzw3C6nFuz1+WyBI1dITfggBXN+6EA OkclZyTaE/sDXe3nb7VjRXaVCNlyeGiC/SCu3mNUDI1JFdN73bDi9+OJeeWwROGBA4Rn VA1g== 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=tUfxllLURYyxX326N8W78Rjw46owLWjVwnBQm7HyOxg=; b=u2XwwEII+Ow+WkDl94l8LnuJE/yQiUp0ChRfqhcAloM8OVkq4wYaBfhVrN/kSPhXc6 R2u7RneCTDcevlsmQOqjyZWONA+TSzPKu9r713xJiEppisklP8gH7ivGQxTMeqBL7EKv D73Oa/TnoO+0KkWYY9Rp2ke955OH9oFjXmEPAluPiWt1JDwleIzJjSg+lELTkNEbhd1x CwXiij62SxOPYyLjdhwETEci4UEup0v0f18U8UYV4VvYW/KxTLEXaGsgIAU+rQzA5fT6 MTzQ+3X4/AGk2BwHcAbyKOT5ZH52OCRVBgTu9NrJ/ufuKs7rYRw8koO8yEJV7t6CjVyJ IPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u3A3zkua; 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 o198-v6sor2076770qke.124.2018.06.13.17.47.20 for (Google Transport Security); Wed, 13 Jun 2018 17:47:20 -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=u3A3zkua; 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=tUfxllLURYyxX326N8W78Rjw46owLWjVwnBQm7HyOxg=; b=u3A3zkua/1eBmo0ofCzGXNbUd92jG64W+kPA5OkLJlrQY8MAl64OEg0EgmljVgBRUI IpYIHsvQbfASGql2lNWTup1Sbgs11Z57X4NdnYFp5WfKBr2WzXIhMifwzrcUoH/oEWC+ NuxfUpy/YuyzEZfc8pTRuXZCLLQWlAQ+EACvtVGxktXXIiqY2mF+RDh5Bo2xxcZ5Zfrw +3D1phcV4Hi0kZ7FIOfrkXHGF+ZtNfoMsrdCYko4fGwHwCosyAklnNlJaNlQ09PPqs+r A+miAUyRuQ1DeT6y0jXJ9FVpv3VNK9gqaaT7GhlA4F6/cve3GYJS0UxwzkxKIkdZO1bW eE3g== 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> 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 | 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]);