mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-23 06:25:12 +00:00
pc: cpu: Consolidate apic-id validity checks in pc_cpu_pre_plug()
Machine code knows about all possible APIC IDs so use that instead of hack which does O(n^2) complexity duplicate checks, interating over global CPUs list. As result duplicate check is done only once with O(log n) complexity. Backports commit 4ec60c76d5ab513e375f17b043d2b9cb849adf6c from qemu
This commit is contained in:
parent
9ee1a82185
commit
0525a9c9fa
|
@ -2085,8 +2085,6 @@ static void x86_cpuid_set_apic_id(struct uc_struct *uc,
|
|||
{
|
||||
X86CPU *cpu = X86_CPU(uc, obj);
|
||||
DeviceState *dev = DEVICE(uc, obj);
|
||||
const int64_t min = 0;
|
||||
const int64_t max = UINT32_MAX;
|
||||
Error *error = NULL;
|
||||
int64_t value;
|
||||
|
||||
|
@ -2101,17 +2099,6 @@ static void x86_cpuid_set_apic_id(struct uc_struct *uc,
|
|||
error_propagate(errp, error);
|
||||
return;
|
||||
}
|
||||
if (value < min || value > max) {
|
||||
error_setg(errp, "Property %s.%s doesn't take value %" PRId64
|
||||
" (minimum: %" PRId64 ", maximum: %" PRId64 ")" ,
|
||||
object_get_typename(obj), name, value, min, max);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((value != cpu->apic_id) && cpu_exists(uc, value)) {
|
||||
error_setg(errp, "CPU with APIC ID %" PRIi64 " exists", value);
|
||||
return;
|
||||
}
|
||||
cpu->apic_id = (uint32_t)value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue