qemu: refactor maximum vcpus supported in aarch64

on aarch64, we support different gic interrupt controllers.
The maximum number of vCPUs depends on the GIC version, or on how
many redistributors we can fit into the memory map.

Fixes: #584

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
This commit is contained in:
root 2018-08-27 13:55:24 +08:00
parent 39ad9702de
commit c4ded6ee5e

View File

@ -107,8 +107,22 @@ func getGuestGICVersion() (version string) {
return "host" return "host"
} }
//In qemu, maximum number of vCPUs depends on the GIC version, or on how
//many redistributors we can fit into the memory map.
//related codes are under github.com/qemu/qemu/hw/arm/virt.c(Line 135 and 1306 in stable-2.11)
//for now, qemu only supports v2 and v3, we treat v4 as v3 based on
//backward compatibility.
var gicList = map[uint32]uint32{
uint32(2): uint32(8),
uint32(3): uint32(123),
uint32(4): uint32(123),
}
// MaxQemuVCPUs returns the maximum number of vCPUs supported // MaxQemuVCPUs returns the maximum number of vCPUs supported
func MaxQemuVCPUs() uint32 { func MaxQemuVCPUs() uint32 {
if hostGICVersion != 0 {
return gicList[hostGICVersion]
}
return uint32(runtime.NumCPU()) return uint32(runtime.NumCPU())
} }