[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/16] util/cacheinfo: fix crash when compiling with uClibc
From: |
Richard Henderson |
Subject: |
[PULL 02/16] util/cacheinfo: fix crash when compiling with uClibc |
Date: |
Tue, 21 Jan 2020 16:49:32 -1000 |
From: Carlos Santos <address@hidden>
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 <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
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.20.1
- [PULL 00/16] tcg patch queue, Richard Henderson, 2020/01/21
- [PULL 01/16] cputlb: Handle NB_MMU_MODES > TARGET_PAGE_BITS_MIN, Richard Henderson, 2020/01/21
- [PULL 02/16] util/cacheinfo: fix crash when compiling with uClibc,
Richard Henderson <=
- [PULL 03/16] vl: Remove unused variable in configure_accelerators, Richard Henderson, 2020/01/21
- [PULL 04/16] vl: Reduce scope of variables in configure_accelerators, Richard Henderson, 2020/01/21
- [PULL 05/16] vl: Remove useless test in configure_accelerators, Richard Henderson, 2020/01/21
- [PULL 06/16] vl: Only choose enabled accelerators in configure_accelerators, Richard Henderson, 2020/01/21
- [PULL 07/16] cputlb: Merge tlb_table_flush_by_mmuidx into tlb_flush_one_mmuidx_locked, Richard Henderson, 2020/01/21
- [PULL 08/16] cputlb: Make tlb_n_entries private to cputlb.c, Richard Henderson, 2020/01/21
- [PULL 09/16] cputlb: Pass CPUTLBDescFast to tlb_n_entries and sizeof_tlb, Richard Henderson, 2020/01/21
- [PULL 10/16] cputlb: Hoist tlb portions in tlb_mmu_resize_locked, Richard Henderson, 2020/01/21
- [PULL 11/16] cputlb: Hoist tlb portions in tlb_flush_one_mmuidx_locked, Richard Henderson, 2020/01/21
- [PULL 12/16] cputlb: Split out tlb_mmu_flush_locked, Richard Henderson, 2020/01/21