Skip to contentSkip to conversation

KVM: use vma_pages() helper

PATCH Applied Yang Li 2 participants 2 messages Sep 29, 2021 KVM

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 KVM: use vma_pages() helper

Use vma_pages function on vma object instead of explicit computation.

Fix the following coccicheck warning:
./virt/kvm/kvm_main.c:3526:29-35: WARNING: Consider using vma_pages helper on vma

---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
index 7851f3a..8f0e9ea 100644
@@ -3523,7 +3523,7 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
 static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct kvm_vcpu *vcpu = file->private_data;
-	unsigned long pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	unsigned long pages = vma_pages(vma);
 
 	if ((kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff) ||
 	     kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff + pages - 1)) &&
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw
Quoted 18 lines · Yang Li

Use vma_pages function on vma object instead of explicit computation.

Fix the following coccicheck warning:
./virt/kvm/kvm_main.c:3526:29-35: WARNING: Consider using vma_pages helper on vma

---
  virt/kvm/kvm_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +0 -0
index 7851f3a..8f0e9ea 100644

virt/kvm/kvm_main.c static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf) · line 3529

Quoted 8 lines
virt/kvm/kvm_main.c +1 -1
@@ -3523,7 +3523,7 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
  static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma)
  {
  	struct kvm_vcpu *vcpu = file->private_data;
-	unsigned long pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	unsigned long pages = vma_pages(vma);
 
  	if ((kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff) ||
  	     kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff + pages - 1)) &&

Queued, thanks.

Paolo