Skip to contentSkip to conversation

kvm: arm64: Properly align the end address of table walk

PATCH In review Keqian Zhu 2 participants 3 messages Jan 15, 2021 – Jan 18, 2021

Subsystems (3)
lore
Share & tools
lore

Keqian Zhu

author
#0 lore raw

PATCH 1/1 kvm: arm64: Properly align the end address of table walk

When align the end address, ought to use its original value.

Fixes b1e57de62cfb ("KVM: arm64: Add stand-alone page-table walker infrastructure")
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +1 -1
index bdf8e55ed308..670b0ef12440 100644
@@ -296,7 +296,7 @@ int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size,
 	struct kvm_pgtable_walk_data walk_data = {
 		.pgt	= pgt,
 		.addr	= ALIGN_DOWN(addr, PAGE_SIZE),
-		.end	= PAGE_ALIGN(walk_data.addr + size),
+		.end	= PAGE_ALIGN(addr + size),
 		.walker	= walker,
 	};
 
Signature · 6 lines
2.19.1

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
maintainer
#1 lore raw
Quoted 13 lines · Keqian Zhu

When align the end address, ought to use its original value.

Fixes b1e57de62cfb ("KVM: arm64: Add stand-alone page-table walker infrastructure")
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +0 -0
index bdf8e55ed308..670b0ef12440 100644

arch/arm64/kvm/hyp/pgtable.c int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, · line 300

Quoted 6 lines
arch/arm64/kvm/hyp/pgtable.c +1 -1
@@ -296,7 +296,7 @@ int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size,
 	struct kvm_pgtable_walk_data walk_data = {
 		.pgt	= pgt,
 		.addr	= ALIGN_DOWN(addr, PAGE_SIZE),
-		.end	= PAGE_ALIGN(walk_data.addr + size),
+		.end	= PAGE_ALIGN(addr + size),
 		.walker	= walker,

Hmm, this is a change in behaviour, no (consider the case where both 'addr' and 'size' are misaligned)? The current code is consistent with the kerneldoc in asm/kvm_pgtable.h, so I don't see the motivation to change it.

Did you hit a bug somewhere?

Will
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

author
#2 lore raw
Quoted 25 lines · Will Deacon
Quoted 13 lines · Keqian Zhu

When align the end address, ought to use its original value.

Fixes b1e57de62cfb ("KVM: arm64: Add stand-alone page-table walker infrastructure")
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +0 -0
index bdf8e55ed308..670b0ef12440 100644

arch/arm64/kvm/hyp/pgtable.c int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, · line 300

Quoted 6 lines
arch/arm64/kvm/hyp/pgtable.c +1 -1
@@ -296,7 +296,7 @@ int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size,
 	struct kvm_pgtable_walk_data walk_data = {
 		.pgt	= pgt,
 		.addr	= ALIGN_DOWN(addr, PAGE_SIZE),
-		.end	= PAGE_ALIGN(walk_data.addr + size),
+		.end	= PAGE_ALIGN(addr + size),
 		.walker	= walker,

Hmm, this is a change in behaviour, no (consider the case where both 'addr' and 'size' are misaligned)? The current code is consistent with the kerneldoc in asm/kvm_pgtable.h, so I don't see the motivation to change it.

Quoted 5 lines

Did you hit a bug somewhere?

Will
.

Not hit a bug, I just read the code to implement a new idea of stage2 DBM support [1]. Yes, according to doc, this is not an issue ("The offset of @addr within a page is ignored."). Sorry to disturb ;-).

[1] https://lore.kernel.org/kvmarm/[email protected]/

Thanks,
Keqian

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm