Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.247 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049886; b=n2SWJMECzMQ9sRNYOI/9DJu552YSYqKePW7+HML4ebdXePwQt65PeuCww4hGb2MaEVDU BU/OhPZywJlwS3u90mO9fYmrS2Cojjfar1NW/phpMMCNZHkWZyaT90Q7Y+8x2yiKCvODc avcEO3l1YevfPA+mH9k4Lxk9J8tIigV/bsX1FZ/eh9u4Wxujup5+7sUQKUlL1BehcxrOg mz5oGhZdYqHSExPEU3CjVDNymmiENEBur/ksFCpe1UFgoybdJhX6wVuHEDbdDGgILkvTR 2HC/p+y6CN80x+jS1Aiaas7RuW5t7tmHgo891uXmxjdTra+mb1woDOeAImangGjBOQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049886; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=aFpNB59S2VaaLzDMPOtHxuahmuPIDY9sh1xiiHlrMFM=; b=HLL7YKoCtic+FxUWttBu+7m5AKLuV6+Vv652Q1AUkOe8hvkVPcu6INkzwa8cwW0KX1Rh buOKSoBV7GJUqvZcdXCkBUr4zKQRgX1CZPut+oMQKMzFbgob8XLuGW0p7J3jWXGp5dyz9 aXzrxmXxN2JryofBPuBL28BtdKzPiQQrzNuhpXMZRsUlBdBb/epu1I9RPJJPL8bYR2oE3 u7HBT50rgmyMMzuPj8fyMnlZo/tPljSGnce23FDLl+0cjk+3B5QaRmx8iRzhu19eUcL6S +D0jLGchydd1xXjLnja84TvQPFqgOecXO80HPJYNcb2iXB94I+9r4R8WjsMyC1IwziQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=rwPGanB3; arc=none smtp.remote-ip=95.215.58.247 Received: from mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94826606A320 for ; Mon, 30 Nov 2026 14:44:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94826606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=rwPGanB3 X-Envelope-To: kvmarm@lists.linux.dev 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: kvmarm@lists.linux.dev 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-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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