svn commit: r365461 - head/sys/libkern

Mitchell Horne mhorne at FreeBSD.org
Tue Sep 8 15:39:20 UTC 2020


Author: mhorne
Date: Tue Sep  8 15:39:19 2020
New Revision: 365461
URL: https://svnweb.freebsd.org/changeset/base/365461

Log:
  arm64: check for CRC32 support via HWCAP
  
  Doing it this way eliminates the assumption about homogeneous support
  for the feature, since HWCAP values are only set if support is present
  on all CPUs.
  
  Reviewed by:	tuexen, markj
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D26032

Modified:
  head/sys/libkern/gsb_crc32.c

Modified: head/sys/libkern/gsb_crc32.c
==============================================================================
--- head/sys/libkern/gsb_crc32.c	Tue Sep  8 15:36:38 2020	(r365460)
+++ head/sys/libkern/gsb_crc32.c	Tue Sep  8 15:39:19 2020	(r365461)
@@ -58,7 +58,8 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #if defined(__aarch64__)
-#include <machine/cpu.h>
+#include <machine/elf.h>
+#include <machine/md_var.h>
 #endif
 #endif /* _KERNEL */
 
@@ -755,14 +756,7 @@ calculate_crc32c(uint32_t crc32c,
 	} else
 #endif
 #if defined(__aarch64__)
-	uint64_t reg;
-
-	/*
-	 * We only test for CRC32 support on the CPU with index 0 assuming that
-	 * this applies to all CPUs.
-	 */
-	reg = READ_SPECIALREG(id_aa64isar0_el1);
-	if (ID_AA64ISAR0_CRC32_VAL(reg) != ID_AA64ISAR0_CRC32_NONE) {
+	if ((elf_hwcap & HWCAP_CRC32) != 0) {
 		return (armv8_crc32c(crc32c, buffer, length));
 	} else
 #endif


More information about the svn-src-head mailing list