From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 904D1606A320 for ; Mon, 30 Nov 2026 14:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=RXh609hz; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=rwPGanB3 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=aFpNB59S2VaaLzDMPOtHxuahmuPIDY9sh1xiiHlrMFM=; b=RXh609hz20CIhTv+800kvn2Aj0 0JCpT3uM6V6bcTP8LTKycsYCLujrHIepSnR8H9XAHbz5oPy21SOCWGOdeQrKrGcxpQ4MdKJLF8j3F p2I1xt9gLkZ2dEhLiJSgnxUCcZyiHSeSK47CAo/YBR7peqCcmLSVDQ+Z6gjYUZ7hjXkKh8bLirKnv EEQ51aNj7tbSrzHH9QGbufdXw1VtNB4fiNAVXxxkbnH6WGZSQtpVWnf+HotyLfuQ9z5x6tkEVNTM2 yPpmqiUXlph3ltMtrHNhIzA9AwAhq4SQPXWhNWBNostbZV8nGhB9NlGg2WtzK6oOCF4TxjAx3QKOZ ZSqRV+fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY2cb-00000004w7a-1DwD; Mon, 30 Nov 2026 14:44:49 +0000 Received: from out-196.mta0.migadu.com ([2001:41d0:1004:224b::c4] helo=mta0.migadu.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY2cX-00000004w6N-3Ct1 for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 14:44:47 +0000 X-Envelope-To: linux-arm-kernel@lists.infradead.org DKIM-Signature: a=rsa-sha256; bh=fBPHjSuTvikkoExhVf1SfkmaY6NPXpgky+uIi2o91Qs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796049883; v=1; x=1796654683; b=rwPGanB3k3YbdVuaWgyWfndGqy1j5eglld8QkXxavCklz52CIAWzTDiuqfQSRjt2ZyXdfpwD hASdCMaLzc8+6NrE1VXLNXvbsgmOCDoJxZYvfGNXNoFHnkfRXd+yfmj5PsW7ZGKl/LH/I+GjGsM jVN/OpQQ5whZdoEOqPVkPY1g= X-Envelope-To: linux-arm-kernel@lists.infradead.org Received: by smtp.migadu.com with ESMTPS id 56d878d9ca8da8b2; Mon, 30 Nov 2026 14:44:43 +0000 X-Mizu-Trace-ID: 56d878d9ca8da8b2 X-Migadu-Flow: FLOW_OUT From: Fuad Tabba To: Marc Zyngier , Oliver Upton Cc: Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Vincent Donnefort , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] KVM: arm64: Fixes for a vCPU caught in a disallowed AArch32 mode Date: Mon, 30 Nov 2026 14:44:35 +0000 Message-ID: <20261130144438.3176276-1-fuad.tabba@linux.dev> X-Mailer: git-send-email 2.47.3 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_064446_083134_C9AAEF2D X-CRM114-Status: GOOD ( 13.38 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi folks, KVM marks a vCPU as uninitialized once its guest has entered a disallowed AArch32 mode, and the VMM has to call KVM_ARM_VCPU_INIT before it can run the vCPU again. This series fixes how KVM_ARM_VCPU_INIT and KVM_RUN handle such a vCPU. KVM_ARM_VCPU_INIT sets the vCPU up a second time, as if it never ran. For a nested vCPU, this can free the VNCR page that the virtual timer still reads, and for any vCPU it resets MPIDR_EL1 and CLIDR_EL1 a second time. With the first patch, a vCPU that has run is only reset. KVM_RUN checks that a vCPU is initialized only when the thread issuing it changes, so the same thread can still run the vCPU. The second patch makes KVM_RUN check every time. For a protected vCPU, EL2 marks its own copy of the vCPU but never checks it. With the third patch, EL2 doesn't run a vCPU that it has marked. Tested on QEMU. The KASAN report in the first patch is from a host booted with kvm-arm.mode=nested, with fault injection failing the nested MMU allocation when the VMM calls KVM_ARM_VCPU_INIT again. With the series, KVM_ARM_VCPU_INIT doesn't reach that allocation, MPIDR_EL1 keeps the value that the VMM wrote, and a protected guest that enters AArch32 EL0 doesn't run again. Based on Linux 7.4-rc3 (aebb727447640). Cheers, /fuad Fuad Tabba (3): KVM: arm64: Don't call kvm_setup_vcpu() again once a vCPU has run KVM: arm64: Reject KVM_RUN on a vCPU that's no longer initialized KVM: arm64: Don't run a protected vCPU that was caught in AArch32 arch/arm64/kvm/arm.c | 8 +++++++- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 4 ++++ arch/arm64/kvm/hyp/nvhe/switch.c | 7 +++---- 3 files changed, 14 insertions(+), 5 deletions(-) base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3 -- 2.47.3