From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F493103E198 for ; Wed, 18 Mar 2026 15:56:58 +0000 (UTC) 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:References:In-Reply-To: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:List-Owner; bh=Q2Bo4Wrx8X+w9pa8/LvM10LXfhgTXyAZZYvN+RoLxJM=; b=sfTfO+bo75FT7Lzd4v+KNqFTBQ kzjUZBrkzuicOR+B+7UWNBHmGFpMeMKNqiIVhSnRJUb6Bz/MLIujXP7O53Nlm9UyKjr3511bnL2ou Kxn8TYBNlKSY970jo22orFTap/Q7jPXplObfgqLs/T8sLHYnLHoLD1+J5aBgyW7mr6Lm3l8OVKCPO 1z5blNGq572XGwELwVSvpjyk+1GLTGqyH5d5gPfa++jOlOwvWm3zKsQV13GvIpGhXPRJ+DOYmOkYn du1D2SVx5pqR3bI0J0bLM/MrzRdaSJ14VcZaLzyIoPmJ2ftiGoRkUGBMj53+5ywOV4M75/llpOwOh +db6oIBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2tGO-00000008q6m-07nw; Wed, 18 Mar 2026 15:56:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2tG3-00000008pkl-22lp for linux-arm-kernel@bombadil.infradead.org; Wed, 18 Mar 2026 15:56:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Q2Bo4Wrx8X+w9pa8/LvM10LXfhgTXyAZZYvN+RoLxJM=; b=Cm9653/KUdaC06SIml8vs6Pujx h5QVdBG6P/F+171Kqosk5Lxn/d4OZm9vNXd2JMZEv7PU08tCxrRkTzaw7yCIQAkPxmX6Nm8hKRhk+ CTPGR9bfjHFoFLpcRqkPSbswU1PXYQCbBxcDhGsO2XZafTiDPmUKmXUsaOYx153fTy3EZUI7YmYRU Net99X2/z6cqRCnOLdgRuB9J3M8+kHJsbNTlELy4weukeRDg1S4utzMFFWvjE3d+1eNN7lrM1WceG FnjO5fZPmQO0P05r8mD5Xqxm8I1PCHF6CHBz/Bdd987v3MSz+lTRLZLt2hGTK3KYsWhQmfPGNw0Wq 101zpMTQ==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2tFy-0000000Bdox-2bDC for linux-arm-kernel@lists.infradead.org; Wed, 18 Mar 2026 15:56:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E50E2008; Wed, 18 Mar 2026 08:56:19 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.61.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E68A93F73B; Wed, 18 Mar 2026 08:56:21 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Joey Gouly , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , Steven Price Subject: [PATCH v13 33/48] arm64: RMI: allow userspace to inject aborts Date: Wed, 18 Mar 2026 15:53:57 +0000 Message-ID: <20260318155413.793430-34-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260318155413.793430-1-steven.price@arm.com> References: <20260318155413.793430-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260318_155626_842280_54D7EECF X-CRM114-Status: GOOD ( 15.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Joey Gouly Extend KVM_SET_VCPU_EVENTS to support realms, where KVM cannot set the system registers, and the RMM must perform it on next REC entry. Signed-off-by: Joey Gouly Signed-off-by: Steven Price Reviewed-by: Gavin Shan --- Documentation/virt/kvm/api.rst | 2 ++ arch/arm64/kvm/guest.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 70911fe6d435..eabe20d3ae76 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -1310,6 +1310,8 @@ User space may need to inject several types of events to the guest. Set the pending SError exception state for this VCPU. It is not possible to 'cancel' an Serror that has been made pending. +User space cannot inject SErrors into Realms. + If the guest performed an access to I/O memory which could not be handled by userspace, for example because of missing instruction syndrome decode information or because there is no device mapped at the accessed IPA, then diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index e62a4feddff3..d9f392cb2759 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -827,6 +827,30 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, u64 esr = events->exception.serror_esr; int ret = 0; + if (vcpu_is_rec(vcpu)) { + /* Cannot inject SError into a Realm. */ + if (serror_pending) + return -EINVAL; + + /* + * If a data abort is pending, set the flag and let the RMM + * inject an SEA when the REC is scheduled to be run. + */ + if (ext_dabt_pending) { + /* + * Can only inject SEA into a Realm if the previous exit + * was due to a data abort of an Unprotected IPA. + */ + if (!(vcpu->arch.rec.run->enter.flags & REC_ENTER_FLAG_EMULATED_MMIO)) + return -EINVAL; + + vcpu->arch.rec.run->enter.flags &= ~REC_ENTER_FLAG_EMULATED_MMIO; + vcpu->arch.rec.run->enter.flags |= REC_ENTER_FLAG_INJECT_SEA; + } + + return 0; + } + /* * Immediately commit the pending SEA to the vCPU's architectural * state which is necessary since we do not return a pending SEA -- 2.43.0