From patchwork Thu Jun 14 00:45:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 929176 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415m6K0nf4z9s01 for ; Thu, 14 Jun 2018 11:21:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OjyGJpQp"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 415m6J6NDRzDrq8 for ; Thu, 14 Jun 2018 11:21:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OjyGJpQp"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::243; helo=mail-qt0-x243.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OjyGJpQp"; dkim-atps=neutral Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 415lM24spfzDrq8 for ; Thu, 14 Jun 2018 10:47:10 +1000 (AEST) Received: by mail-qt0-x243.google.com with SMTP id o9-v6so4285189qtp.3 for ; Wed, 13 Jun 2018 17:47:10 -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=OC8b4rVjUTd56ZG7512Qe86UyCO/IKIIUH/nVlsH5m8=; b=OjyGJpQpd/w/NtTdmhPK6ul8FaHd6ubKGmSu5ntbB0bF14CG/VfjSQh60B6IlFVU5N jXXiTrjZtbPmUeN4T3wcHHzbR/+cKVSEsoF9Mg1kr/JmE4oU8HCbq6PSCBvhIBXNLid5 KfJ6OnSW5TYj9DLtaodY4yl1M20GV5gaigWNQ+WSNdNwdepcq6n1FBK+jtpPKBWXUUQt JLV1KrN1G+zudk4RCteEqEiWAkT1M9QFPlB7f4n5SuF/O3LscSY696+KOdvx0fXIDK/I vBg+pfpIRo6vdAqjM54UEJkGEfyeljAPYWrg3HOrZWsjK3LJG4pwaHmeJXs+hfhRDHkN JtDg== 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=OC8b4rVjUTd56ZG7512Qe86UyCO/IKIIUH/nVlsH5m8=; b=ZzDTSS4rgR0L0pq0D8WSlKkWsps2zdKpFCm+GVlzcuHedJKHY1QlcrMILIQRG/EVG2 yJcJe37MW8efod0CdANsdMw55FIV+Z140+RvCjA8XPY7CjQjraZ7y3Nwd4wNMp1ov3CK 9T0BHthz8jjdEFLN2cW9z/gvKrJxi7YHTyoudDW3zabQ1T0LyGB+IxTg4mHBPqUNlqPh g8jZBT8waMRLRAbDIGPn/u9YKFY8FzwTNxGo2x0gZAc3yegcUtugg76sVo0WwyDTo44h aazxGP5fTAwkwaUPnXcl5qgt2VZEktix4KYW7md9hEn31Y5+hv3pZO1iZTIzqHKoeN5V 32ag== X-Gm-Message-State: APt69E2CPYYDL3rSIxjgZWKMHXrrOFMkVHYn2ojK8DMyeAapLTu6VGue 02+Iwcov8kRiIxBxsxrxqFVKcw== X-Google-Smtp-Source: ADUXVKL9mqM3ZMW1aUzGiKT7A6cMzvIUphySS+jsy5UM9OBYmR5WQZtCDoEOYuGWDP+jzoSa6VRRmQ== X-Received: by 2002:ac8:16b3:: with SMTP id r48-v6mr358531qtj.273.1528937228597; Wed, 13 Jun 2018 17:47:08 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:08 -0700 (PDT) From: Ram Pai To: shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Subject: [PATCH v13 12/24] selftests/vm: introduce two arch independent abstraction Date: Wed, 13 Jun 2018 17:45:03 -0700 Message-Id: <1528937115-10132-13-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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, fweimer@redhat.com, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, mhocko@kernel.org, linux-mm@kvack.org, mingo@redhat.com, aneesh.kumar@linux.vnet.ibm.com, bauerman@linux.vnet.ibm.com, msuchanek@suse.de, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" open_hugepage_file() <- opens the huge page file get_start_key() <-- provides the first non-reserved key. cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann Reviewed-by: Dave Hansen --- tools/testing/selftests/vm/pkey-helpers.h | 10 ++++++++++ tools/testing/selftests/vm/pkey-x86.h | 1 + tools/testing/selftests/vm/protection_keys.c | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/pkey-helpers.h b/tools/testing/selftests/vm/pkey-helpers.h index ada0146..52a1152 100644 --- a/tools/testing/selftests/vm/pkey-helpers.h +++ b/tools/testing/selftests/vm/pkey-helpers.h @@ -179,4 +179,14 @@ static inline void __pkey_write_allow(int pkey, int do_allow_write) #define __stringify_1(x...) #x #define __stringify(x...) __stringify_1(x) +static inline int open_hugepage_file(int flag) +{ + return open(HUGEPAGE_FILE, flag); +} + +static inline int get_start_key(void) +{ + return 1; +} + #endif /* _PKEYS_HELPER_H */ diff --git a/tools/testing/selftests/vm/pkey-x86.h b/tools/testing/selftests/vm/pkey-x86.h index 2b3780d..d5fa299 100644 --- a/tools/testing/selftests/vm/pkey-x86.h +++ b/tools/testing/selftests/vm/pkey-x86.h @@ -48,6 +48,7 @@ #define MB (1<<20) #define pkey_reg_t u32 #define PKEY_REG_FMT "%016x" +#define HUGEPAGE_FILE "/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" static inline u32 pkey_bit_position(int pkey) { diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index c5f9776..9afe894 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -791,7 +791,7 @@ void setup_hugetlbfs(void) * Now go make sure that we got the pages and that they * are 2M pages. Someone might have made 1G the default. */ - fd = open("/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages", O_RDONLY); + fd = open_hugepage_file(O_RDONLY); if (fd < 0) { perror("opening sysfs 2M hugetlb config"); return; @@ -1078,10 +1078,10 @@ void test_kernel_gup_write_to_write_disabled_region(int *ptr, u16 pkey) void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) { int err; - int i; + int i = get_start_key(); /* Note: 0 is the default pkey, so don't mess with it */ - for (i = 1; i < NR_PKEYS; i++) { + for (; i < NR_PKEYS; i++) { if (pkey == i) continue;