From 0457c6b44fd7856706acf57aea3de448e01040a5 Mon Sep 17 00:00:00 2001
Date: Fri, 22 Jan 2021 11:35:45 +0800
Subject: Backport of JDK-8191955

summary: incorrect prefetch distance causes an internal error
LLT:
Bug url: https://bugs.openjdk.java.net/browse/JDK-8191955
---
 hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
index 78e6f1144..211baa9dc 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
@@ -138,6 +138,17 @@ void VM_Version::get_processor_features() {
     if (PrefetchCopyIntervalInBytes >= 32768)
       PrefetchCopyIntervalInBytes = 32760;
   }
+
+  if (AllocatePrefetchDistance !=-1 && (AllocatePrefetchDistance & 7)) {
+    warning("AllocatePrefetchDistance must be multiple of 8");
+    AllocatePrefetchDistance &= ~7;
+  }
+
+  if (AllocatePrefetchStepSize & 7) {
+    warning("AllocatePrefetchStepSize must be multiple of 8");
+    AllocatePrefetchStepSize &= ~7;
+  }
+
   FLAG_SET_DEFAULT(UseSSE42Intrinsics, true);
 
   unsigned long auxv = getauxval(AT_HWCAP);
-- 
2.19.0

