From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796318677; b=YzYa8JV8l9YR69aUZ4NBpf4NxYdamICj0mqjhhKOQMy/7xQjqdH9Vm1IOOl9zoB2zLHy ZRatOsOHRWuMeMoHV3vGqpG4c7sij/qCE9nWYeh9dky/Im9MN3oe9l8qc9ybjlVfItZAx wcJPkerBfJpyEjtr8oMu524umMqDTUGFY8G6uTuMpmDw+DIAAMg5j3gkSCcbJccucbfGh gtU8+O1rr8VRLlC2uoFwv5XeDwG2KJDjr84x0O48P376wkhtY+OUyhly0RWg9ZkQN5W94 W1hvza7zcFX7b8JPRAHLUj/NFOPYWRO+TEUvvcFLvpfPk7iNGe+CKs4Hqn/+lB75Ufg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796318677; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=JyD/OAVsnYfKV6W/GmflRRdpm9APmWzshOaq2YBAr0E=; b=QRx6rrGzNPI1jiGLq0oD451KkfSimI3XNmGcxbPlEPQQGHyiokM7Pdo4I4maaPAxvUWT eAKr1wCC3RHw1ekb/37jVaIqjzGZ14l7phvCTnIQmEoDcJoVu32wGU1936/xhLk67o32s uyOR+4eBFu+MdlbnMOX421x7qW2UDI39MiQIn/Vo+VZgWVbxpYIM78z+Uxx0nb+jhLm/p xwbhDo10p5cJZTkP+gdVSjodm1RVp93QeUaMQLtY6juHIEcJ6XbaqwgtR97DDxjzKI1PQ E+8WCPkeBzr9WOmePgkpGDBRlf1r5UWUjKntkzipumsDwTmguyuneY4hYDSrE8oW4pQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZ19dKFn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCC8C606A322; Thu, 3 Dec 2026 17:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZ19dKFn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 009B41F00893; Thu, 3 Dec 2026 17:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796318677; bh=JyD/OAVsnYfKV6W/GmflRRdpm9APmWzshOaq2YBAr0E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iZ19dKFnnRcrPS0NALu8Y70qJxuouQ5cGXiA/YfP3SY4GgFvQhMGP8TcB1ocf/ISy y34J7Hjq+5Oa0wIwRZdaSzQCvQEgcv3a7rrD0jve1fvcPY/GcxuoITQJBYjpXoMqJB byjJyeTI6i4H7sszU6fmNnShdZBS9nea4JxPXZ+SNBU9+abV4QlLLxeUe4k3Tkpvjy mb++zNLLmMkOGaKfHMD29YJK5g3M0ybHj8qwUK8XBxpaE0xwvfWtG7B82lSuIwcsST TAkYeyzntjgcgcQzOhOs1AFaKzYFhXu7yAXJ2byhM58a2+cnm3gJQBiVqTANver9hI tuIxKwNzHrJHg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 03/12] KVM: s390: Small miscellaneous CMMA fixes Reply-To: sashiko-reviews@lists.linux.dev To: "Claudio Imbrenda" , kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261203161527.188235-4-imbrenda@linux.ibm.com> References: <20261203161527.188235-1-imbrenda@linux.ibm.com> <20261203161527.188235-4-imbrenda@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:24:36 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] KVM: s390: unconditional set_bit() in handle_essa() bounces gmap cacheline - [Low] KVM: s390: duplicate set_bit() and misleading comment in handle_essa() - [Low] KVM: s390: commit message lacks rationale and omits Fixes tag 190df4a212a7 -- commit cd4e277c7fd2a4a1a6aeb296049a2aed0451995b Author: Claudio Imbrenda > KVM: s390: Small miscellaneous CMMA fixes > > Set the CMMA flag also when the first ESSA instruction was performed in > migration mode. > > Set the CMMA flag in kvm_s390_set_cmma_bits() before starting to set > the CMMA values, instead of afterwards. > > Fix the stale comments in handle_essa(). > > Fence UCONTROL VMs from using the KVM_S390_SET_CMMA_BITS ioctl, > returning -EINVAL. > > Fixes: e38c884df921 ("KVM: s390: Switch to new gmap") > Cc: stable@vger.kernel.org > Signed-off-by: Claudio Imbrenda [Severity: Low] The commit message describes what each change does, but not why (for example, why missing GMAP_FLAG_USES_CMM in migration mode breaks kvm_s390_get_cmma_bits(), or why UCONTROL VMs must now be fenced from KVM_S390_SET_CMMA_BITS). Also, failing to mark CMMA as used in the migration-mode branch of handle_essa() was introduced in 190df4a212a7 ("KVM: s390: CMMA tracking, ESSA emulation, migration mode"), not e38c884df921 ("KVM: s390: Switch to new gmap"). Omitting 190df4a212a7 prevents stable backporting to kernels prior to e38c884df921. > diff --git a/arch/s390/kvm/s390/priv.c b/arch/s390/kvm/s390/priv.c > index f22612a127c96..4b590c09240cf 100644 > --- a/arch/s390/kvm/s390/priv.c > +++ b/arch/s390/kvm/s390/priv.c > @@ -1243,19 +1243,15 @@ static int handle_essa(struct kvm_vcpu *vcpu) > if (!READ_ONCE(vcpu->kvm->arch.migration_mode)) { > /* > * CMMA is enabled in the KVM settings, but is disabled in > - * the SIE block and in the mm_context, and we are not doing > - * a migration. Enable CMMA in the mm_context. > - * Since we need to take a write lock to write to the context > - * to avoid races with storage keys handling, we check if the > - * value really needs to be written to; if the value is > - * already correct, we do nothing and avoid the lock. > + * the SIE block and in the gmap, and we are not doing a > + * migration. Enable CMMA in the gmap. > */ > set_bit(GMAP_FLAG_USES_CMM, &vcpu->arch.gmap->flags); [Severity: Low] Both branches of the migration_mode check now start with set_bit(GMAP_FLAG_USES_CMM, &vcpu->arch.gmap->flags); could this be hoisted above the if? The updated comment here also implies CMMA is only enabled in the gmap outside migration mode, which contradicts the else branch below. [ ... ] > @@ -1264,6 +1260,8 @@ static int handle_essa(struct kvm_vcpu *vcpu) > /* Retry the ESSA instruction */ > kvm_s390_retry_instr(vcpu); > } else { > + set_bit(GMAP_FLAG_USES_CMM, &vcpu->arch.gmap->flags); > + > scoped_guard(mutex, &vcpu->kvm->slots_arch_lock) > scoped_guard(read_lock, &vcpu->kvm->mmu_lock) > i =3D __do_essa(vcpu, orc); [Severity: Medium] Can this unconditional set_bit() bounce the struct gmap cacheline across vCPUs during live migration? In migration mode, ECB2_CMMA is cleared so every guest ESSA instruction enters this else branch. On s390, set_bit() unconditionally executes an atomic laog, taking exclusive ownership of the struct gmap cacheline even when GMAP_FLAG_USES_CMM is already set. Because struct gmap fits in a single 256-byte cacheline, this invalidates it for other vCPUs reading gmap->flags on every SIE entry (vcpu_pre_run() -> kvm_is_ucontrol()). Guarding the write with if (!uses_cmm(vcpu->arch.gmap)), as _gmap_enable_skeys() does with uses_skeys(), would keep the cacheline shared after the first ESSA. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203161527.1882= 35-1-imbrenda@linux.ibm.com?part=3D3