@@ -20,6 +20,7 @@ use crate::arch::aarch64::kvm::OptionalCapabilities;
20
20
use crate :: arch:: aarch64:: regs:: { Aarch64RegisterVec , KVM_REG_ARM64_SVE_VLS } ;
21
21
use crate :: cpu_config:: aarch64:: custom_cpu_template:: VcpuFeatures ;
22
22
use crate :: cpu_config:: templates:: CpuConfiguration ;
23
+ use crate :: logger:: warn;
23
24
use crate :: logger:: { IncMetric , METRICS , error} ;
24
25
use crate :: vcpu:: { VcpuConfig , VcpuError } ;
25
26
use crate :: vstate:: memory:: { Address , GuestMemoryMmap } ;
@@ -41,25 +42,18 @@ pub enum VcpuArchError {
41
42
SetMp ( kvm_ioctls:: Error ) ,
42
43
/// Failed FamStructWrapper operation: {0}
43
44
Fam ( vmm_sys_util:: fam:: Error ) ,
44
- /// {0}
45
- GetMidrEl1 ( String ) ,
46
45
/// Failed to set/get device attributes for vCPU: {0}
47
46
DeviceAttribute ( kvm_ioctls:: Error ) ,
48
47
}
49
48
50
49
/// Extract the Manufacturer ID from the host.
51
50
/// The ID is found between bits 24-31 of MIDR_EL1 register.
52
- pub fn get_manufacturer_id_from_host ( ) -> Result < u32 , VcpuArchError > {
51
+ pub fn get_manufacturer_id_from_host ( ) -> Option < u32 > {
53
52
let midr_el1_path = "/sys/devices/system/cpu/cpu0/regs/identification/midr_el1" ;
54
- let midr_el1 = std:: fs:: read_to_string ( midr_el1_path) . map_err ( |err| {
55
- VcpuArchError :: GetMidrEl1 ( format ! ( "Failed to get MIDR_EL1 from host path: {err}" ) )
56
- } ) ?;
53
+ let midr_el1 = std:: fs:: read_to_string ( midr_el1_path) . ok ( ) ?;
57
54
let midr_el1_trimmed = midr_el1. trim_end ( ) . trim_start_matches ( "0x" ) ;
58
- let manufacturer_id = u32:: from_str_radix ( midr_el1_trimmed, 16 ) . map_err ( |err| {
59
- VcpuArchError :: GetMidrEl1 ( format ! ( "Invalid MIDR_EL1 found on host: {err}" , ) )
60
- } ) ?;
61
-
62
- Ok ( manufacturer_id >> 24 )
55
+ let manufacturer_id = u32:: from_str_radix ( midr_el1_trimmed, 16 ) . ok ( ) ?;
56
+ Some ( manufacturer_id >> 24 )
63
57
}
64
58
65
59
/// Saves states of registers into `state`.
0 commit comments