diff --git a/cli/kata-check_amd64.go b/cli/kata-check_amd64.go index db46e246cb..a642602059 100644 --- a/cli/kata-check_amd64.go +++ b/cli/kata-check_amd64.go @@ -74,3 +74,7 @@ func hostIsVMContainerCapable(details vmContainerCapableDetails) error { func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool { return genericArchKernelParamHandler(onVMM, fields, msg) } + +func getCPUDetails() (vendor, model string, err error) { + return genericGetCPUDetails() +} diff --git a/cli/kata-check_arm64.go b/cli/kata-check_arm64.go index ab73393df1..35a4d807f9 100644 --- a/cli/kata-check_arm64.go +++ b/cli/kata-check_arm64.go @@ -5,12 +5,16 @@ package main -import "github.com/sirupsen/logrus" +import ( + "fmt" + + "github.com/sirupsen/logrus" +) const ( cpuFlagsTag = "Features" archCPUVendorField = "CPU implementer" - archCPUModelField = "CPU variant" + archCPUModelField = "CPU architecture" ) // archRequiredCPUFlags maps a CPU flag value to search for and a @@ -49,9 +53,70 @@ func archHostCanCreateVMContainer() error { // hostIsVMContainerCapable checks to see if the host is theoretically capable // of creating a VM container. func hostIsVMContainerCapable(details vmContainerCapableDetails) error { - return genericHostIsVMContainerCapable(details) + count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler) + if err != nil { + return err + } + + if count == 0 { + return nil + } + + return fmt.Errorf("ERROR: %s", failMessage) + } func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool { return genericArchKernelParamHandler(onVMM, fields, msg) } + +// The CPU Vendor here for Arm means the CPU core +// IP Implementer. +// normalizeArmVendor maps 'CPU implementer' in /proc/cpuinfo +// to human-readable description of that value. +func normalizeArmVendor(vendor string) string { + + switch vendor { + case "0x41": + vendor = "ARM Limited" + default: + vendor = "3rd Party Limited" + } + + return vendor +} + +// The CPU Model here for Arm means the Instruction set, that is +// the variant number of Arm processor. +// normalizeArmModel maps 'CPU architecture' in /proc/cpuinfo +// to human-readable description of that value. +func normalizeArmModel(model string) string { + switch model { + case "8": + model = "v8" + case "7", "7M", "?(12)", "?(13)", "?(14)", "?(15)", "?(16)", "?(17)": + model = "v7" + case "6", "6TEJ": + model = "v6" + case "5", "5T", "5TE", "5TEJ": + model = "v5" + case "4", "4T": + model = "v4" + case "3": + model = "v3" + default: + model = "unknown" + } + + return model +} + +func getCPUDetails() (vendor, model string, err error) { + if vendor, model, err := genericGetCPUDetails(); err == nil { + vendor = normalizeArmVendor(vendor) + model = normalizeArmModel(model) + return vendor, model, err + } else { + return vendor, model, err + } +} diff --git a/cli/kata-check_ppc64le.go b/cli/kata-check_ppc64le.go index 750338fdb7..152303876c 100644 --- a/cli/kata-check_ppc64le.go +++ b/cli/kata-check_ppc64le.go @@ -65,3 +65,7 @@ func kvmIsUsable() error { func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool { return genericArchKernelParamHandler(onVMM, fields, msg) } + +func getCPUDetails() (vendor, model string, err error) { + return genericGetCPUDetails() +} diff --git a/cli/utils.go b/cli/utils.go index df83a1aa85..61a8ee1edf 100644 --- a/cli/utils.go +++ b/cli/utils.go @@ -96,10 +96,10 @@ func getDistroDetails() (name, version string, err error) { return "", "", fmt.Errorf("failed to find expected fields in one of %v", files) } -// getCPUDetails returns the vendor and model of the CPU. +// genericGetCPUDetails returns the vendor and model of the CPU. // If it is not possible to determine both values an error is // returned. -func getCPUDetails() (vendor, model string, err error) { +func genericGetCPUDetails() (vendor, model string, err error) { cpuinfo, err := getCPUInfo(procCPUInfo) if err != nil { return "", "", err