Re: [PATCH 1/1] KVM: use KVM_HVA_ERR_BAD to check bad hva

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 1/03/2024 10:25 am, Dongli Zhang wrote:
Replace PAGE_OFFSET with KVM_HVA_ERR_BAD, to facilitate the cscope when
looking for where KVM_HVA_ERR_BAD is used.

Every time I use cscope to query the functions that are impacted by the
return value (KVM_HVA_ERR_BAD) of __gfn_to_hva_many(), I may miss
kvm_is_error_hva().

I am not sure "to facilitate cscope" could be a justification to do some code change in the kernel.


Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
---
  include/linux/kvm_host.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 7e7fd25b09b3..4dc0300e7766 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -143,7 +143,7 @@ static inline bool is_noslot_pfn(kvm_pfn_t pfn)
static inline bool kvm_is_error_hva(unsigned long addr)
  {
-	return addr >= PAGE_OFFSET;
+	return addr >= KVM_HVA_ERR_BAD;
  }
#endif


Also, IIUC the KVM_HVA_ERR_BAD _theoretically_ can be any random value that can make kvm_is_error_hva() return false, while kvm_is_error_hva() must catch all error HVAs.

E.g., if we ever change KVM_HVA_ERR_BAD to use any other value (although I don't see why this could ever happen), then using KVM_HVA_ERR_BAD in kvm_is_error_hva() would be broken.

In other words, it seems to me we should just use PAGE_OFFSET in kvm_is_error_hva().





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux