diff options
author | Alexandru Elisei <alexandru.elisei@arm.com> | 2022-05-25 17:57:03 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2022-05-26 10:04:43 +0100 |
commit | 8ec1e8bf3bc2e99518d857a5164218d513d585ea (patch) | |
tree | 10ef8923441517aff5ccd62de2c14bcd46d8c2f2 | |
parent | 1a992bbaab08994e12a7594b0c39535152093a6b (diff) | |
download | kvmtool-8ec1e8bf3bc2e99518d857a5164218d513d585ea.tar.gz |
arm64: Honor --vcpu-affinity for aarch32 guests
Commit 4639b72f61a3 ("arm64: Add --vcpu-affinity command line argument")
introduced the --vcpu-affinity command line argument to pin the VCPUs to a
given list of physical CPUs. Unfortunately, the affinity is set only for an
arm64 guest, leading to the following error when running a 32-bit guest on
a system with two or more PMUs:
KVM exit reason: 9 ("KVM_EXIT_FAIL_ENTRY")
Registers:
PC: 0x8000c608
PSTATE: 0x200000d3
SP_EL1: 0x0
LR: 0x0
*pc:
0x8000c608: 25 3f a0 e1 83 61 a0 e1
0x8000c610: 83 31 98 e7 04 10 82 e1
0x8000c618: 07 2c 81 e3 28 10 1b e5
0x8000c620: 03 20 82 e3 03 00 a0 e1
*lr:
Warning: unable to translate guest address 0x0 to host
0x00000000: <unknown>
0x00000008: <unknown>
0x00000010: <unknown>
0x00000018: <unknown>
# KVM compatibility warning.
virtio-net device was not detected.
While you have requested a virtio-net device, the guest kernel did not initialize it.
Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_NET=y enabled in .config.
# KVM session ended normally.
Make the error go away by setting the affinity of the VCPUs for both 32-bit
and 64-bit guests.
Fixes: 4639b72f61a3 ("arm64: Add --vcpu-affinity command line argument")
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20220525165704.186754-2-alexandru.elisei@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | arm/aarch64/kvm-cpu.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 4ac0fafa..c8be10b3 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -88,16 +88,7 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) { struct kvm *kvm = vcpu->kvm; struct kvm_one_reg reg; - cpu_set_t *affinity; u64 data; - int ret; - - affinity = kvm->arch.vcpu_affinity_cpuset; - if (affinity) { - ret = sched_setaffinity(0, sizeof(cpu_set_t), affinity); - if (ret == -1) - die_perror("sched_setaffinity"); - } reg.addr = (u64)&data; @@ -179,7 +170,18 @@ int kvm_cpu__configure_features(struct kvm_cpu *vcpu) void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu) { - if (vcpu->kvm->cfg.arch.aarch32_guest) + struct kvm *kvm = vcpu->kvm; + cpu_set_t *affinity; + int ret; + + affinity = kvm->arch.vcpu_affinity_cpuset; + if (affinity) { + ret = sched_setaffinity(0, sizeof(cpu_set_t), affinity); + if (ret == -1) + die_perror("sched_setaffinity"); + } + + if (kvm->cfg.arch.aarch32_guest) return reset_vcpu_aarch32(vcpu); else return reset_vcpu_aarch64(vcpu); |