Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp244153rdb; Thu, 22 Feb 2024 02:15:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9hT5jFPphDy2QDEusiKLBm3ksa9rcYCF1LamjCSViaJDtA13rBI6nhxK8mzc+q40pCkwl5oNxoanAVbJVJRAOFBT6FkgwgYBy7VSG1A== X-Google-Smtp-Source: AGHT+IGkbSdD/0qk2+4Bj7fVsTfaSmo+++1ohU1tnVRg8h+SRRj/gOaPFhVn13OIj85dSmWOh8Fn X-Received: by 2002:a05:6808:2023:b0:3c1:77e3:a771 with SMTP id q35-20020a056808202300b003c177e3a771mr2332326oiw.39.1708596909162; Thu, 22 Feb 2024 02:15:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596909; cv=pass; d=google.com; s=arc-20160816; b=Gf+1VyohdF9XKKEdQz3TdPznAfqdqHuIZVTU/3fRZOnHQHeRHsR8ms5kKrOK14PesG 2OarlahW7avhjOJNSH6QvAMEhLErF6vGrf+1CP1J0iCWsaZJzDe8S2KPof+SU7TiGFOZ eRnsLeujCZiWsIupNkuujuNLctGlJH0UlcSSgw78+gyKzP191kSdJ7CWYqrKpCp1EkX1 zAxtZZt6OtZ2WwR9RCRVlPpO+k0AMyh63A6KZwdkYZS2O5ganI9lcE/P/eFWvYrnJlnI WKzckrHT2aPstPOg6ofp3qRRB3f8tYP0A3b/V+XNGbIS1h3hojKiRqNIs6PzS45H/sG7 Ca+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :from:dkim-signature; bh=dwr3ZK/EESU5ItyIiPXNdclroS1RFnr41MH5ydWu9Go=; fh=3Ym2FBR9f+i2/2GV0QWHc4HA+60wJfJ59K96e+Xu3EE=; b=VrG3dApbJsZ7DcMt+rETM6Dv0lLK/FIKB0J7HEr4f0cqjZLUfzx6EguEFX3H9Z6j+7 H7yTKu1/O2abD/nUV1RAs9q9hJwOe65anhK/0OfYIIDXNAsm8AkX9MUznVSEzd7yK2nD ihAlHMUQ44Mr/BrneMp8umk/mbnffy2sqOCXyrOawTVHBKji5eRs2mLPuoPyKl1Iq0MJ rgE3K7oVBGAoMJLEpaiDLlZi/f9VEzJqdE0s8aQrVGByEwlXnYJFBqFfPXzGO+vr0xPV jQbnyHyx4SoEaVn7T93qbQ+L+Atr1JPr59MHQgQ7CzCyuMdDECCg9E5tDW1lP8KlBZpw nPIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iKdkqw6b; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o1-20020a629a01000000b006e08dbeebdasi9896141pfe.219.2024.02.22.02.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:15:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iKdkqw6b; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7DA9C2809A6 for ; Thu, 22 Feb 2024 10:15:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DF393C07B; Thu, 22 Feb 2024 10:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iKdkqw6b" Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B00443717C; Thu, 22 Feb 2024 10:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596893; cv=none; b=SBVtw9nGBc0rshgmrLfanJxGdQgen8Wpz1rZJ9crJpU6DaLIOpXV6nTpouTrXSDXxklyKepzxyal//4SnG/0m0OxAUppH54qs/QE5b7KdKTDyjd4o2BeNxb5/CjzPXNe3GsAsv4tR3azGMIbnrm8vvv3or95BrkWQ8UQjpw9g98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596893; c=relaxed/simple; bh=eDm1MSEtuuwQgeMt9pxKV0QXXCrHnsB3Vj90LImQKZY=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=GLPNDB/bpiaQYeAHggQguoOAu6Pil32xGP4ILuF/fGBnR/PM6V/uJMA73/SnOAbdvY+cu0pwhDxJuHUYqVc4JwGKQbZpVuNqkXVxsDPnO5CTkgeEkAJ4PRVIofS7bVumfDwmMXNVgQbpjTxwWRj4e7o3+NqvV6LTXBUmG5ZDmN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iKdkqw6b; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-41241f64c6bso11714995e9.0; Thu, 22 Feb 2024 02:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708596881; x=1709201681; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=dwr3ZK/EESU5ItyIiPXNdclroS1RFnr41MH5ydWu9Go=; b=iKdkqw6b0SLKPuWfm/or4L0pjrfzzUewqFP+/eHGUcZ64LodTeOeL4InLPrzgF6qPk sNGbSdqLvS8d4qS7lJAbwos8kGK7qwgKGTJL8Enwy6OWFGUgUH8eAqvE3vI7ZBTeepPi mnxN9fIrneM7vWBZUJFVD6bA7UXn+UU/SlC5mFgI+POIlxN/dDpTqoK5nkyQ9sXcWhRd n6IyeaFJLha9akzjNapG7CebOQMJlh+44TIzPthrp8OraDOgB8+V2fhsyVFGzsVNfeEo RTx/IgPT3yCzxtmJrks4J6WNMDKqrpOT3IhYLt+8uxFZ9vVoSkcIhEsLg1IZkoQHWH4t XXTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708596881; x=1709201681; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dwr3ZK/EESU5ItyIiPXNdclroS1RFnr41MH5ydWu9Go=; b=PEqstR+jcwksz6adzG+4SN1+7vNHQmslfcQ1Zg2kNZmYB9Uoxam5QwHCbjfwjGuaa9 Seke0FHmggvfxVNo2/jj0+ILNjElNYnm5oFWig8pj24EXDvANj8NppLC0MPswQBD7TGh 1AKgsJstNKuvJ1OMUQYZMXPWxBUzjkzXt8xnM6uHF6RJZN/SmfgRGW/MDqGpOANHhVo1 RquYUh9RDTo0wNUflkyINFHmjuuXanQd0RbhQBf9DZykMgCbkcN7V0sX9CNDfgw/3ZWi yQLTfyCAKywutnEg7kfFGFMd8souv1S9LiGXDHRJIkf1dl1Z6cjstJLAh2MX+gfxbK0h 29bg== X-Forwarded-Encrypted: i=1; AJvYcCWXevhzWyKAfllReqPWqvT+2RwG7CtUjgb/ZMTAmPLVfP5xWWUCk7eCdgtSOoD9HhZKWReFT/oIt/LpbGzHd7qt+lpTyqArS1OPMSz90KslxyHSMcE8i8mzeIJ9FMX1u7rw X-Gm-Message-State: AOJu0Yw30M+tvdWyNWhShhhz1pMVkWeCZeGKyQEmrT+L6Za7gh5VRxNO 9M1x73LrG20lRaiB0JwRxF3uxVqzLijv3ZRThfh220/m2K1mxKgP X-Received: by 2002:a05:600c:a39d:b0:40f:df17:f0ce with SMTP id hn29-20020a05600ca39d00b0040fdf17f0cemr15064203wmb.28.1708596880778; Thu, 22 Feb 2024 02:14:40 -0800 (PST) Received: from [192.168.13.104] (54-240-197-234.amazon.com. [54.240.197.234]) by smtp.gmail.com with ESMTPSA id s7-20020a05600c45c700b0041279707ffbsm3654301wmo.15.2024.02.22.02.14.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 02:14:40 -0800 (PST) From: Paul Durrant X-Google-Original-From: Paul Durrant Message-ID: Date: Thu, 22 Feb 2024 10:14:38 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: paul@xen.org Subject: Re: [PATCH] KVM: x86/xen: fix 32-bit pointer cast Content-Language: en-US To: Arnd Bergmann , David Woodhouse , Sean Christopherson , Paolo Bonzini Cc: Arnd Bergmann , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Jens Axboe , Jan Kara , Christian Brauner , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240222100412.560961-1-arnd@kernel.org> Organization: Xen Project In-Reply-To: <20240222100412.560961-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 22/02/2024 10:03, Arnd Bergmann wrote: > From: Arnd Bergmann > > shared_info.hva is a 64-bit variable, so casting to a pointer causes > a warning in 32-bit builds: > > arch/x86/kvm/xen.c: In function 'kvm_xen_hvm_set_attr': > arch/x86/kvm/xen.c:660:45: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] > 660 | void __user * hva = (void *)data->u.shared_info.hva; > > Replace the cast with a u64_to_user_ptr() call that does the right thing. Thanks Arnd. I'd just got a ping from kernel test robot for lack of __user qualifier in the cast (https://lore.kernel.org/oe-kbuild-all/202402221721.mhF8MNVh-lkp@intel.com/), which this should also fix. > > Fixes: 01a871852b11 ("KVM: x86/xen: allow shared_info to be mapped by fixed HVA") > Signed-off-by: Arnd Bergmann > --- > arch/x86/kvm/xen.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Reviewed-by: Paul Durrant > diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c > index 01c0fd138d2f..8a04e0ae9245 100644 > --- a/arch/x86/kvm/xen.c > +++ b/arch/x86/kvm/xen.c > @@ -657,7 +657,7 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data) > gfn_to_gpa(gfn), PAGE_SIZE); > } > } else { > - void __user * hva = (void *)data->u.shared_info.hva; > + void __user * hva = u64_to_user_ptr(data->u.shared_info.hva); > > if (!PAGE_ALIGNED(hva) || !access_ok(hva, PAGE_SIZE)) { > r = -EINVAL;