Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp19785lql; Fri, 12 Apr 2024 02:11:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1zyl3XDuxmhW7LTA0NhCSq+kuXdLFEt3X7iCuMjzRWHil8TXlyzXzpc0u3XIy5RulNpuOeqRzntd4u7bqydvsIGTaXjK252ImlDzpNQ== X-Google-Smtp-Source: AGHT+IHwFIQhb9iecZqJI12/Q3jQqLU1jSVbpyggVZ8VPobCNM1+ngmqEZxSnVQH35s1uP+8FMKQ X-Received: by 2002:a17:902:d2c5:b0:1e4:32ba:1ef with SMTP id n5-20020a170902d2c500b001e432ba01efmr2225812plc.13.1712913102196; Fri, 12 Apr 2024 02:11:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712913102; cv=pass; d=google.com; s=arc-20160816; b=axs5VRW3qi1d/2n/uu48qda6kSYOOxedrDgER3Zl5jc8mffITYneFSTkly4gb9La/T 1VbSqWCvWQedRVP1nPDGRzjTxtBDDzA6DeFXEtm5+EkpMzPvvKCfYP1NdxspagwIO0su /GxswN3FL47Y/ya7NNuYAGfKhoxF3pmXSJz6fF3wKNdxGBGBtho+fyTo/fPZhOMbrXyH ZCV1l5bmYujlVZOUjbEkr9idkwLNpR9qJHC+WbsmRYHpKzbV57lHgiCYsZ6BXso8oIgk sfcbtPJXCKnGdefgcqfId0mNAUDUSQwqQa2iVe6XkYn0YZCNQXnj45AXcCTbX0E5tLdX IHlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HqpIWLkbiOPKDeOUa08qJvM6euWGhcxXsXvvu+w7ufM=; fh=jZlwjFebu20NcQxJoBNXk9wYQkz+p/PzXpXKor2I3KE=; b=ASnsTMTt283uV2WeHgRUv6ODzuQy5TFKsKuoZjewYb9JTgsPpv6/uKXBCPJIHKQ2pZ 3/aZZfzIbnU8PURV7j6spxpkGVjsUxS0RVwDNUoBLPJbYi8GeC8+sKt6GnqDBOgwAZjs fk5x8j2LjIot2TVKMzAIgpeWOVae+yziSF0tSj7cUc0ag6CPytN7YpelwvHDZLAdCjm6 0TljqixIWMGy4E7TRRKKHA69IqORKuL5JQlt5fXxWcaMjyB4RPyDxWagIGLZTguh3IGf 0Gqg6yOvl+av0MylMea+E7m3oyM50vZ6TfiXY8KbvmFlddhl503fzKWC1X8/6pSYTLfw 0SAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s1-20020a170902a50100b001dedba3a6dbsi2824387plq.358.2024.04.12.02.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 02:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-142297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1200628B319 for ; Fri, 12 Apr 2024 08:56:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5044286AE6; Fri, 12 Apr 2024 08:44:24 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F6DF86263; Fri, 12 Apr 2024 08:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911463; cv=none; b=KJEt1vCOgsLSxVYOXaOHId72Sfli2Q3SpXLkMa/LDw/nfjJxNFG+ck+k95Cp2tC0zbeD7u7CnjB1vu3HANl1CH8zbn1qnTso7n7fOxSZQPmTB8y0eAx0pLjkPK4AJWTsW/eQrhWFK6KNwGmGAtp/NdyiNnZ8rQ4mpMvDFQihdoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911463; c=relaxed/simple; bh=ucLdm7kgiNH8UU6TZ/DFxWIYh8yzK/gwevoJN7XpD84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LzocRIzvMZa6TPFQzDds2azlJ9eIuZDdL2o1TMhZla4PkhIZmIXFkuBLfdoXmSl4sHgtAEaSkQeIqkunVNjkjtnMBuqiLCHJzITEKqgSpcw356dw+G2GzHoajTp2Flt2y8o1TXQoMeFjEEKNl1Duddl8psT6uJgn8SNT2oxZEaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 22534113E; Fri, 12 Apr 2024 01:44:51 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA9CB3F6C4; Fri, 12 Apr 2024 01:44:19 -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 , Steven Price Subject: [PATCH v2 27/43] arm64: rme: allow userspace to inject aborts Date: Fri, 12 Apr 2024 09:42:53 +0100 Message-Id: <20240412084309.1733783-28-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084309.1733783-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084309.1733783-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 b4bd3d0928a2..0b2386ee4f15 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -1278,6 +1278,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 a035689dc39b..5223a828a344 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -865,6 +865,30 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, bool has_esr = events->exception.serror_has_esr; bool ext_dabt_pending = events->exception.ext_dabt_pending; + 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->entry.flags & RMI_EMULATED_MMIO)) + return -EINVAL; + + vcpu->arch.rec.run->entry.flags &= ~RMI_EMULATED_MMIO; + vcpu->arch.rec.run->entry.flags |= RMI_INJECT_SEA; + } + + return 0; + } + if (serror_pending && has_esr) { if (!cpus_have_final_cap(ARM64_HAS_RAS_EXTN)) return -EINVAL; -- 2.34.1