Patchwork [2/3] KVM: PPC: Add support for explicit HIOR setting

login
register
mail settings
Submitter Alexander Graf
Date April 16, 2012, 4:54 p.m.
Message ID <E41B4CD8-5314-4535-A664-D3962703F6C4@suse.de>
Download mbox | patch
Permalink /patch/152950/
State New
Headers show

Comments

Alexander Graf - April 16, 2012, 4:54 p.m.
On 01.04.2012, at 21:51, Andreas Schwab wrote:

> Alexander Graf <agraf@suse.de> writes:
> 
>> @@ -662,6 +668,13 @@ static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
>> 	int r = -EINVAL;
>> 
>> 	switch (reg->id) {
>> +#ifdef CONFIG_PPC_BOOK3S
>> +	case KVM_ONE_REG_PPC_HIOR:
>> +		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
> 
> That doesn't build on ppc32, get_user cannot handle 64 bit values.  You
> need to use __get_user64 instead.

Yeah :(. I already have this patch in my tree to fix that:


commit 3c82a50bb07455b2f0663ebc12fffdb647f737d2
Author: Alexander Graf <agraf@suse.de>
Date:   Tue Mar 13 19:59:39 2012 +0100

    KVM: PPC: Book3S: Compile fix for ppc32 in HIOR
    
    On PPC32 we can not use get_user/put_user for 64bit wide variables, as there
    is no single instruction that could load or store variables that big.
    
    So instead, we have to use copy_from/to_user which works everywhere.
    
    Signed-off-by: Alexander Graf <agraf@suse.de>

To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Mackerras - April 16, 2012, 9:42 p.m.
On Mon, Apr 16, 2012 at 06:54:50PM +0200, Alexander Graf wrote:
>
> Yeah :(. I already have this patch in my tree to fix that:
...
>         case KVM_REG_PPC_HIOR:
> -               r = put_user(to_book3s(vcpu)->hior,
> -                            (u64 __user *)(long)reg->addr);
> +               r = copy_to_user((u64 __user *)(long)reg->addr,
> +                               &to_book3s(vcpu)->hior, sizeof(u64));

I folded this in with your other patch that touches these lines and
sent it to Avi, and it is in Linus' tree as b8e6f8ae51.

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

Patch

diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 1717ac8..e2be5ad 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -881,8 +881,8 @@  int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 
        switch (reg->id) {
        case KVM_REG_PPC_HIOR:
-               r = put_user(to_book3s(vcpu)->hior,
-                            (u64 __user *)(long)reg->addr);
+               r = copy_to_user((u64 __user *)(long)reg->addr,
+                               &to_book3s(vcpu)->hior, sizeof(u64));
                break;
        default:
                break;
@@ -897,8 +897,8 @@  int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 
        switch (reg->id) {
        case KVM_REG_PPC_HIOR:
-               r = get_user(to_book3s(vcpu)->hior,
-                            (u64 __user *)(long)reg->addr);
+               r = copy_from_user(&to_book3s(vcpu)->hior,
+                                  (u64 __user *)(long)reg->addr, sizeof(u64));
                if (!r)
                        to_book3s(vcpu)->hior_explicit = true;
                break;--