Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3690501img; Mon, 25 Mar 2019 15:57:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKJGQRFa4DP+hRuMAeUX0ExVEqU3Jmq4ys7omAWjHF2Su8IRxSnBqimLn2t7b5+9Y9Ut0v X-Received: by 2002:a63:ef09:: with SMTP id u9mr2462931pgh.126.1553554661447; Mon, 25 Mar 2019 15:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553554661; cv=none; d=google.com; s=arc-20160816; b=bJFibzcTTZ94jmNk7bw4xWDwezbhERkp7Fm5QPMK3UCJbjXK6AiNllKTQKNBsUOCVb J/BpAnX9WzPJ5VMzFexOa6k59GiHdpxpyiG6H1p500Rw6c7LzGMgH0iCeONGfi4r3hla FBVeoWCYuGiDP5KQksBLWj2wURpA5uLTqnlSFbrvNZ46/oOXiPQAxEoBt7F6YyJJ3PkD Jxxld/nNwaoIwkv9e6rWbIQYkvZuWXnNwb+QYoLD/V6z9VaQBopq7Dbc3xQckZ3Npi1K uiFiuZxd3U2BMG9wbKAQm3vdxhxvcIzsubcifid9tiEf1Wo9PX/sd7WZ+xqYkEUlKa2v GCUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=t/co5ivShfO1mx8x4BL5ijsphKzUNudRZF7meI63Qjs=; b=OW28nw43qRw20qZEtWWELPlbLO74vYsPVSToAO+XbjO1mVejdO3KiJ46an75q8oU78 z/LrhPdjaTIqWuB7nrX6K7+y1hloz0WXMBX8omPdWHkfUywE7UkOAeZuXjbkC2dr1w+j PAHTIQNcCQdPNn2lNOfigGZF3ocRzeoDofvnzRabkqCwDmn/hTUMxjuK3sRP11K4kvBK w++D8VffwA5060PpsFtvFP5eFpI04LPOlp4dlCz4tfI7s30xjY08NYtoxzemoOpfpftE yBs1y7krZWRpHPJrqBKPQ08Ddv63NmeVp80Ja094Zdy16+1BpcckYM9V8kRq4n3sNn0O Zt2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si14189475pgs.557.2019.03.25.15.57.26; Mon, 25 Mar 2019 15:57:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730625AbfCYWzZ (ORCPT + 99 others); Mon, 25 Mar 2019 18:55:25 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:47056 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbfCYWzY (ORCPT ); Mon, 25 Mar 2019 18:55:24 -0400 Received: from p5492e2fc.dip0.t-ipconnect.de ([84.146.226.252] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1h8YUs-0000Tc-Se; Mon, 25 Mar 2019 23:55:15 +0100 Date: Mon, 25 Mar 2019 23:55:14 +0100 (CET) From: Thomas Gleixner To: Ralph Campbell cc: linux-kernel@vger.kernel.org, Craig Bergstrom , Linus Torvalds , Boris Ostrovsky , Fengguang Wu , Greg Kroah-Hartman , Hans Verkuil , Mauro Carvalho Chehab , Peter Zijlstra , Sander Eikelenboom , Sean Young , Ingo Molnar Subject: Re: [PATCH 1/1] x86/mm: Fix limit mmap() of /dev/mem to valid physical addresses In-Reply-To: <39b65bda-cef5-4ea2-ddaa-418e8e71e306@nvidia.com> Message-ID: References: <20190318224653.26549-1-rcampbell@nvidia.com> <20190318224653.26549-2-rcampbell@nvidia.com> <39b65bda-cef5-4ea2-ddaa-418e8e71e306@nvidia.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ralph, On Mon, 25 Mar 2019, Ralph Campbell wrote: > On 3/23/19 12:02 PM, Thomas Gleixner wrote: > > > --- a/arch/x86/mm/mmap.c > > > +++ b/arch/x86/mm/mmap.c > > > @@ -230,7 +230,7 @@ bool mmap_address_hint_valid(unsigned long addr, > > > unsigned long len) > > > /* Can we access it for direct reading/writing? Must be RAM: */ > > > int valid_phys_addr_range(phys_addr_t addr, size_t count) > > > { > > > - return addr + count <= __pa(high_memory); > > > + return addr + count <= __pa_nodebug(high_memory); > > > > This lacks a comment. Aside of that I think there is no point in using > > __pa(high_memory) here. This is all about the physical address range. So > > this can be simply expressed via: > > > > return addr + count <= max_pfn * PAGE_SIZE; > > > > which is much more obvious. > > This looks OK to me for x86_64 but looking at arch/x86/mm/init_32.c, > initmem_init() sets high_memory based on highstart_pfn or max_low_pfn > depending on CONFIG_HIGHMEM. Would using max_pfn in this case work? Aargh. There is also numa_32.c ... So __pa_nodebug(high_memory) should be fine, but looking at the other places which do __pa() on high_memory they all use __pa(high_memory - 1) which is more obvious that the nodebug thing. Thanks, tglx