[PATCH] powerpc/mm: add devmem_is_allowed() for STRICT_DEVMEM checking
Steve Best
sfbest at us.ibm.com
Wed Jun 15 04:17:01 EST 2011
On Tue, 2011-06-14 at 12:30 -0500, Nathan Lynch wrote:
> Hi Steve,
>
> On Tue, 2011-06-14 at 12:58 -0400, Steve Best wrote:
> > diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
> > index e72dcf6..e1aab6b 100644
> > --- a/arch/powerpc/Kconfig.debug
> > +++ b/arch/powerpc/Kconfig.debug
> > @@ -283,4 +283,15 @@ config PPC_EARLY_DEBUG_CPM_ADDR
> > platform probing is done, all platforms selected must
> > share the same address.
> >
> > +config STRICT_DEVMEM
> > + def_bool y
>
> Default new config items to n, please.
ok
>
>
> > --- a/arch/powerpc/mm/mem.c
> > +++ b/arch/powerpc/mm/mem.c
> > @@ -520,3 +520,21 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
> > hash_preload(vma->vm_mm, address, access, trap);
> > #endif /* CONFIG_PPC_STD_MMU */
> > }
> > +
> > +/*
> > + * devmem_is_allowed() checks to see if /dev/mem access to a certain address
> > + * is valid. The argument is a physical page number.
> > + *
> > + * On PowerPC, access has to be given to data regions used by X. We have to
> > + * disallow access to device-exclusive MMIO regions and system RAM.
> > + */
> > +int devmem_is_allowed(unsigned long pfn)
> > +{
> > + if ((pfn >= 57360 || pfn <= 57392))
> > + return 1;
>
> That seems... fragile. Where do these numbers come from, and are they
> appropriate for all platforms and configurations?
This is the range I got from testing pseries blades and servers. maybe
there is a better way to get this range anyone know of a way?
>
>
-Steve
More information about the Linuxppc-dev
mailing list