[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/80] tcg/aarch64: Detect have_lse, have_lse2 for darwin
|
From: |
Richard Henderson |
|
Subject: |
[PULL 12/80] tcg/aarch64: Detect have_lse, have_lse2 for darwin |
|
Date: |
Tue, 16 May 2023 12:40:37 -0700 |
These features are present for Apple M1.
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/aarch64/tcg-target.c.inc | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index fc551a3d10..c64606af5b 100644
--- a/tcg/aarch64/tcg-target.c.inc
+++ b/tcg/aarch64/tcg-target.c.inc
@@ -16,6 +16,9 @@
#ifdef __linux__
#include <asm/hwcap.h>
#endif
+#ifdef CONFIG_DARWIN
+#include <sys/sysctl.h>
+#endif
/* We're going to re-use TCGType in setting of the SF bit, which controls
the size of the operation performed. If we know the values match, it
@@ -2903,6 +2906,27 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode
op)
}
}
+#ifdef CONFIG_DARWIN
+static bool sysctl_for_bool(const char *name)
+{
+ int val = 0;
+ size_t len = sizeof(val);
+
+ if (sysctlbyname(name, &val, &len, NULL, 0) == 0) {
+ return val != 0;
+ }
+
+ /*
+ * We might in the future ask for properties not present in older kernels,
+ * but we're only asking about static properties, all of which should be
+ * 'int'. So we shouln't see ENOMEM (val too small), or any of the other
+ * more exotic errors.
+ */
+ assert(errno == ENOENT);
+ return false;
+}
+#endif
+
static void tcg_target_init(TCGContext *s)
{
#ifdef __linux__
@@ -2910,6 +2934,10 @@ static void tcg_target_init(TCGContext *s)
have_lse = hwcap & HWCAP_ATOMICS;
have_lse2 = hwcap & HWCAP_USCAT;
#endif
+#ifdef CONFIG_DARWIN
+ have_lse = sysctl_for_bool("hw.optional.arm.FEAT_LSE");
+ have_lse2 = sysctl_for_bool("hw.optional.arm.FEAT_LSE2");
+#endif
tcg_target_available_regs[TCG_TYPE_I32] = 0xffffffffu;
tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffffu;
--
2.34.1
- [PULL 07/80] tcg/tci: Use helper_{ld,st}*_mmu for user-only, (continued)
- [PULL 07/80] tcg/tci: Use helper_{ld,st}*_mmu for user-only, Richard Henderson, 2023/05/16
- [PULL 05/80] tcg: Unify helper_{be,le}_{ld,st}*, Richard Henderson, 2023/05/16
- [PULL 09/80] meson: Detect atomic128 support with optimization, Richard Henderson, 2023/05/16
- [PULL 06/80] accel/tcg: Implement helper_{ld,st}*_mmu for user-only, Richard Henderson, 2023/05/16
- [PULL 08/80] tcg: Add 128-bit guest memory primitives, Richard Henderson, 2023/05/16
- [PULL 04/80] accel/tcg: Honor atomicity of stores, Richard Henderson, 2023/05/16
- [PULL 10/80] tcg/i386: Add have_atomic16, Richard Henderson, 2023/05/16
- [PULL 11/80] tcg/aarch64: Detect have_lse, have_lse2 for linux, Richard Henderson, 2023/05/16
- [PULL 13/80] tcg/i386: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 14/80] tcg/aarch64: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 12/80] tcg/aarch64: Detect have_lse, have_lse2 for darwin,
Richard Henderson <=
- [PULL 17/80] tcg/riscv: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 15/80] tcg/ppc: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 16/80] tcg/loongarch64: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 18/80] tcg/arm: Adjust constraints on qemu_ld/st, Richard Henderson, 2023/05/16
- [PULL 19/80] tcg/arm: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 20/80] tcg/mips: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 21/80] tcg/s390x: Use full load/store helpers in user-only mode, Richard Henderson, 2023/05/16
- [PULL 22/80] tcg/sparc64: Allocate %g2 as a third temporary, Richard Henderson, 2023/05/16
- [PULL 23/80] tcg/sparc64: Rename tcg_out_movi_imm13 to tcg_out_movi_s13, Richard Henderson, 2023/05/16
- [PULL 25/80] tcg/sparc64: Rename tcg_out_movi_imm32 to tcg_out_movi_u32, Richard Henderson, 2023/05/16