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 63C8F54723 for ; Fri, 13 Feb 2026 13:52:35 +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=1770990755; cv=none; b=XwWvbjIojhKOYkUBrSzWE4O+kigRTcDp9RQ4HcieawNYRQWtKEYgwD86gNQj2DgkAxIzV+D9FdnlDmgHaZNlrgfTjIVVPMuS7c3YNEleQgJUhHilvQuQXvUl/rhiaK15fqBlBm+4ISToeTTdjKHzvs10BXV/9n8FHkZCamavNj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770990755; c=relaxed/simple; bh=pV4iDxkd8tS38ALbSL/w7Hzb4h/1dnxbhKMm65qgCeE=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=pDvzny6ZIpIb8SnFizbzSglDL2pjck36gZmAuSQ85W8ktdIVtvUM3APVL07yuKA8oRG7VNegM3X7jahjsfip8RP8HrKHFlPFLYHOHCyhtsineJu44TyX4am5L4Z1JQR9VLEIdHR2rIx7OuWwWZfdzxBUPUFDh/54q6QEJi5aGTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RIwol9LQ; 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="RIwol9LQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 257CBC16AAE; Fri, 13 Feb 2026 13:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770990755; bh=pV4iDxkd8tS38ALbSL/w7Hzb4h/1dnxbhKMm65qgCeE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RIwol9LQnymaq9h1PW13F+UDz0nA9uZI/FRffeLqhIcUr2AvITj3WUcpLO2cFlqpL a6wNDkJyM1mNXm/R88PyPJEmCewBDklLy0+oN+v2T9A/d3y7kZaUC7XiILPe54I/SI eCSDXHFYb4KY8nuovzs4ZCR3j/re/nxYJT8j6SteGYvFQozsfBpXIv7C/B8E9EDmcc u+tu9J9utCeIJLAj99yClCWm0HVu3a3vK4wyviOr2xtHZoMYUl2JAhto3mvajJ0J3s +Bxb1tRbyVDVJ0tY81SwTc/xqlOVUvPtGdfN6xmW43HrFzR654gkQ0yZTffVSIM8DY apJnN4NCsaKCQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vqtay-0000000AtKw-47xb; Fri, 13 Feb 2026 13:52:33 +0000 Date: Fri, 13 Feb 2026 13:52:32 +0000 Message-ID: <87ecmoeonz.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Quentin Perret , kvmarm@lists.linux.dev, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com Subject: Re: Broken udelay() on KVM host with a vcpu loaded In-Reply-To: References: <86qzqsbw1m.wl-maz@kernel.org> <86o6lwbchv.wl-maz@kernel.org> 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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev 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: will@kernel.org, qperret@google.com, kvmarm@lists.linux.dev, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com 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 Feb 2026 11:50:17 +0000, Will Deacon wrote: > > On Tue, Feb 10, 2026 at 07:54:36PM +0000, Marc Zyngier wrote: > > On Tue, 10 Feb 2026 15:58:14 +0000, > > Quentin Perret wrote: > > > > > > Ouch, it does seem that the SET_ONE_REG stuff allows to mess with that > > > value _out of vcpu context_, so yeah userspace could change the value > > > while a vcpu thread is preempted in the middle of a udelay loop ... > > > > I don't think so. You can only do that on the vcpu fd, and if the vcpu > > is loaded, it means that you are already holding the vcpu mutex. And > > if you do that from the vcpu thread, then you already have done a > > vcpu_put(). > > Just working this through, I think you're right that the vCPU mutex > saves us here (thanks!), although that's because it's held across the > duration of the KVM_RUN ioctl() and not because of the vcpu_put() (which > would run off the back of the preempt notifier if we were preempted > anyway). Duh, yes. Sorry about the confusing explanation. it was perfectly clear in my head, I swear! > It would be good to capture that in a comment if we go with your > approach of using the virtual counter on the host. Sure, I'll add a comment to that effect and post it shortly. Thanks, M. -- Jazz isn't dead. It just smells funny.