Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp780978rwp; Thu, 13 Jul 2023 00:24:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFbfTeQ2H8EcHCkXwvN0xj9NPIaXMRm3rPBe6kNp517V2+8yf3VNl4FXZNYPwajUS8X7kR X-Received: by 2002:aa7:cfcd:0:b0:514:9929:1b01 with SMTP id r13-20020aa7cfcd000000b0051499291b01mr969875edy.8.1689233089057; Thu, 13 Jul 2023 00:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689233089; cv=none; d=google.com; s=arc-20160816; b=ywZxRwq+kWm+AC8IDGwVjQNM9hbiPWkHJkKNpxIfAY3k9NpvhfRg9KjIZpLg5Te1IO BoCHqZjLlzt9mIlUxbQu0+EU2+7zLXhBop9hrvj1EXDYvoj/EULN6KKvInEpHbU0Zrs3 0JY0QYiXIn8jFwA91Fw7ciCCvtOxfYNfnNLz+BNhMsM6J6p2CN2DyUGlLUgKsQN0Xco+ 23oWkdSc2T+P7jJfV6EK8bm3jw8x+IG41p/Jn6defXICacCZSUoP5zlqlkTrgdcIQl/1 vZp6iA1CglhibDPAkaMWowh3Dyikkwxaw6jzojRtdFcswG+nLAeNSn/EHPzSbNjGHgTR RO4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=wODkCk55kq4Sh7CHviS8BxVpkBeT2S4ed5XyidAno0E=; fh=xEqmviIeBxLoZqCO99/pP4CCIwV66y+Lp4aS9Z+iQbg=; b=NvsRQ9IxOi2EL90A8XG9YL3oho9l3MHlmJVNeJb5+1XgpFp2/qxXYxLx+PGW4Hu0sd UaEDE9VGrvW3xIdKufa3dsUCtPMtg6oLzGyPjGKEcCnkK8vcPJYhbC/yxOZET4C6a+k2 Nq7bCq2HjIdcLgAazpoMpXU4rlXPvw/N+wmtbznLP98zt2hXcM26+Q+qNB2H0zkMyWk0 N4QfU6KEeeVQrWVsShjfZMcjhvsI6bArLc4GN/zi6Iq2wR/Uij3CfHs2C8dNHb4qGeWh H75XTg9cjYOynu1J+fssRuLddfWFDQyVvNS7DmifxqOAYuzuXQMAFFshHRTB7IhW64qG CTsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020aa7c547000000b0051836749133si6813235edr.494.2023.07.13.00.24.25; Thu, 13 Jul 2023 00:24:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbjGMHOC (ORCPT + 99 others); Thu, 13 Jul 2023 03:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234134AbjGMHN5 (ORCPT ); Thu, 13 Jul 2023 03:13:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6A9B19BE for ; Thu, 13 Jul 2023 00:13:48 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E8CE612FC; Thu, 13 Jul 2023 00:14:30 -0700 (PDT) Received: from [10.57.78.6] (unknown [10.57.78.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 26E413F73F; Thu, 13 Jul 2023 00:13:46 -0700 (PDT) Message-ID: <7830cca8-068b-ce56-79fa-61dcb0c18bc2@arm.com> Date: Thu, 13 Jul 2023 08:13:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 2/5] kselftest: vm: Fix mdwe's mmap_FIXED test case To: Florent Revest , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, anshuman.khandual@arm.com, joey.gouly@arm.com, mhocko@suse.com, keescook@chromium.org, david@redhat.com, peterx@redhat.com, izbyshev@ispras.ru, broonie@kernel.org, szabolcs.nagy@arm.com, kpsingh@kernel.org, gthelen@google.com, toiwoton@gmail.com References: <20230704153630.1591122-1-revest@chromium.org> <20230704153630.1591122-3-revest@chromium.org> From: Ryan Roberts In-Reply-To: <20230704153630.1591122-3-revest@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/07/2023 16:36, Florent Revest wrote: > I checked with the original author, the mmap_FIXED test case wasn't > properly tested and fails. Currently, it maps two consecutive (non > overlapping) pages and expects the second mapping to be denied by MDWE > but these two pages have nothing to do with each other so MDWE is > actually out of the picture here. > > What the test actually intended to do was to remap a virtual address > using MAP_FIXED. However, this operation unmaps the existing mapping and > creates a new one so the va is backed by a new page and MDWE is again > out of the picture, all remappings should succeed. > > This patch keeps the test case to make it clear that this situation is > expected to work. > > Signed-off-by: Florent Revest > Reviewed-by: David Hildenbrand > Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute") I'm currently working to get all the mm selftests running (and ideally passing!) on arm64 and saw these same spurious failures. Thanks for the patch! Reviewed-by: Ryan Roberts Tested-by: Ryan Roberts > --- > tools/testing/selftests/mm/mdwe_test.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c > index d0954c657feb..91aa9c3099e7 100644 > --- a/tools/testing/selftests/mm/mdwe_test.c > +++ b/tools/testing/selftests/mm/mdwe_test.c > @@ -168,13 +168,10 @@ TEST_F(mdwe, mmap_FIXED) > self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0); > ASSERT_NE(self->p, MAP_FAILED); > > - p = mmap(self->p + self->size, self->size, PROT_READ | PROT_EXEC, > + /* MAP_FIXED unmaps the existing page before mapping which is allowed */ > + p = mmap(self->p, self->size, PROT_READ | PROT_EXEC, > self->flags | MAP_FIXED, 0, 0); > - if (variant->enabled) { > - EXPECT_EQ(p, MAP_FAILED); > - } else { > - EXPECT_EQ(p, self->p); > - } > + EXPECT_EQ(p, self->p); > } > > TEST_F(mdwe, arm64_BTI)