Skip to content

Commit e7f58a6

Browse files
author
Marc Zyngier
committed
KVM: selftests: arm64: Add support for VM_MODE_P36V48_{4K,64K}
Some of the arm64 systems out there have an IPA space that is positively tiny. Nonetheless, they make great KVM hosts. Add support for 36bit IPA support with 4kB pages, which makes some of the fruity machines happy. Whilst we're at it, add support for 64kB pages as well, though these boxes have no support for it. Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2f41a61 commit e7f58a6

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ enum vm_guest_mode {
4848
VM_MODE_PXXV48_4K, /* For 48bits VA but ANY bits PA */
4949
VM_MODE_P47V64_4K,
5050
VM_MODE_P44V64_4K,
51+
VM_MODE_P36V48_4K,
52+
VM_MODE_P36V48_64K,
5153
NUM_VM_MODES,
5254
};
5355

tools/testing/selftests/kvm/lib/aarch64/processor.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,12 @@ void aarch64_vcpu_setup(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_vcpu_init
249249
case VM_MODE_P52V48_64K:
250250
case VM_MODE_P48V48_64K:
251251
case VM_MODE_P40V48_64K:
252+
case VM_MODE_P36V48_64K:
252253
tcr_el1 |= 1ul << 14; /* TG0 = 64KB */
253254
break;
254255
case VM_MODE_P48V48_4K:
255256
case VM_MODE_P40V48_4K:
257+
case VM_MODE_P36V48_4K:
256258
tcr_el1 |= 0ul << 14; /* TG0 = 4KB */
257259
break;
258260
default:
@@ -272,6 +274,10 @@ void aarch64_vcpu_setup(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_vcpu_init
272274
case VM_MODE_P40V48_64K:
273275
tcr_el1 |= 2ul << 32; /* IPS = 40 bits */
274276
break;
277+
case VM_MODE_P36V48_4K:
278+
case VM_MODE_P36V48_64K:
279+
tcr_el1 |= 1ul << 32; /* IPS = 36 bits */
280+
break;
275281
default:
276282
TEST_FAIL("Unknown guest mode, mode: 0x%x", vm->mode);
277283
}

tools/testing/selftests/kvm/lib/guest_modes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ void guest_modes_append_default(void)
3737
if (ps4k)
3838
vm_mode_default = VM_MODE_P40V48_4K;
3939
}
40+
if (limit >= 36) {
41+
guest_mode_append(VM_MODE_P36V48_4K, ps4k, ps4k);
42+
guest_mode_append(VM_MODE_P36V48_64K, ps64k, ps64k);
43+
}
4044

4145
/*
4246
* Pick the first supported IPA size if the default

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ const char *vm_guest_mode_string(uint32_t i)
172172
[VM_MODE_PXXV48_4K] = "PA-bits:ANY, VA-bits:48, 4K pages",
173173
[VM_MODE_P47V64_4K] = "PA-bits:47, VA-bits:64, 4K pages",
174174
[VM_MODE_P44V64_4K] = "PA-bits:44, VA-bits:64, 4K pages",
175+
[VM_MODE_P36V48_4K] = "PA-bits:36, VA-bits:48, 4K pages",
176+
[VM_MODE_P36V48_64K] = "PA-bits:36, VA-bits:48, 64K pages",
175177
};
176178
_Static_assert(sizeof(strings)/sizeof(char *) == NUM_VM_MODES,
177179
"Missing new mode strings?");
@@ -191,6 +193,8 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = {
191193
[VM_MODE_PXXV48_4K] = { 0, 0, 0x1000, 12 },
192194
[VM_MODE_P47V64_4K] = { 47, 64, 0x1000, 12 },
193195
[VM_MODE_P44V64_4K] = { 44, 64, 0x1000, 12 },
196+
[VM_MODE_P36V48_4K] = { 36, 48, 0x1000, 12 },
197+
[VM_MODE_P36V48_64K] = { 36, 48, 0x10000, 16 },
194198
};
195199
_Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES,
196200
"Missing new mode params?");
@@ -252,9 +256,11 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
252256
vm->pgtable_levels = 3;
253257
break;
254258
case VM_MODE_P40V48_4K:
259+
case VM_MODE_P36V48_4K:
255260
vm->pgtable_levels = 4;
256261
break;
257262
case VM_MODE_P40V48_64K:
263+
case VM_MODE_P36V48_64K:
258264
vm->pgtable_levels = 3;
259265
break;
260266
case VM_MODE_PXXV48_4K:

0 commit comments

Comments
 (0)