Received: by 10.223.164.200 with SMTP id h8csp926540wrb; Mon, 6 Nov 2017 01:06:26 -0800 (PST) X-Google-Smtp-Source: ABhQp+SAxGXb4yIlcGiez/TwiLbXijXyrqoFFYWUnnAPCmhMEUrblCN8umi87Qv6CDka1Y6n/Ix7 X-Received: by 10.99.120.2 with SMTP id t2mr15049432pgc.333.1509959186603; Mon, 06 Nov 2017 01:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509959186; cv=none; d=google.com; s=arc-20160816; b=YVXu1fyiAg6r+4S8UEROr2l3JrJQZfR81fOeG1HvH0bub1c3DQdmpH0p7hadgjnjp0 c2vXTpFq9lkakSYPdXq6s+msIpAwQ20RXvUY5v6Mr2sx7gx5Xb/v7z+KghY4jmWVhTqv q5LP+2DneM/3P0Krlvglu+JRw94Xynke35QJYI/BVv2DkPl+QTCUj75CnZvMCeWs/bPq CcVsB8ilKfYhZyb2Yxlg7wAXk8q6RdasLoE+oNn0wlqvu/8fVlhEBtXxyJ5wkBXLi2UR 0V3TSNrqkqNKe2v018HHS6afOdzXYXJV7rp+KR3CPY0OmNiiF4pYbZWXCNWav5pzh9pz Xh5A== 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=k9eDL1BW93C+KXAL0pwEabbmMfxZEWMVxdL8oHjLfzw=; b=XDGfhX4fxtDcKiz5ASwhA6PdDy8TX//BwizB8OluAUQEFfhYGng6R9PUyHg0e5+YaI UAkbO/8WKzQmKPyZOTY8mdRWuqGi1OYHhas4gNmB9cZcNj8VHTLQgrw5BMRG15276r/D rHq73+78IuWOINiISwwOdhBWLySx3nXBfcObZ7MLTToNxgss1NYLrLRR7pwAWsl+/9Ee aAvczAISaeu1awNWIIYDI6BAull98Ym8U18NV7zvqBAUY4qwbSiQmZgx19bOGUUiDD/J 6VvyPcijNQl0g/Cy8b555uZEDkVHSmxQrswTLnNxz84VO0ZxiUDkCC03F+hBDecEHBM/ vrTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BXqBo8r4; 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 c30si10685711pgn.815.2017.11.06.01.06.13; Mon, 06 Nov 2017 01:06:26 -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=BXqBo8r4; 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 S1752658AbdKFJFd (ORCPT + 98 others); Mon, 6 Nov 2017 04:05:33 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:48107 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbdKFJA0 (ORCPT ); Mon, 6 Nov 2017 04:00:26 -0500 Received: by mail-qk0-f194.google.com with SMTP id m189so10028784qke.4; Mon, 06 Nov 2017 01:00:26 -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=k9eDL1BW93C+KXAL0pwEabbmMfxZEWMVxdL8oHjLfzw=; b=BXqBo8r4R/mF91SCN8DWWYgtxvn2v8RghmF/bqfacvAKExT3TkNk5cD+TOi/r8zzDk sWny8nQuon5ecS2hU2HzP9gR5UlB1PPVVmOadgRD8+8UWbO0SZ+aBY9LMWM85hw55Q/x UTFjjjak4zat42grq+gBpCy9djK70Fe/2RuqI+mIQeK8ZpBqO13hyhcvW+aiLAvKGtIb iHhaNb3+ixM108/mMGSF6y8LzX6z0A9yM8InqzyVPNyuWLDSZgSmxmdMeuk9p9lycP3V 5hfCc/dHouBG87dc8vedqCm5mYM+8xmfBy/8lFJ89y/a5o983TNIg67HNDy7uNJhMKEM onBA== 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=k9eDL1BW93C+KXAL0pwEabbmMfxZEWMVxdL8oHjLfzw=; b=s/1S3xScsphZVokaMyFyfo8SeFS3PqZI+FjpX4/ZV0M/Me1PwHQkDZ4o5+gdtL9PLf HMIBQIt6DURwli6iZU1ddV8wTfeFd007amP2KVd1rOiL6lUR5J8tyunLn5JjTR/QwDNM MI1gL3XxbOtGylXnrk+jrya8R68EQbmfniOJCph6F5Ln3n9W9IQCE16MhtDvkmcLktfU caJRKt4xJx0ctDuj7ey+WYKeqeXOH90AtBvyeLgRrJ7zoakx0J36GD2bmRwcLoXArjug 6Jif81vsCFFcSHLsz8A9RJgccvTuOhoYMBpt3ZBkbNRxMeg8eblf6kNV0+W7IxVrDA8P 2fqw== X-Gm-Message-State: AMCzsaVujm3GZkKkpbx8uQU0WXgrsR+w+RJOieI+UX/h7R07RqnPA4XK ve9c81URQM7Pfl16y79P1sk= X-Received: by 10.55.94.65 with SMTP id s62mr19938577qkb.282.1509958825551; Mon, 06 Nov 2017 01:00:25 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.01.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:25 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.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 Subject: [PATCH v9 45/51] selftest/vm: fix an assertion in test_pkey_alloc_exhaust() Date: Mon, 6 Nov 2017 00:57:37 -0800 Message-Id: <1509958663-18737-46-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-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 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() Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h | 14 ++++++++++++++ tools/testing/selftests/vm/protection_keys.c | 9 ++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/vm/pkey-helpers.h b/tools/testing/selftests/vm/pkey-helpers.h index f764d66..3ea3e06 100644 --- a/tools/testing/selftests/vm/pkey-helpers.h +++ b/tools/testing/selftests/vm/pkey-helpers.h @@ -388,4 +388,18 @@ static inline int get_start_key(void) #endif /* arch */ } +static inline int arch_reserved_keys(void) +{ +#if defined(__i386__) || defined(__x86_64__) /* arch */ + return NR_RESERVED_PKEYS; +#elif __powerpc64__ /* arch */ + if (sysconf(_SC_PAGESIZE) == 4096) + return NR_RESERVED_PKEYS_4K; + else + return NR_RESERVED_PKEYS_64K; +#else /* arch */ + NOT SUPPORTED +#endif /* arch */ +} + #endif /* _PKEYS_HELPER_H */ diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 4fe42cc..8f0dd94 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1166,12 +1166,11 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) pkey_assert(i < NR_PKEYS*2); /* - * There are 16 pkeys supported in hardware. One is taken - * up for the default (0) and another can be taken up by - * an execute-only mapping. Ensure that we can allocate - * at least 14 (16-2). + * There are NR_PKEYS pkeys supported in hardware. arch_reserved_keys() + * are reserved. One can be taken up by an execute-only mapping. + * Ensure that we can allocate at least the remaining. */ - pkey_assert(i >= NR_PKEYS-2); + pkey_assert(i >= (NR_PKEYS-arch_reserved_keys()-1)); for (i = 0; i < nr_allocated_pkeys; i++) { err = sys_pkey_free(allocated_pkeys[i]); -- 1.7.1 From 1583323091302696872@xxx Mon Nov 06 13:22:46 +0000 2017 X-GM-THRID: 1583323091302696872 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread