From: Frantisek Hrbata <fhrbata@redhat.com> To: Dave Hansen <dave.hansen@intel.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, oleg@redhat.com, kamaleshb@in.ibm.com, hechjie@cn.ibm.com, akpm@linux-foundation.org, dvlasenk@redhat.com, prarit@redhat.com, lwoodman@redhat.com, hannsj_uhl@de.ibm.com Subject: Re: [PATCH V2 2/2] x86: add phys addr validity check for /dev/mem mmap Date: Mon, 18 Aug 2014 13:26:35 +0200 [thread overview] Message-ID: <20140818112635.GA3223@localhost.localdomain> (raw) In-Reply-To: <53EE4D11.5020001@intel.com> On Fri, Aug 15, 2014 at 11:10:25AM -0700, Dave Hansen wrote: > On 08/15/2014 04:44 AM, Frantisek Hrbata wrote: > > +int valid_phys_addr_range(phys_addr_t addr, size_t count) > > +{ > > + return addr + count <= __pa(high_memory); > > +} > > + > > +int valid_mmap_phys_addr_range(unsigned long pfn, size_t count) > > +{ > > + return arch_pfn_possible(pfn + (count >> PAGE_SHIFT)); > > +} > > It definitely fixes the issue as you described it. Hi Dave, many thanks for your time and help with this! > > It's a bit unfortunate that the highmem check isn't tied in to the > _existing_ /dev/mem limitations in some way, but it's not a deal breaker > for me. Agreed, I will do some more testing with the "patch" I proposed earlier in our discussion. Meaning the one moving the high_memory check out of the valid_phys_addr_range() to the xlate_dev_mem_ptr() for x86. IMHO this should work fine and it should remove the high_memory limitation. But I for sure can be missing something. If the testing goes well I will post the patch. > > The only other thing is to make sure this doesn't add some limitation to > 64-bit where we can't map things above the end of memory (end of memory > == high_memory on 64-bit). As long as you've done this, I can't see a > downside. Yes, from what I have tested, this patch should not introduce any new limitation, except fixing the PTE problem. Also please note that this kind of check is already done in ioremap by calling the phys_addr_valid(). Again, I hope I haven't overlooked something. Peter and others: Could you please consider including this fix? Of course only if you do not have any other objections or problems with it. Many thanks! -- Frantisek Hrbata
WARNING: multiple messages have this Message-ID (diff)
From: Frantisek Hrbata <fhrbata@redhat.com> To: Dave Hansen <dave.hansen@intel.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, oleg@redhat.com, kamaleshb@in.ibm.com, hechjie@cn.ibm.com, akpm@linux-foundation.org, dvlasenk@redhat.com, prarit@redhat.com, lwoodman@redhat.com, hannsj_uhl@de.ibm.com Subject: Re: [PATCH V2 2/2] x86: add phys addr validity check for /dev/mem mmap Date: Mon, 18 Aug 2014 13:26:35 +0200 [thread overview] Message-ID: <20140818112635.GA3223@localhost.localdomain> (raw) In-Reply-To: <53EE4D11.5020001@intel.com> On Fri, Aug 15, 2014 at 11:10:25AM -0700, Dave Hansen wrote: > On 08/15/2014 04:44 AM, Frantisek Hrbata wrote: > > +int valid_phys_addr_range(phys_addr_t addr, size_t count) > > +{ > > + return addr + count <= __pa(high_memory); > > +} > > + > > +int valid_mmap_phys_addr_range(unsigned long pfn, size_t count) > > +{ > > + return arch_pfn_possible(pfn + (count >> PAGE_SHIFT)); > > +} > > It definitely fixes the issue as you described it. Hi Dave, many thanks for your time and help with this! > > It's a bit unfortunate that the highmem check isn't tied in to the > _existing_ /dev/mem limitations in some way, but it's not a deal breaker > for me. Agreed, I will do some more testing with the "patch" I proposed earlier in our discussion. Meaning the one moving the high_memory check out of the valid_phys_addr_range() to the xlate_dev_mem_ptr() for x86. IMHO this should work fine and it should remove the high_memory limitation. But I for sure can be missing something. If the testing goes well I will post the patch. > > The only other thing is to make sure this doesn't add some limitation to > 64-bit where we can't map things above the end of memory (end of memory > == high_memory on 64-bit). As long as you've done this, I can't see a > downside. Yes, from what I have tested, this patch should not introduce any new limitation, except fixing the PTE problem. Also please note that this kind of check is already done in ioremap by calling the phys_addr_valid(). Again, I hope I haven't overlooked something. Peter and others: Could you please consider including this fix? Of course only if you do not have any other objections or problems with it. Many thanks! -- Frantisek Hrbata -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-08-18 11:27 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-08-14 14:18 [PATCH 0/1] Prevent possible PTE corruption with /dev/mem mmap Frantisek Hrbata 2014-08-14 14:18 ` Frantisek Hrbata 2014-08-14 14:18 ` [PATCH 1/1] x86: add phys addr validity check for " Frantisek Hrbata 2014-08-14 14:18 ` Frantisek Hrbata 2014-08-14 16:36 ` Dave Hansen 2014-08-14 16:36 ` Dave Hansen 2014-08-14 17:20 ` H. Peter Anvin 2014-08-14 17:20 ` H. Peter Anvin 2014-08-14 17:53 ` Frantisek Hrbata 2014-08-14 17:53 ` Frantisek Hrbata 2014-08-14 17:40 ` Frantisek Hrbata 2014-08-14 17:40 ` Frantisek Hrbata 2014-08-15 10:17 ` Frantisek Hrbata 2014-08-15 10:17 ` Frantisek Hrbata 2014-08-15 11:44 ` [PATCH V2 0/2] Prevent possible PTE corruption with " Frantisek Hrbata 2014-08-15 11:44 ` Frantisek Hrbata 2014-08-15 11:44 ` [PATCH V2 1/2] x86: add arch_pfn_possible helper Frantisek Hrbata 2014-08-15 11:44 ` Frantisek Hrbata 2014-08-15 11:44 ` [PATCH V2 2/2] x86: add phys addr validity check for /dev/mem mmap Frantisek Hrbata 2014-08-15 11:44 ` Frantisek Hrbata 2014-08-15 18:10 ` Dave Hansen 2014-08-15 18:10 ` Dave Hansen 2014-08-18 11:26 ` Frantisek Hrbata [this message] 2014-08-18 11:26 ` Frantisek Hrbata 2014-08-20 15:25 ` [PATCH 0/2] x86: allow read/write /dev/mem to access non-system RAM above high_memory Frantisek Hrbata 2014-08-20 15:25 ` Frantisek Hrbata 2014-08-20 15:25 ` [PATCH 1/2] x86: add high_memory check to (xlate|unxlate)_dev_mem_ptr Frantisek Hrbata 2014-08-20 15:25 ` Frantisek Hrbata 2014-08-20 15:25 ` [PATCH 2/2] x86: remove high_memory check from valid_phys_addr_range Frantisek Hrbata 2014-08-20 15:25 ` Frantisek Hrbata
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20140818112635.GA3223@localhost.localdomain \ --to=fhrbata@redhat.com \ --cc=akpm@linux-foundation.org \ --cc=dave.hansen@intel.com \ --cc=dvlasenk@redhat.com \ --cc=hannsj_uhl@de.ibm.com \ --cc=hechjie@cn.ibm.com \ --cc=hpa@zytor.com \ --cc=kamaleshb@in.ibm.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=lwoodman@redhat.com \ --cc=mingo@redhat.com \ --cc=oleg@redhat.com \ --cc=prarit@redhat.com \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.