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 5EE56270EA7 for ; Tue, 29 Apr 2025 03:37:49 +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=1745897870; cv=none; b=HsTMkDfp35djJcl5ydB2U7vmcSEvzqK5O8D27IryntFw0C3FyjiZwmWXL+mun2X7mvDSfXMJAHXbIrMUP5dr6DRzsczS8/sMqL81KkMyK5H6P0/IM/zIqKIksDKuKBaAHHF1o2iJ5ydIYJ1UQ6iH8JTtnYvCJ3DezG3aTk/jeic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745897870; c=relaxed/simple; bh=o0Bsyt7FrbTQfBgId6i0wm7Wph0D2g6CxMizX1LW4V0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ktsbTJhFXmH9Y12gMUw86zOyWnwQ3IJU8OYK4gRgy3ZnRw1JlFfRWGnmxbPuX7QSnUehwuDWvGcccagEteEO5OYsZqtYEO9XrnbRMKbUtcF6swA7OFpkxpLnuuhsZJQS4kG1IUtTskmLq7UijmUbuVeUZZK98ADbehuQE3z+Gr4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FNH2/yEu; 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="FNH2/yEu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 654ECC4CEEB; Tue, 29 Apr 2025 03:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745897869; bh=o0Bsyt7FrbTQfBgId6i0wm7Wph0D2g6CxMizX1LW4V0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=FNH2/yEuwhUksTGtHTEl8lZBWxi0kKElKEoJtS5lNF1XiM6YXm6+bpvm4g6ETLRdm 9vOAnmKfZBPjZcJnZV41JT780Buu2/o7GBGlUMnH+YQDCAFKglEYzjSY41Cxc00tuD HmHKM2ZMNW955iKH3OP48RN2MjUFu4a4eJJjhD8Q8tkIvkfKn5CGA+O5yG8yj5SOK8 B19AQVNwin+EX9HYW0V4IyyBAD9qPbY/aEmEn3uk/QsEeip84+n53o9ufuXagqPs7G 9DRBd2aV9tluav4CpRyV0iCnUze2RV15umtqm11JacPfSNc+vdWpocX7Ar5MHTW0ts 2EVz4F1LJYTEg== X-Mailer: emacs 30.1 (via feedmail 11-beta-1 Q) From: Aneesh Kumar K.V To: Alexandru Elisei Cc: kvm@vger.kernel.org, Suzuki K Poulose , Steven Price , Will Deacon , Julien Thierry Subject: Re: [PATCH kvmtool v3 2/3] cpu: vmexit: Retry KVM_RUN ioctl on EINTR and EAGAIN In-Reply-To: References: <20250428115745.70832-1-aneesh.kumar@kernel.org> <20250428115745.70832-3-aneesh.kumar@kernel.org> Date: Tue, 29 Apr 2025 09:07:02 +0530 Message-ID: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Alexandru Elisei writes: > Hi Aneesh, > > Is this to fix Will's report that the series breaks boot on x86? > Yes. > On Mon, Apr 28, 2025 at 05:27:44PM +0530, Aneesh Kumar K.V (Arm) wrote: >> When KVM_RUN fails with EINTR or EAGAIN, we should retry the ioctl >> without checking kvm_run->exit_reason. These errors don't indicate a >> valid VM exit, hence exit_reason may contain stale or undefined values. > > EAGAIN is not documented in Documentation/virt/kvm/api.rst. So I'm going to > assume it's this code path that is causing the -EAGAIN return value [1]. > IIUC, EAGAIN and EINTR are syscall return errno that indicates a system call need to be retried. Documentation/virt/kvm/api.rst do mention that exit_reason is value only with return value 0. __u32 exit_reason; When KVM_RUN has returned successfully (return value 0), this informs application code why KVM_RUN has returned. > > If that's the case, how does retrying KVM_RUN solve the issue? Just trying to > get to the bottom of it, because there's not much detail in the docs. > > [1] https://elixir.bootlin.com/linux/v6.15-rc3/source/arch/x86/kvm/x86.c#L11532 > > So in that code path vcpu will be in kvm_vcpu_block(vcpu) waiting for the IPI. On IPI kvm_apic_accept_events() will return 0 after setting the vcpu->arch.mp_state. Hence a KVM_RUN ioctl again will find the mp_state correctly updated. -aneesh