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=1796029593; b=hHlMqF7noNNIHsN+WIWJNgj91WhcS87LUG0aVvGPpcy5wqdOMTfiPbELGka9zHGDC3L/ DXOsYtt85UwxZsWTgLx2qXbbTUhjvydf9j0d5gtPcxUM84zhuXHmIds281kJNxgoLRxeK TTQ/KviopwyZS4jbTytdvMA3IiVVHZWk12/VbBJg4r60yPj9erwr12KmPWCOIjBiSugRm kblMSef2z+qEx0rdOnFsjKWFL4tPa/wvaw+4rdd+JnilV+IjGKXnnmD9/rTSV8CFUi4r8 e55lR+ZUT0HDp9PY1FoePv8XGiK/6WBTEt96ixETwviAWa2rBj/jY3xNFPhgKQ11dHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796029593; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Yq2DcD3NukFdrLJ07uky9gHvtfjizVRhW0lgyaNXy6Y=; b=zR+K5ItI0+9m6AAs5ywYlUmx8XXiOKCshO1WJkeYhPv+VD8wjsC5aLLdl5cDDDp4TXcQ h3Oanxcek92qz9ZrK67iuJ14a60G0l3CczJ9kkOZtkKhuyYpgel5DuUvLjrBFNeJXGXjG N4MQGGNCX0QOTVdK9iE1HaGbwvPItkfWuEBscpmSjzvR+NVKwjUCL5NIRjMlm9biGYa3b aIHnOBv7yuIqWYZLE8cVIs5+0g905gZPM9gWqegxonXSM+wu1xbvyG9SpQyik1KqvcF9O xIovuYBiPt3/wV1bYKn/vHPDXGpmxKUZ/uhzD/AE/q+hEVJNM+crL6en6vTCM0R9L4w== 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=Ny0EsG69; 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 2CC1F606A31C; Mon, 30 Nov 2026 09:06:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ny0EsG69 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85B7F1F000C1; Mon, 30 Nov 2026 09:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796029592; bh=Yq2DcD3NukFdrLJ07uky9gHvtfjizVRhW0lgyaNXy6Y=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Ny0EsG69VwveuTYbA9ZvGhySl7NQ5SbT8hTTH//7BOWSEuxtEQcO1Igk0FcaBKYJi k21tL3oSboJOswHYXqNbqPhBu6DOLCSS+YUmnsQWVCYlmFW0g5q7ESRgYu8YBokvs4 giWNduaZKrQsho64vLl62asxmQbPWujwLGoH7ai1Y+9YZ9DqPMIMXa5CR36ruOQafZ Sx36BoTgm5ezYwR9+k+Ox6E1wJkoVf8Q5o7V9VwoTHxsEiC4LdzeTbyTr7P2nNnrec y0PcAu6k+42TDBFG2XISPLePxui0Dsdr4z+/vWWcINtKCveGXl24BQMkN4eKUEFxEN cKk/83/uoK3DQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 9/9] KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state Reply-To: sashiko-reviews@lists.linux.dev To: "Dan Carpenter" Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261130-double_exception_v3-v3-9-864856664b26@pereq.eu> References: <20261130-double_exception_v3-v3-0-864856664b26@pereq.eu> <20261130-double_exception_v3-v3-9-864856664b26@pereq.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 09:06:32 +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 2 potential issues to consider: - [Medium] KVM: arm64: selftests: test_reset() fails to test NESTED_SERROR_PENDING reset - [Low] KVM: arm64: selftests: inaccurate register names in vcpu_reset comment and log -- commit e0dc05479432662821477413d58658908cb2348e Author: Dan Carpenter KVM: arm64: selftests: Test that a vcpu reset clears the vcpu's state This commit adds an arm64 KVM selftest verifying that KVM_ARM_VCPU_INIT resets modified registers, pending SErrors, and pending MMIO reads back to the state of a freshly initialized vCPU. > diff --git a/tools/testing/selftests/kvm/arm64/vcpu_reset.c b/tools/testi= ng/selftests/kvm/arm64/vcpu_reset.c > new file mode 100644 > index 0000000000000..cdc051e4b897e > --- /dev/null > +++ b/tools/testing/selftests/kvm/arm64/vcpu_reset.c > @@ -0,0 +1,210 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * vcpu_reset - Test that resetting a vcpu that has run with KVM_ARM_VCP= U_INIT > + * puts it back in the state of a new vcpu. > + * > + * Before the reset, the vcpu has an MMIO read waiting for userspace and= a > + * pending SError, and userspace has written to every register it can. = After > + * the reset, every register must match a new vcpu's, except the ones in > + * preserved_regs[], which must keep the value userspace wrote, and the > + * counters, which keep counting. No SError may be pending, and the next > + * KVM_RUN must not complete the MMIO read. > + */ [Severity: Low] This isn't a bug, but this comment refers to preserved_regs[] while the code uses is_preserved(). Also, the commit message refers to CLIDR_EL1 and CCSIDR as counters that keep counting, whereas those are cache ID registers in is_preserved() and the counters are KVM_REG_ARM_TIMER_CNT and KVM_REG_ARM_PTIMER_CNT in is_counter(). [ ... ] > +static void test_reset(bool el2) > +{ > + struct kvm_vcpu_events events =3D {}; > + struct regs new, before, after; > + struct kvm_vcpu *vcpu, *ref; > + struct kvm_vm *vm, *ref_vm; > + u64 i, id; > + > + /* > + * A new vcpu: initialised again to undo what the library set up, and > + * through its first KVM_RUN without running any code. > + */ > + ref_vm =3D create_vcpu(el2, &ref); > + vcpu_ioctl(ref, KVM_ARM_VCPU_INIT, &ref->init); > + vcpu_run_complete_io(ref); > + get_regs(ref, &new); > + > + vm =3D create_vcpu(el2, &vcpu); > + virt_map(vm, MMIO_ADDR, MMIO_ADDR, 1); > + > + vcpu_run(vcpu); > + TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_MMIO); > + TEST_ASSERT(!vcpu->run->mmio.is_write, "Expected an MMIO read"); > + memset(vcpu->run->mmio.data, 0x5a, sizeof(vcpu->run->mmio.data)); > + > + events.exception.serror_pending =3D true; > + vcpu_events_set(vcpu, &events); [Severity: Medium] Does calling vcpu_events_set() after vcpu_run() leave NESTED_SERROR_PENDING untested when el2 is true? aarch64_vcpu_setup() sets HCR_EL2_TGE and HCR_EL2_E2H in SYS_HCR_EL2 and leaves PSTATE.A set, so kvm_serror_undeliverable_at_el2() returns false and kvm_inject_serror_esr() pends the SError in HCR_EL2_VSE rather than NESTED_SERROR_PENDING: arch/arm64/kvm/inject_fault.c:kvm_inject_serror_esr() { ... if (vcpu_is_el2(vcpu) && kvm_serror_undeliverable_at_el2(vcpu)) { vcpu_set_vsesr(vcpu, esr); vcpu_set_flag(vcpu, NESTED_SERROR_PENDING); return 1; } ... } Because no KVM_RUN exit occurs between vcpu_events_set() and KVM_ARM_VCPU_INIT, kvm_nested_sync_hwstate() never runs to move HCR_EL2_VSE into NESTED_SERROR_PENDING, and test_reset(true) would pass even if kvm_reset_vcpu() failed to clear NESTED_SERROR_PENDING. Calling vcpu_events_set() before vcpu_run() would let the KVM_EXIT_MMIO exit sync HCR_EL2_VSE into NESTED_SERROR_PENDING while PSTATE.A keeps the SError masked during the guest MMIO read. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-double_exc= eption_v3-v3-0-864856664b26@pereq.eu?part=3D9