diff mbox series

package/qemu: fix crash with uClibc-ng

Message ID 20191019020928.2931-1-unixmania@gmail.com
State Accepted
Headers show
Series package/qemu: fix crash with uClibc-ng | expand

Commit Message

Carlos Santos Oct. 19, 2019, 2:09 a.m. UTC
From: Carlos Santos <unixmania@gmail.com>

On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which
is a valid result, meaning that the limit is indeterminate. Add a patch
that handles this situation using fallback values instead of crashing
due to an assertion failure.

Upstream status:
   https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch

Comments

Thomas Petazzoni Oct. 20, 2019, 2:26 p.m. UTC | #1
On Fri, 18 Oct 2019 23:09:28 -0300
unixmania@gmail.com wrote:

> From: Carlos Santos <unixmania@gmail.com>
> 
> On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which
> is a valid result, meaning that the limit is indeterminate. Add a patch
> that handles this situation using fallback values instead of crashing
> due to an assertion failure.
> 
> Upstream status:
>    https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html
> 
> Signed-off-by: Carlos Santos <unixmania@gmail.com>
> ---
>  ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch

Applied to master, thanks.

Thomas
Carlos Santos Oct. 21, 2019, 2:28 p.m. UTC | #2
On Sun, Oct 20, 2019 at 11:26 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> On Fri, 18 Oct 2019 23:09:28 -0300
> unixmania@gmail.com wrote:
>
> > From: Carlos Santos <unixmania@gmail.com>
> >
> > On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which
> > is a valid result, meaning that the limit is indeterminate. Add a patch
> > that handles this situation using fallback values instead of crashing
> > due to an assertion failure.
> >
> > Upstream status:
> >    https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html
> >
> > Signed-off-by: Carlos Santos <unixmania@gmail.com>
> > ---
> >  ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
> >  1 file changed, 43 insertions(+)
> >  create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch
>
> Applied to master, thanks.
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

Still appears as "New" in patchwork: https://patchwork.ozlabs.org/patch/1179727/
Thomas Petazzoni Oct. 21, 2019, 2:31 p.m. UTC | #3
On Mon, 21 Oct 2019 11:28:55 -0300
Carlos Santos <unixmania@gmail.com> wrote:

> > >  ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
> > >  1 file changed, 43 insertions(+)
> > >  create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch  
> >
> > Applied to master, thanks.
> >
> > Thomas
> > --
> > Thomas Petazzoni, CTO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com  
> 
> Still appears as "New" in patchwork: https://patchwork.ozlabs.org/patch/1179727/

Thanks for reporting, I fixed the patch state. I guess I got distracted
by some $reallife interruption :-)

Thomas
Peter Korsgaard Oct. 30, 2019, 8:58 a.m. UTC | #4
>>>>> "unixmania" == unixmania  <unixmania@gmail.com> writes:

 > From: Carlos Santos <unixmania@gmail.com>
 > On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which
 > is a valid result, meaning that the limit is indeterminate. Add a patch
 > that handles this situation using fallback values instead of crashing
 > due to an assertion failure.

 > Upstream status:
 >    https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html

 > Signed-off-by: Carlos Santos <unixmania@gmail.com>

Committed to 2019.02.x and 2019.08.x, thanks.
diff mbox series

Patch

diff --git a/package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch b/package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch
new file mode 100644
index 0000000000..d1b9e35709
--- /dev/null
+++ b/package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch
@@ -0,0 +1,43 @@ 
+From d82b8540ecaf3cb09a033e4971d8645d3343211e Mon Sep 17 00:00:00 2001
+From: Carlos Santos <casantos@redhat.com>
+Date: Wed, 16 Oct 2019 22:27:30 -0300
+Subject: [PATCH] util/cacheinfo: fix crash when compiling with uClibc
+
+uClibc defines _SC_LEVEL1_ICACHE_LINESIZE and _SC_LEVEL1_DCACHE_LINESIZE
+but the corresponding sysconf calls returns -1, which is a valid result,
+meaning that the limit is indeterminate.
+
+Handle this situation using the fallback values instead of crashing due
+to an assertion failure.
+
+Signed-off-by: Carlos Santos <casantos@redhat.com>
+---
+ util/cacheinfo.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/util/cacheinfo.c b/util/cacheinfo.c
+index ea6f3e99bf..d94dc6adc8 100644
+--- a/util/cacheinfo.c
++++ b/util/cacheinfo.c
+@@ -93,10 +93,16 @@ static void sys_cache_info(int *isize, int *dsize)
+ static void sys_cache_info(int *isize, int *dsize)
+ {
+ # ifdef _SC_LEVEL1_ICACHE_LINESIZE
+-    *isize = sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
++    int tmp_isize = (int) sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
++    if (tmp_isize > 0) {
++        *isize = tmp_isize;
++    }
+ # endif
+ # ifdef _SC_LEVEL1_DCACHE_LINESIZE
+-    *dsize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
++    int tmp_dsize = (int) sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
++    if (tmp_dsize > 0) {
++        *dsize = tmp_dsize;
++    }
+ # endif
+ }
+ #endif /* sys_cache_info */
+-- 
+2.18.1
+