Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Aug 2020 02:12:15 +0000 (UTC)
From:      D Scott Phillips <scottph@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364797 - in head/sys/arm64: acpica arm64
Message-ID:  <202008260212.07Q2CFTo032694@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottph
Date: Wed Aug 26 02:12:15 2020
New Revision: 364797
URL: https://svnweb.freebsd.org/changeset/base/364797

Log:
  arm64/acpi: Give the real PA limit to ACPI
  
  Read PA bits from ID_AA64MMFR0_EL1.PARange.
  
  Reviewed by:	andrew, markj
  Approved by:	scottl (implicit)
  MFC after:	1 week
  Sponsored by:	Ampere Computing, Inc.
  Differential Revision:	https://reviews.freebsd.org/D26133

Modified:
  head/sys/arm64/acpica/acpi_machdep.c
  head/sys/arm64/arm64/identcpu.c

Modified: head/sys/arm64/acpica/acpi_machdep.c
==============================================================================
--- head/sys/arm64/acpica/acpi_machdep.c	Wed Aug 26 02:07:46 2020	(r364796)
+++ head/sys/arm64/acpica/acpi_machdep.c	Wed Aug 26 02:12:15 2020	(r364797)
@@ -232,12 +232,47 @@ acpi_map_addr(struct acpi_generic_address *addr, bus_s
 static void
 parse_pxm_tables(void *dummy)
 {
+	uint64_t mmfr0, parange;
 
 	/* Only parse ACPI tables when booting via ACPI */
 	if (arm64_bus_method != ARM64_BUS_ACPI)
 		return;
 
-	acpi_pxm_init(MAXCPU, (vm_paddr_t)1 << 40);
+	if (!get_kernel_reg(ID_AA64MMFR0_EL1, &mmfr0)) {
+		/* chosen arbitrarily */
+		mmfr0 = ID_AA64MMFR0_PARange_1T;
+	}
+
+	switch (ID_AA64MMFR0_PARange_VAL(mmfr0)) {
+	case ID_AA64MMFR0_PARange_4G:
+		parange = (vm_paddr_t)4 << 30 /* GiB */;
+		break;
+	case ID_AA64MMFR0_PARange_64G:
+		parange = (vm_paddr_t)64 << 30 /* GiB */;
+		break;
+	case ID_AA64MMFR0_PARange_1T:
+		parange = (vm_paddr_t)1 << 40 /* TiB */;
+		break;
+	case ID_AA64MMFR0_PARange_4T:
+		parange = (vm_paddr_t)4 << 40 /* TiB */;
+		break;
+	case ID_AA64MMFR0_PARange_16T:
+		parange = (vm_paddr_t)16 << 40 /* TiB */;
+		break;
+	case ID_AA64MMFR0_PARange_256T:
+		parange = (vm_paddr_t)256 << 40 /* TiB */;
+		break;
+	case ID_AA64MMFR0_PARange_4P:
+		parange = (vm_paddr_t)4 << 50 /* PiB */;
+		break;
+	default:
+		/* chosen arbitrarily */
+		parange = (vm_paddr_t)1 << 40 /* TiB */;
+		printf("Unknown value for PARange in mmfr0 (%#lx)\n", mmfr0);
+		break;
+	}
+
+	acpi_pxm_init(MAXCPU, parange);
 	acpi_pxm_parse_tables();
 	acpi_pxm_set_mem_locality();
 }

Modified: head/sys/arm64/arm64/identcpu.c
==============================================================================
--- head/sys/arm64/arm64/identcpu.c	Wed Aug 26 02:07:46 2020	(r364796)
+++ head/sys/arm64/arm64/identcpu.c	Wed Aug 26 02:12:15 2020	(r364797)
@@ -916,6 +916,13 @@ static struct mrs_user_reg user_regs[] = {
 		.offset = __offsetof(struct cpu_desc, id_aa64dfr0),
 		.fields = id_aa64dfr0_fields,
 	},
+	{	/* id_aa64mmfr0_el1 */
+		.reg = ID_AA64MMFR0_EL1,
+		.CRm = 7,
+		.Op2 = 0,
+		.offset = __offsetof(struct cpu_desc, id_aa64mmfr0),
+		.fields = id_aa64mmfr0_fields,
+	},
 };
 
 #define	CPU_DESC_FIELD(desc, idx)					\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008260212.07Q2CFTo032694>