linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] ARM: runtime patching of __virt_to_phys() and __phys_to_virt()
Date: Tue, 4 Jan 2011 18:06:20 +0000	[thread overview]
Message-ID: <20110104180620.GC24935@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <alpine.LFD.2.00.1101041225070.22191@xanadu.home>

On Tue, Jan 04, 2011 at 12:50:28PM -0500, Nicolas Pitre wrote:
> On Tue, 4 Jan 2011, Russell King - ARM Linux wrote:
> > Our aims are different then.  My aim is to move the code to a point where
> > it works for _everyone_ it possibly can - and theoretically that's every
> > platform except:
> > 
> > 1. MSM due to their PHYS_OFFSET being 2MB aligned, rather than the more
> >    normal 256MB alignment.
> > 2. Anyone with complex V:P mappings
> 
> I completely agree with that goal.  But I'd prefer for those platforms 
> which are not yet supported by this feature not to be able to compile 
> rather than silently ignore the feature and not behave as expected.
> 
> > (1) is dealt with easily by a dependency in the configuration preventing
> > the option being visible.  (2) is dealt with at runtime by ignoring the
> > configuration option - resulting in the p2v tables being empty.  The end
> > result will still run on the platform, but it won't do the relocation
> > stuff.  (2) could also be dealt with by adding the necessary dependencies
> > to the configuration option which is the longer term solution.
> 
> Since (2) is not supported yet with this config option selected, I think 
> it is best to simply #error the build.
> 
> > Lastly, marking the option as 'EXPERIMENTAL' is there to convey that it
> > may not work for everyone, and people should expect things not to work if
> > they enable such an option (and report when that's the case.)
> 
> Sure, hence my #error in the patch which is even easier to diagnose and 
> self explanatory.

You're making a mountain out of a mole hill.  At present, there is one
platform which defines its own complex v:p mapping and that is Realview,
but only when sparsemem is enabled.  As already mentioned, MSM is the
only other platform which can't use this method.  So that's a simple
dependency line against the config.

The other breakages are use of PHYS_OFFSET as an initializer which is a
build-error inducing failure, and adopting the approach I outlined in my
4 patch set results in many of those going away before we get support for
this merged - even better, if PHYS_OFFSET were always to be variable-like,
then we'd stop any new uses even appearing.

> And in fact I think that this would indeed be simpler to just fall back 
> to a global variable for PHYS_OFFSET when a platform defines its own 
> p2v/v2p mapping.  This way, the goal of this feature would be 
> universally available.

Not really.  Platforms define their own mapping because it's not a simple
addition or subtraction, but because it's a complex non-linear conversion.

#define __phys_to_virt(phys)                                            \
        ((phys) >= 0x80000000 ? (phys) - 0x80000000 + PAGE_OFFSET2 :    \
         (phys) >= 0x20000000 ? (phys) - 0x20000000 + PAGE_OFFSET1 :    \
         (phys) + PAGE_OFFSET)

#define __virt_to_phys(virt)                                            \
         ((virt) >= PAGE_OFFSET2 ? (virt) - PAGE_OFFSET2 + 0x80000000 : \
          (virt) >= PAGE_OFFSET1 ? (virt) - PAGE_OFFSET1 + 0x20000000 : \
          (virt) - PAGE_OFFSET)

This doesn't lend itself in any way to a variable-based PHYS_OFFSET, and
could never be subsituted code-wise at run time without significant
effort.

In fact, platforms which have complex V:P mappings can _never_ be a part
of a kernel which has this feature enabled.

  reply	other threads:[~2011-01-04 18:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04  8:20 [PATCH 0/4] variable PHYS_OFFSET support Nicolas Pitre
2011-01-04  8:20 ` [PATCH 1/4] ARM: runtime patching of __virt_to_phys() and __phys_to_virt() Nicolas Pitre
2011-01-04  8:45   ` Russell King - ARM Linux
2011-01-04 14:32     ` Nicolas Pitre
2011-01-04 16:53       ` Russell King - ARM Linux
2011-01-04 17:50         ` Nicolas Pitre
2011-01-04 18:06           ` Russell King - ARM Linux [this message]
2011-01-04 18:25             ` David Brown
2011-01-04 18:33               ` Nicolas Pitre
2011-01-04 19:00                 ` David Brown
2011-01-04 20:17                   ` Russell King - ARM Linux
2011-01-04 18:29             ` Nicolas Pitre
2011-01-04  8:20 ` [PATCH 2/4] ARM: make PHYS_OFFSET actually variable Nicolas Pitre
2011-01-04 12:30   ` Russell King - ARM Linux
2011-01-04 17:54     ` Nicolas Pitre
2011-01-04  8:20 ` [PATCH 3/4] ARM: module support for CONFIG_ARM_PATCH_PHYS_VIRT Nicolas Pitre
2011-01-04 10:06   ` Russell King - ARM Linux
2011-01-04  8:20 ` [PATCH 4/4] ARM: support for Thumb-2 instructions with CONFIG_ARM_PATCH_PHYS_VIRT Nicolas Pitre
2011-01-10 22:20   ` Dave Martin
2011-01-10 22:45     ` Nicolas Pitre
2011-01-10 23:24       ` Russell King - ARM Linux
2011-01-10 23:57         ` Nicolas Pitre
2011-01-04 10:41 ` [PATCH 0/4] variable PHYS_OFFSET support Russell King - ARM Linux
2011-01-04 14:37   ` Nicolas Pitre

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=20110104180620.GC24935@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).