public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: Dongli Zhang <dongli.zhang@oracle.com>, <kvm@vger.kernel.org>
Cc: <pbonzini@redhat.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] KVM: use KVM_HVA_ERR_BAD to check bad hva
Date: Fri, 1 Mar 2024 10:53:22 +1300	[thread overview]
Message-ID: <04398f4e-6098-4559-9604-b9810753801e@intel.com> (raw)
In-Reply-To: <20240229212522.34515-1-dongli.zhang@oracle.com>



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@oracle.com>
> ---
>   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().


  reply	other threads:[~2024-02-29 21:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 21:25 [PATCH 1/1] KVM: use KVM_HVA_ERR_BAD to check bad hva Dongli Zhang
2024-02-29 21:53 ` Huang, Kai [this message]
2024-02-29 22:13   ` Dongli Zhang
2024-02-29 22:39     ` Huang, Kai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04398f4e-6098-4559-9604-b9810753801e@intel.com \
    --to=kai.huang@intel.com \
    --cc=dongli.zhang@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox