#include <mach/host_info.h>
#include <mach/mach_host.h>
#include <arm/cpuid.h>
+#include <kern/zalloc.h>
#include <libkern/libkern.h>
+#include <pexpert/device_tree.h>
#if HYPERVISOR
#include <kern/hv_support.h>
sizeof(integer_t),
arm_host_info, "I", "Number of enabled threads per package");
+static SECURITY_READ_ONLY_LATE(char*) brand_string = NULL;
+static SECURITY_READ_ONLY_LATE(size_t) brand_string_len = 0;
+
+/*
+ * SecureDTLookupEntry() is only guaranteed to work before PE_init_iokit(),
+ * so we load the brand string (if available) in a startup handler.
+ */
+__startup_func
+static void
+sysctl_load_brand_string(void)
+{
+ DTEntry node;
+ void const *value = NULL;
+ unsigned int size = 0;
+
+ if (kSuccess != SecureDTLookupEntry(0, "/product", &node)) {
+ return;
+ }
+
+ if (kSuccess != SecureDTGetProperty(node, "product-soc-name", (void const **) &value, &size)) {
+ return;
+ }
+
+ if (size == 0) {
+ return;
+ }
+
+ brand_string = zalloc_permanent(size, ZALIGN_NONE);
+ if (brand_string == NULL) {
+ return;
+ }
+
+ memcpy(brand_string, value, size);
+ brand_string_len = size;
+}
+STARTUP(SYSCTL, STARTUP_RANK_MIDDLE, sysctl_load_brand_string);
+
/*
* machdep.cpu.brand_string
*
* x86: derived from CPUID data.
- * ARM: cons something up from the CPUID register. Could include cpufamily
- * here and map it to a "marketing" name, but there's no obvious need;
+ * ARM: Grab the product string from the device tree, if it exists.
+ * Otherwise, cons something up from the CPUID register.
* the value is already exported via the commpage. So keep it simple.
*/
static int
__unused void *unused_arg1 = arg1;
__unused int unused_arg2 = arg2;
+ if (brand_string != NULL) {
+ return SYSCTL_OUT(req, brand_string, brand_string_len);
+ }
+
const char *impl;
switch (cpuid_info()->arm_info.arm_implementor) {
SYSCTL_PROC_MACHDEP_CPU_SYSREG(ID_AA64MMFR0_EL1);
// ARM64: AArch64 Instruction Set Attribute Register 1
SYSCTL_PROC_MACHDEP_CPU_SYSREG(ID_AA64ISAR1_EL1);
-/*
- * ARM64: AArch64 Guarded Execution Mode GENTER Vector
- *
- * Workaround for pre-H13, since register cannot be read unless in guarded
- * mode, thus expose software convention that GXF_ENTRY_EL1 is always set
- * to the address of the gxf_ppl_entry_handler.
- */
-#endif /* DEVELOPMENT || DEBUG */
-#if HYPERVISOR
-SYSCTL_NODE(_kern, OID_AUTO, hv, CTLFLAG_RW | CTLFLAG_LOCKED, 0, "Hypervisor info");
-
-SYSCTL_INT(_kern_hv, OID_AUTO, supported,
- CTLFLAG_KERN | CTLFLAG_RD | CTLFLAG_LOCKED,
- &hv_support_available, 0, "");
-
-extern unsigned int arm64_num_vmids;
-
-SYSCTL_UINT(_kern_hv, OID_AUTO, max_address_spaces,
- CTLFLAG_KERN | CTLFLAG_RD | CTLFLAG_LOCKED,
- &arm64_num_vmids, 0, "");
-
-extern uint64_t pmap_ipa_size(uint64_t granule);
-
-static int
-sysctl_ipa_size_16k SYSCTL_HANDLER_ARGS
-{
-#pragma unused(arg1, arg2, oidp)
- uint64_t return_value = pmap_ipa_size(16384);
- return SYSCTL_OUT(req, &return_value, sizeof(return_value));
-}
-
-SYSCTL_PROC(_kern_hv, OID_AUTO, ipa_size_16k,
- CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED,
- 0, 0, sysctl_ipa_size_16k, "P",
- "Maximum size allowed for 16K-page guest IPA spaces");
-
-static int
-sysctl_ipa_size_4k SYSCTL_HANDLER_ARGS
-{
-#pragma unused(arg1, arg2, oidp)
- uint64_t return_value = pmap_ipa_size(4096);
- return SYSCTL_OUT(req, &return_value, sizeof(return_value));
-}
-
-SYSCTL_PROC(_kern_hv, OID_AUTO, ipa_size_4k,
- CTLFLAG_RD | CTLTYPE_QUAD | CTLFLAG_LOCKED,
- 0, 0, sysctl_ipa_size_4k, "P",
- "Maximum size allowed for 4K-page guest IPA spaces");
+#endif /* DEVELOPMENT || DEBUG */
-#endif // HYPERVISOR