Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2680161rwo; Thu, 3 Aug 2023 13:11:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBBJfw0a4kqmVGExoxeOzauTNXitPqSVcmkIfhRJ/QT99cGfzpodNR2l7Y6nhPaZTkj322 X-Received: by 2002:a05:6a00:ac4:b0:679:bc89:e5b with SMTP id c4-20020a056a000ac400b00679bc890e5bmr21306157pfl.19.1691093462542; Thu, 03 Aug 2023 13:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691093462; cv=none; d=google.com; s=arc-20160816; b=DbWtQXpIYZvdIvRqIYTU3sdp9lSeJR/09GU+sb2BAOVVGXD/aaR1rT8asLRw/JfxAp MSmVvb5vm8Sp773Txh/eJCpZt+W1G8EfhgbXUK9W2jusqIHuandpkIgh9NddF6/yei9C avv/C35rSKrCtg3/6hvq9gvraoNbMVEgO9Zq+9VX20pkiZMM1EklvyjokDwIX0ZftyId I/4sGkD+wwdYyxtvR3GEXHZq++Ux1mZps/OoJvpNW0KoTFbkDud8l4w418I4I5W3hjDO FSAmJDg7Z/r6c0xHmwXvd8QhcL0N3pO+ywoGOIPhlMN4CdnpJXmu5k4umPRUC7r9tpd5 0okg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qFYzrSS5XNvQWAYfcj9a9H/bevzOTd1j3Mu4MDu2J6A=; fh=18wL8z9Vztckz2a1HBSq3wbMKHbPpRJ7lDSUxdgce5s=; b=D4lrb4fXIbGl0bj/8v35jymW8c4iMNEHine10PVzC47E67y18iROzbLsm4bMvc0Kbb 7WG4yKBTfwDEiL/rZ96KVbTuQCPLrDfHhC6YAn+0QUFbRJ6ZF3nHiR8i/GX1JeN/fzTw h1RNHCQkYI+/eUe6630phHGaLyLi3Yd6Y4vTaGpyScD9jb+GjWF+12yYiM0MYmwR6A7i aNecWDItgjlcxBfYgaPgpguj4L1t05DFjuVTlAJmQkz1LhPvmWf9frfg/uAH7HDpeq2W AQLsGUp+uv5qptSDiKZPhcCaZxYNPOSSwpHqQJeeJ8t1MIYlF6dtmRN570iWjxb27Wrm sNGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d13fCPqV; 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 h15-20020a056a00218f00b00686f6b403fesi497513pfi.214.2023.08.03.13.10.49; Thu, 03 Aug 2023 13:11:02 -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=d13fCPqV; 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 S230328AbjHCTHa (ORCPT + 99 others); Thu, 3 Aug 2023 15:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbjHCTH0 (ORCPT ); Thu, 3 Aug 2023 15:07:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3039330E9 for ; Thu, 3 Aug 2023 12:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691089604; 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: in-reply-to:in-reply-to:references:references; bh=qFYzrSS5XNvQWAYfcj9a9H/bevzOTd1j3Mu4MDu2J6A=; b=d13fCPqVh2nk/XVFtFdf7YguCY2/mlb3z6gwHycsr2mGnOgy7ndOH8IwUOohPEPrWn7C8T VtpNYbl8L7fvmBfB8mmi7c7m5SWqiaoRmZMKvFgPNQepTWQKm/daZeI1uhlSBF/ac5L1aJ EwlKhRT2D0aQ2HpRyh6XfdX5VTj6lb0= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-nrvNUVAYPxW-Kh5LNqAAlQ-1; Thu, 03 Aug 2023 15:06:43 -0400 X-MC-Unique: nrvNUVAYPxW-Kh5LNqAAlQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4059b5c3dd0so3062701cf.0 for ; Thu, 03 Aug 2023 12:06:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691089602; x=1691694402; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qFYzrSS5XNvQWAYfcj9a9H/bevzOTd1j3Mu4MDu2J6A=; b=hcJzQh9spMHc2Je7BrBrrUiBNmIVGYZHSHzXj7Qs8+F72LW0bR98Cs/Nbqp8iqyXb9 cCxPA22WPOKfq8oZ5lsxJlghdNKMEZBf9eI/0zJa9E6LQ6Uzs8ti1mAYYIMpje9NVMHl WUpkPGR0MOnlclExQck01/EVR6PkjKebv+vL5wL9PbFVuBoQaMrWEjXmdaVm9dQl985/ NskptaVUtImywmZQAAzRpBM59LNKs2Y5KPfswp0A3p7L8VqHUwuSTIuHdYT8LG4Tl6l4 R48yNKq7TESnqgprUovn3GOi0T3Yo9vx6b1WFukeIzLav/y2gip2orarzFEduDmyPUN1 QrkQ== X-Gm-Message-State: ABy/qLbU6A+dXZOrj5ZiOs0VFerHydukaWqE13BVBCtwLt6odKTpq7hE 5bTEoXeX5jmSg1qk42q7FSMQeIMqI+3k3OyP+FZnZctu9HuEGWJi+VTAXTIIl+DMAM7+6n8g19K TspRmVw4a+x2IRYCY5lK76VkB X-Received: by 2002:a05:622a:1828:b0:3f6:a8e2:127b with SMTP id t40-20020a05622a182800b003f6a8e2127bmr20616704qtc.5.1691089602283; Thu, 03 Aug 2023 12:06:42 -0700 (PDT) X-Received: by 2002:a05:622a:1828:b0:3f6:a8e2:127b with SMTP id t40-20020a05622a182800b003f6a8e2127bmr20616681qtc.5.1691089601995; Thu, 03 Aug 2023 12:06:41 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id oo13-20020a05620a530d00b007339c5114a9sm111503qkn.103.2023.08.03.12.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 12:06:41 -0700 (PDT) Date: Thu, 3 Aug 2023 15:06:40 -0400 From: Peter Xu To: David Hildenbrand 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 Subject: Re: [PATCH v3 7/7] selftest/mm: ksm_functional_tests: Add PROT_NONE test Message-ID: References: <20230803143208.383663-1-david@redhat.com> <20230803143208.383663-8-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230803143208.383663-8-david@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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.. > + ksft_test_result_fail("ptrace write failed\n"); > + goto unmap; > + } > + } Acked-by: Peter Xu -- Peter Xu