From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFDCDCA9EA0 for ; Tue, 22 Oct 2019 17:14:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8240C2084B for ; Tue, 22 Oct 2019 17:14:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GM7WBWGa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8240C2084B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F292D6B0007; Tue, 22 Oct 2019 13:14:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED89B6B0008; Tue, 22 Oct 2019 13:14:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D79DF6B000A; Tue, 22 Oct 2019 13:14:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id B7C436B0007 for ; Tue, 22 Oct 2019 13:14:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 5067A8151 for ; Tue, 22 Oct 2019 17:14:01 +0000 (UTC) X-FDA: 76072068282.22.jewel82_401b75ccbcc1a X-HE-Tag: jewel82_401b75ccbcc1a X-Filterd-Recvd-Size: 6866 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Oct 2019 17:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571764439; 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=zGQAc5VmCetr7C7c8aFEmIaobGzhiGLNzJdeTackaIM=; b=GM7WBWGanO2YELPYe2+w7yq9uXndEn8XdD7qiZeWiAo5kkslxy195tG2UJQ1o3Az3JubV9 JLETtGblJpHcJ+FrpUGMnXBpHkB7qdAhBI843Wc1MNw6Mwi30AcFSeJMnCldH+DWvrPeBG eLTBsP/F2A5wXejD/Sz/vE491h+bMac= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-qLpykW4SPYy_CRKVfRekMA-1; Tue, 22 Oct 2019 13:13:58 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 356831800D6A; Tue, 22 Oct 2019 17:13:53 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-248.ams2.redhat.com [10.36.116.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54CE05ED21; Tue, 22 Oct 2019 17:13:31 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Michal Hocko , Andrew Morton , kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, devel@driverdev.osuosl.org, xen-devel@lists.xenproject.org, x86@kernel.org, Alexander Duyck , Alexander Duyck , Alex Williamson , Allison Randal , Andy Lutomirski , "Aneesh Kumar K.V" , Anshuman Khandual , Anthony Yznaga , Ben Chan , Benjamin Herrenschmidt , Borislav Petkov , Boris Ostrovsky , Christophe Leroy , Cornelia Huck , Dan Carpenter , Dan Williams , Dave Hansen , Fabio Estevam , Greg Kroah-Hartman , Haiyang Zhang , "H. Peter Anvin" , Ingo Molnar , "Isaac J. Manjarres" , Jeremy Sowden , Jim Mattson , Joerg Roedel , Johannes Weiner , Juergen Gross , KarimAllah Ahmed , Kate Stewart , Kees Cook , "K. Y. Srinivasan" , Madhumitha Prabakaran , Matt Sickler , Mel Gorman , Michael Ellerman , Michal Hocko , Mike Rapoport , Mike Rapoport , Nicholas Piggin , Nishka Dasgupta , Oscar Salvador , Paolo Bonzini , Paul Mackerras , Paul Mackerras , Pavel Tatashin , Pavel Tatashin , Peter Zijlstra , Qian Cai , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Rob Springer , Sasha Levin , Sean Christopherson , =?UTF-8?q?Simon=20Sandstr=C3=B6m?= , Stefano Stabellini , Stephen Hemminger , Thomas Gleixner , Todd Poynor , Vandana BN , Vitaly Kuznetsov , Vlastimil Babka , Wanpeng Li , YueHaibing Subject: [PATCH RFC v1 02/12] mm/usercopy.c: Prepare check_page_span() for PG_reserved changes Date: Tue, 22 Oct 2019 19:12:29 +0200 Message-Id: <20191022171239.21487-3-david@redhat.com> In-Reply-To: <20191022171239.21487-1-david@redhat.com> References: <20191022171239.21487-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: qLpykW4SPYy_CRKVfRekMA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable 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: Right now, ZONE_DEVICE memory is always set PG_reserved. We want to change that. Let's make sure that the logic in the function won't change. Once we no longer set these pages to reserved, we can rework this function to perform separate checks for ZONE_DEVICE (split from PG_reserved checks). Cc: Kees Cook Cc: Andrew Morton Cc: Kate Stewart Cc: Allison Randal Cc: "Isaac J. Manjarres" Cc: Qian Cai Cc: Thomas Gleixner Signed-off-by: David Hildenbrand --- mm/usercopy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/usercopy.c b/mm/usercopy.c index 660717a1ea5c..a3ac4be35cde 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -203,14 +203,15 @@ static inline void check_page_span(const void *ptr, u= nsigned long n, =09 * device memory), or CMA. Otherwise, reject since the object spans =09 * several independently allocated pages. =09 */ -=09is_reserved =3D PageReserved(page); +=09is_reserved =3D PageReserved(page) || is_zone_device_page(page); =09is_cma =3D is_migrate_cma_page(page); =09if (!is_reserved && !is_cma) =09=09usercopy_abort("spans multiple pages", NULL, to_user, 0, n); =20 =09for (ptr +=3D PAGE_SIZE; ptr <=3D end; ptr +=3D PAGE_SIZE) { =09=09page =3D virt_to_head_page(ptr); -=09=09if (is_reserved && !PageReserved(page)) +=09=09if (is_reserved && !(PageReserved(page) || +=09=09=09=09 is_zone_device_page(page))) =09=09=09usercopy_abort("spans Reserved and non-Reserved pages", =09=09=09=09 NULL, to_user, 0, n); =09=09if (is_cma && !is_migrate_cma_page(page)) --=20 2.21.0