From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E07B64252B5; Wed, 8 Jul 2026 10:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783507386; cv=none; b=KI+9fcC4BTCPEy3ZLxKSfs/+iZk37TmMVlMFRKX4RnVxQAZ21UU0Td+YtyXKRB7K3GIP4iNOuiAmHgxGCshI2M3qZwseEUeeLuxpZXNIpBXuPytrilh9uzdnth6cFdWxEPhOifkzZD7XhTMATzW+AfdOGA2KqNZY9P+igObiuLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783507386; c=relaxed/simple; bh=g1cEDVucPut9nx4DxUDgLwvwvEc+KFxNwPycj1pZ2/Q=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=MEgiYnJZ4OkVRFt9yOTiv+dulCvnVfuPdeUkUN746n2uD4v1IJmr3CVndZywLivPmtg2fOrM2ShWbEcBMpNdJZJ6bsDd8WgsEcPafFYoj672iRbkAH7Cpxuk2P04KVZ08XOBlIi0UXiyaqAkD8Gbp0K7sX197sMSAC/toZmZbxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eok20oS+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Eok20oS+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F29401F000E9; Wed, 8 Jul 2026 10:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783507373; bh=l4UyoSNyXebLeXjulHaoflPQw9V3It1bzboWcTLzP7s=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Eok20oS+ydCL9nQkOELYtvSANI3EO+8Mppguumlyf4qv4bE/mnNXLqjmaKSJLdLAz e6wySYAdHbh0lv8vXonOiEQ1APKQGtVddR3qvacEXeqAGRcGA1Nr85Lgc3tF1lgoo2 bLF4lm+DuOFXrVmxvIDPZq/3uf3OfiMmil7FQwibynaZFTySQNWU4ZltrUHId1Jlf5 YsFeiJTQHvj3P9MVcPixYII7pO1Y15qOzHIniZGV/3SMGy3jCBCoW3GvxJ3JKpl6Bi 8IQwKmj/gDaHZCvwr6Vo2JjHZnC0Ya/9yiBQRw77Z5UBjQ53S4As7lVm39Rmv10X43 qSS3NqxqZ35vg== 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 1whPju-00000002mQn-1Zh5; Wed, 08 Jul 2026 10:42:50 +0000 Date: Wed, 08 Jul 2026 11:44:37 +0100 Message-ID: <874ii97obu.wl-maz@kernel.org> From: Marc Zyngier To: Steffen Eiden Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Alexander Gordeev , Andreas Grapentin , Arnd Bergmann , Catalin Marinas , Christian Borntraeger , Claudio Imbrenda , David Hildenbrand , Friedrich Welter , Gautam Gala , Hariharan Mari , Heiko Carstens , Hendrik Brueckner , Ilya Leoshkevich , Janosch Frank , Joey Gouly , Nico Boehr , Nina Schoetterl-Glausch , Oliver Upton , Paolo Bonzini , Suzuki K Poulose , Sven Schnelle , Ulrich Weigand , Vasily Gorbik , Will Deacon , Zenghui Yu Subject: Re: [PATCH v4 25/27] KVM: s390: arm64: Implement vCPU IOCTLs In-Reply-To: <20260706085229.979525-26-seiden@linux.ibm.com> References: <20260706085229.979525-1-seiden@linux.ibm.com> <20260706085229.979525-26-seiden@linux.ibm.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/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: seiden@linux.ibm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, agordeev@linux.ibm.com, gra@linux.ibm.com, arnd@arndb.de, catalin.marinas@arm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, david@kernel.org, fritz@linux.ibm.com, ggala@linux.ibm.com, hari55@linux.ibm.com, hca@linux.ibm.com, brueckner@linux.ibm.com, iii@linux.ibm.com, frankja@linux.ibm.com, joey.gouly@arm.com, nrb@linux.ibm.com, oss@nina.schoetterlglausch.eu, oupton@kernel.org, pbonzini@redhat.com, suzuki.poulose@arm.com, svens@linux.ibm.com, Ulrich.Weigand@de.ibm.com, gor@linux.ibm.com, will@kernel.org, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 06 Jul 2026 09:52:25 +0100, Steffen Eiden wrote: > > +static void adjust_pc(struct kvm_vcpu *vcpu) > +{ > + if (vcpu_get_flag(vcpu, INCREMENT_PC)) { > + kvm_skip_instr(vcpu); > + vcpu_clear_flag(vcpu, INCREMENT_PC); > + } > +} Can you clarify the semantics of adjust_pc() here? arm64 also deals with exceptions in the same code, and I wonder how you deal with this. > + > +static void arm_vcpu_run(struct kvm_vcpu *vcpu) > +{ > + struct kvm_sae_block *sae_block = &vcpu->arch.sae_block; > + > + adjust_pc(vcpu); > + > + local_irq_disable(); > + guest_enter_irqoff(); > + local_irq_enable(); > + > + sae_block->icptr = 0; > + > + sae64a(sae_block); > + > + local_irq_disable(); > + guest_exit_irqoff(); > + local_irq_enable(); > +} > + > +/** kvm_arch_vcpu_ioctl_run() - run arm64 vCPU > + * > + * Execute arm64 guest instructions using SAE. > + * > + * Returns: > + * 1 enter the guest (should not be observed by userspace) > + * 0 exit to userspace > + * < 0 exit to userspace, where the return value indicates n error > + * > + * > + */ > +int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) > +{ > + DECLARE_KERNEL_FPU_ONSTACK32(fpu_save); > + struct kvm_run *kvm_run = vcpu->run; > + int ret; > + > + if (kvm_run->exit_reason == KVM_EXIT_MMIO) { > + ret = kvm_handle_mmio_return(vcpu); > + if (ret <= 0) > + return ret; > + } > + > + vcpu_load(vcpu); > + > + kernel_fpu_begin(&fpu_save, KERNEL_FPC | KERNEL_VXR); > + load_vx_regs((vcpu->arch.ctxt.vregs)); > + > + if (!vcpu->wants_to_run) { > + ret = -EINTR; > + goto out; > + } > + > + kvm_sigset_activate(vcpu); > + > + might_fault(); > + > + ret = 1; > + do { > + if (signal_pending(current)) { > + kvm_run->exit_reason = KVM_EXIT_INTR; > + ret = -EINTR; > + continue; > + } > + > + if (need_resched()) > + schedule(); > + > + if (ret > 0) > + ret = check_vcpu_requests(vcpu); > + > + vcpu->arch.sae_block.icptr = 0; > + > + arm_vcpu_run(vcpu); > + > + ret = handle_exit(vcpu); > + > + } while (ret > 0); > + > + kvm_sigset_deactivate(vcpu); > +out: > + if (unlikely(vcpu_get_flag(vcpu, INCREMENT_PC))) > + adjust_pc(vcpu); arm64 has the following statements: if (unlikely(vcpu_get_flag(vcpu, PENDING_EXCEPTION) || vcpu_get_flag(vcpu, INCREMENT_PC))) kvm_call_hyp(__kvm_adjust_pc, vcpu); It isn't clear to me why you can afford not to deal with pending exceptions when returning to userspace. Thanks, M. -- Jazz isn't dead. It just smells funny.