From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH v3 5/6] util: Use qemu_getauxval in linux qemu_cache_utils_init
Date: Thu, 17 Oct 2013 08:29:40 -0700 [thread overview]
Message-ID: <1382023781-26323-6-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1382023781-26323-1-git-send-email-rth@twiddle.net>
With this we no longer pass down envp, and thus all systems can have
the same void prototype. So also eliminate a useless thunk.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
include/qemu/cache-utils.h | 4 ++--
linux-user/main.c | 2 +-
util/cache-utils.c | 51 ++++++++++++++++++----------------------------
vl.c | 2 +-
4 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/include/qemu/cache-utils.h b/include/qemu/cache-utils.h
index 2c57f78..211245b 100644
--- a/include/qemu/cache-utils.h
+++ b/include/qemu/cache-utils.h
@@ -12,7 +12,7 @@ struct qemu_cache_conf {
extern struct qemu_cache_conf qemu_cache_conf;
-void qemu_cache_utils_init(char **envp);
+void qemu_cache_utils_init(void);
/* mildly adjusted code from tcg-dyngen.c */
static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
@@ -38,7 +38,7 @@ static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
}
#else
-#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0)
+#define qemu_cache_utils_init() do { } while (0)
#endif
#endif /* QEMU_CACHE_UTILS_H */
diff --git a/linux-user/main.c b/linux-user/main.c
index 0e45336..50db755 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3702,7 +3702,7 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_QOM);
qemu_init_auxval(envp);
- qemu_cache_utils_init(envp);
+ qemu_cache_utils_init();
if ((envlist = envlist_create()) == NULL) {
(void) fprintf(stderr, "Unable to allocate envlist\n");
diff --git a/util/cache-utils.c b/util/cache-utils.c
index b94013a..0470030 100644
--- a/util/cache-utils.c
+++ b/util/cache-utils.c
@@ -1,3 +1,4 @@
+#include "qemu-common.h"
#include "qemu/cache-utils.h"
#if defined(_ARCH_PPC)
@@ -9,31 +10,33 @@ struct qemu_cache_conf qemu_cache_conf = {
#if defined _AIX
#include <sys/systemcfg.h>
-static void ppc_init_cacheline_sizes(void)
+void qemu_cache_utils_init(void)
{
qemu_cache_conf.icache_bsize = _system_configuration.icache_line;
qemu_cache_conf.dcache_bsize = _system_configuration.dcache_line;
}
#elif defined __linux__
+#include "qemu/osdep.h"
+#include "elf.h"
-#define QEMU_AT_NULL 0
-#define QEMU_AT_DCACHEBSIZE 19
-#define QEMU_AT_ICACHEBSIZE 20
-
-static void ppc_init_cacheline_sizes(char **envp)
+void qemu_cache_utils_init(void)
{
- unsigned long *auxv;
-
- while (*envp++);
+ unsigned long dsize = qemu_getauxval(AT_DCACHEBSIZE);
+ unsigned long isize = qemu_getauxval(AT_ICACHEBSIZE);
- for (auxv = (unsigned long *) envp; *auxv != QEMU_AT_NULL; auxv += 2) {
- switch (*auxv) {
- case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
- case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
- default: break;
+ if (dsize == 0 || isize == 0) {
+ if (dsize == 0) {
+ fprintf(stderr, "getauxval AT_DCACHEBSIZE failed\n");
+ }
+ if (isize == 0) {
+ fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
}
+ exit(1);
+
}
+ qemu_cache_conf.dcache_bsize = dsize;
+ qemu_cache_conf.icache_bsize = isize;
}
#elif defined __APPLE__
@@ -41,7 +44,7 @@ static void ppc_init_cacheline_sizes(char **envp)
#include <sys/types.h>
#include <sys/sysctl.h>
-static void ppc_init_cacheline_sizes(void)
+void qemu_cache_utils_init(void)
{
size_t len;
unsigned cacheline;
@@ -55,9 +58,8 @@ static void ppc_init_cacheline_sizes(void)
qemu_cache_conf.icache_bsize = cacheline;
}
}
-#endif
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -65,7 +67,7 @@ static void ppc_init_cacheline_sizes(void)
#include <sys/types.h>
#include <sys/sysctl.h>
-static void ppc_init_cacheline_sizes(void)
+void qemu_cache_utils_init(void)
{
size_t len = 4;
unsigned cacheline;
@@ -81,17 +83,4 @@ static void ppc_init_cacheline_sizes(void)
}
#endif
-#ifdef __linux__
-void qemu_cache_utils_init(char **envp)
-{
- ppc_init_cacheline_sizes(envp);
-}
-#else
-void qemu_cache_utils_init(char **envp)
-{
- (void) envp;
- ppc_init_cacheline_sizes();
-}
-#endif
-
#endif /* _ARCH_PPC */
diff --git a/vl.c b/vl.c
index 1b0b2d3..4b46c70 100644
--- a/vl.c
+++ b/vl.c
@@ -2894,7 +2894,7 @@ int main(int argc, char **argv, char **envp)
rtc_clock = QEMU_CLOCK_HOST;
qemu_init_auxval(envp);
- qemu_cache_utils_init(envp);
+ qemu_cache_utils_init();
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
--
1.8.3.1
next prev parent reply other threads:[~2013-10-17 15:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 15:29 [Qemu-devel] [PATCH v3 0/6] Improve getauxval support Richard Henderson
2013-10-17 15:29 ` [Qemu-devel] [PATCH v3 1/6] osdep: Create qemu_getauxval and qemu_init_auxval Richard Henderson
2013-10-17 15:33 ` Peter Maydell
2013-10-17 15:29 ` [Qemu-devel] [PATCH v3 2/6] tcg-ppc64: Use qemu_getauxval Richard Henderson
2013-10-17 15:29 ` [Qemu-devel] [PATCH v3 3/6] tcg-arm: " Richard Henderson
2013-11-29 11:29 ` Peter Maydell
2013-10-17 15:29 ` [Qemu-devel] [PATCH v3 4/6] tcg-s390: Use qemu_getauxval in query_facilities Richard Henderson
2013-10-17 15:29 ` Richard Henderson [this message]
2013-10-17 15:29 ` [Qemu-devel] [PATCH v3 6/6] linux-user: Use qemu_getauxval for AT_EXECFD Richard Henderson
2013-10-17 15:33 ` Peter Maydell
2013-10-28 17:30 ` [Qemu-devel] [PATCH v3 0/6] Improve getauxval support Richard Henderson
2013-11-19 6:58 ` Richard Henderson
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=1382023781-26323-6-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).