From patchwork Thu Dec 22 20:55:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13080323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D95AC4332F for ; Thu, 22 Dec 2022 20:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBEC5900003; Thu, 22 Dec 2022 15:55:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6F6E900002; Thu, 22 Dec 2022 15:55:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B36D7900003; Thu, 22 Dec 2022 15:55:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A080D900002 for ; Thu, 22 Dec 2022 15:55:22 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 752D81609F6 for ; Thu, 22 Dec 2022 20:55:22 +0000 (UTC) X-FDA: 80271147684.11.99A3A97 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id E8633120007 for ; Thu, 22 Dec 2022 20:55:20 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bTuxpvvw; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671742521; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=qcDRS9Sce9ANj40wLqgQKKpvrIhr1uJpBf+ytEcZupg=; b=yhj5ppus/sXhcSEUBboBLwap/Tz7oiZcSn2oFrcVbAZQ4hXpdXMKC+5NS0SIMMH50Xz7MN 2mYJH5ZSKiZYgljViCUgtZslw90AYOwa41Y+SF/73OSnoe3T2gojSfrdgpg/AvqZEdjJ7b F05U09uxifxXYjQKdCiEjUcD9P9pUqs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bTuxpvvw; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671742521; a=rsa-sha256; cv=none; b=k7wx29TcWm2dK4PK1Prt73Ah7Mnp1tut4ecsmuK6OpaRbMlYB40uIW2rxt1Xy5UPl+Ytq7 L0pExrjVWU1BgKrSPnzvcS0wHCuB76vsEeInDdIGk8QWIytMvQ6ScOgq7EkTyt0wFxIWCk qH+n4uEgx7c2T3SROX/xSll9edy6+jM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671742520; 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=bTuxpvvwldao8yndIJyLKxAdpc+MDsNKiTWcSe/AmYjjag6yjflBuOZL4z35kwwM86DdDH siYokV9jidhWbgk8hnvOwJ2JRX/RpFm3y97WTCKHu0kL+i87th7p6qlCSLbE7VgJAoSu+V zPfnU3W3hyCp00uofDqbcSiJliWG2e4= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E8633120007 X-Stat-Signature: qsy7a9yzcpbtmskx31ggxfyk6qda55qx X-HE-Tag: 1671742520-672487 X-HE-Meta: U2FsdGVkX1+HIG54EPTleY+FC5JEWphGOvBIcPuEFZIcw1lNTrG70PJ+ypZdHV6qpbsYeW5wj4E6p9TXBMRw0kYa8oLx49dwsxMB2TZGxTSGAqrEerhB3/+Pt+TJ1W3PI6mAWfvHaVxvTauJgwSJZoAcoL4lTA6yrmdBvQz0BGlTKjmqHTqsc2BppFA8Um9fvXfZIcQb8SD/JDwJFzfcj4NSGEH4pVbbDMq34ofrDqP+sq1NQWjjzZcyj9UdQV2KSAAEF2uFWJ/yvQeZ8UIpmHcqOQkRLd2PsL/0BUOnJY8vh3p3dB5aXB3ZvtOk+VWESFBvWj4IhY3FYHN7QNnUjSc1KgM1YT1IoPtycJVw1VCDKYz2I/+5vyDKF9sxmR9LHIRihWHpwBZvwrhI/dv+VCRye0vyOeYatIqkAAJhngyG3nDKN5CoYmEAUGOms+Jy69qQX/MCtuLMHNB2f9Xqnp+OFlLQnNhydOD5kZHaIwOeCvLrHOK1rBbPre7DgswuUAEFOwQ4IxACkJ8LmWRFhkVMCNVb0fnluM2ZKnWHKcct9JDQMbfZVb2VBUy3dHuwE9GZchPP3MXL6acwi1PdFtELG9acSBdfWNpINCNwxYYv6oE8RE3qjX14xiseVVOycYx07ChI/klFMVQXjGu8GKUREeW+lQ+xgovYfwsIahaPu8upVMpeKZcXqTdpXG4jMD9hlhHg05uj8lhl4KY6JQNI4t68N5QaW0LITjmjNnLwaDN6C9FEHhvuVoQtTUqg74LrQ9JXZHTGvz90Yglzn3i+qrBbGx/REIs4xuEYNPFp4CFBPjDUp4SBs5eU7HuQHhtWvFWtbK9dXEUISoroTNtQB+4B+tPrFZWnbwE4P1hITkYEIrxJe8ZkDkq0c8MDQ+ELsKsiXrAYTHyS2F3sL4ZbdiRrpLvhcbrDxqVXJvC0nihwBlj5gvcnUMa4mTWKlsnIY4o45itDgaZF0Ya z0g== 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: 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(-) Reviewed-by: Peter Xu