[PATCH] libbpf: Fix readelf output parsing for Fedora

2019-12-13 Thread Thadeu Lima de Souza Cascardo
Fedora binutils has been patched to show "other info" for a symbol at the
end of the line. This was done in order to support unmaintained scripts
that would break with the extra info. [1]

[1] 
https://src.fedoraproject.org/rpms/binutils/c/b8265c46f7ddae23a792ee8306fbaaeacba83bf8

This in turn has been done to fix the build of ruby, because of checksec.
[2] Thanks Michael Ellerman for the pointer.

[2] https://bugzilla.redhat.com/show_bug.cgi?id=1479302

As libbpf Makefile is not unmaintained, we can simply deal with either
output format, by just removing the "other info" field, as it always comes
inside brackets.

Cc: Aurelien Jarno 
Fixes: 3464afdf11f9 (libbpf: Fix readelf output parsing on powerpc with recent 
binutils)
Reported-by: Justin Forbes 
Signed-off-by: Thadeu Lima de Souza Cascardo 
---
 tools/lib/bpf/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index defae23a0169..23ae06c43d08 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -147,6 +147,7 @@ TAGS_PROG := $(if $(shell which etags 
2>/dev/null),etags,ctags)
 
 GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
+  sed 's/\[.*\]//' | \
   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | 
\
   sort -u | wc -l)
 VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \
@@ -213,6 +214,7 @@ check_abi: $(OUTPUT)libbpf.so
 "versioned in $(VERSION_SCRIPT)." >&2;  \
readelf -s --wide $(BPF_IN_SHARED) | \
cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' |   \
+   sed 's/\[.*\]//' |   \
awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
readelf -s --wide $(OUTPUT)libbpf.so |   \
-- 
2.24.0



Re: [PATCH] libbpf: fix readelf output parsing on powerpc with recent binutils

2019-12-11 Thread Thadeu Lima de Souza Cascardo
On Wed, Dec 11, 2019 at 09:33:53AM -0600, Justin Forbes wrote:
> On Tue, Dec 10, 2019 at 4:26 PM Thadeu Lima de Souza Cascardo
>  wrote:
> >
> > On Tue, Dec 10, 2019 at 12:58:33PM -0600, Justin Forbes wrote:
> > > On Mon, Dec 2, 2019 at 3:37 AM Daniel Borkmann  
> > > wrote:
> > > >
> > > > On Mon, Dec 02, 2019 at 04:53:26PM +1100, Michael Ellerman wrote:
> > > > > Aurelien Jarno  writes:
> > > > > > On powerpc with recent versions of binutils, readelf outputs an 
> > > > > > extra
> > > > > > field when dumping the symbols of an object file. For example:
> > > > > >
> > > > > > 35: 083896 FUNCLOCAL  DEFAULT 
> > > > > > [: 8] 1 btf_is_struct
> > > > > >
> > > > > > The extra "[: 8]" prevents the GLOBAL_SYM_COUNT 
> > > > > > variable to
> > > > > > be computed correctly and causes the checkabi target to fail.
> > > > > >
> > > > > > Fix that by looking for the symbol name in the last field instead 
> > > > > > of the
> > > > > > 8th one. This way it should also cope with future extra fields.
> > > > > >
> > > > > > Signed-off-by: Aurelien Jarno 
> > > > > > ---
> > > > > >  tools/lib/bpf/Makefile | 4 ++--
> > > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > Thanks for fixing that, it's been on my very long list of test 
> > > > > failures
> > > > > for a while.
> > > > >
> > > > > Tested-by: Michael Ellerman 
> > > >
> > > > Looks good & also continues to work on x86. Applied, thanks!
> > >
> > > This actually seems to break horribly on PPC64le with binutils 2.33.1
> > > resulting in:
> > > Warning: Num of global symbols in sharedobjs/libbpf-in.o (32) does NOT
> > > match with num of versioned symbols in libbpf.so (184). Please make
> > > sure all LIBBPF_API symbols are versioned in libbpf.map.
> > >
> > > This is the only arch that fails, with x86/arm/aarch64/s390 all
> > > building fine.  Reverting this patch allows successful build across
> > > all arches.
> > >
> > > Justin
> >
> > Well, I ended up debugging this same issue and had the same fix as Jarno's 
> > when
> > I noticed his fix was already applied.
> >
> > I just installed a system with the latest binutils, 2.33.1, and it still 
> > breaks
> > without such fix. Can you tell what is the output of the following command 
> > on
> > your system?
> >
> > readelf -s --wide tools/lib/bpf/sharedobjs/libbpf-in.o | cut -d "@" -f1 | 
> > sed 's/_v[0-9]_[0-9]_[0-9].*//' | awk '/GLOBAL/ && /DEFAULT/ && !/UND/ 
> > {print $0}'
> >
> 
> readelf -s --wide tools/lib/bpf/sharedobjs/libbpf-in.o | cut -d "@"
> -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | awk '/GLOBAL/ && /DEFAULT/ &&
> !/UND/ {print $0}'
>373: 000141bc  1376 FUNCGLOBAL DEFAULT1
> libbpf_num_possible_cpus [: 8]
>375: 0001869c   176 FUNCGLOBAL DEFAULT1 btf__free
> [: 8]
[...]

This is a patch on binutils carried by Fedora:

https://src.fedoraproject.org/rpms/binutils/c/b8265c46f7ddae23a792ee8306fbaaeacba83bf8

" b8265c Have readelf display extra symbol information at the end of the line. "

It has the following comment:

# FIXME:The proper fix would be to update the scripts that are expecting
#   a fixed output from readelf.  But it seems that some of them are
#   no longer being maintained.

This commit is from 2017, had it been on binutils upstream, maybe the situation
right now would be different.

Honestly, it seems the best way out is to filter the other information in the
libbpf Makefile.

Does the following patch work for you?


diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 56ce6292071b..e6f99484d7d5 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -145,6 +145,7 @@ PC_FILE := $(addprefix $(OUTPUT),$(PC_FILE))
 
 GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
+  sed 's/\[.*\]//' | \
   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}' | \
   sort -u | wc -l)
 VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \
@@ -217,6 +218,7 @@ check_abi: $(OUTPUT)libbpf.so
 "versioned in $(VERSION_SCRIPT)." >&2;  \
readelf -s --wide $(OUTPUT)libbpf-in.o | \
cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' |   \
+   sed 's/\[.*\]//' |   \
awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}'|   \
sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
readelf -s --wide $(OUTPUT)libbpf.so |   \



Re: [PATCH] libbpf: fix readelf output parsing on powerpc with recent binutils

2019-12-10 Thread Thadeu Lima de Souza Cascardo
On Tue, Dec 10, 2019 at 12:58:33PM -0600, Justin Forbes wrote:
> On Mon, Dec 2, 2019 at 3:37 AM Daniel Borkmann  wrote:
> >
> > On Mon, Dec 02, 2019 at 04:53:26PM +1100, Michael Ellerman wrote:
> > > Aurelien Jarno  writes:
> > > > On powerpc with recent versions of binutils, readelf outputs an extra
> > > > field when dumping the symbols of an object file. For example:
> > > >
> > > > 35: 083896 FUNCLOCAL  DEFAULT [: 8] 
> > > > 1 btf_is_struct
> > > >
> > > > The extra "[: 8]" prevents the GLOBAL_SYM_COUNT variable to
> > > > be computed correctly and causes the checkabi target to fail.
> > > >
> > > > Fix that by looking for the symbol name in the last field instead of the
> > > > 8th one. This way it should also cope with future extra fields.
> > > >
> > > > Signed-off-by: Aurelien Jarno 
> > > > ---
> > > >  tools/lib/bpf/Makefile | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > Thanks for fixing that, it's been on my very long list of test failures
> > > for a while.
> > >
> > > Tested-by: Michael Ellerman 
> >
> > Looks good & also continues to work on x86. Applied, thanks!
> 
> This actually seems to break horribly on PPC64le with binutils 2.33.1
> resulting in:
> Warning: Num of global symbols in sharedobjs/libbpf-in.o (32) does NOT
> match with num of versioned symbols in libbpf.so (184). Please make
> sure all LIBBPF_API symbols are versioned in libbpf.map.
> 
> This is the only arch that fails, with x86/arm/aarch64/s390 all
> building fine.  Reverting this patch allows successful build across
> all arches.
> 
> Justin

Well, I ended up debugging this same issue and had the same fix as Jarno's when
I noticed his fix was already applied.

I just installed a system with the latest binutils, 2.33.1, and it still breaks
without such fix. Can you tell what is the output of the following command on
your system?

readelf -s --wide tools/lib/bpf/sharedobjs/libbpf-in.o | cut -d "@" -f1 | sed 
's/_v[0-9]_[0-9]_[0-9].*//' | awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $0}' 

Cascardo.



Bug#883432: Enable CRASH_DUMP for ppc64el/ppc64

2017-12-04 Thread Thadeu Lima de Souza Cascardo
Package: src:linux
Followup-For: Bug #883432

Attaching proper patch on top of master.
>From 98fcd489810cf181f53bd917df8dde8a8ec9c317 Mon Sep 17 00:00:00 2001
From: Thadeu Lima de Souza Cascardo <casca...@debian.org>
Date: Thu, 30 Nov 2017 08:39:00 -0200
Subject: [PATCH] [ppc64el,ppc64] Enable CRASH_DUMP

Signed-off-by: Thadeu Lima de Souza Cascardo <casca...@debian.org>
---
 debian/changelog| 3 +++
 debian/config/kernelarch-powerpc/config-arch-64 | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index fce0aaf88558..69f9dbc286c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,9 @@ linux (4.14.2-1) unstable; urgency=medium
   * mm, thp: Do not make page table dirty unconditionally in touch_p[mu]d()
 (CVE-2017-1000405)
 
+  [ Thadeu Lima de Souza Cascardo ]
+  * [ppc64el,ppc64] Enable CRASH_DUMP
+
  -- Ben Hutchings <b...@decadent.org.uk>  Thu, 30 Nov 2017 12:33:47 +
 
 linux (4.14-1~exp1) experimental; urgency=medium
diff --git a/debian/config/kernelarch-powerpc/config-arch-64 
b/debian/config/kernelarch-powerpc/config-arch-64
index 329e7a225a48..e47804aa2b61 100644
--- a/debian/config/kernelarch-powerpc/config-arch-64
+++ b/debian/config/kernelarch-powerpc/config-arch-64
@@ -2,7 +2,7 @@
 ## file: arch/powerpc/Kconfig
 ##
 CONFIG_PPC_TRANSACTIONAL_MEM=y
-# CONFIG_CRASH_DUMP is not set
+CONFIG_CRASH_DUMP=y
 CONFIG_IRQ_ALL_CPUS=y
 CONFIG_NUMA=y
 ## choice: Page size
-- 
2.15.0



Bug#883432: Enable CRASH_DUMP for ppc64el/ppc64

2017-12-03 Thread Thadeu Lima de Souza Cascardo
Source: linux
Severity: wishlist
Tags: patch

kdump won't work on ppc64el, as CRASH_DUMP is not enabled. This has been
used for IBM Power systems for a long time on other OSes, so it should
be safe to enable on 64-bit PPC.

Changes in kdump-tools and makedumpfile that make sense only on ppc64
are in progress to get good kdump support on Debian 64-bit PPC.

The attached patch might have been mangled, sorry about that.
commit 0a2ddd58d9deff60663c7340b8f912c093e9ef24 (HEAD -> master)
Author: Thadeu Lima de Souza Cascardo <casca...@debian.org>
Date:   Thu Nov 30 08:39:00 2017 -0200

[ppc64el,ppc64] Enable CRASH_DUMP

Signed-off-by: Thadeu Lima de Souza Cascardo <casca...@debian.org>

diff --git a/debian/config/kernelarch-powerpc/config-arch-64 
b/debian/config/kernelarch-powerpc/config-arch-64
index 329e7a225a48..e47804aa2b61 100644
--- a/debian/config/kernelarch-powerpc/config-arch-64
+++ b/debian/config/kernelarch-powerpc/config-arch-64
@@ -2,7 +2,7 @@
 ## file: arch/powerpc/Kconfig
 ##
 CONFIG_PPC_TRANSACTIONAL_MEM=y
-# CONFIG_CRASH_DUMP is not set
+CONFIG_CRASH_DUMP=y
 CONFIG_IRQ_ALL_CPUS=y
 CONFIG_NUMA=y
 ## choice: Page size



Bug#841044: Problem with gem network card

2016-11-01 Thread Thadeu Lima de Souza Cascardo
Hey, Christian.

Can you build a patched kernel or a patched driver? If you need help, I
can provide some instructions later this week, after I do it myself on a
G4 I am about to put my hands on.

If you already know how to do it, the patch below does two things: it
will do a chip reset instead of only a MAC reset when there is an
overflow. I hope this will fix things for you, but I would like to do
more tests so we can find out why the MAC reset is not working so I can
convince upstream to accept such an approach (which would require a
different patch).

The second thing it does is accept an ioctl to do the MAC and chip
reset, likely during normal operation. This will require a small
userspace program I will send later, so we can test whether the MAC and
chip reset work under light load on the card. The test would go this
way: setup the interface up, issue one of the resets, then try to use
the network. If it works fine, great, the reset didn't break anything,
and we need to investigate the specific occasion when there is an
overflow. If things stop working, then the reset itself is causing the
problem.

Thanks.
Cascardo.
---
diff --git a/drivers/net/ethernet/sun/sungem.c 
b/drivers/net/ethernet/sun/sungem.c
index d6ad0fb..e140363 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -473,6 +473,10 @@ static int gem_rxmac_interrupt(struct net_device *dev, 
struct gem *gp, u32 gem_s
dev->stats.rx_fifo_errors++;
 
ret = gem_rxmac_reset(gp);
+   if (ret == 0) {
+   netdev_err(dev, "RXMAC reset succeeded, will reset 
everything anyway.\n");
+   ret = 1;
+   }
}
 
if (rxmac_stat & MAC_RXSTAT_ACE)
@@ -2705,6 +2709,13 @@ static int gem_ioctl(struct net_device *dev, struct 
ifreq *ifr, int cmd)
data->val_in);
rc = 0;
break;
+   case SIOCDEVPRIVATE:
+   rc = gem_rxmac_reset(gp);
+   break;
+   case SIOCDEVPRIVATE + 1:
+   gem_schedule_reset(gp);
+   rc = 0;
+   break;
}
return rc;
 }



Re: firmware-nonfree : ipw2200 ?

2008-10-27 Thread Thadeu Lima de Souza Cascardo
On Mon, Oct 27, 2008 at 10:49:53AM +0100, Franklin PIAT wrote:
 Which command do I use, to generate the debian/rules.gen?
 linux-support-* provides no README file unfortunately.
 
 According to the license, I need to place a symlink to the license,
 in /lib/firmware (sorry lintian and fhs). Should I :
 1. create a [links] section in the define (and modify gencontrol)
 2. create a ipw2200/links file (and copy it to debian/*.links)
 3. create a file debian/firmware-ipw2200.links [ouch].
 4. do something else (maybe in debian/templates)?
 
 Thanks,
 
 Franklin
 

If I've read the FAQ (posted earlier in this thread) correctly, if
Debian uses a centralized location for license files, which
/usr/share/doc/packagename/copyright is, then Debian should be able to
put the license there and does not need to put a copy in the same
directory as the firmware files.

Regards,
Cascardo.


signature.asc
Description: Digital signature


Bug#364672: linux-image-2.6.26-1-686: Workaround for intel8x0 suspend

2008-08-11 Thread Thadeu Lima de Souza Cascardo
On Mon, Aug 11, 2008 at 06:10:44PM +0200, maximilian attems wrote:
 On Tue, 05 Aug 2008, Thadeu Lima de Souza Cascardo wrote:
 
  Package: linux-image-2.6.26-1-686
  Version: 2.6.26-1
  Followup-For: Bug #364672
  
  I have this bug here, although I don't know it is for the same reason,
  since what solves the problem here is disabling
  CONFIG_SND_AC97_POWER_SAVE, which was introduced after 2.6.18. I've sent
  a patch upstream trying to fix this, but it was not accepted yet, since
  it was not the right fix.
  
  Please, would you disable CONFIG_SND_AC97_POWER_SAVE for lenny?
 afair it can be disabled on boot time.
 
 -- 
 maks

You can disable AC97 power saving, but that won't fix the problem I am
describing, because the intel8x0 driver will do a cold reset when
resuming instead of a warm reset if the config option is enabled,
whatever the ac97_codec option is.

Regards,
Thadeu Cascardo.


signature.asc
Description: Digital signature


Bug#364672: linux-image-2.6.26-1-686: Workaround for intel8x0 suspend

2008-08-05 Thread Thadeu Lima de Souza Cascardo
Package: linux-image-2.6.26-1-686
Version: 2.6.26-1
Followup-For: Bug #364672

I have this bug here, although I don't know it is for the same reason,
since what solves the problem here is disabling
CONFIG_SND_AC97_POWER_SAVE, which was introduced after 2.6.18. I've sent
a patch upstream trying to fix this, but it was not accepted yet, since
it was not the right fix.

Please, would you disable CONFIG_SND_AC97_POWER_SAVE for lenny?

Regards,
Thadeu Cascardo.


-- Package-specific info:

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.27-rc1 (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages linux-image-2.6.26-1-686 depends on:
ii  cdebconf [debconf-2.0]0.131  Debian Configuration Management Sy
ii  debconf [debconf-2.0] 1.5.22 Debian configuration management sy
ii  initramfs-tools [linux-initra 0.92e  tools for generating an initramfs
ii  module-init-tools 3.4-1  tools for managing Linux kernel mo

Versions of packages linux-image-2.6.26-1-686 recommends:
ii  libc6-i6862.7-12 GNU C Library: Shared libraries [i

-- debconf information excluded



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]