diff mbox

[4/9] KVM: define kvm_bad_pfn statically

Message ID 5014F0E1.4010909@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong July 29, 2012, 8:14 a.m. UTC
Then, remove get_bad_pfn

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 include/linux/kvm_host.h |    1 +
 virt/kvm/kvm_main.c      |    7 +------
 2 files changed, 2 insertions(+), 6 deletions(-)

Comments

Marcelo Tosatti Aug. 2, 2012, 1:15 p.m. UTC | #1
On Sun, Jul 29, 2012 at 04:14:25PM +0800, Xiao Guangrong wrote:
> Then, remove get_bad_pfn
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
> ---
>  include/linux/kvm_host.h |    1 +
>  virt/kvm/kvm_main.c      |    7 +------
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 4de56cd..b02203f 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -50,6 +50,7 @@
> 
>  #define kvm_fault_pfn		(-EFAULT)
>  #define kvm_hwpoison_pfn	(-EHWPOISON)
> +#define kvm_bad_pfn		(-ENOENT)

Remind me what is the guarantee that -Exxx does not clash with
a valid pfn number?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Mackerras Aug. 3, 2012, 12:01 a.m. UTC | #2
On Thu, Aug 02, 2012 at 10:15:27AM -0300, Marcelo Tosatti wrote:

> Remind me what is the guarantee that -Exxx does not clash with
> a valid pfn number?

A pfn number is an address >> PAGE_SHIFT, so it will have the top 12
(at least) bits clear, whereas -Exxx will have the top bit set.

Paul.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Aug. 3, 2012, 8:13 a.m. UTC | #3
Marcelo, Paul,

Thanks for your review!

On 08/03/2012 08:01 AM, Paul Mackerras wrote:
> On Thu, Aug 02, 2012 at 10:15:27AM -0300, Marcelo Tosatti wrote:
> 
>> Remind me what is the guarantee that -Exxx does not clash with
>> a valid pfn number?
> 
> A pfn number is an address >> PAGE_SHIFT, so it will have the top 12
> (at least) bits clear, whereas -Exxx will have the top bit set.
> 

Yes.

As this way is hard to understand and it will break huge memory support
on PAE 32bit cpu, i have used a new way in the v2:

http://marc.info/?l=linux-kernel&m=134398012027025&w=2

Please review the new version.



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 4de56cd..b02203f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -50,6 +50,7 @@ 

 #define kvm_fault_pfn		(-EFAULT)
 #define kvm_hwpoison_pfn	(-EHWPOISON)
+#define kvm_bad_pfn		(-ENOENT)

 /*
  * vcpu->requests bit members
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 390a03d..da16191 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -943,11 +943,6 @@  int is_error_pfn(pfn_t pfn)
 }
 EXPORT_SYMBOL_GPL(is_error_pfn);

-static pfn_t get_bad_pfn(void)
-{
-	return -ENOENT;
-}
-
 int is_noslot_pfn(pfn_t pfn)
 {
 	return pfn == -ENOENT;
@@ -1152,7 +1147,7 @@  static pfn_t __gfn_to_pfn(struct kvm *kvm, gfn_t gfn, bool atomic, bool *async,

 	addr = gfn_to_hva(kvm, gfn);
 	if (kvm_is_error_hva(addr))
-		return get_bad_pfn();
+		return kvm_bad_pfn;

 	return hva_to_pfn(addr, atomic, async, write_fault, writable);
 }