Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6908082pxb; Wed, 17 Feb 2021 17:36:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZIlrQ64CtezqLjELn7G3q2UzaSClTWdFiOJLUAmCiroAuBi84wAyFcpi+FcQ7yQLGFfVR X-Received: by 2002:aa7:cac6:: with SMTP id l6mr1586653edt.357.1613612193273; Wed, 17 Feb 2021 17:36:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613612193; cv=pass; d=google.com; s=arc-20160816; b=MF66lkmcAb3k/zS4k/DWrGGYGI7FlpA+DGefIAQSBjlNOimSvqyU9WRGCgThE/JPME WXCV0hMUbKHp0QmI9GZ7RqJhOmnaDpIb59FEOLBKCV/vP9mz709BzWQzpmHBL3cfq1Rk psp1R6kcuAx45q1a676uVxMZPy/U2Sov7Ivw1ypD7UV3LXsU9VzdytGlId2swQ2Ad2ul mGrndV5oXT8J7j9XgCu3pllvSbPoI+4bMLSOrEl5/IlGTGK5s+VBInwLNciwd66RjtFL lKR6+oSzEB7pZ3Df38KW21gN7HJiGAowl8czdVv2vyTzhzC3vCOG722D9ae0WlUKiD6t Pi4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature:dkim-signature; bh=OVqA+PbaFmiyjxAVRNx+Uw6lKSpqd8E68DM9sL9ZS6Q=; b=JBQivuuywq4NryDcIId4BiUwH+U7f4BgC3jpcvPHyCvNDwAKwtzOwtSO77HvN6H0Sm rq32Zf/SecLcA8O52WYo2Z2owcMW/+gwTMAkfwTqa/2vYRIYuHk9IWS319iRjsXSLFoE D4upsLyGvLCoAS/ryerX11QmDDL+UKs07y2YirOxuI4UyCv5Fg6oFhaWB3Ga2GIrJM3v XFtaF83rPaZXo6+aQO0JznvluoXwT2plpMFKrXNKR2/2to3qn0CaRyDLe1a3NrS2p+b5 UKKmJbh/H/rLrJ8WOlbLpYEjzuLt1p4LzMNYA6RvIhJM+Yt+qMMoR4kvzHsFWjFk87AG e0Yg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=m8kqPqrr; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YFiyL1MA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si1328079ejz.721.2021.02.17.17.36.04; Wed, 17 Feb 2021 17:36:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=m8kqPqrr; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YFiyL1MA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbhBRBfI (ORCPT + 99 others); Wed, 17 Feb 2021 20:35:08 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:45954 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbhBRBfE (ORCPT ); Wed, 17 Feb 2021 20:35:04 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11I1Y9RK052475; Thu, 18 Feb 2021 01:34:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=OVqA+PbaFmiyjxAVRNx+Uw6lKSpqd8E68DM9sL9ZS6Q=; b=m8kqPqrrT/Y+J7sdraOxwaViL2SfQlt/kidSWC0x4hZov+OD1+eo2CcdfIyR/mH8FlED ekhQUqPwjFqMt7TeHWtnxpPf+9bIwf04OLhY6QzoASU6+QoV4Z+IqNMcgQpTmId2lcES VbNS/dKa55UjN9G3C/3tgxYkBz06nwvUVc0gPX5NnGmzPS7tXtTeJhfV9GXJVo9N9rae Xoqz3KXOk4w1vfUyGfB/zy+g/NYiEiqwJB/eaWecMJuwhRUi9wcRS8MR1/trKUYFUSL1 +zRQzwRKIv1ZhREl/ZD67P1bJLTKek6XYXzInABwf6oQfiP8FxjSHtYGtNEcFAP/T4+C cw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 36pd9abtw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Feb 2021 01:34:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11I1VdhK147489; Thu, 18 Feb 2021 01:34:08 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2052.outbound.protection.outlook.com [104.47.38.52]) by userp3020.oracle.com with ESMTP id 36prhtknuf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Feb 2021 01:34:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdC0Iyp8rLUT1LsV4xhRaU0lsqu8PpMmMtABEVVkCUQ1Q71oNi8qTErTWvtRSH2+RDfRCgdFGOfbrJTBi7VrfR6qkRchr3V/V1nOOJ7feNZINIzVaoh2iw0SqmD+ameaFc5dWYQcy0zIlmOcFapR+m8tgkCxrMNs0kFYk0jNZ0vKIApqKF9tm1TODICqQytadndruhv7jcTGVo7XjRGYUSWOCZBgukXlb5Ycovr7/OnFBrEzVv2h2ezSSrD9v9hqR97n5a/hCxvl5HkixYryR7SK9/aTEdLs/gJXoe7c6lYUKeuTauYZOtYOfanYU6trTeCpRcp8JU/NXDzgAGLIgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OVqA+PbaFmiyjxAVRNx+Uw6lKSpqd8E68DM9sL9ZS6Q=; b=Ae0JD4zw6rwa7S+5Z9vey+jqFXh+gaCNnZ+smblGXK9wwu7a36Kw8yA3iR2wMrn7VHc/c24+Wl3mgcDSdu4duZvtJq7CoHuQwG9iRCxd46muWiKti1IUg1e+1u59K523nquc4oO2fxa8U+dWSPPnIVSEZRByoYYz0f8DGbWwac7sNqCYKJUnHHibS1RbooKGD5gy7SgvZGyzAXhCDhs4KgnDWRleB+edAMb7YovN3yryPlqeNi3MSGiVMWMTQjBa5fwxKKKURSUbSrxGSCqXbyrTDacvVVGITGN63+uxxRNtXu+ULXbOhmKpclZzbjak/Xm9OIDjk4dT+LZQCCYW+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OVqA+PbaFmiyjxAVRNx+Uw6lKSpqd8E68DM9sL9ZS6Q=; b=YFiyL1MAD9oghA/C+nGjYSVGCdJDZ2uab4GIbdtXDBQNyac+LM+UMa6SlS98GcceFwwPbjk4aPQcIKaPj1+aYhIhfr1TysEzafqeV7SLPAGY9Od69quu+nKzgFTy0bakrkuH7irm4q2HYVOL8xwredxKi4afMUQkPjoxZ9W0v/I= Authentication-Results: linux-foundation.org; dkim=none (message not signed) header.d=none;linux-foundation.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by BYAPR10MB3496.namprd10.prod.outlook.com (2603:10b6:a03:125::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Thu, 18 Feb 2021 01:34:05 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::e035:c568:ac66:da00]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::e035:c568:ac66:da00%4]) with mapi id 15.20.3846.041; Thu, 18 Feb 2021 01:34:05 +0000 Subject: Re: [PATCH v2 2/4] hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled To: Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Rapoport , Andrea Arcangeli , Axel Rasmussen , Matthew Wilcox , "Kirill A . Shutemov" , Andrew Morton References: <20210217204418.54259-1-peterx@redhat.com> <20210217204619.54761-1-peterx@redhat.com> From: Mike Kravetz Message-ID: Date: Wed, 17 Feb 2021 17:34:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 In-Reply-To: <20210217204619.54761-1-peterx@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [50.38.35.18] X-ClientProxiedBy: MW2PR2101CA0030.namprd21.prod.outlook.com (2603:10b6:302:1::43) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.2.112] (50.38.35.18) by MW2PR2101CA0030.namprd21.prod.outlook.com (2603:10b6:302:1::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.2 via Frontend Transport; Thu, 18 Feb 2021 01:34:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c048bc85-57a5-4198-898f-08d8d3ad4778 X-MS-TrafficTypeDiagnostic: BYAPR10MB3496: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9SV0Afgm/WEcC84x91fBz2J4ASuzY/Waa+r7CnIfD+b953+YQ2cyisRRNDNx5xCV1c0X6FSVAM5nF3px8QWPkTKh52HfhF1YbEun8VGCa7Pth1zt5/R0F7fYrCIfsboJ59y4fl6rQQoBgNIGkbkiv4TRM7+Vy0gh53x/lzG9mroHibBbj3uHmYw5nrn+AQ2hY5TOvnFezcacGeXqkXXvD59O14VNV8z810CoG3howZ5ggpo+bgEkNw3DpAOe6gOcD7uZ9j0QjFtIABsMdU1CEzwzcRicy/S5XWJZIpcsoiVCTggpaVq4/nqLIoo7L8do8HA2ot63K837cjc7WJWKBUwBYJYN5h4jqyltyFeUIJZa2kMk4HfQ7BrS8IAFX+idXpJcekV2RtK2eNLF8jVFAdse6Iq0VQEcT5qv9Oc0nNS/5jqla9MRxP4Qs9FC1df7FqFWd79RAub2nFBjjsYSmfyFkO454fQ9i9dDQd0YF+EF1ZvBS/yuyzL6Vv7MVt0zVfupKUd+SBeRUWgVeUVkVDlGFjV6EYf3utVHd8HCkDzQJwCF1bWxxU1SYvxyh5yEtRArgsqvrbsHsZXKXcVxarEyYq0L3/2DuYBqOpwwjYDhWkd8NRYvoT3YVpph7ngr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(366004)(136003)(376002)(396003)(39860400002)(36756003)(16576012)(31686004)(83380400001)(186003)(66476007)(316002)(66946007)(4326008)(66556008)(31696002)(16526019)(2906002)(8936002)(44832011)(478600001)(6486002)(52116002)(26005)(956004)(86362001)(8676002)(2616005)(54906003)(53546011)(5660300002)(14583001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ZW9vRXV4MU9oNGVFM2JONDVUZ1pFcmhQYk1ieVI0V2k0WW1mNW0xRnRGM3dx?= =?utf-8?B?V3JwTGpCaUgybnhEVXlrdzZnTXU1KzkzdFhZRTFvMm4xTHJFb2RBN3JjWFVG?= =?utf-8?B?OWd0dENjVDJmZ0ZuL2dyQVFYZE5ONXpyenNXNnNkdU1NMmdFTzRaOVJ5OXNw?= =?utf-8?B?cFhzWWpBY3NVMjBkUTR2ZWozSjJYbUtGSDMwc1lDUVF2UjdvN0RzMnRJKzUx?= =?utf-8?B?SVdyemZSSlliVjRjcDRDclZBb2tMSTNieU05STNlYXdGN1NnL0xKNlhXQ2Zt?= =?utf-8?B?TzgyS0lFdC9qc1lVb1Q0cWxoS0RsbUhlc0E3dWVDOEdBRVBZMmFDS2Y0RklE?= =?utf-8?B?Tmp6R0FJL2o3bUdEZVluSGNldCtGMlNFVjVqSzRhbTNXdCt4NS9KOEFWZlhL?= =?utf-8?B?TWVhQWMyQ3JjeDMzYkJlcTJsTStEbzJWYkJaYzI4RzlwZkJHWUp1R1hlSWI5?= =?utf-8?B?eFNuZjZnaGZaRzMyazhvQnVnYkIxcTJwRzJ4bENTSFA0SHNNV3pRN2xjZE55?= =?utf-8?B?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aEdp?= =?utf-8?B?blRHY0x0QnZwZmxkMEo5WjM4cE5xcDFvOXlsV3hRZkFJUzltaXFmaHgzZFho?= =?utf-8?B?WWtmSE1Jak52NjBuZ3hKRHdCcWNHb2RDb3dTUEtTMjRHanJSdXZkT3RpS2ha?= =?utf-8?B?eGlsMVFjaTl6YjFtdXRudWlXaTFDdnFHSHQ3QS9tSVpjUkUxV1V2dWJ0M1My?= =?utf-8?B?ejJ5RjBXZEJoSUZOdDMyenk2dVkxbmQ0aHNUdTBIZmxDaVQ3QTVsQlRLTzRQ?= =?utf-8?B?K1ViNUdxaUNjWHorWi9CbmV5akpRMjJYMWoyTURabG1CbzVIQUNUUkxjaDQ3?= =?utf-8?Q?SLhrQBkceFeZSE45QcEjrCDn47YDQF9nkYMqNrY?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c048bc85-57a5-4198-898f-08d8d3ad4778 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 01:34:05.6164 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FwBbILI7jy0AEeiPX52TP38CWRuKe3bHlJLM6Hzi7EpTY1YuOnbn9KPDaz6Trtcl77UJrvF5koZiP9aw77Qd+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3496 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9898 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102180008 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9898 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102180009 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/17/21 12:46 PM, Peter Xu wrote: > Huge pmd sharing could bring problem to userfaultfd. The thing is that > userfaultfd is running its logic based on the special bits on page table > entries, however the huge pmd sharing could potentially share page table > entries for different address ranges. That could cause issues on either: > > - When sharing huge pmd page tables for an uffd write protected range, the > newly mapped huge pmd range will also be write protected unexpectedly, or, > > - When we try to write protect a range of huge pmd shared range, we'll first > do huge_pmd_unshare() in hugetlb_change_protection(), however that also > means the UFFDIO_WRITEPROTECT could be silently skipped for the shared > region, which could lead to data loss. > > Since at it, a few other things are done altogether: > > - Move want_pmd_share() from mm/hugetlb.c into linux/hugetlb.h, because > that's definitely something that arch code would like to use too > > - ARM64 currently directly check against CONFIG_ARCH_WANT_HUGE_PMD_SHARE when > trying to share huge pmd. Switch to the want_pmd_share() helper. > > Since at it, move vma_shareable() from huge_pmd_share() into want_pmd_share(). > > Signed-off-by: Peter Xu > --- > arch/arm64/mm/hugetlbpage.c | 3 +-- > include/linux/hugetlb.h | 2 ++ > include/linux/userfaultfd_k.h | 9 +++++++++ > mm/hugetlb.c | 20 ++++++++++++++------ > 4 files changed, 26 insertions(+), 8 deletions(-) Thanks, Reviewed-by: Mike Kravetz -- Mike Kravetz