Received: by 10.223.185.116 with SMTP id b49csp5900345wrg; Wed, 28 Feb 2018 00:10:38 -0800 (PST) X-Google-Smtp-Source: AH8x226NoaqJ0x/2V1ED+LD5mr/buBo2RD2RyhEEcTgvl3U8OXK2j3VK2kjhNjl7yBt0NftmyWYm X-Received: by 2002:a17:902:64d7:: with SMTP id y23-v6mr17030179pli.258.1519805437878; Wed, 28 Feb 2018 00:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519805437; cv=none; d=google.com; s=arc-20160816; b=Vz+7kPRug0dcre9y+fCHDR0TfFhmmp/yroTeS0BxFMKYZ5RhzEm8y7Wc2dvhtMxao7 SgdHPw63bmUkpmhGuauDKQ9+UuUxFFPevHrIrAXOVyA3JpCiA0JXZh9GUOSy9h2O8HIo EkTmI079tY/pxmHlHGATh35Ry4kYdTWsSrUooNp11rlKw/REq58vYPb0R6zMpwCBQDgf 7L9HD22tcatuGKwgFYpqG1dK/9WREUV7BMLtbGVZO36sfpdEHlbU8XKqPmesrzgbv6Yq n+TvyONPEFaimUR8PC5PaJm5A2dEQNBkJe1wzG+dppIAzzE1WrT/Kw6GKWD0VtuzrcH5 c/Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:mime-version:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=UwQu14yBoV1v+zZubklOQXlE5X6pVLUIKQpB48CWLlQ=; b=gNEyA0b2yEN3b9PHPuWc8cesrzFzYOon5vjqwhTysMGfGjSFbM+1XlogYR0EOzs8PF 0GTEqhzEAfbORRDK9KonOVo3H8uIUbXPbWLchYaYWc8yRq9WjqUkYglKcGsk5hpynAkr 7drIqcinBSZo70EDfxW5yv0cqlhTJmLWnr+sfgIQjkbgfnq6kxH63Q63gEFITn+nrj1d AJj4SA3dHx0yyzVDjFRoSSaIJhkBvpjDop3sTiCWh6Vl2b5y3vwYnuNE06VdlRveJYub 6+Yv7kjX2hGGtsK/7OW6tA8sFiT0s8FA2EUA8F5umt2PMqxRNrIccudf+oT6kDr1qdXP 5fmA== 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 n59-v6si877392plb.690.2018.02.28.00.10.20; Wed, 28 Feb 2018 00:10:37 -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 S1752130AbeB1IIP (ORCPT + 99 others); Wed, 28 Feb 2018 03:08:15 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56388 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbeB1IIO (ORCPT ); Wed, 28 Feb 2018 03:08:14 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1S87AiO015248 for ; Wed, 28 Feb 2018 03:08:14 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gdqaek24e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 03:08:13 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Feb 2018 08:08:11 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 28 Feb 2018 08:08:08 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1S888rM44105818; Wed, 28 Feb 2018 08:08:08 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCAB6A4055; Wed, 28 Feb 2018 08:01:11 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 803C6A4053; Wed, 28 Feb 2018 08:01:10 +0000 (GMT) Received: from skywalker (unknown [9.85.71.165]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Wed, 28 Feb 2018 08:01:10 +0000 (GMT) Received: (nullmailer pid 22513 invoked by uid 1000); Wed, 28 Feb 2018 08:08:05 -0000 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 Subject: Re: [PATCH] selftests/vm: Update max va test to check for high address return. In-Reply-To: <20180228035830.10089-1-aneesh.kumar@linux.vnet.ibm.com> References: <20180228035830.10089-1-aneesh.kumar@linux.vnet.ibm.com> Date: Wed, 28 Feb 2018 13:38:05 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 18022808-0040-0000-0000-00000438B362 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022808-0041-0000-0000-000020DAE37A Message-Id: <87vaeha656.fsf@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=8 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802280096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Aneesh Kumar K.V" writes: > 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 One issue I noticed is how to make this conditional so that we can still run the test on x86 with 4 level page table? > --- > 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 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org