From patchwork Fri Jan 27 11:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118531 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 713C6C38142 for ; Fri, 27 Jan 2023 11:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uj/NF0i+uI96Vlq7XLeode/0g1gs9P9gXO1SBUl3k8Q=; b=SWe8TIHBtXJK7E S/ZpwN53dWrQtZQcAjtCfSJ5QIl7oyzSZfZ/tSbmUeESTajQs+cpHiSbaMHSx3xcZKQBmpH/VFjow Z0YDsQ4sa3HxrkBvNiOsuMYwJJJccefYX4GaZwwq4S9fu/+2fsM2O/ooVilfvS4I/vjd/1urdgX40 moXdUC4xPGGL9e1WiAlzhPviHHhvCG7oQIv565mq4Q2uv/Av0Xt4rL1+9qal5Qe/gn0u+VzOSyr+x Vo7IwKT/vY/yRxxB9nuU1bLtvbri0YmZDlXuz5rzQPLZdHd6hKOG5xwzLQBbq1qDKRrbxy4/9vIWo aNAV9WooTrBO24CdhvWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNNT-00ELCY-MI; Fri, 27 Jan 2023 11:58:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5F-00ECfn-1V for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:39:54 +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 A44601576; Fri, 27 Jan 2023 03:40:33 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1E5433F64C; Fri, 27 Jan 2023 03:39:49 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 01/31] arm64: Disable MTE when CFI flash is emulated Date: Fri, 27 Jan 2023 11:39:02 +0000 Message-Id: <20230127113932.166089-2-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_033953_178118_0075953A X-CRM114-Status: UNSURE ( 8.53 ) X-CRM114-Notice: Please train this message. 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 CFI Flash file image cannot be mapped into the memory of the guest if MTE is enabled. Thus disable MTE if flash emulation is requested. Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 54200c9e..5a53badb 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -145,6 +145,12 @@ void kvm__arch_enable_mte(struct kvm *kvm) return; } + if (kvm->cfg.flash_filename) { + kvm->cfg.arch.mte_disabled = true; + pr_info("MTE is incompatible with CFI flash support, disabling"); + return; + } + if (kvm->cfg.arch.mte_disabled) { pr_debug("MTE disabled by user"); return; From patchwork Fri Jan 27 11:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118532 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 42E6BC38142 for ; Fri, 27 Jan 2023 12:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wpmDHM1J8rF2VEFRCCiPmkTyjVZMTna7NkE1cjUkzoI=; b=hki+MWC/JcGO67 VNA8sIBhTgOVQ7j/WGvtFS6NKpws2IASbmerxMD2fTHT7VztFRjgYeP2L9YoIEPTqfW43pJEuxMT2 0VnEMdKUKepCm+PE2RhxxmJU/+/SHL1eDhWm3fHbs3Sw0U0PoobvoBylqXZx7Sj6DY/+R+8tqc1Nr cEaVt4vI5czvg5bi9WB5mdfuixL4KtchA6GV3I9qZZCBFlL4Dju68BVDZuWlAimkqSajq5l7U9hot iM5tuWOUqfVyGT29x5pv8mzvIM+K/uuD7KP9h4HpH+WR4pRy8/LmLtfcO4zPR2Ewuh7h9kW52B2Et gY8aHk5Tloy2WtnSVT7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNNy-00ELUH-7O; Fri, 27 Jan 2023 11:59:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5H-00EChC-J4 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:39:56 +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 86EAB15BF; Fri, 27 Jan 2023 03:40:36 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F3FB23F64C; Fri, 27 Jan 2023 03:39:51 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 02/31] script: update_headers: Ignore missing architectures Date: Fri, 27 Jan 2023 11:39:03 +0000 Message-Id: <20230127113932.166089-3-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_033955_704961_4D1CE59B X-CRM114-Status: UNSURE ( 7.39 ) X-CRM114-Notice: Please train this message. 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 Ignore missing architectures for header updates, for use with older kernels. Signed-off-by: Suzuki K Poulose --- util/update_headers.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/util/update_headers.sh b/util/update_headers.sh index 789e2a42..bdfb798c 100755 --- a/util/update_headers.sh +++ b/util/update_headers.sh @@ -48,6 +48,7 @@ copy_optional_arch () { for arch in arm64 mips powerpc riscv x86 do + [ -f $LINUX_ROOT/arch/${arch} ] || continue; case "$arch" in arm64) KVMTOOL_PATH=arm/aarch64 copy_optional_arch asm/sve_context.h ;; From patchwork Fri Jan 27 11:39:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118533 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 B8E94C54EAA for ; Fri, 27 Jan 2023 12:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=izdaFpgvA9qE97T/CDoDes/P3KitdIfEXs2oxSN+TRo=; b=l9jxzfKwFxoFgv eZ75Juoh3RM6cRC8JWq973jredyH/hc7L3hlcNjL8xUjqvH8vGtK90EfK1+CehmGKTMmcB4QyLQJb 4LkiRdYRSsMwGRy6oB4PIZv+Oywu4dq1OPdcT+RMHiJohKl6GirpzMGsIdwWONoY2ETxFo+VnS8w0 nayNzELvipPU0nbbJQgMu2Q3KTj0RKq2R4k6nTx8XkyD6ol7oyPWouEaKi6hGgz1vP7eGafO0D1g0 J3z0oyypc9EVxQT8fNR3a1N/Ouj3ZPH1a22Qx7XDgTXNWvbVElY4W2D19Fn37c75VBF/ijfsEewR3 DdSz16SY4f2yvJJ0t6yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNOh-00ELof-Tz; Fri, 27 Jan 2023 12:00:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5K-00ECik-Cd for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:39:59 +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 68AA515DB; Fri, 27 Jan 2023 03:40:39 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D6A303F64C; Fri, 27 Jan 2023 03:39:54 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 03/31] hw: cfi flash: Handle errors in memory transitions Date: Fri, 27 Jan 2023 11:39:04 +0000 Message-Id: <20230127113932.166089-4-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_033958_504986_B8258881 X-CRM114-Status: UNSURE ( 8.79 ) X-CRM114-Notice: Please train this message. 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 Handle failures in creating the memory maps and back in transitioning the CFI flash. e.g., with MTE enabled, CFI flash emulation breaks with the map operation, silently. And we later hit unhandled aborts in the guest. To avoid such issues, let us make sure we catch the error and handle it right at source. Signed-off-by: Suzuki K Poulose --- hw/cfi_flash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/cfi_flash.c b/hw/cfi_flash.c index 7faecdfb..bce546bc 100644 --- a/hw/cfi_flash.c +++ b/hw/cfi_flash.c @@ -455,6 +455,8 @@ static int map_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev) KVM_MEM_TYPE_RAM | KVM_MEM_TYPE_READONLY); if (!ret) sfdev->is_mapped = true; + else + die("CFI Flash: ERROR: Unable to map memory: %d\n", ret); return ret; } @@ -472,6 +474,8 @@ static int unmap_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev) if (!ret) sfdev->is_mapped = false; + else + die("CFI Flash: Failed to unmap Flash %d", ret); return ret; } From patchwork Fri Jan 27 11:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118534 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 E900EC54EAA for ; Fri, 27 Jan 2023 12:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mLkeX6Tbf4Ohs1VsCo3rVR+BpL+MKOo+Mrrx8XNrj1A=; b=J85qedZnpbN850 k+ESQ1ACUMYCey4WpJykLUUeA6B0QB+61La/sPZGr9Q72JJx+VeHGEzGq1pbIQzso8PJJyI+H8tUJ T+RNxJ4aJXsIn7YiuwSjjCsQPTqbpm6AuwHRKKJUBvntltsmwfofdPfXe0/1ZdV/H06vtngCP6wPZ R0dV1wwlahxvvXSA0sZzjMEc00rp3rgk3A2xzwx1gaOVzpKBLP7QP38hIRLpJO9m+69WxwukhzFL6 tZYzWu7oEOHp1N4iBQf8HHKxWrk/tOrKnqjTXbbG9/UN1UyrlXXpGw2LOY+n4OS5Kqyx3xGVdiNVb 8f3T88oB6MGysIPYGQHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNP6-00EM2K-Ta; Fri, 27 Jan 2023 12:00:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5N-00ECjw-3l for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:02 +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 415CD1650; Fri, 27 Jan 2023 03:40:42 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B89653F64C; Fri, 27 Jan 2023 03:39:57 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 04/31] Add --nocompat option to disable compat warnings Date: Fri, 27 Jan 2023 11:39:05 +0000 Message-Id: <20230127113932.166089-5-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034001_286702_C37A8FFB X-CRM114-Status: GOOD ( 15.35 ) 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: Alexandru Elisei Commit e66942073035 ("kvm tools: Guest kernel compatability") added the functionality that enables devices to print a warning message if the device hasn't been initialized by the time the VM is destroyed. The purpose of these messages is to let the user know if the kernel hasn't been built with the correct Kconfig options to take advantage of the said devices (all using virtio). Since then, kvmtool has evolved and now supports loading different payloads (like firmware images), and having those warnings even when it is entirely intentional for the payload not to touch the devices can be confusing for the user and makes the output unnecessarily verbose in those cases. Add the --nocompat option to disable the warnings; the warnings are still enabled by default. Reported-by: Christoffer Dall Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- builtin-run.c | 5 ++++- guest_compat.c | 1 + include/kvm/kvm-config.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin-run.c b/builtin-run.c index bb7e6e8d..f8edfb3f 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -183,6 +183,8 @@ static int mem_parser(const struct option *opt, const char *arg, int unset) OPT_BOOLEAN('\0', "nodefaults", &(cfg)->nodefaults, "Disable" \ " implicit configuration that cannot be" \ " disabled otherwise"), \ + OPT_BOOLEAN('\0', "nocompat", &(cfg)->nocompat, "Disable" \ + " compat warnings"), \ OPT_CALLBACK('\0', "9p", NULL, "dir_to_share,tag_name", \ "Enable virtio 9p to share files between host and" \ " guest", virtio_9p_rootdir_parser, kvm), \ @@ -797,7 +799,8 @@ static int kvm_cmd_run_work(struct kvm *kvm) static void kvm_cmd_run_exit(struct kvm *kvm, int guest_ret) { - compat__print_all_messages(); + if (!kvm->cfg.nocompat) + compat__print_all_messages(); init_list__exit(kvm); diff --git a/guest_compat.c b/guest_compat.c index fd4704b2..a413c12c 100644 --- a/guest_compat.c +++ b/guest_compat.c @@ -88,6 +88,7 @@ int compat__print_all_messages(void) printf("\n # KVM compatibility warning.\n\t%s\n\t%s\n", msg->title, msg->desc); + printf("\tTo stop seeing this warning, use the --nocompat option.\n"); list_del(&msg->list); compat__free(msg); diff --git a/include/kvm/kvm-config.h b/include/kvm/kvm-config.h index 368e6c7d..88df7cc2 100644 --- a/include/kvm/kvm-config.h +++ b/include/kvm/kvm-config.h @@ -30,6 +30,7 @@ struct kvm_config { u64 vsock_cid; bool virtio_rng; bool nodefaults; + bool nocompat; int active_console; int debug_iodelay; int nrcpus; From patchwork Fri Jan 27 11:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118535 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 6002AC38142 for ; Fri, 27 Jan 2023 12:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YViJ6YmVwxMzMaw5NRPeyrx5ttmqFufaYgPjFn5XuhY=; b=sueF3qdlRDh8+c rvFf/I8CdPJhksiesY2l9LSOjmviIPNBItkoSdTHd9jM2ElmqbVtgH/Tg4BkaLmA0YJZAVWkskgSE sS2V1z566+AXj2Xe8586YJPL6vhVea/ahDPy8PoXzZe5QWAKGGMz/KQIdGxF+uM8L7DOPQXSkdEYP laNynlQhAwilwVRAx7Upe2hGZHKDVEhuVNwwQRbpV4teqCZigbwZoHbJjXcY80xusVQdcUZIOuO9X 7TJFp3UFQvd2YOwL/IZIJ47ugR+rVbFjIlPOMu89vYiPGxBXIIPWUJKApOAE4cKQeH3PN3l7LTrp0 IoaNka1jjj/t2lBvgkZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNPf-00EMJA-AD; Fri, 27 Jan 2023 12:01:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5Q-00ECld-67 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:05 +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 2471D1684; Fri, 27 Jan 2023 03:40:45 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 911713F64C; Fri, 27 Jan 2023 03:40:00 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 05/31] arm64: Check pvtime support against the KVM instance Date: Fri, 27 Jan 2023 11:39:06 +0000 Message-Id: <20230127113932.166089-6-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034004_314004_F29F3276 X-CRM114-Status: GOOD ( 10.89 ) 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 KVM_CAP_STEAL_TIME can be checked against a VM instance. To allow controlling the feature depending on the VM type, use the cap against the VM. Signed-off-by: Suzuki K Poulose --- arm/aarch64/pvtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arm/aarch64/pvtime.c b/arm/aarch64/pvtime.c index 2933ac7c..839aa8a7 100644 --- a/arm/aarch64/pvtime.c +++ b/arm/aarch64/pvtime.c @@ -58,8 +58,8 @@ int kvm_cpu__setup_pvtime(struct kvm_cpu *vcpu) if (kvm_cfg->no_pvtime) return 0; - has_stolen_time = kvm__supports_extension(vcpu->kvm, - KVM_CAP_STEAL_TIME); + has_stolen_time = kvm__supports_vm_extension(vcpu->kvm, + KVM_CAP_STEAL_TIME); if (!has_stolen_time) { kvm_cfg->no_pvtime = true; return 0; From patchwork Fri Jan 27 11:39:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118536 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 A6185C38142 for ; Fri, 27 Jan 2023 12:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zrGR1cuS6Trrpj5XL607CpuatRRnQifCnlERFIUY1Mo=; b=ivOluqclkFCDoS /VTyNkkB4zj6RKJMja/U/yj9AXva8y0LwzgD1c0IoXdbxYtzf1KKbK1/Kw/no/P1xBaUsk4XAK+V8 XmLgflHNeMlqmeDgiHex+T7l8bjla9rYTBGH7IZh0DffRJWXuQ5b2tpYj1Dwp46GAZRYtcNoJ/nO5 c4hKuzV9P9DZCqKWai9ZaqdygU3+p0+p8YxLI5v7bocHYVaafrKB6LbVQivOmCwuGnZx1E5s7f2Wk V4JHqcEyasg5vkvdufkS831KudVohSyK/nx8QyO92P8LcE3miV4sD9BJAHiGhjfEjvUfvhSfLCRGq x4OdIH9RLEfqJ9fhDmhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNPw-00EMPP-Vk; Fri, 27 Jan 2023 12:01:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5S-00ECnC-PM for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:08 +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 06F48165C; Fri, 27 Jan 2023 03:40:48 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7406D3F64C; Fri, 27 Jan 2023 03:40:03 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 06/31] arm64: Check SVE capability on the VM instance Date: Fri, 27 Jan 2023 11:39:07 +0000 Message-Id: <20230127113932.166089-7-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034006_911046_0DAE677F X-CRM114-Status: GOOD ( 10.64 ) 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 Similar to PVtime, check the SVE capability on the VM instance to account for the different VM types and the corresponding support. Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm-cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index c8be10b3..da809806 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -150,13 +150,15 @@ void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) } /* Enable SVE if available */ - if (kvm__supports_extension(kvm, KVM_CAP_ARM_SVE)) + if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) init->features[0] |= 1UL << KVM_ARM_VCPU_SVE; } int kvm_cpu__configure_features(struct kvm_cpu *vcpu) { - if (kvm__supports_extension(vcpu->kvm, KVM_CAP_ARM_SVE)) { + struct kvm *kvm = vcpu->kvm; + + if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) { int feature = KVM_ARM_VCPU_SVE; if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) { From patchwork Fri Jan 27 11:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118537 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 1514CC38142 for ; Fri, 27 Jan 2023 12:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7f+K4VsJWFkALEAItc+sm1QIJ3h6EYhJOyHIm8x8Bec=; b=se2s53Hs+sgYfo AVB7V9lKCqI5l5QbGkZ+0PXlWfNjtkOcRtGyvSXyySCy3G+ThUAkOZzkZpeRAYeOXdxF4AF3PL60j x/cS6bF7M3hSaahUx7kSmwm1it2T+NUZZe0kBBHiB4T17BBzmcMliqvPtvnoDrnNO7ZJtgdL3j5DD MeG3Ur++RpYXSGQYhOwABtQ1w5KDGnuPUlIKDdvgXumLYKU3t9O90mA4r1O/Ah9zw+DHAnJVWsGf7 Rc3f5dcDw+YotJB7ltBo/0eEuK1+sPW0IV75EiOHUTk29oTOFgZtTAFgaCMD2bQ6D1g3SLqRLq9Fh K16inS+3sJ0/TegKbYmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNQg-00EMns-QL; Fri, 27 Jan 2023 12:02:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5V-00ECoJ-Ox for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:11 +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 D42961688; Fri, 27 Jan 2023 03:40:50 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 56CDA3F64C; Fri, 27 Jan 2023 03:40:06 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 07/31] arm64: Add option to disable SVE Date: Fri, 27 Jan 2023 11:39:08 +0000 Message-Id: <20230127113932.166089-8-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034010_016246_F38BF476 X-CRM114-Status: GOOD ( 13.10 ) 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 kvmtool enables SVE whenever it is supported by the KVM. However, Realm VMs may want controlled features, which gets measured during the creation. Thus, provide an option to disable the SVE, to preserve the current behavior of SVE on by default. Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 4 +++- arm/aarch64/kvm-cpu.c | 8 +++++--- arm/include/arm-common/kvm-config-arch.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index eae8080d..b055fef4 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -19,7 +19,9 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); "Specify random seed for Kernel Address Space " \ "Layout Randomization (KASLR)"), \ OPT_BOOLEAN('\0', "no-pvtime", &(cfg)->no_pvtime, "Disable" \ - " stolen time"), + " stolen time"), \ + OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ + "Disable SVE"), #include "arm-common/kvm-config-arch.h" #endif /* KVM__KVM_CONFIG_ARCH_H */ diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index da809806..e7649239 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -149,8 +149,9 @@ void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC; } - /* Enable SVE if available */ - if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) + /* If SVE is not disabled explicitly, enable if available */ + if (!kvm->cfg.arch.disable_sve && + kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) init->features[0] |= 1UL << KVM_ARM_VCPU_SVE; } @@ -158,7 +159,8 @@ int kvm_cpu__configure_features(struct kvm_cpu *vcpu) { struct kvm *kvm = vcpu->kvm; - if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) { + if (!kvm->cfg.arch.disable_sve && + kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) { int feature = KVM_ARM_VCPU_SVE; if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) { diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 9949bfe4..6599305b 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -15,6 +15,7 @@ struct kvm_config_arch { enum irqchip_type irqchip; u64 fw_addr; bool no_pvtime; + bool disable_sve; }; int irqchip_parser(const struct option *opt, const char *arg, int unset); From patchwork Fri Jan 27 11:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118556 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 113E3C54EAA for ; Fri, 27 Jan 2023 12:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JiTokPQy+Kn/JwoeQw399hmYl7tWnTlUDoKts6pJbjU=; b=flwjNSKHFikM4Z SNqloErVbhxy3uhCA1e7ar9Qfvn0o79mDr4O1w/eUJOi5ghwzQs9eVih9tHHVgdi2cc3jANNCVSY4 amlZoArrsSqVG4TqP5Fp4e1wfyAIxe6lEmrEdh7eWiX1Gbs19RDzRnyhHAd5yOq9018L338aMB3yx GSETeWmgw4fcUVEUxwmNaGSBoyRdp1MAiKDRrxyWZGlqyTn/01CtHJIIqth8bcUcXxdl6wpi2yfud Nfo0V9W6uWGcn8C/5ptW6/PPHMp6tDnn8u2wHZSoWu814FW1dC4WLfhDbaTcGhg+tEc1S3dIEWFOi prByMNhPN7SFxPKexFbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNRG-00EN5G-MQ; Fri, 27 Jan 2023 12:02:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5Y-00ECq5-EV for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:15 +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 ADE761691; Fri, 27 Jan 2023 03:40:53 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 30A043F64C; Fri, 27 Jan 2023 03:40:09 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 08/31] linux: Update kernel headers for RME support Date: Fri, 27 Jan 2023 11:39:09 +0000 Message-Id: <20230127113932.166089-9-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034012_668713_E04872CE X-CRM114-Status: GOOD ( 19.21 ) 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 Update the RME specific ABI bits from the kernel headers. Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/asm/kvm.h | 64 +++++++++++++++++++++++++++++++++++ include/linux/kvm.h | 22 +++++++++--- include/linux/virtio_blk.h | 19 ----------- include/linux/virtio_net.h | 14 ++++---- include/linux/virtio_ring.h | 16 +++------ 5 files changed, 93 insertions(+), 42 deletions(-) diff --git a/arm/aarch64/include/asm/kvm.h b/arm/aarch64/include/asm/kvm.h index 316917b9..653a08fb 100644 --- a/arm/aarch64/include/asm/kvm.h +++ b/arm/aarch64/include/asm/kvm.h @@ -108,6 +108,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ +#define KVM_ARM_VCPU_REC 7 /* VCPU REC state as part of Realm */ struct kvm_vcpu_init { __u32 target; @@ -400,6 +401,69 @@ enum { #define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 #define KVM_DEV_ARM_ITS_CTRL_RESET 4 +/* KVM_CAP_ARM_RME kvm_enable_cap->args[0] points to this */ +#define KVM_CAP_ARM_RME_CONFIG_REALM 0 +#define KVM_CAP_ARM_RME_CREATE_RD 1 +#define KVM_CAP_ARM_RME_INIT_IPA_REALM 2 +#define KVM_CAP_ARM_RME_POPULATE_REALM 3 +#define KVM_CAP_ARM_RME_ACTIVATE_REALM 4 + +#define KVM_CAP_ARM_RME_MEASUREMENT_ALGO_ZERO (0x01ULL << 7) +#define KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256 0 +#define KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA512 1 + +#define KVM_CAP_ARM_RME_RPV_SIZE 64 + +/* List of configuration items accepted for KVM_CAP_ARM_RME_CONFIG_REALM */ +#define KVM_CAP_ARM_RME_CFG_RPV 0 +#define KVM_CAP_ARM_RME_CFG_HASH_ALGO 1 +#define KVM_CAP_ARM_RME_CFG_SVE 2 +#define KVM_CAP_ARM_RME_CFG_DBG 3 +#define KVM_CAP_ARM_RME_CFG_PMU 4 + +struct kvm_cap_arm_rme_config_item { + __u32 cfg; + union { + /* cfg == KVM_CAP_ARM_RME_CFG_RPV */ + struct { + __u8 rpv[KVM_CAP_ARM_RME_RPV_SIZE]; + }; + + /* cfg == KVM_CAP_ARM_RME_CFG_HASH_ALGO */ + struct { + __u32 hash_algo; + }; + + /* cfg == KVM_CAP_ARM_RME_CFG_SVE */ + struct { + __u32 sve_vq; + }; + + /* cfg == KVM_CAP_ARM_RME_CFG_DBG */ + struct { + __u32 num_brps; + __u32 num_wrps; + }; + + /* cfg == KVM_CAP_ARM_RME_CFG_PMU */ + struct { + __u32 num_pmu_cntrs; + }; + /* Fix the size of the union */ + __u8 reserved[256]; + }; +}; + +struct kvm_cap_arm_rme_populate_realm_args { + __u64 populate_ipa_base; + __u64 populate_ipa_size; +}; + +struct kvm_cap_arm_rme_init_ipa_args { + __u64 init_ipa_base; + __u64 init_ipa_size; +}; + /* Device Control API on vcpu fd */ #define KVM_ARM_VCPU_PMU_V3_CTRL 0 #define KVM_ARM_VCPU_PMU_V3_IRQ 0 diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 0d5d4419..789c7f89 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -903,14 +903,25 @@ struct kvm_ppc_resize_hpt { #define KVM_S390_SIE_PAGE_OFFSET 1 /* - * On arm64, machine type can be used to request the physical - * address size for the VM. Bits[7-0] are reserved for the guest - * PA size shift (i.e, log2(PA_Size)). For backward compatibility, - * value 0 implies the default IPA size, 40bits. + * On arm64, machine type can be used to request both the machine type and + * the physical address size for the VM. + * + * Bits[11-8] are reserved for the ARM specific machine type. + * + * Bits[7-0] are reserved for the guest PA size shift (i.e, log2(PA_Size)). + * For backward compatibility, value 0 implies the default IPA size, 40bits. */ +#define KVM_VM_TYPE_ARM_SHIFT 8 +#define KVM_VM_TYPE_ARM_MASK (0xfULL << KVM_VM_TYPE_ARM_SHIFT) +#define KVM_VM_TYPE_ARM(_type) \ + (((_type) << KVM_VM_TYPE_ARM_SHIFT) & KVM_VM_TYPE_ARM_MASK) +#define KVM_VM_TYPE_ARM_NORMAL KVM_VM_TYPE_ARM(0) +#define KVM_VM_TYPE_ARM_REALM KVM_VM_TYPE_ARM(1) + #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) + /* * ioctls for /dev/kvm fds: */ @@ -1177,7 +1188,8 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 #define KVM_CAP_S390_ZPCI_OP 221 #define KVM_CAP_S390_CPU_TOPOLOGY 222 -#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 + +#define KVM_CAP_ARM_RME 300 // FIXME: Large number to prevent conflicts #ifdef KVM_CAP_IRQ_ROUTING diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h index 58e70b24..d888f013 100644 --- a/include/linux/virtio_blk.h +++ b/include/linux/virtio_blk.h @@ -40,7 +40,6 @@ #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ -#define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */ /* Legacy feature bits */ #ifndef VIRTIO_BLK_NO_LEGACY @@ -122,21 +121,6 @@ struct virtio_blk_config { __u8 write_zeroes_may_unmap; __u8 unused1[3]; - - /* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */ - /* - * The maximum secure erase sectors (in 512-byte sectors) for - * one segment. - */ - __virtio32 max_secure_erase_sectors; - /* - * The maximum number of secure erase segments in a - * secure erase command. - */ - __virtio32 max_secure_erase_seg; - /* Secure erase commands must be aligned to this number of sectors. */ - __virtio32 secure_erase_sector_alignment; - } __attribute__((packed)); /* @@ -171,9 +155,6 @@ struct virtio_blk_config { /* Write zeroes command */ #define VIRTIO_BLK_T_WRITE_ZEROES 13 -/* Secure erase command */ -#define VIRTIO_BLK_T_SECURE_ERASE 14 - #ifndef VIRTIO_BLK_NO_LEGACY /* Barrier before this op. */ #define VIRTIO_BLK_T_BARRIER 0x80000000 diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index 6cb842ea..29ced555 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h @@ -56,7 +56,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ -#define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ +#define VIRTIO_NET_F_NOTF_COAL 53 /* Guest can handle notifications coalescing */ #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ @@ -364,24 +364,24 @@ struct virtio_net_hash_config { */ #define VIRTIO_NET_CTRL_NOTF_COAL 6 /* - * Set the tx-usecs/tx-max-packets parameters. + * Set the tx-usecs/tx-max-packets patameters. + * tx-usecs - Maximum number of usecs to delay a TX notification. + * tx-max-packets - Maximum number of packets to send before a TX notification. */ struct virtio_net_ctrl_coal_tx { - /* Maximum number of packets to send before a TX notification */ __le32 tx_max_packets; - /* Maximum number of usecs to delay a TX notification */ __le32 tx_usecs; }; #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0 /* - * Set the rx-usecs/rx-max-packets parameters. + * Set the rx-usecs/rx-max-packets patameters. + * rx-usecs - Maximum number of usecs to delay a RX notification. + * rx-max-frames - Maximum number of packets to receive before a RX notification. */ struct virtio_net_ctrl_coal_rx { - /* Maximum number of packets to receive before a RX notification */ __le32 rx_max_packets; - /* Maximum number of usecs to delay a RX notification */ __le32 rx_usecs; }; diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index f8c20d3d..476d3e5c 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -93,21 +93,15 @@ #define VRING_USED_ALIGN_SIZE 4 #define VRING_DESC_ALIGN_SIZE 16 -/** - * struct vring_desc - Virtio ring descriptors, - * 16 bytes long. These can chain together via @next. - * - * @addr: buffer address (guest-physical) - * @len: buffer length - * @flags: descriptor flags - * @next: index of the next descriptor in the chain, - * if the VRING_DESC_F_NEXT flag is set. We chain unused - * descriptors via this, too. - */ +/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ struct vring_desc { + /* Address (guest-physical). */ __virtio64 addr; + /* Length. */ __virtio32 len; + /* The flags as indicated above. */ __virtio16 flags; + /* We chain unused descriptors via this, too */ __virtio16 next; }; From patchwork Fri Jan 27 11:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118557 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 D05B8C61DA7 for ; Fri, 27 Jan 2023 12:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8Tv3Q69/b9Mw5eUisagIWn1QFxGNpxBRROuOWZEIlwY=; b=4zHuTiU1FYV2wY L22wZqRz4z+82cDFmOT8Ae7xyLdCMseeT/S6yeX595mYI9bpd4hbjtDQhUw0GjhMV5ghcjFU2Ee/q SPQJ5jpP+1L2seJxqvEr99YRAjEuegC1EOd28WwyzJ5YdUIV0H6V2MuzpLHIrtm/mvyeKejFqfpcN 737GlD2fceyYTyGQKQifBPpvlrtVnaCvQdkfOt8CU9vLeWpKu6OdZQg9VgNdG6EVO1X5hWz/CEfsq Iy3GtqbHM+BNg7Frwi+HvOc8mSumdxIih1Z6Y8omwSZ354Wp8+kE0WHRD+x3iLr0cMOUQMcLVaGmc CrHXHGzrXTS8NzFpg6fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNRk-00ENIt-IQ; Fri, 27 Jan 2023 12:03:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5b-00ECqx-Ij for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:17 +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 8928E169C; Fri, 27 Jan 2023 03:40:56 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0A2453F64C; Fri, 27 Jan 2023 03:40:11 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 09/31] arm64: Add --realm command line option Date: Fri, 27 Jan 2023 11:39:10 +0000 Message-Id: <20230127113932.166089-10-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034015_791233_C942C01D X-CRM114-Status: GOOD ( 11.90 ) 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: Alexandru Elisei Add the --realm command line option which causes kvmtool to exit with an error if specified, but which will be enabled once realms are fully supported by kvmtool. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 5 ++++- arm/aarch64/kvm.c | 20 ++++++++++++++++++-- arm/include/arm-common/kvm-config-arch.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index b055fef4..d2df850a 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -21,7 +21,10 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); OPT_BOOLEAN('\0', "no-pvtime", &(cfg)->no_pvtime, "Disable" \ " stolen time"), \ OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ - "Disable SVE"), + "Disable SVE"), \ + OPT_BOOLEAN('\0', "realm", &(cfg)->is_realm, \ + "Create VM running in a realm using Arm RME"), + #include "arm-common/kvm-config-arch.h" #endif /* KVM__KVM_CONFIG_ARCH_H */ diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 5a53badb..25be2f2d 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -38,9 +38,8 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset) return 0; } -void kvm__arch_validate_cfg(struct kvm *kvm) +static void validate_mem_cfg(struct kvm *kvm) { - if (kvm->cfg.ram_addr < ARM_MEMORY_AREA) { die("RAM address is below the I/O region ending at %luGB", ARM_MEMORY_AREA >> 30); @@ -52,6 +51,23 @@ void kvm__arch_validate_cfg(struct kvm *kvm) } } +static void validate_realm_cfg(struct kvm *kvm) +{ + if (!kvm->cfg.arch.is_realm) + return; + + if (kvm->cfg.arch.aarch32_guest) + die("Realms supported only for 64bit guests"); + + die("Realms not supported"); +} + +void kvm__arch_validate_cfg(struct kvm *kvm) +{ + validate_mem_cfg(kvm); + validate_realm_cfg(kvm); +} + u64 kvm__arch_default_ram_address(void) { return ARM_MEMORY_AREA; diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 6599305b..5eb791da 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -11,6 +11,7 @@ struct kvm_config_arch { bool aarch32_guest; bool has_pmuv3; bool mte_disabled; + bool is_realm; u64 kaslr_seed; enum irqchip_type irqchip; u64 fw_addr; From patchwork Fri Jan 27 11:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118558 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 C7C4FC54EAA for ; Fri, 27 Jan 2023 12:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p7h0Bg58zIsV/CLZMeOYalNIsln0ijLsd9MhafjFrlM=; b=R5f1D40cBl2uwt 0/aVxsEnmeuQ/UW+SwvxR9MPGpAI2fTfWePv52+VMqOMVo6V6FZgHgmmKU4OkSe2XElNlIJ/tnwPk GysjedUfaFGHZP9nz5WUuErKUO2QhpfwIphNfeWfk3O2d/znf24fvsZVdhcF9eFWghA5HTfy10gfF abPJywORnqtnNWLbKU9YNGxC5t/YsHYkcRP69ZkdojTWZNYfoSJtb+dNquIfAIje2/6I9ZoBEBkGG rzfY5ZXR8hs83zK+ONG+C4G+cUH6V+lg1CvDdcLRgayRj0AXm1rkEJ/Bw/80ofjWC3vx7jwMru9T6 S9Eo8/b3llUXXUgvvI8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNSS-00ENik-50; Fri, 27 Jan 2023 12:03:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5e-00ECrz-1o for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:19 +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 62808169E; Fri, 27 Jan 2023 03:40:59 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D96673F64C; Fri, 27 Jan 2023 03:40:14 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 10/31] arm64: Create a realm virtual machine Date: Fri, 27 Jan 2023 11:39:11 +0000 Message-Id: <20230127113932.166089-11-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034018_202854_82145E14 X-CRM114-Status: GOOD ( 12.94 ) 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: Christoffer Dall Set the machine type to realm when creating a VM via the KVM_CREATE_VM ioctl. Signed-off-by: Christoffer Dall [ Alex E: Reworked patch, split the command line option into a different patch ] Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 25be2f2d..5db4c572 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -131,12 +131,15 @@ int kvm__arch_get_ipa_limit(struct kvm *kvm) int kvm__get_vm_type(struct kvm *kvm) { unsigned int ipa_bits, max_ipa_bits; - unsigned long max_ipa; + unsigned long max_ipa, vm_type; - /* If we're running on an old kernel, use 0 as the VM type */ + vm_type = kvm->cfg.arch.is_realm ? \ + KVM_VM_TYPE_ARM_REALM : KVM_VM_TYPE_ARM_NORMAL; + + /* If we're running on an old kernel, use 0 as the IPA bits */ max_ipa_bits = kvm__arch_get_ipa_limit(kvm); if (!max_ipa_bits) - return 0; + return vm_type; /* Otherwise, compute the minimal required IPA size */ max_ipa = kvm->cfg.ram_addr + kvm->cfg.ram_size - 1; @@ -147,7 +150,8 @@ int kvm__get_vm_type(struct kvm *kvm) if (ipa_bits > max_ipa_bits) die("Memory too large for this system (needs %d bits, %d available)", ipa_bits, max_ipa_bits); - return KVM_VM_TYPE_ARM_IPA_SIZE(ipa_bits); + vm_type |= KVM_VM_TYPE_ARM_IPA_SIZE(ipa_bits); + return vm_type; } void kvm__arch_enable_mte(struct kvm *kvm) From patchwork Fri Jan 27 11:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118559 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 5A002C38142 for ; Fri, 27 Jan 2023 12:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pkdZBb41T+zA4nwlv6NkzRGMAYw/32HtdH49wIHFMp8=; b=Y6ZgjKAjILjnp1 72sEoqzjdPvCzhLyHCGqaj7oq0GUV8iwwy3/HMObDJaXg9oALfYMdc+cS8otMs7w2smhkBHVJ4EGh YOCL88CGPO95adSTNECRoW+tpp1+Cf9Tf3B/AgDyFEix8x3WrUNoC1BRfhz+UJHOV6bZ2Ax+JuaEp gLz/5DAvtQHu/FJukq1SFIrfmH8iSH7SJlN+v/A10fABN80+cQoOB1M7rPaUfOEq8CdxTHtKev7iP V+tNnF6ngu2DzVPmazyuTtjTmVyisA2AO1BN82obonZ3ONo1A40dbhwYrOrYv2/1bbGu3T2YN7FB/ pNL4fz7ZuPy2kkZVRIbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNT7-00EO7Q-Ok; Fri, 27 Jan 2023 12:04:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5h-00ECtp-01 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:24 +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 3C11D16A3; Fri, 27 Jan 2023 03:41:02 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B29523F64C; Fri, 27 Jan 2023 03:40:17 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 11/31] arm64: Lock realm RAM in memory Date: Fri, 27 Jan 2023 11:39:12 +0000 Message-Id: <20230127113932.166089-12-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034022_417411_C6B97705 X-CRM114-Status: GOOD ( 13.68 ) 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: Alexandru Elisei RMM doesn't yet support paging protected memory pages. Thus the VMM must pin the entire VM memory. Use mlock2 to keep the realm pages pinned in memory once they are faulted in. Use the MLOCK_ONFAULT flag to prevent pre-mapping the pages and maintain some semblance of on demand-paging for a realm VM. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/kvm.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/arm/kvm.c b/arm/kvm.c index d51cc15d..0e40b753 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -7,6 +7,8 @@ #include "arm-common/gic.h" +#include + #include #include #include @@ -24,6 +26,25 @@ bool kvm__arch_cpu_supports_vm(void) return true; } +static void try_increase_mlock_limit(struct kvm *kvm) +{ + u64 size = kvm->arch.ram_alloc_size; + struct rlimit mlock_limit, new_limit; + + if (getrlimit(RLIMIT_MEMLOCK, &mlock_limit)) { + perror("getrlimit(RLIMIT_MEMLOCK)"); + return; + } + + if (mlock_limit.rlim_cur > size) + return; + + new_limit.rlim_cur = size; + new_limit.rlim_max = max((rlim_t)size, mlock_limit.rlim_max); + /* Requires CAP_SYS_RESOURCE capability. */ + setrlimit(RLIMIT_MEMLOCK, &new_limit); +} + void kvm__init_ram(struct kvm *kvm) { u64 phys_start, phys_size; @@ -49,8 +70,27 @@ void kvm__init_ram(struct kvm *kvm) kvm->ram_start = (void *)ALIGN((unsigned long)kvm->arch.ram_alloc_start, SZ_2M); - madvise(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, - MADV_MERGEABLE); + /* + * Do not merge pages if this is a Realm. + * a) We cannot replace a page in realm stage2 without export/import + * + * Pin the realm memory until we have export/import, due to the same + * reason as above. + * + * Use mlock2(,,MLOCK_ONFAULT) to allow faulting in pages and thus + * allowing to lazily populate the PAR. + */ + if (kvm->cfg.arch.is_realm) { + int ret; + + try_increase_mlock_limit(kvm); + ret = mlock2(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, + MLOCK_ONFAULT); + if (ret) + die_perror("mlock2"); + } else { + madvise(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, MADV_MERGEABLE); + } madvise(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, MADV_HUGEPAGE); From patchwork Fri Jan 27 11:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118560 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 49D6CC54EAA for ; Fri, 27 Jan 2023 12:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6DAuA1Krl6O2WE5g8/a58xERWmYT+TwSCDNpcSZg8VA=; b=1vPhsYQ+4FMyQW 92ZcjZqXnrtAlhkCe8y0J8V3NOXjlure1kiZwsEJbQy13ev00HKQwb2lcRUg1rbP167+s1JtifYol Ae7ViBcThkjZEpS9CPEGwE3qD7nGZ6sYWIvOeE5eNJzs8bknOv3iSs5p216IMPRJaNsfoJLboeltB 3Kn4Jx05c6EgPuoJkVo2u6FKduQ9OmoFhPpGXx5cGL3JOuoQpnoHif+Pj/HPNzfJ5VEPQa3cvTjtR 1yHzFzbIiaeFxnTUTp5/4xG/Y7DqVaiYhTv5sfpG6rRDA805XEnjZWfGJ0dqk6P8aeBbMv5Erpp7V kHofwQ9/sWyK9vd2R+0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNTn-00EOU9-Ae; Fri, 27 Jan 2023 12:05:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5j-00ECvM-Ru for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:26 +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 14FA01692; Fri, 27 Jan 2023 03:41:05 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8C0393F64C; Fri, 27 Jan 2023 03:40:20 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 12/31] arm64: Create Realm Descriptor Date: Fri, 27 Jan 2023 11:39:13 +0000 Message-Id: <20230127113932.166089-13-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034024_058185_1F860CB9 X-CRM114-Status: GOOD ( 14.63 ) 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: Alexandru Elisei Create the Realm Descriptor using the measurement algorithm set with --measurement-algo. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- Makefile | 1 + arm/aarch32/include/asm/realm.h | 10 ++++++++++ arm/aarch64/include/asm/realm.h | 10 ++++++++++ arm/aarch64/realm.c | 14 ++++++++++++++ arm/kvm.c | 3 +++ 5 files changed, 38 insertions(+) create mode 100644 arm/aarch32/include/asm/realm.h create mode 100644 arm/aarch64/include/asm/realm.h create mode 100644 arm/aarch64/realm.c diff --git a/Makefile b/Makefile index ed2414bd..88cdf6d2 100644 --- a/Makefile +++ b/Makefile @@ -192,6 +192,7 @@ ifeq ($(ARCH), arm64) OBJS += arm/aarch64/kvm.o OBJS += arm/aarch64/pvtime.o OBJS += arm/aarch64/pmu.o + OBJS += arm/aarch64/realm.o ARCH_INCLUDE := $(HDRS_ARM_COMMON) ARCH_INCLUDE += -Iarm/aarch64/include diff --git a/arm/aarch32/include/asm/realm.h b/arm/aarch32/include/asm/realm.h new file mode 100644 index 00000000..5aca6cca --- /dev/null +++ b/arm/aarch32/include/asm/realm.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASM_REALM_H +#define __ASM_REALM_H + +#include "kvm/kvm.h" + +static inline void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) {} + +#endif /* ! __ASM_REALM_H */ diff --git a/arm/aarch64/include/asm/realm.h b/arm/aarch64/include/asm/realm.h new file mode 100644 index 00000000..e176f15f --- /dev/null +++ b/arm/aarch64/include/asm/realm.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASM_REALM_H +#define __ASM_REALM_H + +#include "kvm/kvm.h" + +void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm); + +#endif /* ! __ASM_REALM_H */ diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c new file mode 100644 index 00000000..3a4adb66 --- /dev/null +++ b/arm/aarch64/realm.c @@ -0,0 +1,14 @@ +#include "kvm/kvm.h" + +#include + +void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) +{ + struct kvm_enable_cap rme_create_rd = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_CREATE_RD, + }; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_create_rd) < 0) + die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CREATE_RD)"); +} diff --git a/arm/kvm.c b/arm/kvm.c index 0e40b753..2510a322 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -127,6 +127,9 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) void kvm__arch_init(struct kvm *kvm) { + if (kvm->cfg.arch.is_realm) + kvm_arm_realm_create_realm_descriptor(kvm); + /* Create the virtual GIC. */ if (gic__create(kvm, kvm->cfg.arch.irqchip)) die("Failed to create virtual GIC"); From patchwork Fri Jan 27 11:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118562 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 7E97DC38142 for ; Fri, 27 Jan 2023 12:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qHRSgF3sVWR3kcTW4moV6rhtLtNsNboIr3RnadtUFos=; b=PHiFpY2MkS8mOY 3LTLM27x28nSdbwbwVGX3bmyH6yC5WapyURcDKqf5srIt8rpCTFSZ/09JhH8CP9DPgVe5DIP4OJCF TYOgDNmOJqh/znKesu6rgTpBlnvlHb05QclphXrnCeJAoiXqOjHzP7YGzNq/K39t0jzQmoh4efVjr Cdh665x9tQaNaCZRWlmtyXycpuzCkvc4tUWcRr5yTjBBaY6HNLFEKOOCgxXYVN84h5WoHwx2eA+DK Vs/f9VXW98R+DIOIYdu1yMaWI2pyPCm37gE1QEjWYhpFYsd5o7/hQg/CPrKWJ4xOxsuJH0DDJc904 sGGJu1+tgOQzx0GUHlgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNUv-00EP3b-IO; Fri, 27 Jan 2023 12:06:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5m-00ECwQ-QR for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:33 +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 E28C316F8; Fri, 27 Jan 2023 03:41:07 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6552D3F64C; Fri, 27 Jan 2023 03:40:23 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 13/31] arm64: Add --measurement-algo command line option for a realm Date: Fri, 27 Jan 2023 11:39:14 +0000 Message-Id: <20230127113932.166089-14-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034027_014782_51CA0F8E X-CRM114-Status: GOOD ( 14.21 ) 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: Christoffer Dall Add the command line option to specify the algorithm that will be used to create the cryptographic measurement of the realm. Valid options are "sha256" and "sha512". The final measurement will be a hash using the selected algorithm Signed-off-by: Christoffer Dall Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 5 ++++- arm/aarch64/kvm.c | 17 ++++++++++++++++- arm/include/arm-common/kvm-arch.h | 1 + arm/include/arm-common/kvm-config-arch.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index d2df850a..b93999b6 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -23,7 +23,10 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ "Disable SVE"), \ OPT_BOOLEAN('\0', "realm", &(cfg)->is_realm, \ - "Create VM running in a realm using Arm RME"), + "Create VM running in a realm using Arm RME"), \ + OPT_STRING('\0', "measurement-algo", &(cfg)->measurement_algo, \ + "sha256, sha512", \ + "Realm Measurement algorithm, default: sha256"), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 5db4c572..a5a98b2e 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -53,12 +53,27 @@ static void validate_mem_cfg(struct kvm *kvm) static void validate_realm_cfg(struct kvm *kvm) { - if (!kvm->cfg.arch.is_realm) + if (!kvm->cfg.arch.is_realm) { + if (kvm->cfg.arch.measurement_algo) + die("--measurement-algo valid only with --realm"); return; + } if (kvm->cfg.arch.aarch32_guest) die("Realms supported only for 64bit guests"); + if (kvm->cfg.arch.measurement_algo) { + if (strcmp(kvm->cfg.arch.measurement_algo, "sha256") == 0) + kvm->arch.measurement_algo = KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256; + else if (strcmp(kvm->cfg.arch.measurement_algo, "sha512") == 0) + kvm->arch.measurement_algo = KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA512; + else + die("unknown realm measurement algorithm"); + } else { + pr_debug("Realm Hash algorithm: Using default SHA256\n"); + kvm->arch.measurement_algo = KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256; + } + die("Realms not supported"); } diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index b2ae373c..68224b1c 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -113,6 +113,7 @@ struct kvm_arch { u64 dtb_guest_start; cpu_set_t *vcpu_affinity_cpuset; + u64 measurement_algo; }; #endif /* ARM_COMMON__KVM_ARCH_H */ diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 5eb791da..a2faa3af 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -6,6 +6,7 @@ struct kvm_config_arch { const char *dump_dtb_filename; const char *vcpu_affinity; + const char *measurement_algo; unsigned int force_cntfrq; bool virtio_trans_pci; bool aarch32_guest; From patchwork Fri Jan 27 11:39:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118561 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 88C41C54EAA for ; Fri, 27 Jan 2023 12:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N91+gW/R0PzPtiiA/VOHBC98W26E72YSjlfb5YQT+fI=; b=nTx7ySyFVbdQeQ 0RTTrbdHR5xUh/YPmMwbIdPTlxe5UcxKrUFY0MmV2r0h/Ef84ZHBczV8hm4HTZTuE6n0QJtHIbGdq PnwkNTb1EcgtiReDyhF+Gr/aQdI5YTvzZuaCs5bYqloKH1UtCK2a4Pd4pMoRUHZfWjb5+41rEmZ5W 9pDZjMiX7HIKw6jYz0tnTkEdxtJNAes4HBj0Jv5E+pDATH9Rr0uok9v3IEOCQ1fMPt+Q54E0B5Lv1 UsHon8gZYbAmsOi6t4aSErKWSYYCT3M9jkIpdYk/rpFGPa5EQkbCgbfoB7igQaGKrp1WUqMWeOaxk z+NJeIVK/xc9eN3xgE4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNUO-00EOna-1P; Fri, 27 Jan 2023 12:05:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5p-00ECxE-LT for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:33 +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 BC9521758; Fri, 27 Jan 2023 03:41:10 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E5DB3F64C; Fri, 27 Jan 2023 03:40:26 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 14/31] arm64: Add configuration step for Realms Date: Fri, 27 Jan 2023 11:39:15 +0000 Message-Id: <20230127113932.166089-15-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034029_793178_67A13869 X-CRM114-Status: GOOD ( 10.06 ) 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 Realm must be configured before it is created. Add the step to specify the parameters for the Realm. Signed-off-by: Suzuki K Poulose --- arm/aarch64/realm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c index 3a4adb66..31543e55 100644 --- a/arm/aarch64/realm.c +++ b/arm/aarch64/realm.c @@ -2,6 +2,29 @@ #include + +static void realm_configure_hash_algo(struct kvm *kvm) +{ + struct kvm_cap_arm_rme_config_item hash_algo_cfg = { + .cfg = KVM_CAP_ARM_RME_CFG_HASH_ALGO, + .hash_algo = kvm->arch.measurement_algo, + }; + + struct kvm_enable_cap rme_config = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_CONFIG_REALM, + .args[1] = (u64)&hash_algo_cfg, + }; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_config) < 0) + die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CONFIG_REALM) hash_algo"); +} + +static void realm_configure_parameters(struct kvm *kvm) +{ + realm_configure_hash_algo(kvm); +} + void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) { struct kvm_enable_cap rme_create_rd = { @@ -9,6 +32,7 @@ void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) .args[0] = KVM_CAP_ARM_RME_CREATE_RD, }; + realm_configure_parameters(kvm); if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_create_rd) < 0) die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CREATE_RD)"); } From patchwork Fri Jan 27 11:39:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118563 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 AC22AC54EAA for ; Fri, 27 Jan 2023 12:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gf2CLGr+C+CDst7/UwmE4rryS/gmeM/xr9ipiMbDYYM=; b=u2AzlMildf8+cV +GNeStFGF3g049F0FSR2Ys/Os/1DGtKk/58yHB0BoP43m1gQV5SCgZCTdbhYqcq+fPHsmqAfumm0h bQHFYMo60uK3TUqj8FEOBKPSltYg9VAlhH/XLoc1EuzhosbAV15gc+qSR8R7rloM7o0Q3Tq1o3Kc1 L4wZalpGa+6191UpuWI7kmUxHBwVPRQBLFhLft+YuTOb4YFXLKVxWFoZs6WMrwg+emmIk8yy1BJ9B +m425x2V1JyBRgkeKHQsVlSKArVcljZlCFaD/1BZKFdKNrdlji6MsfFxRvqaVPGBNUhMxeRhBti/g vZqUnk/2FH9VlorpAm8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNVa-00EPOn-65; Fri, 27 Jan 2023 12:07:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5t-00ECzD-3R for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:36 +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 95E9C175D; Fri, 27 Jan 2023 03:41:13 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 186843F64C; Fri, 27 Jan 2023 03:40:28 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 15/31] arm64: Add support for Realm Personalisation Value Date: Fri, 27 Jan 2023 11:39:16 +0000 Message-Id: <20230127113932.166089-16-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034033_740200_3DD8CD23 X-CRM114-Status: GOOD ( 12.82 ) 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 Add option to specify Realm personalisation value Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 6 +++++- arm/aarch64/kvm.c | 7 +++++++ arm/aarch64/realm.c | 23 +++++++++++++++++++++++ arm/include/arm-common/kvm-config-arch.h | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index b93999b6..f2e659ad 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -26,7 +26,11 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); "Create VM running in a realm using Arm RME"), \ OPT_STRING('\0', "measurement-algo", &(cfg)->measurement_algo, \ "sha256, sha512", \ - "Realm Measurement algorithm, default: sha256"), + "Realm Measurement algorithm, default: sha256"),\ + OPT_STRING('\0', "realm-pv", &(cfg)->realm_pv, \ + "personalisation value", \ + "Personalisation Value (only) for Realm VMs"), + #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index a5a98b2e..4798e359 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -56,6 +56,8 @@ static void validate_realm_cfg(struct kvm *kvm) if (!kvm->cfg.arch.is_realm) { if (kvm->cfg.arch.measurement_algo) die("--measurement-algo valid only with --realm"); + if (kvm->cfg.arch.realm_pv) + die("--realm-pv valid only with --realm"); return; } @@ -74,6 +76,11 @@ static void validate_realm_cfg(struct kvm *kvm) kvm->arch.measurement_algo = KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256; } + if (kvm->cfg.arch.realm_pv) { + if (strlen(kvm->cfg.arch.realm_pv) > KVM_CAP_ARM_RME_RPV_SIZE) + die("Invalid size for Realm Personalization Value\n"); + } + die("Realms not supported"); } diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c index 31543e55..2e0be982 100644 --- a/arm/aarch64/realm.c +++ b/arm/aarch64/realm.c @@ -20,9 +20,32 @@ static void realm_configure_hash_algo(struct kvm *kvm) die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CONFIG_REALM) hash_algo"); } +static void realm_configure_rpv(struct kvm *kvm) +{ + struct kvm_cap_arm_rme_config_item rpv_cfg = { + .cfg = KVM_CAP_ARM_RME_CFG_RPV, + }; + + struct kvm_enable_cap rme_config = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_CONFIG_REALM, + .args[1] = (u64)&rpv_cfg, + }; + + if (!kvm->cfg.arch.realm_pv) + return; + + memset(&rpv_cfg.rpv, 0, sizeof(rpv_cfg.rpv)); + memcpy(&rpv_cfg.rpv, kvm->cfg.arch.realm_pv, strlen(kvm->cfg.arch.realm_pv)); + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_config) < 0) + die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CONFIG_REALM) RPV"); +} + static void realm_configure_parameters(struct kvm *kvm) { realm_configure_hash_algo(kvm); + realm_configure_rpv(kvm); } void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index a2faa3af..80a3b18e 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -7,6 +7,7 @@ struct kvm_config_arch { const char *dump_dtb_filename; const char *vcpu_affinity; const char *measurement_algo; + const char *realm_pv; unsigned int force_cntfrq; bool virtio_trans_pci; bool aarch32_guest; From patchwork Fri Jan 27 11:39:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118578 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 6336CC38142 for ; Fri, 27 Jan 2023 12:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wkB7t9sq9Od5ChigeV9Uu70QXJ2dK4kYE3Z3E8BCs/s=; b=1AuRGp3MZzSdNn VKRPlZy01i54NDpYjNPaUjbBMhvwcdzuOqpd3WlIISpAaKw+QB9n3MdcLMdbPXqrPlmoCnER06PNR toI0WOPjUKb4+VM/eQ+pLm18Mf7p3IAe8xUIANRLwXpAW4JbUJGMVTGsI7CQ4088mYks0j4mZq0g5 dyGUJx//bdW3GcURHNeXYIpvz9EmqDrYu2kYpBZ29skIP1dNdz4E9VzfPWcn4imHcl3eZMtaTEVkj 3ttT/8O0ix6+ec14VIw3zII+g06pzDqGOScKyiqFjimIRTzVpauVbOjP6j+z4KwTEo6GQEa+Zml4t nNlTC02BZPhFTw+C5Yog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNW7-00EPdl-Hi; Fri, 27 Jan 2023 12:07:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5v-00ECzy-El for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:37 +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 6EDC71763; Fri, 27 Jan 2023 03:41:16 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E5B2D3F64C; Fri, 27 Jan 2023 03:40:31 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 16/31] arm64: Add support for specifying the SVE vector length for Realm Date: Fri, 27 Jan 2023 11:39:17 +0000 Message-Id: <20230127113932.166089-17-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034035_656792_C36065EE X-CRM114-Status: GOOD ( 15.35 ) 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 Add option to specify SVE vector length for realms. Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 6 ++++-- arm/aarch64/kvm.c | 23 +++++++++++++++++++++++ arm/aarch64/realm.c | 21 +++++++++++++++++++++ arm/include/arm-common/kvm-arch.h | 1 + arm/include/arm-common/kvm-config-arch.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index f2e659ad..0f42c2c2 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -29,8 +29,10 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset); "Realm Measurement algorithm, default: sha256"),\ OPT_STRING('\0', "realm-pv", &(cfg)->realm_pv, \ "personalisation value", \ - "Personalisation Value (only) for Realm VMs"), - + "Personalisation Value (only) for Realm VMs"), \ + OPT_U64('\0', "sve-vl", &(cfg)->sve_vl, \ + "SVE Vector Length the VM" \ + "(only supported for Realms)"), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 4798e359..fca1410b 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -51,13 +51,19 @@ static void validate_mem_cfg(struct kvm *kvm) } } +#define SVE_VL_ALIGN 128 + static void validate_realm_cfg(struct kvm *kvm) { + u32 sve_vl; + if (!kvm->cfg.arch.is_realm) { if (kvm->cfg.arch.measurement_algo) die("--measurement-algo valid only with --realm"); if (kvm->cfg.arch.realm_pv) die("--realm-pv valid only with --realm"); + if (kvm->cfg.arch.sve_vl) + die("--sve-vl valid only with --realm"); return; } @@ -76,6 +82,23 @@ static void validate_realm_cfg(struct kvm *kvm) kvm->arch.measurement_algo = KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256; } + sve_vl = kvm->cfg.arch.sve_vl; + if (sve_vl) { + if (kvm->cfg.arch.disable_sve) + die("SVE VL requested when SVE is disabled"); + if (!IS_ALIGNED(sve_vl, SVE_VL_ALIGN)) + die("SVE VL is not aligned to %dbit\n", SVE_VL_ALIGN); + kvm->arch.sve_vq = (sve_vl / SVE_VL_ALIGN) - 1; + } else { + /* + * Disable SVE for Realms, if a VL is not requested. + * The SVE VL will be measured as part of the parameter + * and we do not want to add an unknown entity to the + * measurement. + */ + kvm->cfg.arch.disable_sve = true; + } + if (kvm->cfg.arch.realm_pv) { if (strlen(kvm->cfg.arch.realm_pv) > KVM_CAP_ARM_RME_RPV_SIZE) die("Invalid size for Realm Personalization Value\n"); diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c index 2e0be982..fc7f8d6a 100644 --- a/arm/aarch64/realm.c +++ b/arm/aarch64/realm.c @@ -42,10 +42,31 @@ static void realm_configure_rpv(struct kvm *kvm) die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CONFIG_REALM) RPV"); } +static void realm_configure_sve(struct kvm *kvm) +{ + struct kvm_cap_arm_rme_config_item sve_cfg = { + .cfg = KVM_CAP_ARM_RME_CFG_SVE, + .sve_vq = kvm->arch.sve_vq, + }; + + struct kvm_enable_cap rme_config = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_CONFIG_REALM, + .args[1] = (u64)&sve_cfg, + }; + + if (kvm->cfg.arch.disable_sve) + return; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_config) < 0) + die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CONFIG_REALM) SVE"); +} + static void realm_configure_parameters(struct kvm *kvm) { realm_configure_hash_algo(kvm); realm_configure_rpv(kvm); + realm_configure_sve(kvm); } void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index 68224b1c..41b31f11 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -114,6 +114,7 @@ struct kvm_arch { cpu_set_t *vcpu_affinity_cpuset; u64 measurement_algo; + u64 sve_vq; }; #endif /* ARM_COMMON__KVM_ARCH_H */ diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 80a3b18e..d923fd9e 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -19,6 +19,7 @@ struct kvm_config_arch { u64 fw_addr; bool no_pvtime; bool disable_sve; + u64 sve_vl; }; int irqchip_parser(const struct option *opt, const char *arg, int unset); From patchwork Fri Jan 27 11:39:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118579 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 A0A88C54EAA for ; Fri, 27 Jan 2023 12:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nudTigmO37xiTu4hfynCzszPhyWaseId2bO4fcysGFw=; b=K+T/HxXZDAZJF+ pUjVJycJcOkZUvmLRT3uDmtQuL3Be6HsKZAMHcwgHov9tqYSnhUtkOgTbnV5ETXMmzxktPJw7O2VY yMDGU4Y6CIG+FzdFs631eXriLqDNZqgHHkgzLVZa6ll+DWFKZfyfuabDX5zQWFDLuxhzQc2oXgZAx DwsA5JnkPrXA6/bylToGFhLAlWSICFFakSEBCRnVATFkh+O2W2Pm2mE6R8IDFX5iQAwQOqUB00OJK 3ZY/q9di3NP1qp7ajxr1bsTF8fNxAaqTzKAlkq5JaOQsjqwbtXKAlheyAg4IeyHUZaZhiBzZVJbK3 sJGBMlAId/9o//V6Q/Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNWr-00EPyf-1o; Fri, 27 Jan 2023 12:08:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN5y-00ED1C-4T for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:39 +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 480471576; Fri, 27 Jan 2023 03:41:19 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BEBA93F64C; Fri, 27 Jan 2023 03:40:34 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 17/31] arm: Add kernel size to VM context Date: Fri, 27 Jan 2023 11:39:18 +0000 Message-Id: <20230127113932.166089-18-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034038_285649_16EFB1EB X-CRM114-Status: GOOD ( 13.10 ) 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: Alexandru Elisei Add the kernel image size to the VM context, as we are going to use it later. This matches what we already do with the initrd. Signed-off-by: Alexandru Elisei [Fix kernel size printed in debug messages] Signed-off-by: Suzuki K Poulose --- arm/include/arm-common/kvm-arch.h | 1 + arm/kvm.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index 41b31f11..b5a4b851 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -108,6 +108,7 @@ struct kvm_arch { */ u64 memory_guest_start; u64 kern_guest_start; + u64 kern_size; u64 initrd_guest_start; u64 initrd_size; u64 dtb_guest_start; diff --git a/arm/kvm.c b/arm/kvm.c index 2510a322..acb627b2 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -153,7 +153,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, limit = kvm->ram_start + min(kvm->ram_size, (u64)SZ_256M) - 1; pos = kvm->ram_start + kvm__arch_get_kern_offset(kvm, fd_kernel); - kvm->arch.kern_guest_start = host_to_guest_flat(kvm, pos); file_size = read_file(fd_kernel, pos, limit - pos); if (file_size < 0) { if (errno == ENOMEM) @@ -161,9 +160,12 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, die_perror("kernel read"); } + + kvm->arch.kern_guest_start = host_to_guest_flat(kvm, pos); + kvm->arch.kern_size = file_size; kernel_end = pos + file_size; - pr_debug("Loaded kernel to 0x%llx (%zd bytes)", - kvm->arch.kern_guest_start, file_size); + pr_debug("Loaded kernel to 0x%llx (%llu bytes)", + kvm->arch.kern_guest_start, kvm->arch.kern_size); /* * Now load backwards from the end of memory so the kernel From patchwork Fri Jan 27 11:39:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118580 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 BFE3BC54EAA for ; Fri, 27 Jan 2023 12:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hWGwxLKPoIFLAJ+pSeTxk8n83PSMSeG/8v6K1KXuvuE=; b=kjbQiof5e9XwR3 CWb2EV7/MHRIeAbM0J1WA6BY0qvKDpwRfY9zQbAQmd7jIUVcitSuVMqW8v/yZ+f/SnpTyqp/QBRtX Gm3mfzbkbexTFhGDgE9F+zPPDbVXoi0flcwJ0zjnlNj7qFZ6fziUf5UQPHQsyXrWvkQsuGZlrFRNO hCXStMXN04Kmirvg1XsiH4vb5igPtDSapxDeTpp+AJ9MyMotW9HaITyhPDQq7vRa2pKceG48yH6MF IpsjJlQ6NPwvPS6y4ISwuPL9l4fMMFnZBnxO5r7jZvRaAbGOUtBeoUKrt7TqWRX45R+yEKzUQlS3K 4mHiK+H+WMGUQcvx2LUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNXa-00EQKb-7W; Fri, 27 Jan 2023 12:09:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN60-00ED36-RO for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:43 +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 2199715DB; Fri, 27 Jan 2023 03:41:22 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 980F33F64C; Fri, 27 Jan 2023 03:40:37 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 18/31] arm64: Populate initial realm contents Date: Fri, 27 Jan 2023 11:39:19 +0000 Message-Id: <20230127113932.166089-19-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034041_060298_9528ED25 X-CRM114-Status: GOOD ( 28.02 ) 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: Alexandru Elisei Populate the realm memory with the initial contents, which include the device tree blob, the kernel image, and initrd, if specified, or the firmware image. Populating an image in the realm involves two steps: a) Mark the IPA area as RAM - INIT_IPA_REALM b) Load the contents into the IPA - POPULATE_REALM Wherever we know the actual size of an image in memory, we make sure the "memory area" is initialised to RAM. e.g., Linux kernel image size from the header which includes the bss etc. The "file size" on disk for the Linux image is much smaller. We mark the region of size Image.header.size as RAM (a), from the kernel load address. And load the Image file into the memory (b) above. At the moment we only detect the Arm64 Linux Image header format. Since we're already touching the code that copies the initrd in guest memory, let's do a bit of cleaning and remove a useless local variable. Signed-off-by: Alexandru Elisei [ Make sure the Linux kernel image area is marked as RAM ] Signed-off-by: Suzuki K Poulose --- arm/aarch32/include/asm/realm.h | 3 + arm/aarch64/include/asm/realm.h | 3 + arm/aarch64/realm.c | 112 ++++++++++++++++++++++++++++++++ arm/fdt.c | 6 ++ arm/kvm.c | 20 ++++-- include/linux/kernel.h | 1 + 6 files changed, 140 insertions(+), 5 deletions(-) diff --git a/arm/aarch32/include/asm/realm.h b/arm/aarch32/include/asm/realm.h index 5aca6cca..fcff0e55 100644 --- a/arm/aarch32/include/asm/realm.h +++ b/arm/aarch32/include/asm/realm.h @@ -6,5 +6,8 @@ #include "kvm/kvm.h" static inline void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) {} +static inline void kvm_arm_realm_populate_kernel(struct kvm *kvm) {} +static inline void kvm_arm_realm_populate_initrd(struct kvm *kvm) {} +static inline void kvm_arm_realm_populate_dtb(struct kvm *kvm) {} #endif /* ! __ASM_REALM_H */ diff --git a/arm/aarch64/include/asm/realm.h b/arm/aarch64/include/asm/realm.h index e176f15f..6e760ac9 100644 --- a/arm/aarch64/include/asm/realm.h +++ b/arm/aarch64/include/asm/realm.h @@ -6,5 +6,8 @@ #include "kvm/kvm.h" void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm); +void kvm_arm_realm_populate_kernel(struct kvm *kvm); +void kvm_arm_realm_populate_initrd(struct kvm *kvm); +void kvm_arm_realm_populate_dtb(struct kvm *kvm); #endif /* ! __ASM_REALM_H */ diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c index fc7f8d6a..eddccece 100644 --- a/arm/aarch64/realm.c +++ b/arm/aarch64/realm.c @@ -1,5 +1,7 @@ #include "kvm/kvm.h" +#include +#include #include @@ -80,3 +82,113 @@ void kvm_arm_realm_create_realm_descriptor(struct kvm *kvm) if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_create_rd) < 0) die_perror("KVM_CAP_RME(KVM_CAP_ARM_RME_CREATE_RD)"); } + +static void realm_init_ipa_range(struct kvm *kvm, u64 start, u64 size) +{ + struct kvm_cap_arm_rme_init_ipa_args init_ipa_args = { + .init_ipa_base = start, + .init_ipa_size = size + }; + struct kvm_enable_cap rme_init_ipa_realm = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_INIT_IPA_REALM, + .args[1] = (u64)&init_ipa_args + }; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_init_ipa_realm) < 0) + die("unable to intialise IPA range for Realm %llx - %llx (size %llu)", + start, start + size, size); + +} + +static void __realm_populate(struct kvm *kvm, u64 start, u64 size) +{ + struct kvm_cap_arm_rme_populate_realm_args populate_args = { + .populate_ipa_base = start, + .populate_ipa_size = size + }; + struct kvm_enable_cap rme_populate_realm = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_POPULATE_REALM, + .args[1] = (u64)&populate_args + }; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &rme_populate_realm) < 0) + die("unable to populate Realm memory %llx - %llx (size %llu)", + start, start + size, size); +} + +static void realm_populate(struct kvm *kvm, u64 start, u64 size) +{ + realm_init_ipa_range(kvm, start, size); + __realm_populate(kvm, start, size); +} + +static bool is_arm64_linux_kernel_image(void *header) +{ + struct arm64_image_header *hdr = header; + + return memcmp(&hdr->magic, ARM64_IMAGE_MAGIC, sizeof(hdr->magic)) == 0; +} + +static ssize_t arm64_linux_kernel_image_size(void *header) +{ + struct arm64_image_header *hdr = header; + + if (is_arm64_linux_kernel_image(header)) + return le64_to_cpu(hdr->image_size); + die("Not arm64 Linux kernel Image"); +} + +void kvm_arm_realm_populate_kernel(struct kvm *kvm) +{ + u64 start, end, mem_size; + void *header = guest_flat_to_host(kvm, kvm->arch.kern_guest_start); + + start = ALIGN_DOWN(kvm->arch.kern_guest_start, SZ_4K); + end = ALIGN(kvm->arch.kern_guest_start + kvm->arch.kern_size, SZ_4K); + + if (is_arm64_linux_kernel_image(header)) + mem_size = arm64_linux_kernel_image_size(header); + else + mem_size = end - start; + + realm_init_ipa_range(kvm, start, mem_size); + __realm_populate(kvm, start, end - start); +} + +void kvm_arm_realm_populate_initrd(struct kvm *kvm) +{ + u64 kernel_end, start, end; + + kernel_end = ALIGN(kvm->arch.kern_guest_start + kvm->arch.kern_size, SZ_4K); + start = ALIGN_DOWN(kvm->arch.initrd_guest_start, SZ_4K); + /* + * Because we align the initrd to 4 bytes, it is theoretically possible + * for the start of the initrd to overlap with the same page where the + * kernel ends. + */ + if (start < kernel_end) + start = kernel_end; + end = ALIGN(kvm->arch.initrd_guest_start + kvm->arch.initrd_size, SZ_4K); + if (end > start) + realm_populate(kvm, start, end - start); +} + +void kvm_arm_realm_populate_dtb(struct kvm *kvm) +{ + u64 initrd_end, start, end; + + initrd_end = ALIGN(kvm->arch.initrd_guest_start + kvm->arch.initrd_size, SZ_4K); + start = ALIGN_DOWN(kvm->arch.dtb_guest_start, SZ_4K); + /* + * Same situation as with the initrd, but now it is the DTB which is + * overlapping with the last page of the initrd, because the initrd is + * populated first. + */ + if (start < initrd_end) + start = initrd_end; + end = ALIGN(kvm->arch.dtb_guest_start + FDT_MAX_SIZE, SZ_4K); + if (end > start) + realm_populate(kvm, start, end - start); +} diff --git a/arm/fdt.c b/arm/fdt.c index 286ccadf..762a604d 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -7,6 +7,8 @@ #include "arm-common/gic.h" #include "arm-common/pci.h" +#include + #include #include @@ -231,6 +233,10 @@ static int setup_fdt(struct kvm *kvm) if (kvm->cfg.arch.dump_dtb_filename) dump_fdt(kvm->cfg.arch.dump_dtb_filename, fdt_dest); + + if (kvm->cfg.arch.is_realm) + kvm_arm_realm_populate_dtb(kvm); + return 0; } late_init(setup_fdt); diff --git a/arm/kvm.c b/arm/kvm.c index acb627b2..57c5b5f7 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -6,6 +6,7 @@ #include "kvm/fdt.h" #include "arm-common/gic.h" +#include #include @@ -167,6 +168,9 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, pr_debug("Loaded kernel to 0x%llx (%llu bytes)", kvm->arch.kern_guest_start, kvm->arch.kern_size); + if (kvm->cfg.arch.is_realm) + kvm_arm_realm_populate_kernel(kvm); + /* * Now load backwards from the end of memory so the kernel * decompressor has plenty of space to work with. First up is @@ -188,7 +192,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, /* ... and finally the initrd, if we have one. */ if (fd_initrd != -1) { struct stat sb; - unsigned long initrd_start; if (fstat(fd_initrd, &sb)) die_perror("fstat"); @@ -199,7 +202,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, if (pos < kernel_end) die("initrd overlaps with kernel image."); - initrd_start = guest_addr; file_size = read_file(fd_initrd, pos, limit - pos); if (file_size == -1) { if (errno == ENOMEM) @@ -208,11 +210,13 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, die_perror("initrd read"); } - kvm->arch.initrd_guest_start = initrd_start; + kvm->arch.initrd_guest_start = guest_addr; kvm->arch.initrd_size = file_size; pr_debug("Loaded initrd to 0x%llx (%llu bytes)", - kvm->arch.initrd_guest_start, - kvm->arch.initrd_size); + kvm->arch.initrd_guest_start, kvm->arch.initrd_size); + + if (kvm->cfg.arch.is_realm) + kvm_arm_realm_populate_initrd(kvm); } else { kvm->arch.initrd_size = 0; } @@ -269,6 +273,8 @@ bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename) /* Kernel isn't loaded by kvm, point start address to firmware */ kvm->arch.kern_guest_start = fw_addr; + kvm->arch.kern_size = fw_sz; + pr_debug("Loaded firmware to 0x%llx (%zd bytes)", kvm->arch.kern_guest_start, fw_sz); @@ -283,6 +289,10 @@ bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename) kvm->arch.dtb_guest_start, kvm->arch.dtb_guest_start + FDT_MAX_SIZE); + if (kvm->cfg.arch.is_realm) + /* We hijack the kernel fields to describe the firmware. */ + kvm_arm_realm_populate_kernel(kvm); + return true; } diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 6c22f1c0..25f19c20 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -9,6 +9,7 @@ #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define ALIGN_DOWN(x,a) __ALIGN_MASK(x - (typeof(x))((a) - 1),(typeof(x))(a)-1) #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) From patchwork Fri Jan 27 11:39:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118581 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 08A29C54EAA for ; Fri, 27 Jan 2023 12:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WDX4xRmnp15VD2+WlG+VW1a2vLBVmgBGmiEEwBZSN94=; b=IR6idjqOC6peh9 dJijT/kkQqfTBLPybA4Pkmfp9v/YH+ZJUSdUkhk4DSrqMexiGCNZN9ywZatm79u7JFeGN6aB2AqM6 2KWAoIeQLTbGEgdpQyjgcyehPWbzVAfSefTG5Mz9R5Csm1C/5Pb3m+k95U3UmSIOmFyUwSrFSwWM6 6LtEx8xjj4U5Jonvp0TCj2tL+WHS6i+auSg8IVdil58/7pL0qP9IJVhSYe8XBXfhEmACR91gtj5Fg /y+fy4+S0L6SomWXnu//K9NVA2+vTb9GwdFWm+YONedTXCTX8hkJJ0uk2iY+/kHx3R/vIu3zsxfju 3l9GruABX+YRuqIO+wSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNYO-00EQhq-L8; Fri, 27 Jan 2023 12:10:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN64-00ED4Y-R5 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:46 +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 EF4CE2B; Fri, 27 Jan 2023 03:41:24 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 713E03F64C; Fri, 27 Jan 2023 03:40:40 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 19/31] arm64: Don't try to set PSTATE for VCPUs belonging to a realm Date: Fri, 27 Jan 2023 11:39:20 +0000 Message-Id: <20230127113932.166089-20-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034044_961053_D78E5023 X-CRM114-Status: GOOD ( 11.57 ) 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: Christoffer Dall RME doesn't allow setting the PSTATE but resets it to an architectural value, and KVM also does not allow setting this register from user space, so stop trying to do that. Signed-off-by: Christoffer Dall Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm-cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index e7649239..37f9aa9d 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -92,11 +92,13 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) reg.addr = (u64)&data; - /* pstate = all interrupts masked */ - data = PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | PSR_MODE_EL1h; - reg.id = ARM64_CORE_REG(regs.pstate); - if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0) - die_perror("KVM_SET_ONE_REG failed (spsr[EL1])"); + if (!kvm->cfg.arch.is_realm) { + /* pstate = all interrupts masked */ + data = PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | PSR_MODE_EL1h; + reg.id = ARM64_CORE_REG(regs.pstate); + if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0) + die_perror("KVM_SET_ONE_REG failed (PSTATE)"); + } /* x1...x3 = 0 */ data = 0; From patchwork Fri Jan 27 11:39:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118582 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 E135EC38142 for ; Fri, 27 Jan 2023 12:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XhLNY/S1YFiLBMxbvWUMtIcnf3z9lkl/8eyb+/7XBp8=; b=vRz1j9ScqwD4CL FUxYyagRcBfiFm1V/T30npfQNlZDxh6BiKV8+SlGMVgwzO2KzVvT8VjESFYakF83maPtNb9HPu09f CP5fpxXo/anV32P/nUghI38BtDQaF1plHwIYZraU9+OOE0m0cjJlHF6S+u9VKROfOZ0nwUTaoqEqF xb/FAeMINLeNv9+U4dgFnQvHwbcrD51IhiuTfFcWdJo2rt/f3/ceCDK8avMwb2h/iHMoT/FBv4eSb KaX6YilcBrECgEsQ5nyfdApWpXGN7S2fPRu8YwiYX7U0eLsSe/dHYQudLGc6qidhIQLuRMQOIu7Lk dZCKf6XfD7RYok/eMaqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNZ0-00EQzz-AT; Fri, 27 Jan 2023 12:10:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN66-00ED6O-QY for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:48 +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 D149115BF; Fri, 27 Jan 2023 03:41:27 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4AF653F64C; Fri, 27 Jan 2023 03:40:43 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 20/31] arm64: Finalize realm VCPU after reset Date: Fri, 27 Jan 2023 11:39:21 +0000 Message-Id: <20230127113932.166089-21-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034046_954563_20881350 X-CRM114-Status: UNSURE ( 8.84 ) X-CRM114-Notice: Please train this message. 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: Alexandru Elisei In order to run a VCPU belonging to a realm, that VCPU must be in the finalized state. Finalize the CPU after reset, since kvmtool won't be touching the VCPU state afterwards. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm-cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 37f9aa9d..24e570c4 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -128,6 +128,13 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, ®) < 0) die_perror("KVM_SET_ONE_REG failed (pc)"); } + + if (kvm->cfg.arch.is_realm) { + int feature = KVM_ARM_VCPU_REC; + + if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature) < 0) + die_perror("KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_REC)"); + } } void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) From patchwork Fri Jan 27 11:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118583 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 6C80DC38142 for ; Fri, 27 Jan 2023 12:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PPtcC/tLqCUJnT4nylWTOThUZKFWpZJAOwzV0+5lNA0=; b=vUgEJn5pLDYiUq QNhPuhjGAS/4pH0CZk5gHNBjKmaEsBR03BfX34iqIMX8nvdnIkppno/k/kvNcLIBRpEtKbXR1He+f b8FL5V2G0n7qJeRF+Ru2TK661/tHmOQWe4xdLb/3p5RACatZtQ8jJGDh8U9Ccj89HPq2xhCvbPOlh zuZzbbm4DSVIYJrqIJs2PLUUrrVEoPB6re9ClmJBo+buG6EInRHi4MfpVG3hxhUxBx3tXawdWPq0o Q9lgXNWsKqAX9Rv1kV81atxuDt9Wd3ag4ZeSXBQ/UBM1RvFU3Zl+jsn8rGTo0NL2iG6N/XduZwXWT kD2YrcWs6L1x0UWBs+/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNZp-00EROX-MV; Fri, 27 Jan 2023 12:11:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN69-00ED8R-Go for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:51 +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 AAE681650; Fri, 27 Jan 2023 03:41:30 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2D7A03F64C; Fri, 27 Jan 2023 03:40:46 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 21/31] init: Add last_{init, exit} list macros Date: Fri, 27 Jan 2023 11:39:22 +0000 Message-Id: <20230127113932.166089-22-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034049_677862_A2568A50 X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. 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: Alexandru Elisei Add a last_init macro for constructor functions that will be executed last in the initialization process. Add a symmetrical macro, last_exit, for destructor functions that will be the last to be executed when kvmtool exits. The list priority for the late_{init, exit} macros has been bumped down a spot, but their relative priority remains unchanged, to keep the same size for the init_lists and exit_lists. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- include/kvm/util-init.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/kvm/util-init.h b/include/kvm/util-init.h index 13d4f04d..e6a0e169 100644 --- a/include/kvm/util-init.h +++ b/include/kvm/util-init.h @@ -39,7 +39,8 @@ static void __attribute__ ((constructor)) __init__##cb(void) \ #define dev_init(cb) __init_list_add(cb, 5) #define virtio_dev_init(cb) __init_list_add(cb, 6) #define firmware_init(cb) __init_list_add(cb, 7) -#define late_init(cb) __init_list_add(cb, 9) +#define late_init(cb) __init_list_add(cb, 8) +#define last_init(cb) __init_list_add(cb, 9) #define core_exit(cb) __exit_list_add(cb, 0) #define base_exit(cb) __exit_list_add(cb, 2) @@ -47,5 +48,6 @@ static void __attribute__ ((constructor)) __init__##cb(void) \ #define dev_exit(cb) __exit_list_add(cb, 5) #define virtio_dev_exit(cb) __exit_list_add(cb, 6) #define firmware_exit(cb) __exit_list_add(cb, 7) -#define late_exit(cb) __exit_list_add(cb, 9) +#define late_exit(cb) __exit_list_add(cb, 8) +#define last_exit(cb) __exit_list_add(cb, 9) #endif From patchwork Fri Jan 27 11:39:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118584 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 CA5F8C38142 for ; Fri, 27 Jan 2023 12:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GZZldezSf9sKIPUYfmjduSLNqJ279La4bxhKPUfBKB0=; b=3PtpsbcKVLAAk/ 2ab4nY6Ht2GD35M4juMfCfw0vfIVm1LH00NNHKkIkC91KHH0PKyizW0YkIh1wIKYWix8sTwwGTetV nbfxDGFTZpq4xOLG/LIKa5awH8qKUJrz7gPI5CcFRHNn3X2WNNO0HCutRl0VMa5rfT7W5WJdyJy5M Dl9OjixK02H3GKIYPBsV9oxwyICQtz+PCelyy9MdvaGE3Aa3aXd2A+0D8RFaKflTShm0wy+KMWNCP 181p0AKhl/TzdUaTbyxYJkNF/ILkJCq4ZmG+IHy5urYQ5e6nw2/jHCoV61mp95PWCXX8J02OK8Ys2 cG6ADtXV9yIVGTQmpD6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNaQ-00ERf1-4k; Fri, 27 Jan 2023 12:12:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6C-00EDAb-Cj for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:55 +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 85B3D175A; Fri, 27 Jan 2023 03:41:33 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 068563F64C; Fri, 27 Jan 2023 03:40:48 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 22/31] arm64: Activate realm before the first VCPU is run Date: Fri, 27 Jan 2023 11:39:23 +0000 Message-Id: <20230127113932.166089-23-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034052_797300_8C0050DC X-CRM114-Status: GOOD ( 18.23 ) 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: Alexandru Elisei Before KVM can run a VCPU belong to a realm, the realm be activated. Activating a realm prevents the adding of new object and seals the cryptographic measurement of that realm. The VCPU state is part of the measurement, which means that realm activation must be performed after all VCPUs have been reset. Current RMM implementation can only create RECs in the order of their MPIDRs. VCPUs get assigned MPIDRs by KVM based on their VCPU id. Reset the VCPUs in the order they were created from the main thread instead of doing it from their own thread, which doesn't guarantee any ordering. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm-cpu.c | 4 ++++ arm/aarch64/realm.c | 35 +++++++++++++++++++++++++++++++ arm/include/arm-common/kvm-arch.h | 1 + 3 files changed, 40 insertions(+) diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 24e570c4..32fa7609 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -187,6 +187,10 @@ void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu) cpu_set_t *affinity; int ret; + /* VCPU reset is done before activating the realm. */ + if (kvm->arch.realm_is_active) + return; + affinity = kvm->arch.vcpu_affinity_cpuset; if (affinity) { ret = sched_setaffinity(0, sizeof(cpu_set_t), affinity); diff --git a/arm/aarch64/realm.c b/arm/aarch64/realm.c index eddccece..808d39c5 100644 --- a/arm/aarch64/realm.c +++ b/arm/aarch64/realm.c @@ -1,4 +1,5 @@ #include "kvm/kvm.h" +#include "kvm/kvm-cpu.h" #include #include @@ -192,3 +193,37 @@ void kvm_arm_realm_populate_dtb(struct kvm *kvm) if (end > start) realm_populate(kvm, start, end - start); } + +static void kvm_arm_realm_activate_realm(struct kvm *kvm) +{ + struct kvm_enable_cap activate_realm = { + .cap = KVM_CAP_ARM_RME, + .args[0] = KVM_CAP_ARM_RME_ACTIVATE_REALM, + }; + + if (ioctl(kvm->vm_fd, KVM_ENABLE_CAP, &activate_realm) < 0) + die_perror("KVM_CAP_ARM_RME(KVM_CAP_ARM_RME_ACTIVATE_REALM)"); + + kvm->arch.realm_is_active = true; +} + +static int kvm_arm_realm_finalize(struct kvm *kvm) +{ + int i; + + if (!kvm->cfg.arch.is_realm) + return 0; + + /* + * VCPU reset must happen before the realm is activated, because their + * state is part of the cryptographic measurement for the realm. + */ + for (i = 0; i < kvm->nrcpus; i++) + kvm_cpu__reset_vcpu(kvm->cpus[i]); + + /* Activate and seal the measurement for the realm. */ + kvm_arm_realm_activate_realm(kvm); + + return 0; +} +last_init(kvm_arm_realm_finalize) diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index b5a4b851..6d48e13c 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -116,6 +116,7 @@ struct kvm_arch { cpu_set_t *vcpu_affinity_cpuset; u64 measurement_algo; u64 sve_vq; + bool realm_is_active; }; #endif /* ARM_COMMON__KVM_ARCH_H */ From patchwork Fri Jan 27 11:39:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118591 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 95B10C54EAA for ; Fri, 27 Jan 2023 12:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BKOXfWZzjoXwRgXcFTZZqjftENqQr23dZnyPCF8QfDw=; b=BdSxNC7ZHfDrQ7 cheSZb7yul3ngYz98DZeiR60XLwMnMy3ma/SbiJy5JIzOndMB5YKS0SVaZQM/MMeDEC+fOmRiybrh O8n8gerheY0Auc0J5PNXwOsjeknn2HeetIaVf6HnVDc7mOYKOrdmk9Yekc3KrTZVcx4mqnuXPObMO oa78WxnNUDTh5gLd93d7hSXejVW/jThEvY1EcciQZs0cDfFHSk1MAjnYFP3tp9GLfriW71ZRjtiqH aZvNWzYtVuAKTcZwS+AIdl2497ByuOAu3r0M6KoCwTjFtmSJSQ7OanmH20gtZ724MDMro3+wpJ51t lmdA603iiX2So0Ah230w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNbA-00ERzj-3i; Fri, 27 Jan 2023 12:12:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6F-00EDCT-5X for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:57 +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 68CBE1595; Fri, 27 Jan 2023 03:41:36 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D6C173F64C; Fri, 27 Jan 2023 03:40:51 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 23/31] arm64: Specify SMC as the PSCI conduits for realms Date: Fri, 27 Jan 2023 11:39:24 +0000 Message-Id: <20230127113932.166089-24-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034055_324603_C5BA64D0 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. 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: Christoffer Dall This lets the VM use the RMM implementation for PSCI. Signed-off-by: Christoffer Dall Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/fdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arm/fdt.c b/arm/fdt.c index 762a604d..c46ff410 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -208,7 +208,14 @@ static int setup_fdt(struct kvm *kvm) _FDT(fdt_property_string(fdt, "compatible", "arm,psci")); fns = &psci_0_1_fns; } - _FDT(fdt_property_string(fdt, "method", "hvc")); + + + if (kvm->cfg.arch.is_realm) { + _FDT(fdt_property_string(fdt, "method", "smc")); + } else { + _FDT(fdt_property_string(fdt, "method", "hvc")); + } + _FDT(fdt_property_cell(fdt, "cpu_suspend", fns->cpu_suspend)); _FDT(fdt_property_cell(fdt, "cpu_off", fns->cpu_off)); _FDT(fdt_property_cell(fdt, "cpu_on", fns->cpu_on)); From patchwork Fri Jan 27 11:39:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118592 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 CE713C61DA7 for ; Fri, 27 Jan 2023 12:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hOt/M8VJOQNvX5gafqBt7Y4KfkNc7ZLI2CtdU1+5ltU=; b=NmIw4qxPywUXOk vyiRtTZD0wQl7HZmIHY1DpC1pERPBb745fyIf1OKr/cpj4IM9Bu5zkZTuyZYw9FXZuNuGLWvpdUW1 rRCYowUjLIv3YSAfg8NP05KXrJ4sQkeewu0WYB9iss98To2PpJmHeWebkxbhztsXlrShgcwRZF0sv 3OuKHuUnTivjWu0CSLXnPNmb+A/taP1wWnh84tlngCJGKGdOonCED+RaBVwKP9OGjoKWSUkJyijm2 AKn2AJ6vR/YQhOiC/4rbSeNPjnD9zvLxwF+otNaI8nn1ZWpw1COr6z6Rwbiye8kGFSLLsBirrI8qt 452fQHCuGXHqyjewXqxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNbq-00ESJg-Cu; Fri, 27 Jan 2023 12:13:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6I-00EDEK-5y for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:40:59 +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 4B9CB1762; Fri, 27 Jan 2023 03:41:39 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B8BF43F8D6; Fri, 27 Jan 2023 03:40:54 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 24/31] arm64: Don't try to debug a realm Date: Fri, 27 Jan 2023 11:39:25 +0000 Message-Id: <20230127113932.166089-25-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034058_397297_654DF602 X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. 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: Alexandru Elisei Don't read the register values for a running realm, because they don't reflect the actual hardware state of a realm. And don't try to read realm memory, because that will promptly lead to kvmtool being killed. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm-cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 32fa7609..a29a3413 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -250,6 +250,9 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu) reg.addr = (u64)&data; + if (vcpu->kvm->cfg.arch.is_realm) + return; + dprintf(debug_fd, "\n*pc:\n"); reg.id = ARM64_CORE_REG(regs.pc); if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) @@ -274,6 +277,11 @@ void kvm_cpu__show_registers(struct kvm_cpu *vcpu) reg.addr = (u64)&data; dprintf(debug_fd, "\n Registers:\n"); + if (vcpu->kvm->cfg.arch.is_realm) { + dprintf(debug_fd, " UNACCESSIBLE\n"); + return; + } + reg.id = ARM64_CORE_REG(regs.pc); if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) die("KVM_GET_ONE_REG failed (pc)"); From patchwork Fri Jan 27 11:39:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118593 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 2B912C61DA4 for ; Fri, 27 Jan 2023 12:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uAXNRO+q4G9c7zq5jAu94MaE9I6qq4uIvQUms8au0vw=; b=MGF6krxZ04lELR ZK10QWFVzGhmxgrvesxxVFJxx5Zy20C0Yr2qRyDvORhya3YroFpowGwB6wvu8sdfSpwCIF5AlEfMo w6OsD2UA5joKYuNGnBU5sl8HvphvoEsnz9wL2VCUOIE94egW/Ntp9aXwGoJmzLJNJPJyfI3Ly3TDT h4ygS2yW+zAxqHgzjcWsct8TdpfpN+LB23NrzRPq/yNuz7P1Je+cVNYgcPP3j6AqPrgpGB49piBZo QZdhrXYauBFT+7V5fI7l4XLqvYPA3O4MNjLzy47m3KEPi5F/v6Li4VOR/F8Dudoz+44Ccgmi7zul1 GyNmYX8FZHkPkFAJgi+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNcL-00ESZb-40; Fri, 27 Jan 2023 12:14:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6K-00EDFk-Tz for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:02 +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 2D1C71764; Fri, 27 Jan 2023 03:41:42 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9B35E3F64C; Fri, 27 Jan 2023 03:40:57 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 25/31] arm64: realm: Double the IPA space Date: Fri, 27 Jan 2023 11:39:26 +0000 Message-Id: <20230127113932.166089-26-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034101_057110_BF8AD44B X-CRM114-Status: UNSURE ( 8.35 ) X-CRM114-Notice: Please train this message. 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 The Realm's IPA space is divided into 2 halves. Protected (lower half) and Unprotected (upper half). KVM implements aliasing of the IPA, where the unprotected IPA is alias of the corresponding protected ipa. Thus we must double the IPA space required for a given VM. Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index fca1410b..344c568b 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -189,6 +189,9 @@ int kvm__get_vm_type(struct kvm *kvm) /* Otherwise, compute the minimal required IPA size */ max_ipa = kvm->cfg.ram_addr + kvm->cfg.ram_size - 1; ipa_bits = max(32, fls_long(max_ipa)); + /* Realm needs double the IPA space */ + if (kvm->cfg.arch.is_realm) + ipa_bits++; pr_debug("max_ipa %lx ipa_bits %d max_ipa_bits %d", max_ipa, ipa_bits, max_ipa_bits); From patchwork Fri Jan 27 11:39:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118594 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 2D281C54EAA for ; Fri, 27 Jan 2023 12:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jiHtH1V7WCdS/Ks/lVTYxm6glRuns42hW7E3FzhTj/o=; b=LrXzjqknLbmK4c vR0A8skC11xKUy1OA7FkJ0M2mfB3e69LNotGKzcKFvPVROtaJ8UfFYinjDAGo07XWgxMVqqtc8uVa qZhZDt26J6F8p66OcNoyf+QuDkB2CK7D+3+I82CRCYjrhohZilBtbMZRuL1hqpNSQ6MXvEYAwRh4d I8e+s8w5UNZoLKxwLhi3SN1ZBmcMua5wgCPSBVj6BHD1n/upE7nTLX/Q9BFeeXJaZGwpP4ujogzDB n7k+5ybUBYnkvElew2OUIYKyIf5/EaLznSindBtTzkFeNRRyPXIeXFvkFHoATTBv3jmm+puz9p9Z+ OeIJhMPX2r72wIo/PjTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNcw-00ESqh-Pe; Fri, 27 Jan 2023 12:14:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6O-00EDGq-53 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:07 +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 06657176A; Fri, 27 Jan 2023 03:41:45 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7CD023F64C; Fri, 27 Jan 2023 03:41:00 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 26/31] virtio: Add a wrapper for get_host_features Date: Fri, 27 Jan 2023 11:39:27 +0000 Message-Id: <20230127113932.166089-27-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034104_342965_E747CF57 X-CRM114-Status: GOOD ( 12.23 ) 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 Add a wrapper to the vdev->ops->get_host_features() to allow setting platform specific flags outside the device Signed-off-by: Suzuki K Poulose --- include/kvm/virtio.h | 2 ++ virtio/core.c | 5 +++++ virtio/mmio-legacy.c | 2 +- virtio/mmio-modern.c | 2 +- virtio/pci-legacy.c | 2 +- virtio/pci-modern.c | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h index 94bddefe..e95cfad5 100644 --- a/include/kvm/virtio.h +++ b/include/kvm/virtio.h @@ -248,4 +248,6 @@ void virtio_set_guest_features(struct kvm *kvm, struct virtio_device *vdev, void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, void *dev, u8 status); +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev); + #endif /* KVM__VIRTIO_H */ diff --git a/virtio/core.c b/virtio/core.c index ea0e5b65..50e7f86d 100644 --- a/virtio/core.c +++ b/virtio/core.c @@ -283,6 +283,11 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, vdev->ops->notify_status(kvm, dev, ext_status); } +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev) +{ + return vdev->ops->get_host_features(kvm, dev); +} + bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev, void *dev, unsigned long offset, void *data, size_t size, bool is_write) diff --git a/virtio/mmio-legacy.c b/virtio/mmio-legacy.c index 7ca7e69f..42673236 100644 --- a/virtio/mmio-legacy.c +++ b/virtio/mmio-legacy.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, break; case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel == 0) - val = vdev->ops->get_host_features(vmmio->kvm, + val = virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); ioport__write32(data, val); break; diff --git a/virtio/mmio-modern.c b/virtio/mmio-modern.c index 6c0bb382..a09fa8e9 100644 --- a/virtio/mmio-modern.c +++ b/virtio/mmio-modern.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel > 1) break; - features |= vdev->ops->get_host_features(vmmio->kvm, vmmio->dev); + features |= virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); val = features >> (32 * vmmio->hdr.host_features_sel); break; case VIRTIO_MMIO_QUEUE_NUM_MAX: diff --git a/virtio/pci-legacy.c b/virtio/pci-legacy.c index 58047967..d5f5dee7 100644 --- a/virtio/pci-legacy.c +++ b/virtio/pci-legacy.c @@ -44,7 +44,7 @@ static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - val = vdev->ops->get_host_features(kvm, vpci->dev); + val = virtio_dev_get_host_features(vdev, kvm, vpci->dev); ioport__write32(data, val); break; case VIRTIO_PCI_QUEUE_PFN: diff --git a/virtio/pci-modern.c b/virtio/pci-modern.c index c5b4bc50..2c5bf3f8 100644 --- a/virtio/pci-modern.c +++ b/virtio/pci-modern.c @@ -158,7 +158,7 @@ static bool virtio_pci__common_read(struct virtio_device *vdev, case VIRTIO_PCI_COMMON_DF: if (vpci->device_features_sel > 1) break; - features |= vdev->ops->get_host_features(vpci->kvm, vpci->dev); + features |= virtio_dev_get_host_features(vdev, vpci->kvm, vpci->dev); val = features >> (32 * vpci->device_features_sel); ioport__write32(data, val); break; From patchwork Fri Jan 27 11:39:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118595 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 B0BD1C54EAA for ; Fri, 27 Jan 2023 12:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6eTiE1SVJE7a8ZcMCQo8u94yv75nhaPkhku3t2BRhJQ=; b=UgfGp0neW6D6jf WlYOAiV8ylNukcBTrPTAbgzdhr8Qr1vjw2znpKFzFzHo2IwrBTcRQ27l66QtEMALy0JsBo0rL5WGm HMBRobUP2Jpv5BxUCW0fXMZN9ry2s0+spLOq7jsX/blrmc+utNIUezDMaidA7MwkrI7Xn2Hc9ENZd 4sQ4Z1osYbh+vDRoa1ZJVyOsdsAfWuzyd/raNU8ozyg4QbJXA04FuMRPuY0XMqqtDzWjS4EYhVtNV zlZ/lH0VfCDqMWcpw0vFBR0xsyXo81H5J2kfU8uM7VcjxtZAWfVMMZHf9iwSArF91qQx9uQ0DP6y4 tGnbfe9XZd9ZMj5vcxzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNdc-00ETBt-Qy; Fri, 27 Jan 2023 12:15:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6Q-00EDHz-OB for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:08 +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 D6C8F1684; Fri, 27 Jan 2023 03:41:47 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 561883F64C; Fri, 27 Jan 2023 03:41:03 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 27/31] virtio: Add arch specific hook for virtio host flags Date: Fri, 27 Jan 2023 11:39:28 +0000 Message-Id: <20230127113932.166089-28-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034106_932546_71BDBDEF X-CRM114-Status: UNSURE ( 9.64 ) X-CRM114-Notice: Please train this message. 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 Add callbacks for archs to provide virtio host flags. Signed-off-by: Suzuki K Poulose --- arm/aarch32/kvm.c | 5 +++++ arm/aarch64/kvm.c | 5 +++++ include/kvm/kvm.h | 2 ++ mips/kvm.c | 5 +++++ powerpc/kvm.c | 5 +++++ riscv/kvm.c | 5 +++++ virtio/core.c | 5 ++++- x86/kvm.c | 5 +++++ 8 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arm/aarch32/kvm.c b/arm/aarch32/kvm.c index 768a56bb..849c55d3 100644 --- a/arm/aarch32/kvm.c +++ b/arm/aarch32/kvm.c @@ -12,3 +12,8 @@ u64 kvm__arch_default_ram_address(void) { return ARM_MEMORY_AREA; } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 344c568b..a4664237 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -234,3 +234,8 @@ void kvm__arch_enable_mte(struct kvm *kvm) pr_debug("MTE capability enabled"); } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 3872dc65..a3624de4 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -203,6 +203,8 @@ int kvm__arch_free_firmware(struct kvm *kvm); bool kvm__arch_cpu_supports_vm(void); void kvm__arch_read_term(struct kvm *kvm); +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm); + #ifdef ARCH_HAS_CFG_RAM_ADDRESS static inline bool kvm__arch_has_cfg_ram_address(void) { diff --git a/mips/kvm.c b/mips/kvm.c index 0faa03a9..e23d5cf9 100644 --- a/mips/kvm.c +++ b/mips/kvm.c @@ -374,3 +374,8 @@ void ioport__map_irq(u8 *irq) void serial8250__inject_sysrq(struct kvm *kvm, char sysrq) { } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} diff --git a/powerpc/kvm.c b/powerpc/kvm.c index 7b0d0669..6b3ab93f 100644 --- a/powerpc/kvm.c +++ b/powerpc/kvm.c @@ -529,3 +529,8 @@ int kvm__arch_free_firmware(struct kvm *kvm) { return 0; } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} diff --git a/riscv/kvm.c b/riscv/kvm.c index 4d6f5cb5..884321ca 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -182,3 +182,8 @@ int kvm__arch_setup_firmware(struct kvm *kvm) { return 0; } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} diff --git a/virtio/core.c b/virtio/core.c index 50e7f86d..674f6fae 100644 --- a/virtio/core.c +++ b/virtio/core.c @@ -285,7 +285,10 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev) { - return vdev->ops->get_host_features(kvm, dev); + u64 features = kvm__arch_get_virtio_host_features(kvm); + + features |= vdev->ops->get_host_features(kvm, dev); + return features; } bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev, diff --git a/x86/kvm.c b/x86/kvm.c index 328fa750..961b5d3f 100644 --- a/x86/kvm.c +++ b/x86/kvm.c @@ -387,3 +387,8 @@ void kvm__arch_read_term(struct kvm *kvm) serial8250__update_consoles(kvm); virtio_console__inject_interrupt(kvm); } + +u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) +{ + return 0; +} From patchwork Fri Jan 27 11:39:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118596 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 9C8C5C54EAA for ; Fri, 27 Jan 2023 12:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RAtL6Zi8Rne+a1bz3YCULFA71hDpbwoVtdiECgVnJXU=; b=Zx0EqgHP4fisDw iL2VslF1OD8fqa1Jd+ZFSzkRhBnArQBRSSlFsMjUh9RozHOiM7UUoCgLe+nTupRV7myDc3PohBnGu Nc1IcOeyGEVoXZ9/39f5zZoR/ALoli4cjvYXHKvmHXlftMZWmqCt8vHfMHeY/JaBx2FYMQd8775Sf 9Lz0ReAvAvexw4LeRd8zkhiKb0IOlD7hdeKwc1cydYTFCh6y91qQSwChAgHim+E8W9riNmeUkHn65 ekdmHvdJq75pulWzRvS8kE3jW090MCQ+yrcRyQ0heEBvHxGUCE4sFHALM6ZCVtTFo02xYRW7s1H/9 1eVuAxTHZ652QfVlhxVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNe8-00ETPV-Mo; Fri, 27 Jan 2023 12:15:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6T-00EDJ9-Bp for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:10 +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 B8BAC165C; Fri, 27 Jan 2023 03:41:50 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 329813F64C; Fri, 27 Jan 2023 03:41:06 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 28/31] arm64: realm: Enforce virtio F_ACCESS_PLATFORM flag Date: Fri, 27 Jan 2023 11:39:29 +0000 Message-Id: <20230127113932.166089-29-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034109_587413_7DEA3A45 X-CRM114-Status: GOOD ( 11.04 ) 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 For realms, force the F_ACCESS_PLATFORM flag to ensure DMA-APIs are triggered for virtio in Linux Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index a4664237..1f3a0def 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -237,5 +238,10 @@ void kvm__arch_enable_mte(struct kvm *kvm) u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) { - return 0; + u64 features = 0; + + /* Enforce F_ACCESS_PLATFORM for Realms */ + if (kvm->cfg.arch.is_realm) + features |= (1ULL << VIRTIO_F_ACCESS_PLATFORM); + return features; } From patchwork Fri Jan 27 11:39:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118597 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 9CA2DC38142 for ; Fri, 27 Jan 2023 12:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cRvdqXvru0qeVHXHT+0mIuYB7keQjp9FsLj+KMFDQmE=; b=znEc4i/9IhTS8U JYaPxLcbnwLkDVVd9XoH5uOZVeBdFSSVgtRXtLbOh/XR6FJlkpC1sS8k9rSI2ZSe88pwZIjG6W7+L lTa1Wz6L2odCQG+moDPl2DPPSqcKutO60645rmYy1Ou3w/0+UGx8XsBRxidPZwhoUVAWtdv048j3J LCw0RYZRhpIMee6BczIWQnunoh7/9LYiKYMctZ0cYopd843oSGa7XWPI7E5m779ybOctcAUQsiMR4 zsuygne+FLSOOAE6t6Ew1SCfjU7dEIeJMZxN/ZR176Z0ApQ4nKIRZqtskJKXrcVctKREBvPw9kwMv 5xW09Ha4YnnZZBvn8sUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNeh-00ETgn-HW; Fri, 27 Jan 2023 12:16:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6W-00EDKj-BR for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:14 +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 AC9DC1688; Fri, 27 Jan 2023 03:41:53 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14CAB3F64C; Fri, 27 Jan 2023 03:41:08 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly Subject: [RFC kvmtool 29/31] mmio: add arch hook for an unhandled MMIO access Date: Fri, 27 Jan 2023 11:39:30 +0000 Message-Id: <20230127113932.166089-30-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034112_570675_2DD0E3AC X-CRM114-Status: UNSURE ( 9.46 ) X-CRM114-Notice: Please train this message. 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 Add a hook that allows an architecture to run some code on an unhandled MMIO access. Signed-off-by: Joey Gouly Signed-off-by: Suzuki K Poulose --- arm/kvm-cpu.c | 4 ++++ include/kvm/kvm-cpu.h | 2 ++ mips/kvm-cpu.c | 4 ++++ mmio.c | 3 +++ powerpc/kvm-cpu.c | 4 ++++ riscv/kvm-cpu.c | 4 ++++ x86/kvm-cpu.c | 4 ++++ 7 files changed, 25 insertions(+) diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 98bc5fdf..90a15ae9 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -152,3 +152,7 @@ bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu) void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu) { } + +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *vcpu) +{ +} diff --git a/include/kvm/kvm-cpu.h b/include/kvm/kvm-cpu.h index 0f16f8d6..d0c40598 100644 --- a/include/kvm/kvm-cpu.h +++ b/include/kvm/kvm-cpu.h @@ -29,4 +29,6 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu); void kvm_cpu__arch_nmi(struct kvm_cpu *cpu); void kvm_cpu__run_on_all_cpus(struct kvm *kvm, struct kvm_cpu_task *task); +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *cpu); + #endif /* KVM__KVM_CPU_H */ diff --git a/mips/kvm-cpu.c b/mips/kvm-cpu.c index 30a3de18..0ce88ac3 100644 --- a/mips/kvm-cpu.c +++ b/mips/kvm-cpu.c @@ -217,3 +217,7 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu) void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu) { } + +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *cpu) +{ +} diff --git a/mmio.c b/mmio.c index 5a114e99..7e31079b 100644 --- a/mmio.c +++ b/mmio.c @@ -206,6 +206,9 @@ bool kvm__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data, fprintf(stderr, "Warning: Ignoring MMIO %s at %016llx (length %u)\n", to_direction(is_write), (unsigned long long)phys_addr, len); + + kvm_cpu__arch_unhandled_mmio(vcpu); + goto out; } diff --git a/powerpc/kvm-cpu.c b/powerpc/kvm-cpu.c index 461e0a90..e0c20f9d 100644 --- a/powerpc/kvm-cpu.c +++ b/powerpc/kvm-cpu.c @@ -288,3 +288,7 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu) { /* Does nothing yet */ } + +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *cpu) +{ +} diff --git a/riscv/kvm-cpu.c b/riscv/kvm-cpu.c index f98bd7ae..8417e361 100644 --- a/riscv/kvm-cpu.c +++ b/riscv/kvm-cpu.c @@ -461,3 +461,7 @@ void kvm_cpu__show_registers(struct kvm_cpu *vcpu) kvm_cpu__show_csrs(vcpu); } + +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *cpu) +{ +} diff --git a/x86/kvm-cpu.c b/x86/kvm-cpu.c index b02ff65e..ac075ee4 100644 --- a/x86/kvm-cpu.c +++ b/x86/kvm-cpu.c @@ -444,3 +444,7 @@ void kvm_cpu__arch_nmi(struct kvm_cpu *cpu) ioctl(cpu->vcpu_fd, KVM_NMI); } + +void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *cpu) +{ +} From patchwork Fri Jan 27 11:39:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118598 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 5B46CC54EAA for ; Fri, 27 Jan 2023 12:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KRyGiae+wX736sLRHmRu0S1cQoKRu8ikc4nPpMq5vuE=; b=2F1xNYzZwY3VDa jl39ef9qHZUkdcOilFQ1PEbIlpPh1fb/Nc8+5a+g7cpMtr/IUdP8HMpeli3wyRhPnvEBG3M1ERpcT mrUF/5QipvMC7vR77Tr3j8rgcuSjf8t43m54bQFrpV0UI0H8keE71+NTq6hE1jAFACZzlkPsq3ES5 2oYU3plWmJFfnAJRGwjS39uM+D6GtUgPtvS4ltGZwXKrAZwX2aoGfAvBEyW4b5vv15WyuqMtSiok/ BC4xUymeNOKCgXtqG4yRksMtWW8FZHLMFXM9ENY+kdIlSnsAW3elOCAosZzK79URDRefHpRUukYSo KB+0uVKVdiLqWo29iSHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNfn-00EUBx-6B; Fri, 27 Jan 2023 12:17:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6Z-00EDMN-AM for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:16 +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 A914E1691; Fri, 27 Jan 2023 03:41:56 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 08A9B3F64C; Fri, 27 Jan 2023 03:41:11 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly Subject: [RFC kvmtool 30/31] arm64: realm: inject an abort on an unhandled MMIO access Date: Fri, 27 Jan 2023 11:39:31 +0000 Message-Id: <20230127113932.166089-31-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034115_456493_CC5274B2 X-CRM114-Status: UNSURE ( 8.69 ) X-CRM114-Notice: Please train this message. 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 For Realms, inject a synchronous external abort, instead of ignoring unknown MMIO accesses. Signed-off-by: Joey Gouly Signed-off-by: Suzuki K Poulose --- arm/kvm-cpu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 90a15ae9..c96d75eb 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -155,4 +155,13 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu) void kvm_cpu__arch_unhandled_mmio(struct kvm_cpu *vcpu) { + struct kvm_vcpu_events events = { }; + + if (!vcpu->kvm->cfg.arch.is_realm) + return; + + events.exception.ext_dabt_pending = 1; + + if (ioctl(vcpu->vcpu_fd, KVM_SET_VCPU_EVENTS, &events) < 0) + die_perror("KVM_SET_VCPU_EVENTS failed"); } From patchwork Fri Jan 27 11:39:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 13118602 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 C7EC5C38142 for ; Fri, 27 Jan 2023 12:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dxLRA1wPE+iD/yg+h1FwJiYcGZYORrWmO8Uhcvoqim8=; b=iBY57B4mq9hldo MU36BxL4w/vmcnhY6bRsjCRZwUTCxP15/RxF2T91MLBO6nqLuiYvYY8/R+B+Yv0LJvbFAXwWK5Ibv Ivcau/VQTbR/DUH5dPdXGCHpY/vXZfnh+fHyt2n87oU86xyCFAZ8fm4r42t+Jn2A6PiY/VR6HJc70 keyK6Awz1uzN+BjQCxhMYHdQe1YXcj9pwjg6AxgYJ1yjzGE290GeoJY6vJXSTWzP52Jcdpq9aHjvU owaKl2EUnNs17lccoxYhlKLfkv0GUzB9rcztZpMAzFQjbXf/c8yqP73L2DO2QG4FJwHRMTCITrKwE PNyC8sIZWpfQX1j5MAwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNgh-00EUZv-Nr; Fri, 27 Jan 2023 12:18:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6c-00EDNz-9x for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:19 +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 8AE0E169C; Fri, 27 Jan 2023 03:41:59 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 04DDB3F64C; Fri, 27 Jan 2023 03:41:14 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 31/31] arm64: Allow the user to create a realm Date: Fri, 27 Jan 2023 11:39:32 +0000 Message-Id: <20230127113932.166089-32-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034118_443611_46ACC454 X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. 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: Alexandru Elisei We have everything in place to create a realm, allow the user to do so. Signed-off-by: Alexandru Elisei Signed-off-by: Suzuki K Poulose --- arm/aarch64/kvm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c index 1f3a0def..422dbec2 100644 --- a/arm/aarch64/kvm.c +++ b/arm/aarch64/kvm.c @@ -104,8 +104,6 @@ static void validate_realm_cfg(struct kvm *kvm) if (strlen(kvm->cfg.arch.realm_pv) > KVM_CAP_ARM_RME_RPV_SIZE) die("Invalid size for Realm Personalization Value\n"); } - - die("Realms not supported"); } void kvm__arch_validate_cfg(struct kvm *kvm)