Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp308116rwb; Fri, 4 Aug 2023 13:05:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUgc3xBV44KABJDeGruldpESl2gkY4BcoPNYXQewigihQqF/B0ibaa7Bhx2Zs5DA2K0AA3 X-Received: by 2002:a05:6402:754:b0:522:806b:8f4a with SMTP id p20-20020a056402075400b00522806b8f4amr2221157edy.32.1691179556172; Fri, 04 Aug 2023 13:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691179556; cv=none; d=google.com; s=arc-20160816; b=KJMHOgllIfbZqsmxInXyByOfetk34EG5Y8KXIxcMePvh3iAvLRlL2M48I8cJ7Wkp7w VNlpyAu3vF+3d1BcNtYROZGX/fgnzAiWNcw/ROmS2VJjX1rHnyI57yLvxeTFk6DcyfS7 sw12kHe3thqLyjJnCIsUdNlFf3trRi8DzX+UdLlWJQN3+CwWcbP9hSd0IHXDNELEJ/Qp VvJQZh+fJhfcXUYs4LJnUtsqBWk6bjpo2kVv1U4hBemBacj20PqaPxg1TRfojmsSdthw oYhmOjn4HLq8oZmqWXTjg3NnZCBtkDUoXNMUqKqx52vt53XG16v+lXXFVWeAtmwxs65C qtaA== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=plknfH3SDQ/AujyL8eWFqeOy7h7VD7A1dUfZFnOOKDM=; fh=JSI3mfTnp8KhR5p/oUIQdNCmFnB4xf0pPWAN5y+zaY8=; b=jkdVPQ8SnUk08JgzQMKKlG2ixWzknegSxGFcsxmcXGYnGu1mUqvOlx+u09u6KNNEVS FyoEkuuDHDBPhz+lWfVPSyMrUoVZQmaJBdJOYnRfdiZyL/AT27HghsThp4CT7FHGEMH2 WBYOdwGDAoDRVWW+HZqrBB2mr1GWaiDsSx2Enp2+V2E7V6mIsQcZSU1o3k8cApRdhumP qfc7/P9pQFWBmcUgtTlx+sK93xVzp7pxDhJ8nu9hkSBIcVaYtiqoxlemCOXs53JYjBU0 7OWJXA3L+BMLnCNvVFUbxs0LzAEr6JCSuui9ZFN2qX3xOHmw4Y16EJzdf7hhHrqHxNQh pIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BbimRuwN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a056402074500b0052275246241si1955450edy.189.2023.08.04.13.05.28; Fri, 04 Aug 2023 13:05:56 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BbimRuwN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjHDSBY (ORCPT + 99 others); Fri, 4 Aug 2023 14:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjHDSBV (ORCPT ); Fri, 4 Aug 2023 14:01:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B01546A8 for ; Fri, 4 Aug 2023 11:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691172034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=plknfH3SDQ/AujyL8eWFqeOy7h7VD7A1dUfZFnOOKDM=; b=BbimRuwNeLcqubjf0P0fbZemwkJ/NWqiM3ZiVKsJwsug3oTlOFgHNXY2gbYXArmCqnFED/ LvZXeAGLDMd5S7Ss1qB20C8QjvUWHu+0bT9+NSm+Fgju3akmuG7mk0i3ZRJeG6Jl6a1aqo KPRiYcEDr65oOQKm1dGuTJdJbcaMn6Y= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-zD1dSulTMcKEwRfLJPGtMA-1; Fri, 04 Aug 2023 14:00:29 -0400 X-MC-Unique: zD1dSulTMcKEwRfLJPGtMA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3176c4de5bbso1189051f8f.0 for ; Fri, 04 Aug 2023 11:00:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691172028; x=1691776828; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=plknfH3SDQ/AujyL8eWFqeOy7h7VD7A1dUfZFnOOKDM=; b=lp73QBeqlF7ZtrhKy66xxyMDVXhjvIfmukCKeFASeQ3V5FXCuBNILk2df7HAac89Bm y5t5aZqbVidZPqnZx7oTz+OkFArDlZcpnO3aTU0kx84BSxKEQBsaVYhD0XRYDqFHzEUB 0YhHE/Bl4kRGp+nic1BaQVO3M+nBVD8K9tanMy2CmTwxm26dwPpBaQdt4f3b6HGY7O7R mkUOA5RPMjhikDjsYTdZUQfUHyt42LWlKAjXvd5+WiI2IfZY966QGKYDDObRl3DXiZPx rwoy9tFYJBNhactF4o1ngZ9+rjFarro0O6j2sq5SvaW7hycYI9goEPy7h9SdYAZyEusf uFCg== X-Gm-Message-State: AOJu0YxcNd3uexpEc9KjuPafsbiBwgOjD2JeAaQ8zSFnz8G7RYDAvWYs V0EpRiSiat5gvxxpxJ3o0QPNePnDlo9BSpwb7RezXIQnyabPmbaDUE5T4jucbH1Ub5dthuJ16nm h1Z7weAlGo3rnHAWlAAtUqKWJ X-Received: by 2002:adf:e90b:0:b0:314:49e4:b0c4 with SMTP id f11-20020adfe90b000000b0031449e4b0c4mr1906972wrm.70.1691172028376; Fri, 04 Aug 2023 11:00:28 -0700 (PDT) X-Received: by 2002:adf:e90b:0:b0:314:49e4:b0c4 with SMTP id f11-20020adfe90b000000b0031449e4b0c4mr1906951wrm.70.1691172027948; Fri, 04 Aug 2023 11:00:27 -0700 (PDT) Received: from ?IPV6:2003:d8:2f2d:8e00:a20e:59bc:3c13:4806? (p200300d82f2d8e00a20e59bc3c134806.dip0.t-ipconnect.de. [2003:d8:2f2d:8e00:a20e:59bc:3c13:4806]) by smtp.gmail.com with ESMTPSA id m15-20020a056000008f00b0031417b0d338sm3082057wrx.87.2023.08.04.11.00.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Aug 2023 11:00:27 -0700 (PDT) Message-ID: Date: Fri, 4 Aug 2023 20:00:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 7/7] selftest/mm: ksm_functional_tests: Add PROT_NONE test Content-Language: en-US To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrew Morton , Linus Torvalds , liubo , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard , Mel Gorman , Shuah Khan , Paolo Bonzini References: <20230803143208.383663-1-david@redhat.com> <20230803143208.383663-8-david@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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 03.08.23 21:06, Peter Xu wrote: > On Thu, Aug 03, 2023 at 04:32:08PM +0200, David Hildenbrand wrote: >> Let's test whether merging and unmerging in PROT_NONE areas works as >> expected. >> >> Pass a page protection to mmap_and_merge_range(), which will trigger >> an mprotect() after writing to the pages, but before enabling merging. >> >> Make sure that unsharing works as expected, by performing a ptrace write >> (using /proc/self/mem) and by setting MADV_UNMERGEABLE. >> >> Note that this implicitly tests that ptrace writes in an inaccessible >> (PROT_NONE) mapping work as expected. >> >> Signed-off-by: David Hildenbrand > > [...] > >> +static void test_prot_none(void) >> +{ >> + const unsigned int size = 2 * MiB; >> + char *map; >> + int i; >> + >> + ksft_print_msg("[RUN] %s\n", __func__); >> + >> + map = mmap_and_merge_range(0x11, size, PROT_NONE, false); >> + if (map == MAP_FAILED) >> + goto unmap; >> + >> + /* Store a unique value in each page on one half using ptrace */ >> + for (i = 0; i < size / 2; i += pagesize) { >> + lseek(mem_fd, (uintptr_t) map + i, SEEK_SET); >> + if (write(mem_fd, &i, sizeof(size)) != sizeof(size)) { > > sizeof(i)? May not matter a huge lot, though.. Oh, indeed, thanks! > >> + ksft_test_result_fail("ptrace write failed\n"); >> + goto unmap; >> + } >> + } > > Acked-by: Peter Xu > Thanks! -- Cheers, David / dhildenb