summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-07-22 09:13:49 +0000
committerkib <kib@FreeBSD.org>2010-07-22 09:13:49 +0000
commit9ac2754b6d3dd9b7de4909a0d80515d971da738e (patch)
treea1e7b78633c799b8be45f7c7e0bf35589eceef96 /sys/amd64
parent3f34a9652f0bdd0c831fbb46eb6f576ec725fd9c (diff)
downloadFreeBSD-src-9ac2754b6d3dd9b7de4909a0d80515d971da738e.zip
FreeBSD-src-9ac2754b6d3dd9b7de4909a0d80515d971da738e.tar.gz
When compat32 binary asks for the value of hw.machine_arch, report the
name of 32bit sibling architecture instead of the host one. Do the same for hw.machine on amd64. Add a safety belt debug.adaptive_machine_arch sysctl, to turn the substitution off. Reviewed by: jhb, nwhitehorn MFC after: 2 weeks
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/identcpu.c26
-rw-r--r--sys/amd64/include/param.h3
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c
index 52e7568..b188c97 100644
--- a/sys/amd64/amd64/identcpu.c
+++ b/sys/amd64/amd64/identcpu.c
@@ -76,8 +76,30 @@ static void print_via_padlock_info(void);
int cpu_class;
char machine[] = "amd64";
-SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
- machine, 0, "Machine class");
+
+#ifdef SCTL_MASK32
+extern int adaptive_machine_arch;
+#endif
+
+static int
+sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
+{
+#ifdef SCTL_MASK32
+ static const char machine32[] = "i386";
+#endif
+ int error;
+
+#ifdef SCTL_MASK32
+ if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch)
+ error = SYSCTL_OUT(req, machine32, sizeof(machine32));
+ else
+#endif
+ error = SYSCTL_OUT(req, machine, sizeof(machine));
+ return (error);
+
+}
+SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD,
+ NULL, 0, sysctl_hw_machine, "A", "Machine class");
static char cpu_model[128];
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h
index c940597..9a742f9 100644
--- a/sys/amd64/include/param.h
+++ b/sys/amd64/include/param.h
@@ -59,6 +59,9 @@
#ifndef MACHINE_ARCH
#define MACHINE_ARCH "amd64"
#endif
+#ifndef MACHINE_ARCH32
+#define MACHINE_ARCH32 "i386"
+#endif
#if defined(SMP) || defined(KLD_MODULE)
#define MAXCPU 32
OpenPOWER on IntegriCloud