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=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 6EE67CA9EB6 for ; Wed, 23 Oct 2019 10:29:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1907920650 for ; Wed, 23 Oct 2019 10:29:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XseFJxHL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1907920650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46ymnP3CpczDqS6 for ; Wed, 23 Oct 2019 21:28:57 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=207.211.31.81; helo=us-smtp-delivery-1.mimecast.com; envelope-from=david@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="XseFJxHL"; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46yjxR5454zDqP5 for ; Wed, 23 Oct 2019 19:20:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571818840; 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=ZYwRT87GkK/iKD1IC7yG62REkwJqyJxXRU8O7sH7WsI=; b=XseFJxHLQVzFmrOvPVNELeRYAB/zQWx8lYVv2LlZvZycG8KTPa/ym2JDMxSVxQWiDdNSm4 faUxyQN9t4S3ln6De95Q3vHX/q0o1k2Afi+LUE/I2JBoDkSsgvRVWiScA6B84rVDY8rs3A DW/epqiYHp7JF0Xd+XxFIqehJkdQ3mo= 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-61-HevUVdjDPbOvQMNsP_rCWQ-1; Wed, 23 Oct 2019 04:20:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9CFB800D54; Wed, 23 Oct 2019 08:20:30 +0000 (UTC) Received: from [10.36.117.79] (ovpn-117-79.ams2.redhat.com [10.36.117.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CEFA5C219; Wed, 23 Oct 2019 08:20:14 +0000 (UTC) Subject: Re: [PATCH RFC v1 02/12] mm/usercopy.c: Prepare check_page_span() for PG_reserved changes To: linux-kernel@vger.kernel.org References: <20191022171239.21487-1-david@redhat.com> <20191022171239.21487-3-david@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Wed, 23 Oct 2019 10:20:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191022171239.21487-3-david@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: HevUVdjDPbOvQMNsP_rCWQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Wed, 23 Oct 2019 21:21:34 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kate Stewart , Sasha Levin , linux-hyperv@vger.kernel.org, Michal Hocko , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, Pavel Tatashin , KarimAllah Ahmed , Dave Hansen , Alexander Duyck , Michal Hocko , linux-mm@kvack.org, Paul Mackerras , "H. Peter Anvin" , Wanpeng Li , Alexander Duyck , "K. Y. Srinivasan" , Fabio Estevam , Ben Chan , Kees Cook , devel@driverdev.osuosl.org, Stefano Stabellini , Stephen Hemminger , "Aneesh Kumar K.V" , Joerg Roedel , x86@kernel.org, YueHaibing , Mike Rapoport , Madhumitha Prabakaran , Peter Zijlstra , Ingo Molnar , Vlastimil Babka , Nishka Dasgupta , Anthony Yznaga , Oscar Salvador , Dan Carpenter , "Isaac J. Manjarres" , Matt Sickler , Juergen Gross , Anshuman Khandual , Haiyang Zhang , =?UTF-8?Q?Simon_Sandstr=c3=b6m?= , Dan Williams , kvm-ppc@vger.kernel.org, Qian Cai , Alex Williamson , Mike Rapoport , Borislav Petkov , Nicholas Piggin , Andy Lutomirski , xen-devel@lists.xenproject.org, Boris Ostrovsky , Todd Poynor , Vitaly Kuznetsov , Allison Randal , Jim Mattson , Vandana BN , Jeremy Sowden , Greg Kroah-Hartman , Cornelia Huck , Pavel Tatashin , Mel Gorman , Sean Christopherson , Rob Springer , Thomas Gleixner , Johannes Weiner , Paolo Bonzini , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 22.10.19 19:12, David Hildenbrand wrote: > Right now, ZONE_DEVICE memory is always set PG_reserved. We want to > change that. >=20 > 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). >=20 > 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(-) >=20 > 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,= unsigned 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 @Kees, would it be okay to stop checking against ZONE_DEVICE pages here=20 or is there a good rationale behind this? (I would turn this patch into a simple update of the comment if we agree=20 that we don't care) --=20 Thanks, David / dhildenb