From 37d4606018e6b0ddac2f5024ac5b31d3efa14f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Fri, 7 Jun 2024 08:51:14 +0200 Subject: [PATCH] Fix sshutil cpu.HasAES detection on linux/arm64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders F Björklund --- pkg/sshutil/sshutil.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/sshutil/sshutil.go b/pkg/sshutil/sshutil.go index 1963fc564d6..31930d3c868 100644 --- a/pkg/sshutil/sshutil.go +++ b/pkg/sshutil/sshutil.go @@ -324,6 +324,11 @@ func detectValidPublicKey(content string) bool { func detectAESAcceleration() bool { if !cpu.Initialized { + if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" { + // cpu.Initialized seems to always be false, even when the cpu.ARM64 struct is filled out + // it is only being set by readARM64Registers, but not by readHWCAP or readLinuxProcCPUInfo + return cpu.ARM64.HasAES + } if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { // golang.org/x/sys/cpu supports darwin/amd64, linux/amd64, and linux/arm64, // but apparently lacks support for darwin/arm64: https://github.com/golang/sys/blob/v0.5.0/cpu/cpu_arm64.go#L43-L60