svn commit: r226039 - head/sys/x86/acpica

John Baldwin jhb at FreeBSD.org
Wed Oct 5 16:03:47 UTC 2011


Author: jhb
Date: Wed Oct  5 16:03:47 2011
New Revision: 226039
URL: http://svn.freebsd.org/changeset/base/226039

Log:
  Ignore SRAT memory entries if the memory range does not overlap with an
  existing phys_avail[] table.  If a hw.physmem setting causes a memory
  domain to not be present in phys_avail[], the SRAT table will now be
  ignored rather than triggering a panic when a CPU in the missing domain
  tries to allocate a page.
  
  MFC after:	1 week

Modified:
  head/sys/x86/acpica/srat.c

Modified: head/sys/x86/acpica/srat.c
==============================================================================
--- head/sys/x86/acpica/srat.c	Wed Oct  5 15:52:40 2011	(r226038)
+++ head/sys/x86/acpica/srat.c	Wed Oct  5 16:03:47 2011	(r226039)
@@ -59,6 +59,26 @@ static vm_paddr_t srat_physaddr;
 
 static void	srat_walk_table(acpi_subtable_handler *handler, void *arg);
 
+/*
+ * Returns true if a memory range overlaps with at least one range in
+ * phys_avail[].
+ */
+static int
+overlaps_phys_avail(vm_paddr_t start, vm_paddr_t end)
+{
+	int i;
+
+	for (i = 0; phys_avail[i] != 0 && phys_avail[i + 1] != 0; i += 2) {
+		if (phys_avail[i + 1] < start)
+			continue;
+		if (phys_avail[i] < end)
+			return (1);
+		break;
+	}
+	return (0);
+	
+}
+
 static void
 srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *arg)
 {
@@ -111,6 +131,12 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *e
 			    "enabled" : "disabled");
 		if (!(mem->Flags & ACPI_SRAT_MEM_ENABLED))
 			break;
+		if (!overlaps_phys_avail(mem->BaseAddress,
+		    mem->BaseAddress + mem->Length)) {
+			printf("SRAT: Ignoring memory at addr %jx\n",
+			    (uintmax_t)mem->BaseAddress);
+			break;
+		}
 		if (num_mem == VM_PHYSSEG_MAX) {
 			printf("SRAT: Too many memory regions\n");
 			*(int *)arg = ENXIO;


More information about the svn-src-all mailing list