From patchwork Fri Jul 2 22:57:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12356777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4FEFC07E97 for ; Fri, 2 Jul 2021 22:57:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B08B61416 for ; Fri, 2 Jul 2021 22:57:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B08B61416 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 131EB6B0087; Fri, 2 Jul 2021 18:57:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 109238D0007; Fri, 2 Jul 2021 18:57:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F161A8D0005; Fri, 2 Jul 2021 18:57:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id C992F6B0087 for ; Fri, 2 Jul 2021 18:57:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6E468181BA3E1 for ; Fri, 2 Jul 2021 22:57:20 +0000 (UTC) X-FDA: 78319160640.30.0D7D551 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf13.hostedemail.com (Postfix) with ESMTP id 2C531100828E for ; Fri, 2 Jul 2021 22:57:20 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id 67-20020a2514460000b029053a9edba2a6so14971655ybu.7 for ; Fri, 02 Jul 2021 15:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Rhp3BKIpjKyJeRxRqWuyTX92X8tONQf5DKJFV9GgdPE=; b=jP6e9IO3/r9FhSoIPdfURhKoRHCxT5xQUApYE6/gUGXLM9a9PTNU03v1AG559/Oef1 qO+fMjuAi8sY6Xu2HRAFiWeqoQqEmrp20Mpwk2FgWTvkBVY7Uq998kduzXbHsgnR1MoG u4fYb8fR+Y5g6i7kRfqIGioY/zPUsFgjjhSgtC5EvnXeXK8WK66RpzdSez1lDSj6eruC 1KCLWTzA02yNr119sCJPBnRLG7YdIhIOCmwVLxoXVSVVV6acel8/KcfcDRICED+6h28b IrL3bMSyW/1GEeH5CiLHWZxMwtvg6zrRRpr415PD7D6gHoX/JblLaw66SGkJ03zU0CVx HXew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Rhp3BKIpjKyJeRxRqWuyTX92X8tONQf5DKJFV9GgdPE=; b=tLMKjbWtIUeEUV2fzda8TNSAFi5v30nHA0H3yRTCk3DiaJKcpt7AuQ4NfnixhCg0ZK qmNX7A2BAqW3Y1795aMcns1PXpKa7a1md/Vv+7XM3dcloXGBk+Ifel3kEqyWwdrrrTkv r4d95Y52KRT8RJL8o+wTZ+SRESm/Umd1HBxW0nPcsw8/Ztl0nRXehf2iFcScIW/xeIJY XBHv8WjZyMvGyIH5prnPBtjdwfwvzgiPssvgPGa+3wUzTxvE05N7z9Be+tSH2+AZ5b7U N4w399cd0KfBotS8OYZtGc+PiUNaTONKOEc6LSnj/w/CFtFuHw2h5yavXq9RxgLMHmHi x+pA== X-Gm-Message-State: AOAM530oexmkdrECJ7RimWkFYdvAOZKvzyUlIqfRDCqpqw5pcl4n1eZ4 XQjA94Ypt1d+4wdGqMbpK1I2Jec= X-Google-Smtp-Source: ABdhPJyIch8GVJL4w7nrHJMHGWxgT6FV0mQw9ZNNo6Ko0q38HKIAU5ZDqISC3Io0os18G3/Bc2grOV4= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:7c5b:5407:a2db:c8fb]) (user=pcc job=sendgmr) by 2002:a25:abf3:: with SMTP id v106mr2304897ybi.299.1625266639324; Fri, 02 Jul 2021 15:57:19 -0700 (PDT) Date: Fri, 2 Jul 2021 15:57:05 -0700 In-Reply-To: <20210702225705.2477947-1-pcc@google.com> Message-Id: <20210702225705.2477947-3-pcc@google.com> Mime-Version: 1.0 References: <20210702225705.2477947-1-pcc@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v3 2/2] selftest: use mmap instead of posix_memalign to allocate memory From: Peter Collingbourne To: Catalin Marinas , Vincenzo Frascino , Dave Martin , Will Deacon , Andrew Morton , Andrea Arcangeli Cc: Peter Collingbourne , Alistair Delva , Lokesh Gidra , William McVicker , Evgenii Stepanov , Mitch Phillips , Linux ARM , linux-mm@kvack.org, Andrey Konovalov , stable@vger.kernel.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2C531100828E Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=jP6e9IO3; spf=pass (imf13.hostedemail.com: domain of 3z5nfYAMKCI47uuy66y3w.u64305CF-442Dsu2.69y@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3z5nfYAMKCI47uuy66y3w.u64305CF-442Dsu2.69y@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 4qnous4kxn8fe88iduwpao9eewerjeho X-HE-Tag: 1625266640-107397 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This test passes pointers obtained from anon_allocate_area to the userfaultfd and mremap APIs. This causes a problem if the system allocator returns tagged pointers because with the tagged address ABI the kernel rejects tagged addresses passed to these APIs, which would end up causing the test to fail. To make this test compatible with such system allocators, stop using the system allocator to allocate memory in anon_allocate_area, and instead just use mmap. Co-developed-by: Lokesh Gidra Signed-off-by: Lokesh Gidra Signed-off-by: Peter Collingbourne Fixes: c47174fc362a ("userfaultfd: selftest") Cc: # 5.4 Link: https://linux-review.googlesource.com/id/Icac91064fcd923f77a83e8e133f8631c5b8fc241 --- tools/testing/selftests/vm/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index f5ab5e0312e7..d0f802053dfd 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -197,8 +197,10 @@ static int anon_release_pages(char *rel_area) static void anon_allocate_area(void **alloc_area) { - if (posix_memalign(alloc_area, page_size, nr_pages * page_size)) { - fprintf(stderr, "out of memory\n"); + *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (*alloc_area == MAP_FAILED) { + fprintf(stderr, "anon memory mmap failed\n"); *alloc_area = NULL; } }