[RFC PATCH v2 12/43] KVM: Check struct kvm_run against PAGE_SIZE_MIN

Eric Curtin ericcurtin17 at gmail.com
Mon Nov 30 17:51:44 PST 2026


From: Ryan Roberts <ryan.roberts at arm.com>

With boot-time page size selection PAGE_SIZE is not a compile-time
constant, so the BUILD_BUG_ON() in kvm_vm_ioctl_create_vcpu() that
checks sizeof(struct kvm_run) against PAGE_SIZE cannot be evaluated.

Check against PAGE_SIZE_MIN instead. If kvm_run fits in the smallest
possible page it fits in whichever page size is chosen at boot.

No functional change for compile-time page sizes.

Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Reviewed-by: Sean Christopherson <seanjc at google.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
(cherry picked from commit 76729ec02c8773a6f44897c7629f594ab451312c)
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 83e727bf6452..794f41a2d052 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4294,7 +4294,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, unsigned long id)
 
 	vcpu->vcpu_idx = -1;
 
-	BUILD_BUG_ON(sizeof(struct kvm_run) > PAGE_SIZE);
+	BUILD_BUG_ON(sizeof(struct kvm_run) > PAGE_SIZE_MIN);
 	page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 	if (!page) {
 		r = -ENOMEM;



More information about the linux-arm-kernel mailing list