Received: by 10.223.185.116 with SMTP id b49csp5730767wrg; Tue, 27 Feb 2018 20:05:29 -0800 (PST) X-Google-Smtp-Source: AH8x224ps6uY4uipwbtgBelhgpJYaBTLBY3gt3yzKlGC1Q7VqEOIPwwqpdv6k+EUxkOItEKSNrDB X-Received: by 10.101.83.194 with SMTP id z2mr13115298pgr.133.1519790729620; Tue, 27 Feb 2018 20:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519790729; cv=none; d=google.com; s=arc-20160816; b=AoQeJH9rsz9dDSqMUdt/w5sg7w366jP6DrZNzsOtMl0rtH8XPpDphynV8gfK8Yn8Be PKdlDVkBi/9uGX0v+uJaPlNSrdGD+ptzJ1f55lmUBwl1HMvl93A3RUe3jijuFoLVzjGJ UkaC2IOjQHirojusDryArf2bZP/kMiOMhR6/v9SSDvcibcrXeznw9F+hjunybfEHvQoh df/1tt9IlWJUneAO1sp4rwJwz3V8IxRdGzFA7/L5TYI5HMIsSJdrVWd2zTbskkM/TAeg sWATTDVJuchGN2kHP9RHnNcWEnJqAxyU5pIjSRJLz4WBWHUh5aD2OEWTlf9h/4tlME+E oWeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zKyNhhXVkUpgrOcU3Ns7Sm+UVEcs/Bekl69Nivvr4Pw=; b=1IcIcYcL/VvS7xpuJuL6DHTM9eKu0WTGnCPtI2uHm8z01sMaQ0yGlW+3uJDrpGghkV eDdykSpmgYmtANztmWLc94X5aTlBIQVPsYCqYVcvZkJ6MHcVY8VSA1CO6W3Fnaiw22QB YsTQGBN6H4tj6w9B3suWVjnYABrGtL1ETFbWP1tRzUb9UKCJOD1d/80mCehsIjob7EHY 0+FIVPz/aB+j1CSongUGQsZ+J1v2cRhJAorr3TlyR7beL6ZU0fB48jo+/CrIDWl4xkHl EloNF+QakE5enMH6AwqiXNlRJaNbnSXJzzC+eYNaYF/7TKafjDrhz3/siAQVfaXrZGhA mFhw== ARC-Authentication-Results: i=1; mx.google.com; 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 k5si449639pgp.751.2018.02.27.20.05.14; Tue, 27 Feb 2018 20:05:29 -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; 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 S1752192AbeB1D6y (ORCPT + 99 others); Tue, 27 Feb 2018 22:58:54 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56716 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752172AbeB1D6v (ORCPT ); Tue, 27 Feb 2018 22:58:51 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1S3t7W4084548 for ; Tue, 27 Feb 2018 22:58:50 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gdfyk9anx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Feb 2018 22:58:50 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Feb 2018 20:58:49 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Feb 2018 20:58:46 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1S3wkV213041972; Tue, 27 Feb 2018 20:58:46 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37A65C6043; Tue, 27 Feb 2018 20:58:46 -0700 (MST) Received: from skywalker.ibmmodules.com (unknown [9.85.71.165]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 0861EC603C; Tue, 27 Feb 2018 20:58:43 -0700 (MST) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, "Kirill A . Shutemov" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH] selftests/vm: Update max va test to check for high address return. Date: Wed, 28 Feb 2018 09:28:30 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18022803-0028-0000-0000-0000093C014A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008601; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00996132; UDB=6.00506390; IPR=6.00775455; MB=3.00019771; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-28 03:58:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022803-0029-0000-0000-000039C6EC3C Message-Id: <20180228035830.10089-1-aneesh.kumar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-28_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802280045 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mmap(-1,..) is expected to search from max supported VA top down. It should find an address above ADDR_SWITCH_HINT. Explicitly check for this. Also derefer the address even if we failed the addr check. Signed-off-by: Aneesh Kumar K.V --- tools/testing/selftests/vm/va_128TBswitch.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/vm/va_128TBswitch.c b/tools/testing/selftests/vm/va_128TBswitch.c index e7fe734c374f..f68fa4bd8179 100644 --- a/tools/testing/selftests/vm/va_128TBswitch.c +++ b/tools/testing/selftests/vm/va_128TBswitch.c @@ -44,6 +44,7 @@ struct testcase { unsigned long flags; const char *msg; unsigned int low_addr_required:1; + unsigned int high_addr_required:1; unsigned int keep_mapped:1; }; @@ -108,6 +109,7 @@ static struct testcase testcases[] = { .flags = MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(HIGH_ADDR)", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = HIGH_ADDR, @@ -115,12 +117,14 @@ static struct testcase testcases[] = { .flags = MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(HIGH_ADDR) again", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = HIGH_ADDR, .size = 2 * PAGE_SIZE, .flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, .msg = "mmap(HIGH_ADDR, MAP_FIXED)", + .high_addr_required = 1, }, { .addr = (void *) -1, @@ -128,12 +132,14 @@ static struct testcase testcases[] = { .flags = MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(-1)", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = (void *) -1, .size = 2 * PAGE_SIZE, .flags = MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(-1) again", + .high_addr_required = 1, }, { .addr = ((void *)(ADDR_SWITCH_HINT - PAGE_SIZE)), @@ -193,6 +199,7 @@ static struct testcase hugetlb_testcases[] = { .flags = MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(HIGH_ADDR, MAP_HUGETLB)", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = HIGH_ADDR, @@ -200,12 +207,14 @@ static struct testcase hugetlb_testcases[] = { .flags = MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(HIGH_ADDR, MAP_HUGETLB) again", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = HIGH_ADDR, .size = HUGETLB_SIZE, .flags = MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, .msg = "mmap(HIGH_ADDR, MAP_FIXED | MAP_HUGETLB)", + .high_addr_required = 1, }, { .addr = (void *) -1, @@ -213,12 +222,14 @@ static struct testcase hugetlb_testcases[] = { .flags = MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(-1, MAP_HUGETLB)", .keep_mapped = 1, + .high_addr_required = 1, }, { .addr = (void *) -1, .size = HUGETLB_SIZE, .flags = MAP_HUGETLB | MAP_PRIVATE | MAP_ANONYMOUS, .msg = "mmap(-1, MAP_HUGETLB) again", + .high_addr_required = 1, }, { .addr = (void *)(ADDR_SWITCH_HINT - PAGE_SIZE), @@ -257,14 +268,16 @@ static int run_test(struct testcase *test, int count) if (t->low_addr_required && p >= (void *)(ADDR_SWITCH_HINT)) { printf("FAILED\n"); ret = 1; - } else { - /* - * Do a dereference of the address returned so that we catch - * bugs in page fault handling - */ - memset(p, 0, t->size); + } else if (t->high_addr_required && p < (void *)(ADDR_SWITCH_HINT)) { + printf("FAILED\n"); + ret = 1; + } else printf("OK\n"); - } + /* + * Do a dereference of the address returned so that we catch + * bugs in page fault handling + */ + memset(p, 0, t->size); if (!t->keep_mapped) munmap(p, t->size); } -- 2.14.3