Skip to contentSkip to conversation

KVM: arm64: Fixes to KVM struct allocation

PATCH Applied Oliver Upton 5 participants 8 messages Nov 19, 2025 – Nov 20, 2025

Subsystems (2)
lore
Share & tools
lore

Oliver Upton

author maintainer
#0 lore raw

cover KVM: arm64: Fixes to KVM struct allocation

Small fix to drop __GFP_HIGHMEM from KVM struct allocation GFP flags, which was always completely pointless and now trips a WARN for passing such an unsupported flag to vmalloc().

Oliver Upton (2):
KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation
KVM: arm64: Use kvzalloc() for kvm struct allocation

 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa

Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH 1/2 KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation

A recent change on the receiving end of vmalloc() started warning about unsupported GFP flags passed by the caller. Nathan reports that this warning fires in kvm_arch_alloc_vm(), owing to the fact that KVM is passing a meaningless __GFP_HIGHMEM.

Do as the warning says and fix the code.

---
 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/arm.c +1 -1
index 870953b4a8a7..e791fa52f874 100644
@@ -440,7 +440,7 @@ struct kvm *kvm_arch_alloc_vm(void)
 	if (!has_vhe())
 		return kzalloc(sz, GFP_KERNEL_ACCOUNT);
 
-	return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_HIGHMEM | __GFP_ZERO);
+	return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 }
 
 int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
Signature · 1 line
2.47.3
author maintainer
#3 lore raw

PATCH 2/2 KVM: arm64: Use kvzalloc() for kvm struct allocation

In reply to Oliver Upton

Physically-allocated KVM structs aren't necessary when in VHE mode as there's no need to share with the hyp's address space. Of course, there can still be a performance benefit from physical allocations.

Use kvzalloc() for opportunistic physical allocations.

---
 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/arm.c +1 -1
index e791fa52f874..ecbe2c8dc00c 100644
@@ -440,7 +440,7 @@ struct kvm *kvm_arch_alloc_vm(void)
 	if (!has_vhe())
 		return kzalloc(sz, GFP_KERNEL_ACCOUNT);
 
-	return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+	return kvzalloc(sz, GFP_KERNEL_ACCOUNT);
 }
 
 int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
Signature · 1 line
2.47.3
reviewer Reviewed-by on the v1 series
#4 lore raw
In reply to Oliver Upton
Quoted 8 lines · Oliver Upton

Small fix to drop __GFP_HIGHMEM from KVM struct allocation GFP flags, which was always completely pointless and now trips a WARN for passing such an unsupported flag to vmalloc().

Oliver Upton (2):
KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation
KVM: arm64: Use kvzalloc() for kvm struct allocation

Quoted 5 lines
 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa

Also nice to drop a usage of a __-prefixed function.

Quoted 3 lines
Signature · 1 line
2.47.3
maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to Oliver Upton
Quoted 11 lines · Oliver Upton

Small fix to drop __GFP_HIGHMEM from KVM struct allocation GFP flags, which was always completely pointless and now trips a WARN for passing such an unsupported flag to vmalloc().

Oliver Upton (2):
KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation
KVM: arm64: Use kvzalloc() for kvm struct allocation

 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Seems sensible. FWIW:

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Acked-by on the v1 series
#6 lore raw
In reply to Oliver Upton
Quoted 10 lines · Oliver Upton

Small fix to drop __GFP_HIGHMEM from KVM struct allocation GFP flags, which was always completely pointless and now trips a WARN for passing such an unsupported flag to vmalloc().

Oliver Upton (2):
KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation
KVM: arm64: Use kvzalloc() for kvm struct allocation

 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

For the series:

author maintainer Applied
#7 lore raw
In reply to Oliver Upton
Quoted 9 lines · Oliver Upton

Small fix to drop __GFP_HIGHMEM from KVM struct allocation GFP flags, which was always completely pointless and now trips a WARN for passing such an unsupported flag to vmalloc().

Oliver Upton (2):
KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation
KVM: arm64: Use kvzalloc() for kvm struct allocation

[...]

Applied to next, thanks!

[1/2] KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation

      https://git.kernel.org/kvmarm/kvmarm/c/297877069bc2
[2/2] KVM: arm64: Use kvzalloc() for kvm struct allocation
      https://git.kernel.org/kvmarm/kvmarm/c/cb17d79ff51d

--
Best,
Oliver

Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] KVM: arm64: Drop useless __GFP_HIGHMEM from kvm struct allocation

In reply to Oliver Upton
Quoted 11 lines · Oliver Upton

A recent change on the receiving end of vmalloc() started warning about unsupported GFP flags passed by the caller. Nathan reports that this warning fires in kvm_arch_alloc_vm(), owing to the fact that KVM is passing a meaningless __GFP_HIGHMEM.

Do as the warning says and fix the code.

Thanks for the patch!

Quoted 20 lines
---
 arch/arm64/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/arm.c +1 -1
index 870953b4a8a7..e791fa52f874 100644
@@ -440,7 +440,7 @@ struct kvm *kvm_arch_alloc_vm(void)
 	if (!has_vhe())
 		return kzalloc(sz, GFP_KERNEL_ACCOUNT);
 
-	return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_HIGHMEM | __GFP_ZERO);
+	return __vmalloc(sz, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 }
 
 int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
Signature · 1 line
2.47.3