xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] xen/arm: domain_build: Ignore empty memory bank
@ 2020-12-07 15:36 Elliott Mitchell
  2020-12-07 23:17 ` Elliott Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Elliott Mitchell @ 2020-12-07 15:36 UTC (permalink / raw)
  To: xen-devel; +Cc: Stefano Stabellini, Julien Grall, Volodymyr Babchuk

Previously Xen had stopped processing Device Trees if an empty
(size == 0) memory bank was found.

Commit 5a37207df52066efefe419c677b089a654d37afc changed this behavior to
ignore such banks.  Unfortunately this means these empty nodes are
visible to code which accesses the device trees.  Have domain_build also
ignore these entries.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---

Looking at this, I think the problem is likely even larger than this and
really needs a proper solution closer to the core of the device-tree
code.  Likely either all device-tree handling code needs to be audited
for ignoring zero-size entries, or the core should take care of these and
nothing outside of xen/common/device_tree.c should ever see these (except
perhaps to confirm such entries exist as flags).  Notably this is the
*second* location where zero-size device-tree entries need to be ignored,
action might be worthwhile before a third is confirmed.
---
 xen/arch/arm/domain_build.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index e824ba34b0..0b83384bd3 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1405,6 +1405,11 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev,
     {
         struct map_range_data mr_data = { .d = d, .p2mt = p2mt };
         res = dt_device_get_address(dev, i, &addr, &size);
+
+        /* Some DT may describe empty bank, ignore them */
+        if ( !size )
+            continue;
+
         if ( res )
         {
             printk(XENLOG_ERR "Unable to retrieve address %u for %s\n",
-- 


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] xen/arm: domain_build: Ignore empty memory bank
  2020-12-07 15:36 [RFC PATCH] xen/arm: domain_build: Ignore empty memory bank Elliott Mitchell
@ 2020-12-07 23:17 ` Elliott Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Elliott Mitchell @ 2020-12-07 23:17 UTC (permalink / raw)
  To: Ian Jackson
  Cc: xen-devel, Stefano Stabellini, Julien Grall, Volodymyr Babchuk

On Mon, Dec 07, 2020 at 07:36:11AM -0800, Elliott Mitchell wrote:
> Commit 5a37207df52066efefe419c677b089a654d37afc changed this behavior to
> ignore such banks.  Unfortunately this means these empty nodes are
> visible to code which accesses the device trees.  Have domain_build also
> ignore these entries.

It is implicit, but I discovered 7d2b21fd36c2a47799eed71c67bae7faa1ec4272
actually broke Xen for me.  As such I believe this should get into
stable-4.14 as a bugfix.

Taking a second look, that error message is bad.  The preliminary fix I
came up with was:   if(!addr) continue;

As I thought the 0 it was reporting was an address of 0.  Perhaps
"Unable to retrieve address for index %u of %s\n"?

(I opted for testing size after finding the source of the bug and decided
duplicating behavior was better)


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-07 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 15:36 [RFC PATCH] xen/arm: domain_build: Ignore empty memory bank Elliott Mitchell
2020-12-07 23:17 ` Elliott Mitchell

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).