virt inclusion category:bugfix bugzilla:https://atomgit.com/openeuler/kernel/issues/8756 CVE:NA ----------------------------------------------------------- Currently, there are two methods for determining whether a chip supports certain features: 1. Reading the chip's CPU type from the BIOS 2. Reading the value of the MIDR register The issue with method 1 is that each time a new chip is introduced, the corresponding CPU type needs to be defined, resulting in poor code compatibility. Therefore, method 2 has been adopted to replace method 1. Previous patches have already eliminated the dependency on CPU type, let's remove the definition of CPU type and its related interfaces. Signed-off-by:Li Qiqi <liqiqi23@huawei.com> --- arch/arm64/kvm/arm.c | 1 - arch/arm64/kvm/hisilicon/hisi_virt.c | 92 ---------------------------- arch/arm64/kvm/hisilicon/hisi_virt.h | 12 ---- 3 files changed, 105 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 7f7dbf90659f..93097a8876df 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2929,7 +2929,6 @@ static __init int kvm_arm_init(void) return err; } - probe_hisi_cpu_type(); kvm_ncsnp_support = hisi_ncsnp_supported(); kvm_dvmbm_support = hisi_dvmbm_supported(); kvm_info("KVM ncsnp %s\n", kvm_ncsnp_support ? "enabled" : "disabled"); diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.c b/arch/arm64/kvm/hisilicon/hisi_virt.c index a0a9748f1bec..1e5fc5d0ed00 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.c +++ b/arch/arm64/kvm/hisilicon/hisi_virt.c @@ -10,104 +10,12 @@ #include "hisi_virt.h" #include <linux/bitfield.h> -static enum hisi_cpu_type cpu_type = UNKNOWN_HI_TYPE; - static bool dvmbm_enabled; #ifdef CONFIG_ARM64_HISI_IPIV static bool ipiv_enabled; #endif -static const char * const hisi_cpu_type_str[] = { - "Hisi1612", - "Hisi1616", - "Hisi1620", - "HIP09", - "HIP10", - "HIP10C", - "HIP12", - "Unknown" -}; - -/* ACPI Hisi oem table id str */ -static const char * const oem_str[] = { - "HIP06 ", /* Hisi 1612 */ - "HIP07 ", /* Hisi 1616 */ - "HIP08 ", /* Hisi 1620 */ - "HIP09 ", /* HIP09 */ - "HIP10 ", /* HIP10 */ - "HIP10C ", /* HIP10C */ - "HIP12 " /* HIP12 */ -}; - -/* - * Probe Hisi CPU type form ACPI. - */ -static enum hisi_cpu_type acpi_get_hisi_cpu_type(void) -{ - struct acpi_table_header *table; - acpi_status status; - int i, str_size = ARRAY_SIZE(oem_str); - - /* Get oem table id from ACPI table header */ - status = acpi_get_table(ACPI_SIG_DSDT, 0, &table); - if (ACPI_FAILURE(status)) { - pr_warn("Failed to get ACPI table: %s\n", - acpi_format_exception(status)); - return UNKNOWN_HI_TYPE; - } - - for (i = 0; i < str_size; ++i) { - if (!strncmp(oem_str[i], table->oem_table_id, 8)) - return i; - } - - return UNKNOWN_HI_TYPE; -} - -/* of Hisi cpu model str */ -static const char * const of_model_str[] = { - "Hi1612", - "Hi1616" -}; - -/* - * Probe Hisi CPU type from DT. - */ -static enum hisi_cpu_type of_get_hisi_cpu_type(void) -{ - const char *model; - int ret, i, str_size = ARRAY_SIZE(of_model_str); - - /* - * Note: There may not be a "model" node in FDT, which - * is provided by the vendor. In this case, we are not - * able to get CPU type information through this way. - */ - ret = of_property_read_string(of_root, "model", &model); - if (ret < 0) { - pr_warn("Failed to get Hisi cpu model by OF.\n"); - return UNKNOWN_HI_TYPE; - } - - for (i = 0; i < str_size; ++i) { - if (strstr(model, of_model_str[i])) - return i; - } - - return UNKNOWN_HI_TYPE; -} - -void probe_hisi_cpu_type(void) -{ - if (!acpi_disabled) - cpu_type = acpi_get_hisi_cpu_type(); - else - cpu_type = of_get_hisi_cpu_type(); - - kvm_info("detected: Hisi CPU type '%s'\n", hisi_cpu_type_str[cpu_type]); -} - /* * We have the fantastic HHA ncsnp capability on Kunpeng 920, * with which hypervisor doesn't need to perform a lot of cache diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.h b/arch/arm64/kvm/hisilicon/hisi_virt.h index 180618e42cbc..b89c779e0869 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.h +++ b/arch/arm64/kvm/hisilicon/hisi_virt.h @@ -7,16 +7,6 @@ #define __HISI_VIRT_H__ #ifdef CONFIG_KVM_HISI_VIRT -enum hisi_cpu_type { - HI_1612, - HI_1616, - HI_1620, - HI_IP09, - HI_IP10, - HI_IP10C, - HI_IP12, - UNKNOWN_HI_TYPE -}; /* HIP12 */ #ifdef CONFIG_ARM64_HISI_IPIV @@ -91,7 +81,6 @@ enum hisi_cpu_type { #define DVMBM_DIE2_CLUSTER_SHIFT_HIP12 0 #define DVMBM_MAX_DIES_HIP12 8 -void probe_hisi_cpu_type(void); bool hisi_ncsnp_supported(void); bool hisi_dvmbm_supported(void); #ifdef CONFIG_ARM64_HISI_IPIV @@ -110,7 +99,6 @@ void kvm_tlbi_dvmbm_vcpu_load(struct kvm_vcpu *vcpu); void kvm_tlbi_dvmbm_vcpu_put(struct kvm_vcpu *vcpu); void kvm_hisi_reload_lsudvmbm(struct kvm *kvm); #else -static inline void probe_hisi_cpu_type(void) {} static inline bool hisi_ncsnp_supported(void) { return false; -- 2.43.0