From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22182364D6; Fri, 13 Dec 2024 17:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734110132; cv=none; b=hlVq4Jc9VqJHn/yQgmL4Ws3hsJVgjJn1Nv9Avp1/k8NSU6JgdS9H0WIs1aQfwEBvuYn6+tjes/AlOu8YyMY3ZtS+n0koq7U3db6EPd5iFHzCgtRVUxYnFfFtSUuWlPR/9Si4eUBkxGxmM4/LajLGBQEWJBy/4DDHgXhrZJ6zshc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734110132; c=relaxed/simple; bh=2YJ7aI7lgNgInMsZf1T3jkaRml+zGxaMkU8tu0NSViU=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=GAk9Nqb6zpBLQOKRv0avaYyY6EE25oFzHmEQ64MGtz56tMyU0lMP/9652FtWB+6r2/xSmZa7v7EDur/oS3O6xhJeNWRrqeDgtEtd3UHaS2VD9EX5DqBZLbN8bGRgyYXMHGIab2ChrM218hafzR2gWb974gIpA7vXJBtSHVOdU9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jwFnfZHt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jwFnfZHt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CAEFC4CED0; Fri, 13 Dec 2024 17:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734110130; bh=2YJ7aI7lgNgInMsZf1T3jkaRml+zGxaMkU8tu0NSViU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jwFnfZHtJRdNKH+ybm0QEKAg3qZ60IbY6L+VQxt6+YdW6BM9uAmHxcpXyXVYEzrWP zS6eE7+dWYNwAcELVtbJ8ASixRhGLltL43p7NN601ihIoHc2VFp1tK0cOMprJ1iUgy Sv/yj3sFyCi+2fo2qth+eR/ynsRTrG4gbk/sMkoZSQprSQlMZ+xD614plNzaEUwzaO taWeJtDMp8NIklaovuK6UEAV0H4q5z3lNBqUd4nNbTFsOFifCqtH6dCdI7WruFce93 GBWzlkhIQKssH89xiDNeCVssv6vKGkDj+TpS1/rXUQ2h4B3eOJoDPFh4aryZtmsBWI /NKGalKaxhcXg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tM9GC-003W5f-7g; Fri, 13 Dec 2024 17:15:28 +0000 Date: Fri, 13 Dec 2024 17:15:27 +0000 Message-ID: <86bjxfsdw0.wl-maz@kernel.org> From: Marc Zyngier To: Uros Bizjak Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon Subject: Re: [PATCH 1/3] KVM: arm64: timers: Fix percpu address space issues in kvm_timer_hyp_init() In-Reply-To: <20241213145809.2918-1-ubizjak@gmail.com> References: <20241213145809.2918-1-ubizjak@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ubizjak@gmail.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 13 Dec 2024 14:57:52 +0000, Uros Bizjak wrote: > > Cast return value from kvm_get_running_vcpus() in the __percpu > address space to the generic address space via uintptr_t [1] > to fix a couple of: > > arch_timer.c:1395:66: warning: incorrect type in argument 2 (different address spaces) > arch_timer.c:1395:66: expected void *vcpu_info > arch_timer.c:1395:66: got struct kvm_vcpu *[noderef] __percpu * > > sparse warnings. > > There were no changes in the resulting object files. > > [1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name > > Signed-off-by: Uros Bizjak > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: Joey Gouly > Cc: Suzuki K Poulose > Cc: Zenghui Yu > Cc: Catalin Marinas > Cc: Will Deacon > --- > arch/arm64/kvm/arch_timer.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c > index 1215df590418..a13bb9e8dc19 100644 > --- a/arch/arm64/kvm/arch_timer.c > +++ b/arch/arm64/kvm/arch_timer.c > @@ -1392,7 +1392,7 @@ int __init kvm_timer_hyp_init(bool has_gic) > > if (has_gic) { > err = irq_set_vcpu_affinity(host_vtimer_irq, > - kvm_get_running_vcpus()); > + (void *)(uintptr_t)kvm_get_running_vcpus()); > if (err) { > kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); > goto out_free_vtimer_irq; > @@ -1416,7 +1416,7 @@ int __init kvm_timer_hyp_init(bool has_gic) > > if (has_gic) { > err = irq_set_vcpu_affinity(host_ptimer_irq, > - kvm_get_running_vcpus()); > + (void *)(uintptr_t)kvm_get_running_vcpus()); > if (err) { > kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); > goto out_free_ptimer_irq; I think the fix is worse than the current code, because there is no real semantics behind the pointer being passed to irq_set_vcpu_affinity(). All that is required is that it is a non-NULL pointer. I expect the following hack to work just as well and not suffer from any sparse indigestion. Untested though. M. diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 1215df5904185..8058d92048fb4 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -1391,8 +1391,7 @@ int __init kvm_timer_hyp_init(bool has_gic) } if (has_gic) { - err = irq_set_vcpu_affinity(host_vtimer_irq, - kvm_get_running_vcpus()); + err = irq_set_vcpu_affinity(host_vtimer_irq, info); if (err) { kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); goto out_free_vtimer_irq; @@ -1415,8 +1414,7 @@ int __init kvm_timer_hyp_init(bool has_gic) } if (has_gic) { - err = irq_set_vcpu_affinity(host_ptimer_irq, - kvm_get_running_vcpus()); + err = irq_set_vcpu_affinity(host_ptimer_irq, info); if (err) { kvm_err("kvm_arch_timer: error setting vcpu affinity\n"); goto out_free_ptimer_irq; -- Without deviation from the norm, progress is not possible.