2009-10-09 11:43:37

by Frederik Deweerdt

[permalink] [raw]
Subject: [patch] kvm: fix pointer cast

Hi,

On a 32 bits compile, commit 3da0dd433dc399a8c0124d0614d82a09b6a49bce
introduced the following warnings:

arch/x86/kvm/mmu.c: In function ‘kvm_set_pte_rmapp’:
arch/x86/kvm/mmu.c:770: warning: cast to pointer from integer of different size
arch/x86/kvm/mmu.c: In function ‘kvm_set_spte_hva’:
arch/x86/kvm/mmu.c:849: warning: cast from pointer to integer of different size

The following patch uses 'unsigned long' instead of u64 to match the
pointer size on both arches.

Regards,
Frederik


Signed-off-by: Frederik Deweerdt <[email protected]>

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 685a4ff..818b92a 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -748,7 +748,8 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn)
return write_protected;
}

-static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
+static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
+ unsigned long data)
{
u64 *spte;
int need_tlb_flush = 0;
@@ -763,7 +764,8 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
return need_tlb_flush;
}

-static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
+static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
+ unsigned long data)
{
int need_flush = 0;
u64 *spte, new_spte;
@@ -799,9 +801,10 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
return 0;
}

-static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, u64 data,
+static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
+ unsigned long data,
int (*handler)(struct kvm *kvm, unsigned long *rmapp,
- u64 data))
+ unsigned long data))
{
int i, j;
int retval = 0;
@@ -846,10 +849,11 @@ int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)

void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
{
- kvm_handle_hva(kvm, hva, (u64)&pte, kvm_set_pte_rmapp);
+ kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp);
}

-static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
+static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
+ unsigned long data)
{
u64 *spte;
int young = 0;


2009-10-10 11:52:33

by Izik Eidus

[permalink] [raw]
Subject: Re: [patch] kvm: fix pointer cast

On 10/09/2009 01:42 PM, Frederik Deweerdt wrote:
> Hi,
>
> On a 32 bits compile, commit 3da0dd433dc399a8c0124d0614d82a09b6a49bce
> introduced the following warnings:
>
> arch/x86/kvm/mmu.c: In function ‘kvm_set_pte_rmapp’:
> arch/x86/kvm/mmu.c:770: warning: cast to pointer from integer of different size
> arch/x86/kvm/mmu.c: In function ‘kvm_set_spte_hva’:
> arch/x86/kvm/mmu.c:849: warning: cast from pointer to integer of different size
>
> The following patch uses 'unsigned long' instead of u64 to match the
> pointer size on both arches.
>
> Regards,
> Frederik
>
>
> Signed-off-by: Frederik Deweerdt<[email protected]>
>
>
Acked-by: Izik Eidus <[email protected]>

2009-10-12 19:18:32

by Marcelo Tosatti

[permalink] [raw]
Subject: Re: [patch] kvm: fix pointer cast

On Sat, Oct 10, 2009 at 01:59:53PM +0200, Izik Eidus wrote:
> On 10/09/2009 01:42 PM, Frederik Deweerdt wrote:
>> Hi,
>>
>> On a 32 bits compile, commit 3da0dd433dc399a8c0124d0614d82a09b6a49bce
>> introduced the following warnings:
>>
>> arch/x86/kvm/mmu.c: In function ‘kvm_set_pte_rmapp’:
>> arch/x86/kvm/mmu.c:770: warning: cast to pointer from integer of different size
>> arch/x86/kvm/mmu.c: In function ‘kvm_set_spte_hva’:
>> arch/x86/kvm/mmu.c:849: warning: cast from pointer to integer of different size
>>
>> The following patch uses 'unsigned long' instead of u64 to match the
>> pointer size on both arches.
>>
>> Regards,
>> Frederik
>>
>>
>> Signed-off-by: Frederik Deweerdt<[email protected]>
>>
>>
> Acked-by: Izik Eidus <[email protected]>

Applied, thanks.