Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp690640rwj; Thu, 22 Dec 2022 13:21:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFw5M//9UbrdZgm3oF2K8J0kFGa6Bbta4OWMFPxMF5O+WAPf0mB8E0HaYbcFIDXtg8w9Cn X-Received: by 2002:a05:6402:2890:b0:47e:eaae:9a56 with SMTP id eg16-20020a056402289000b0047eeaae9a56mr4520882edb.5.1671744109031; Thu, 22 Dec 2022 13:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671744109; cv=none; d=google.com; s=arc-20160816; b=TMRBSmx4agLG7CnKr18q55ufuk+3Y0xT1gEAqMHHP8NRwqtudC3T6LEUK6BXjtZ5ts YFI6VG5FFG+AWYmZdOEuLJRYf+3TeUiFlxPkXwk7qK1Dk6cz5WWzthxrMkvDCUIm3W8+ E671MIZwpkC8d3dI0ADacmO4QSt27GOa9cU4VxgAbV/KfbaJiTmd3E3GfC4V8SA0DE75 3Icog2F73jDV/xlwcEJ+bgBuvd/66Rr9BOnyIv3tqLkmG/sRx4/b4mdGhuUAL22vIryM YqQu335WuK90pdCofE6RGxXL85gSR+fsJNNp4ko7Jc6IHsUDRhRrsQbqFO2QzUKBPNd0 ai2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qcDRS9Sce9ANj40wLqgQKKpvrIhr1uJpBf+ytEcZupg=; b=l57EUnowfVuPy3INhJZPXI0hyTMVv5bocAShiVo+yYEXW9RD6Md5Qmb69GHc3AEQPV /ufubzxbjUCWEtcPIKPoTSm6h7pFAL71JxVIZRTpRSvUpy86JukWfYlFh5i6kOTVRuaf aa99SbHgwpjMxWRDbGXCqGB6kjZqmkAKPCmNcj8vyV9LrGpl/4IJMPcaHz5zpmMVLk1A v+52LQ7aw2HpCxMzgrrV4eh47rWrCnMyme3pieGcSs9o1645b1VuKL1n9eBg7kL5l1vp dArzWY4J9sdIzW5f8LMO6XFgmbt/koxJ1uy/9AjM7pI5hAnPATV6ZfsCwzkF7qsXVRXS ozKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuO8X1SH; 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 fd16-20020a056402389000b0046ba3001425si1275948edb.60.2022.12.22.13.21.14; Thu, 22 Dec 2022 13:21:49 -0800 (PST) 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=IuO8X1SH; 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 S235370AbiLVU4K (ORCPT + 68 others); Thu, 22 Dec 2022 15:56:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235061AbiLVU4G (ORCPT ); Thu, 22 Dec 2022 15:56:06 -0500 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 DFDC41C916 for ; Thu, 22 Dec 2022 12:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671742518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qcDRS9Sce9ANj40wLqgQKKpvrIhr1uJpBf+ytEcZupg=; b=IuO8X1SHUxOcs/LckNhMnnTV9RhMYdaHxaxVA3ui2TE4CEPWg22QOexdCaWiaj3EUlC4dc zj7UBNryobFoaxKYCeSU938/ly0TjyyDwqJj11yqip1EpyHsIZKJD1rTG9xEv2ZsX+pfdc VRbFd8kgYN2UVPhDZT2wZES00k/Lir0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-zkxOB09qPE2IQI9M8lcv7Q-1; Thu, 22 Dec 2022 15:55:15 -0500 X-MC-Unique: zkxOB09qPE2IQI9M8lcv7Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08AAD87A383; Thu, 22 Dec 2022 20:55:15 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D45D340C2064; Thu, 22 Dec 2022 20:55:12 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Mike Kravetz , Peter Xu , Muchun Song , Miaohe Lin Subject: [PATCH v1 0/2] mm/hugetlb: uffd-wp fixes for hugetlb_change_protection() Date: Thu, 22 Dec 2022 21:55:09 +0100 Message-Id: <20221222205511.675832-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Playing with virtio-mem and background snapshots (using uffd-wp) on hugetlb in QEMU, I managed to trigger a VM_BUG_ON(). Looking into the details, hugetlb_change_protection() seems to not handle uffd-wp correctly in all cases. Patch #1 fixes my test case. I don't have reproducers for patch #2, as it requires running into migration entries. I did not yet check in detail yet if !hugetlb code requires similar care. Cc: Andrew Morton Cc: Mike Kravetz Cc: Peter Xu Cc: Muchun Song Cc: Miaohe Lin David Hildenbrand (2): mm/hugetlb: fix PTE marker handling in hugetlb_change_protection() mm/hugetlb: fix uffd-wp handling for migration entries in hugetlb_change_protection() mm/hugetlb.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) -- 2.38.1