From patchwork Wed Apr 19 22:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217557 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 45907C77B7C for ; Wed, 19 Apr 2023 22:24: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=YCIMz2Gc7AUZNN4gRy1X8Ck5sXnv+LeX+06Frjt/tVM=; b=mPF2bgSY/aAncJ kBqLqUO5K432nYfcH6nWxB25JVhyuOXPYhzG9DnRQ33+QOaiLMluR8HWNrHF4ux1/rn0JXE7lba3+ HUxfAbYXlLG/rWjz98yZ3jRrO6nkMNKOc70HKYXyjn+BsBZXAI2preMQSfjjaWh0QdDctcnLfTZxP KEdM02AbevSV3ZLeyTkjYJl5QcxrsPjH1B/ljS0FfAoOrqv/3nohMqrD0DcbDcdl+UfATWXFbTRzb SV1mobZBiWcKT8P2AcWEnidE+KnvhPm3g1AmH0ogker7n6jXLgozbjS/XE5kELakI0UBiv5uKroXw akAW1UGyaZVYUNXTJB2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDf-006Ud4-0X; Wed, 19 Apr 2023 22:24:07 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDd-006UaK-0H for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:24:06 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-246bb512038so200194a91.1 for ; Wed, 19 Apr 2023 15:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943044; x=1684535044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LXsqDGUR1sIAzl083YrDdeF8Dcz5MG5TcoJ+FCFYQPE=; b=ohOEHO7BV/FHEqjDiY6pG/sbPPkvlHxUUXDxUV7dZqgZIIWVcpKe0qvs+coh7D9ZRh B9hkxCLFKh8o9nAC2rlRn7bMm1mBtWYtjnNK9pkEtJDD583cXnspj2Ze6kFtPx4sD05T M0i9ezLAErgLCl4r/YZAwl7ub1kBW72A2bCM2VN+GllxhNlhbw4174U5Fs0Rqs8lwuLx 6dFmv6DPhfk7Q0h+47Fu4cY06lgOcb8Yfc8WZoxCPJavUfQg727zdhXtl53U+ZG5ga3H Ua4k+o9Cp2yjV6jziSpH7zmCITKPG2JXN/AwelqUy5IqPzKZ18t594Y0qlAjZCJGwgwu OUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943044; x=1684535044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LXsqDGUR1sIAzl083YrDdeF8Dcz5MG5TcoJ+FCFYQPE=; b=LGlSmP8eZHQCrs7b9o9kIkupL89i5S76Tw9KbJbQNBP/1ok2nAqHq6e50Bhpg7z1sc Bz7YdXi0BjgJEVB57IBk78vU+5T8AH1WAFF/1K9ZS16fzqocdZTpeFF2pUkrKsllVeyz pbyQ9Xtji1ML78gjLARlz3HJNlyawTcHJ6aO2H0TqVoBuBiA1QuE5ec+f0U4wgFB6zoH bLlj7ZrZdRP3G7hT63GeXq7LYH8+wCHRYW5d/9jOciIZtzuHn9yx2XbaQ+/OCinrkNlk 5wyP/U7w0sEYpAW2D5D0bTGgUjdtV0LF5P1lsLj7lccp4I5FV9uulL0jUk60V+ftU/zX he5g== X-Gm-Message-State: AAQBX9dn2uxmPHGnKHCskMV2ucPeSFVt4VK8LUYAghg6lzSZPGtjJktL O0nGntKu6PqXNm5xVsAH5+ZBLw== X-Google-Smtp-Source: AKy350ZHJJEltFWMtiEqeoirE/coBcaQIIAAD+T2dcklEUVhjT2GbyU5FBvkRUpdkDap1R/DwivJLA== X-Received: by 2002:a17:90a:be01:b0:247:1e30:5880 with SMTP id a1-20020a17090abe0100b002471e305880mr3727645pjs.38.1681943044256; Wed, 19 Apr 2023 15:24:04 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:04 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 01/10] riscv: Add a CoVE VM type. Date: Wed, 19 Apr 2023 15:23:41 -0700 Message-Id: <20230419222350.3604274-2-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_152405_121969_83ED3ED6 X-CRM114-Status: GOOD ( 10.36 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The KVM needs to distinguish if an user wants to create a CoVE VM instead of a traditional VM. Define a RISC-V specific CoVE VM type that can be passed as a VM type. Signed-off-by: Atish Patra --- include/linux/kvm.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/kvm.h b/include/linux/kvm.h index ba4c4b0..000d2b9 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -911,6 +911,8 @@ struct kvm_ppc_resize_hpt { #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) + +#define KVM_VM_TYPE_RISCV_COVE (1UL << 9) /* * ioctls for /dev/kvm fds: */ From patchwork Wed Apr 19 22:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217559 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 696D1C77B73 for ; Wed, 19 Apr 2023 22:24: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=w0BZx3fEP3BAfbeNiUGLnc4C8B5RTfktBzxSozP9yb4=; b=ZZb+JZuHPqxaaK fAV6cltcl0ueNiH8Z/D/9NmD+Ls2hrox9BapySDzGCwNGEIIFgy51++0Mw1TJfpe1fmfGNALlAjek tKdkwSoof/urf5BBRV2L/6ZD7hFWkl0e4DI1ICIqTPf21EMvxh5jKFGXtMfmuBaJ6KrRL693RZSWU 2fdA2p1hG8a0wPFS4TW0CFbFi+vWuXoKb6PuVedd6NysWFP+0AfLhXxq3NvLJL5a+vg101/9tVwBY 7Xw/OMSy7ypskSAX9ShWxJO5FOb4Ji/wo5p+53gm3U3SR6VPNbYpN03NoRoZzCvgDmkXyloLCRd/B X+wuZNcPjVkTaA+dOgCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDk-006Ui7-0n; Wed, 19 Apr 2023 22:24:12 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDg-006UcW-0w for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:24:09 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-51efefe7814so276549a12.3 for ; Wed, 19 Apr 2023 15:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943046; x=1684535046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nDYPek2GW62ZjpMwmsxfE9d0xDPaKHdBMm+cEZKc8s8=; b=gbm655ZKGYsSplRJThxaUIliJsDtxxCNHAd8Jsh9rquTj5wgjudHgZwJA550iZsQk9 VB0SQu2x2QDE7zie14SgvIe7dnOfITMaMnMjD/onrUT0al1gT1sDadgULueeivhnEmTD JNLdLb2hMXSDd97f9GLtgcoOoiKtiFWFueifxdMTSbyKE0Z6Gv5tcQoRd/Nk8sLhR8hd DGNAlG+7Czxou3KoS1S39Pu0wydKlsp73goQ0cZbb90x0/1svTeMdjxcJ4JUnBS4z1ue xceJZmumlSVFCncTt6FuOgv+xYSVDvprfYgxAUggRJ/YOlKDghslSrOk6KKM64ujkV1m 0exg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943046; x=1684535046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nDYPek2GW62ZjpMwmsxfE9d0xDPaKHdBMm+cEZKc8s8=; b=WV1htk3JIH7rfc9e5iSiB6907oV5kOiWzRKKUIcHVtZbdSIbfcXS/PpCGOHA1YXFcY qXbVsLNuxqdYeO404O69Fyt2+wHOUFsPv6Iq+rdpsCaOMOwz0c7RuBo5nEoTwhUF8/6l M6SzEFMO2bE9TLtEAFVWQpsuSLld6vC4st/cO0WbXWa/9ZXx0FoAUcRxK7bA02m+u/Ha cHJsZsOCndR2D8ljuf1naqNOed7+Sla8oxgPwuhAD4ID/UlKRK3VEGw2xLpZxwTrKigW l+pZEB7JEt03oycIIV0OIgyBWavl4TY0wJRCRG1p21wkqO/VaWYHPIe7dFc5keIn4lVg BBMw== X-Gm-Message-State: AAQBX9cPswExy/ohQ2C8THWBH403kf/UlAFqUuChadpjsMrsoRxyP2Ol sghN32eaA/1zirNSQYXoF6IV4g== X-Google-Smtp-Source: AKy350ZvU/B8LPyorDIQytWlfNOBgumMg9x+NGoZu6TjngTCY2lrTTdfxOrkdp5JkE0zcFgeJL83hQ== X-Received: by 2002:a17:903:120e:b0:1a6:c12d:9020 with SMTP id l14-20020a170903120e00b001a6c12d9020mr7842484plh.24.1681943046020; Wed, 19 Apr 2023 15:24:06 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:05 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 02/10] riscv: Define a command line option for CoVE VM Date: Wed, 19 Apr 2023 15:23:42 -0700 Message-Id: <20230419222350.3604274-3-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_152408_336999_1802065E X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The user should be able configure the VMM to instantiate a CoVE VM via a command line. Add the new option cove-vm. Signed-off-by: Atish Patra --- riscv/include/kvm/kvm-config-arch.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h index aed4fbf..01276ea 100644 --- a/riscv/include/kvm/kvm-config-arch.h +++ b/riscv/include/kvm/kvm-config-arch.h @@ -10,6 +10,7 @@ struct kvm_config_arch { u64 custom_mimpid; bool ext_disabled[KVM_RISCV_ISA_EXT_MAX]; bool sbi_ext_disabled[KVM_RISCV_SBI_EXT_MAX]; + bool cove_vm; }; #define OPT_ARCH_RUN(pfx, cfg) \ @@ -66,6 +67,7 @@ struct kvm_config_arch { "Disable SBI Experimental Extensions"), \ OPT_BOOLEAN('\0', "disable-sbi-vendor", \ &(cfg)->sbi_ext_disabled[KVM_RISCV_SBI_EXT_VENDOR], \ - "Disable SBI Vendor Extensions"), + "Disable SBI Vendor Extensions"), \ + OPT_BOOLEAN('\0', "cove-vm", &(cfg)->cove_vm, "CoVE VM"), #endif /* KVM__KVM_CONFIG_ARCH_H */ From patchwork Wed Apr 19 22:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217560 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 6EA93C77B75 for ; Wed, 19 Apr 2023 22:24:20 +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=DlliyQO6ed8lKVKE+vb49pVw80HWT9nCDvBE/4C4W+4=; b=uaqJHHuZEIvJ9A 7CBT55U7oFdcODKHq7HrEHh72TcU9mVNwXAV2qhjV3QDhX9+bVRRaEjlSxwR8pgWOunozDsJ77ivP TGyPdk3t5XJcYh9qHnXeGCAScrTkhfRKxTIDKAHlQxXuZWpYc+nyTTsEKKJoiqqBOoUribyckf9AR 8U1hAdrfsx6T+NntjW5zmSKS1NXM0x3LG9J1N5q7uHW037uTREMPzw61w0d8MV8qgg2Fow/3sxBld wKzjBeqkbO3mwwRAdWHFZvK0VmobkZtoMvR2VlIwVKc6U9OrNHR3MjHY9jo1IGJ59xLsKGnLIxl1G tfjLoox0IMRPPtlbzZXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDk-006Ujg-2j; Wed, 19 Apr 2023 22:24:12 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDg-006Ue0-2H for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:24:10 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1a52667955dso5477365ad.1 for ; Wed, 19 Apr 2023 15:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943048; x=1684535048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sx5yCGWct6pM6GpC/mvdByE459bnHS7kFRJEEmvmIAE=; b=3p9iTgdU1fM6SCFnmbdU2SRrkZIz70XAXwuZckkQOMwQBsxli9xyQOj3eelNgilUbh Ys8/7Ew5TPJfNpxVGDr0CtIGeK0FA4rEB+OIcbXgq5wyTLnVYPvSZ8aMalLarGl9SYQB 5RACL91+xtTKghPY756sehNtiuCKsCnVWuoe+lw1F03ENQxtWOfB9WS65O7GV37PILFO Dk35L2JW1UKZe1fvGcD1U01nAz5TPWWbGAHGpwD1ZT3uAJFTUyTj5jlwZGRm00f0H14O tl+5fi2Hb+F0OmZuIVTWcPUeShVBuC5Hht10Q7j0AV8S9TF+U8wIpbjtIc2XL8zQkszI EVlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943048; x=1684535048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sx5yCGWct6pM6GpC/mvdByE459bnHS7kFRJEEmvmIAE=; b=OswX5YYCg/ptp8BP8w0rkXyadV8odsxJQyqhn3gMsqk4RNs3VYJtl3/irFU0send9a QGBrSX4p/ywRXXovbIh44iRpHhAJ/Et7MbKPiJXCIA/3vZSGRbA7rh6cACLEpPCaXtIg IJaX9MDFxGIV80zHVGUk1DH1l0UipS/BKxkafVhhwVUUD4QarR40zhFichkA/Yh0+Rgy 2klroadVE6iFhf+HSKBuxKOEUUlSDbwetmWpVqQo4K50qMi4zB8Ezt6wTkEDkO0DoFxj EGEpO4kYf1ST7vLitwF1RvVWYAEqqnnIdjWIYXfEOotjoZCvmJ6yTzEEg0j63CxCPizh nKuQ== X-Gm-Message-State: AAQBX9fG+DMDO2ZLf1+4oqyekky67m1ocJqRrbeXJoVX5/tUX8TAhRjc t8uHlz9kOTnoG0IxklnR2G/eKg== X-Google-Smtp-Source: AKy350YPzGRajmyQ2O5tL/h5sOqIMWA3WFpT3qCLbVNDZ6itlq+/cjeCHlrQkCoL9IBGQLSaGxxwuA== X-Received: by 2002:a17:903:2905:b0:19a:b869:f2f8 with SMTP id lh5-20020a170903290500b0019ab869f2f8mr5951568plb.21.1681943047880; Wed, 19 Apr 2023 15:24:07 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:07 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 03/10] riscv: Define a measure region IOCTL Date: Wed, 19 Apr 2023 15:23:43 -0700 Message-Id: <20230419222350.3604274-4-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_152408_747975_9431D2F4 X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org CoVE VM images needs to be measured by the TSM. The VMM updates the host about these images via a new IOCTL. The host makes appropriate ecalls for TSM to perform the measurement. Signed-off-by: Atish Patra --- include/linux/kvm.h | 2 ++ riscv/include/asm/kvm.h | 6 ++++++ riscv/include/kvm/kvm-arch.h | 2 ++ riscv/kvm.c | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 000d2b9..d4969a0 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -1547,6 +1547,8 @@ struct kvm_s390_ucas_mapping { #define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3) #define KVM_ARM_MTE_COPY_TAGS _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags) +#define KVM_RISCV_COVE_MEASURE_REGION _IOR(KVMIO, 0xb5, struct kvm_riscv_cove_measure_region) + /* ioctl for vm fd */ #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h index 1dce9a4..2bacc38 100644 --- a/riscv/include/asm/kvm.h +++ b/riscv/include/asm/kvm.h @@ -98,6 +98,12 @@ struct kvm_riscv_timer { __u64 state; }; +struct kvm_riscv_cove_measure_region { + unsigned long user_addr; + unsigned long gpa; + unsigned long size; +}; + /* * ISA extension IDs specific to KVM. This is not the same as the host ISA * extension IDs as that is internal to the host and should not be exposed diff --git a/riscv/include/kvm/kvm-arch.h b/riscv/include/kvm/kvm-arch.h index 9f2159f..08ac54a 100644 --- a/riscv/include/kvm/kvm-arch.h +++ b/riscv/include/kvm/kvm-arch.h @@ -120,4 +120,6 @@ void riscv__generate_irq_prop(void *fdt, u8 irq, enum irq_type irq_type); void riscv__irqchip_create(struct kvm *kvm); +void kvm_cove_measure_region(struct kvm *kvm, unsigned long uaddr, + unsigned long gpa, unsigned long rsize); #endif /* KVM__KVM_ARCH_H */ diff --git a/riscv/kvm.c b/riscv/kvm.c index a9ade1f..99b253e 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -13,6 +13,27 @@ struct kvm_ext kvm_req_ext[] = { { 0, 0 }, }; +void kvm_cove_measure_region(struct kvm *kvm, unsigned long uaddr, + unsigned long gpa, unsigned long rsize) +{ + int ret; + + if (!kvm->cfg.arch.cove_vm) + return; + + struct kvm_riscv_cove_measure_region mr = { + .user_addr = uaddr, + .gpa = gpa, + .size = rsize, + }; + + ret = ioctl(kvm->vm_fd, KVM_RISCV_COVE_MEASURE_REGION, &mr); + if (ret < 0) { + ret = -errno; + die("Setting measure region failed for CoVE VM\n"); + } +} + u64 kvm__arch_default_ram_address(void) { return RISCV_RAM; From patchwork Wed Apr 19 22:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217681 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 0AAAFC7EE20 for ; Wed, 19 Apr 2023 23:31:03 +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=LRfTCshYF1QnxYh8pwVT712wM1N7DvOuCmFBsnKWh1k=; b=sW9E9PKV65pplM DvEb/6AVnDExlEC9bQYom3O3pf9BjZL+4PGrjmH3ws4Uy89nPkb5zpH+wlbGmKsx0I+mc3rM8Pm3c aNjGIYlP1Oy5A6fMtjplYgAZ6H9rWgNmxld/uarIDe9wAoN3P4YSDeEo1ga/Inl7r9fUHRoW3zLaX h1x+QKkJvgBjK2L+gv+n5qzR983XYFQE7IwMH7xzCc5uVT6X5IcvmPqVaBJqR92lStzx2DauVIL4p BBBsuMxqlaEs4idJh9PqYXQp5Mo3j2AxJcBY7kAzl7V61u2hvqNZ7xJ16PNNDY1MZCyk15kH0DaxW M0dCaihC5bdN4UhnVIbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppHGG-006ejN-1x; Wed, 19 Apr 2023 23:30:52 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDi-006Ufw-2C for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:24:12 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-63b64a32fd2so482785b3a.2 for ; Wed, 19 Apr 2023 15:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943050; x=1684535050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DqxJzuQg4YHoKMLWmjQ5z9IqDd25T8M3gtHVASWlMsA=; b=CdFLGUbJVpNnlbN6H0RysN3QwK8Q22dGILzUyKn1eed3BCAW6+MEMsBRDq2/F3MfEN 8F/42PROs9h1k2Q7VrH4EPO6wp5xxtsziRkW162nuTlbeuaKnWv/CAiPccnTCWWIYPQk oJLjTPMoTHn4eG+8ibMKGv7GyStv5zxs81LmeyyaemazO9r8w0RuVqYmdLVQ/35zsHF4 Epuj0d4WbFCdWHPxERyyC/wFKBbzXDxx2K1QzNu3em+Y/D7eT+3ZwnJpBriORGuqa1bG mG11CSzZymcMK9J81Dm4lnZ1qJfC6fNYaISOIHAhx4fE/+Qh3aPrGDxSYFrQFc63TMHE cEug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943050; x=1684535050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DqxJzuQg4YHoKMLWmjQ5z9IqDd25T8M3gtHVASWlMsA=; b=CKAkC+v35jT9NJG/EuxU0yWcc46wUpTHOV8sOXX19SL1aX3PHTRbeRR5W2oFNWEZpn 6OzbpBcqt4XAsFYmOymx9rujQeUxS/MmrwWwddKrZjpPdTCBWVCsIhVh6+qNtybXOBOg IU4Mo6/OZYiQQvhgt0hntlvhBcCenWXyD4EX/3OnE5vzCa4+l0lYVwiHSHxMe0RSOC1p AR23WmLg7qwssULX7XapAc2u+ftgk52W0lgk6+XVAMLSbAxkM9v3XYHz/kEJL2RR1Tkd lvw7vQE2/UbOJdbuubnWKphxL4QQ1xBGJslvcp+KcF2qBEM99BkNirXmpFF4xdbrHRUg /a6A== X-Gm-Message-State: AAQBX9f3xmJ741RJu376InbaAB1SoUpg//KI13LiQ8bxEzQThJ+GpkNi 8xccIGsai3iXDOP0rxORhH+1RQ== X-Google-Smtp-Source: AKy350Y1oJzpFyEWrofUoiBPrqInLwUP0IdbCjWNBlR0+a+fpEuwpi5wATQkdQOE2P7s+B2OF642XA== X-Received: by 2002:a17:902:db08:b0:1a6:8405:f709 with SMTP id m8-20020a170902db0800b001a68405f709mr8145477plx.20.1681943049834; Wed, 19 Apr 2023 15:24:09 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:09 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 04/10] riscv: Invoke measure region for VM images Date: Wed, 19 Apr 2023 15:23:44 -0700 Message-Id: <20230419222350.3604274-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_152410_722072_558F8F05 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The DT, initrd and kernel images needs to be measured before a CoVE VM can be started to validate its authenticity. Hookup the measure region API for these three components. Signed-off-by: Atish Patra --- riscv/fdt.c | 3 +++ riscv/kvm.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/riscv/fdt.c b/riscv/fdt.c index 61a28bb..07ec336 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -254,6 +254,9 @@ static int setup_fdt(struct kvm *kvm) if (kvm->cfg.arch.dump_dtb_filename) dump_fdt(kvm->cfg.arch.dump_dtb_filename, fdt_dest); + + kvm_cove_measure_region(kvm, (unsigned long)fdt_dest, + kvm->arch.dtb_guest_start, FDT_MAX_SIZE); return 0; } late_init(setup_fdt); diff --git a/riscv/kvm.c b/riscv/kvm.c index 99b253e..d59e8bc 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -148,6 +148,8 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, pr_debug("Loaded kernel to 0x%llx (%zd bytes)", kvm->arch.kern_guest_start, file_size); + kvm_cove_measure_region(kvm, (unsigned long)pos, kvm->arch.kern_guest_start, + file_size); /* Place FDT just after kernel at FDT_ALIGN address */ pos = kernel_end + FDT_ALIGN; guest_addr = ALIGN(host_to_guest_flat(kvm, pos), FDT_ALIGN); @@ -188,6 +190,8 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, pr_debug("Loaded initrd to 0x%llx (%llu bytes)", kvm->arch.initrd_guest_start, kvm->arch.initrd_size); + kvm_cove_measure_region(kvm, (unsigned long)pos, initrd_start, + file_size); } else { kvm->arch.initrd_size = 0; } From patchwork Wed Apr 19 22:23:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217664 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 373BDC6FD18 for ; Wed, 19 Apr 2023 23:11: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=R1gzQU5rxAKlRJDCOvql9fkzWRlB45PsE9AVwxOd6Lw=; b=S2DNx4A3Nb5c/2 tck7coU8xmvn1prPckmWkV8Q1acy3rES0Sv9U2qIUX6OfYiXqpXqNFylcMTmgP4CClQz5YXPa6uDX gD84HfjRwu37aB5waoUlTngmSC/uR0x8J8HJVmkIbQNE1V/hUx8XByE8FIXY/p5FvDZeUp0tem0v0 9G6EoKfQYH87w4V9PVD4WaPSXt7vm0fvAk2RXiYja0qQ+P7nn+7wyQZpW+QOYD33Ev2P0lRw8W0uJ SoX4pldhV0oFiXbRxGhjwPZ5Nc9tIJtwhZyKsbGKkiMBshACqOrz3Z/kUZe8WymtdYdJNfnpcMr8Z pjd/rCDLWhRo9wLwGqIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGxo-006cbP-3B; Wed, 19 Apr 2023 23:11:48 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGxo-006cbC-03 for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 23:11:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=E81F/sZHqFlmC4PTTDxmyvFtDAnkdcxCBJVjUmPx/Qw=; b=dg2TufElZVDJDZRFhwcm+mvjE3 ZjubXSt0F1dOLINhEW2aLAULeeiOA5G3sYZ9qF31AFrKf9j0C8h8uOb5B0ElRZaUwFJWkEYtJ/iE8 L8wCwBH2//E3mk3Px3beeomtnIIJhX0a75w6v8CPQI3oevNlFBI+LA0vBW95JfQ/kG+SOilefCyB8 3F8NwWdsk0yBAvbADh2/QT6jBb2yELnuEpWYmn17/6LeFHM8Qq7evmHsvCq2jLOA98ier8FKSBg+m bP/ZwirBUijI/mhOhzPCBT6aP+wORUl6zuu6MudxJD6SaHA6/iYPSU5T2b5sI0YdeE2AIgE0J3tod ZhznK0xQ==; Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDn-0021gF-2u for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:26:21 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1a6f0d8cdfeso4530635ad.2 for ; Wed, 19 Apr 2023 15:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943052; x=1684535052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E81F/sZHqFlmC4PTTDxmyvFtDAnkdcxCBJVjUmPx/Qw=; b=h8qvhmk4lDaY4kQIaAqeKrnT156suhglOdhOFhlubu1kF8monJSVNUgUE+j1dG31u3 2u4SpVYqZ4tfegebKpsL38KKycJWXvEDDTgK8UNr6JRmWeQLZM10VY51+CKxQiNgddvl jVlFZj35wrKDUORGT0J+qOCCKpjlGHzbKe/sGfoeSgQinTk47q9jptfvuPOOM2rG+CYr zwGu3oFCrdRFjF7E7+wb2JbG1bH3s5tlAZXNHsT/M1j9N2DMFEV+pbXVFPMwgsNs8Fq+ +9F3bZPSaGt+4fI+77DT77iqb04ZT/uOhlexxfDhgZPl/024tDlCe5TFxeig37XFSsp8 WtKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943052; x=1684535052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E81F/sZHqFlmC4PTTDxmyvFtDAnkdcxCBJVjUmPx/Qw=; b=h7aM4T6RQNZT9+/JxnciPNoXOLA5aMiHwDuqcPIlPjwjTxNBU92drWRzI53S5QuSYf 9YaaUUJ7McfWvdkG9PxN39xw6vShTHrDUUm0qWDuhoNpehDAA20YdCH0INCZFZhrEAEM vSOvjj0OdNrGi3MGGzOBZiqVvy4lF+7v3yUGEG2QYjDMPUtq5s5iHrRmI9LhgYPXyhNj 1eLDqjntFtEmMVo8Bn/jqyF74mN0x0UqtMAG/ehKNh4EnPsJGqghjYTS4P3XZfgb1rr6 +wJsz6Pb1jxUVXk5w+4TpybZFb91Bz5mRmcoWcB8407WOAb5bv90dAohPBT3YcvMjDqd IHhA== X-Gm-Message-State: AAQBX9fhkyWL9RaYaDwJf7wkF3xaP1upusUjyWa4nr+iPM07LnypxvJo 6BM5lVF0wTNeeQfwgJjB4wdXLg== X-Google-Smtp-Source: AKy350ZDizFV7lhpli0WrCYYrT6iDsFp55kYpsDPb3wO0+TsDTvsM5wAJ/jQ030A1Tz0V9swMbp+9w== X-Received: by 2002:a17:902:da8a:b0:1a6:97fd:29e7 with SMTP id j10-20020a170902da8a00b001a697fd29e7mr8449012plx.27.1681943051998; Wed, 19 Apr 2023 15:24:11 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:11 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 05/10] riscv: Do not create APLIC for TVMs Date: Wed, 19 Apr 2023 15:23:45 -0700 Message-Id: <20230419222350.3604274-6-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_232618_942331_C99F6C34 X-CRM114-Status: GOOD ( 12.20 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The CoVE VMs do not support wired interrupts. Thus no need of APLIC at this point. Signed-off-by: Atish Patra --- riscv/aia.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/riscv/aia.c b/riscv/aia.c index 8c85b3f..a3b8618 100644 --- a/riscv/aia.c +++ b/riscv/aia.c @@ -143,6 +143,11 @@ static int aia__init(struct kvm *kvm) .attr = KVM_DEV_RISCV_AIA_CTRL_INIT, }; + + /* CoVE VM only supports hardware with physical guest interrupt file */ + if (kvm->cfg.arch.cove_vm) + aia_mode = KVM_DEV_RISCV_AIA_MODE_HWACCEL; + /* Setup global device attribute variables */ aia_mode_attr.addr = (u64)(unsigned long)&aia_mode; aia_nr_ids_attr.addr = (u64)(unsigned long)&aia_nr_ids; @@ -160,10 +165,7 @@ static int aia__init(struct kvm *kvm) ret = ioctl(aia_fd, KVM_GET_DEVICE_ATTR, &aia_nr_ids_attr); if (ret) return ret; - aia_nr_sources = irq__get_nr_allocated_lines(); - ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_nr_sources_attr); - if (ret) - return ret; + aia_hart_bits = fls_long(kvm->nrcpus); ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_hart_bits_attr); if (ret) @@ -172,12 +174,21 @@ static int aia__init(struct kvm *kvm) /* Save number of HARTs for FDT generation */ aia_nr_harts = kvm->nrcpus; - /* Set AIA device addresses */ - aia_addr = AIA_APLIC_ADDR(aia_nr_harts); - aia_addr_attr.attr = KVM_DEV_RISCV_AIA_ADDR_APLIC; - ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_addr_attr); - if (ret) - return ret; + /* CoVE VMs do not support APLIC yet */ + if (!kvm->cfg.arch.cove_vm) { + aia_nr_sources = irq__get_nr_allocated_lines(); + ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_nr_sources_attr); + if (ret) + return ret; + + /* Set AIA device addresses */ + aia_addr = AIA_APLIC_ADDR(aia_nr_harts); + aia_addr_attr.attr = KVM_DEV_RISCV_AIA_ADDR_APLIC; + ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_addr_attr); + if (ret) + return ret; + } + for (i = 0; i < kvm->nrcpus; i++) { aia_addr = AIA_IMSIC_ADDR(i); aia_addr_attr.attr = KVM_DEV_RISCV_AIA_ADDR_IMSIC(i); From patchwork Wed Apr 19 22:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217662 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 06B7FC6FD18 for ; Wed, 19 Apr 2023 23:09:13 +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=DvPhld+Fiex6puhD8+XIYWfploKcFAI6sOMcot1tEI8=; b=XFHF3YINB8iEgv TaotIsXAQ8En8I9iQiHDHQZj406y7TRkTZtHEFZpPjYX9H+c9GicoDvREIRxWnyOWXCcclazzxDTN qygnb9T7zWsWzjQxv+AIHzse8WwE6l/A5QqmnHlWz+3tlW5x1mPTKYXDrYyDUXHur6kOi8TTrXHbN BV+Ui5v0O7Ai1XumcPJrCy7UAJYSXgNhHyjxPz/CA2GL2Uft1+dH65/goEcLlfrYX+btbu+LKHATS nTPLmqjuJ+zv9+ki+sDHz3X93dT4+sjDOxBmPvS7t9ZsKYlwY+WDs2n1FMVK5na04e2dqtn00nODS d6p2038atVtvStPmfgIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGvE-006cFq-0Q; Wed, 19 Apr 2023 23:09:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGvC-006cFN-0c for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 23:09:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=2k6fZhtBjuovD0xJN9/3Mss7sJpSj6M+Lhg1puIM9yQ=; b=V7gtSVrXJu90A9P8V7RCq2+Z8F dWHkY4rQomX03yj0axokrdoLXhj0+Xurzf70oim+s774CDw8x+jlzPg+Xzf3pF/pl/lw98Nt+JE8n Yf4AN7mQ6ARzS7+HUIzBntJk/mMuD9rgzPib13f+2Q714bLcwD4phox0TAQSs+Y/hFE8oFp8OeugD Z8zQ8RPDXHFX1atYEaJdnCz+jRkHNuyxIiAAS+Ndt6zf1i71BHX96mFSf6dRzasV9OG/cRTGJsl38 0uJKCNU6ojEOydlD2YuRokKGFqJSSJjkaaYb6/GJLce3gp0Cke+lMhK0Sp7UhGPqasR+EPy2Who15 VwS2hc6g==; Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDo-0021gI-0T for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:26:24 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a5197f00e9so4695535ad.1 for ; Wed, 19 Apr 2023 15:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943053; x=1684535053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2k6fZhtBjuovD0xJN9/3Mss7sJpSj6M+Lhg1puIM9yQ=; b=frHFpOgJMj3IyT+0l6lF4ggQqLWSqJ+R5Lwl83JFjnZ1FgOj+RCeflj5OiteP2veXj hs8UabqlFhDeAfeVOqN8nsOlJjF/2yPcJvsYdreBOn4W0VsT07xnNPxxC9wRqCbEDrEI ZWpU6jo5/ivGxGl/5WlSrPuw4s+yWAlTdUEKKQGRxh6JkIhcKHr1ykdZxEako+r8BVLI Iia+UAGrprs58WkfVvjD7u2w/7WcLDjo2lLLRaRlMw3OivWlNDMPp50fyu9RdhML7Hv4 wHYTWA+nkcv0sFjdO1RQEsLbEgouvwKngVct5OCtGdc8SgVKzfHhIkTKi03d/OSMpN46 dypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943053; x=1684535053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2k6fZhtBjuovD0xJN9/3Mss7sJpSj6M+Lhg1puIM9yQ=; b=VugUWO0try83afKGQa31e6FBI6zlp/tk5QqDq8/6nVe20TeeXGWx/DJhEzCh9sE1cO Kvn9BPXN74+BS5zhqb0TlnHs8EJdnQkC+xT42ZqFt3mME6arN9b76ySeCoKP46O1GAI3 XnRjPBfEa2Iirml9+UqU50VXARhf3eeVp3EMfcr+HdJ0hT0eqKO4kuIMXKWoz2lBPqS4 ALjnEk4mRf60IwMl4CLwpqiM5xwhZtXd0Pps5JyTbFoSRCFMm5ku4ypGt4WA/703fFJ8 41aIvFR1R05Rtd0rp8Tp/ZgDozBh11WKhF3F5+0TS10K9q8A1P64JZMMEn2dXHmelWyd G3Bg== X-Gm-Message-State: AAQBX9evzSrC/TjP3PPFgE95leZcrcjiI6sgIn36+1kiJktMaSAB2o78 Epxz1jvrmxduF8+3TKG4OaMf2A== X-Google-Smtp-Source: AKy350a+wtlv0SH4nHUTs3X+REynERjZtWfA6CRUt3D8Ejpa/aSb6HljJIxaa3PlyPoDKWKx8hTZ+g== X-Received: by 2002:a17:903:8c6:b0:1a0:42d4:e38a with SMTP id lk6-20020a17090308c600b001a042d4e38amr7048884plb.11.1681943053760; Wed, 19 Apr 2023 15:24:13 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:13 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 06/10] riscv: Change initrd alignment to a page size Date: Wed, 19 Apr 2023 15:23:46 -0700 Message-Id: <20230419222350.3604274-7-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_232621_192342_A534424D X-CRM114-Status: GOOD ( 11.72 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, the initrd image is aligned to 8. This is problematic for CoVE where the image is expected to be aligned at page granularity level. Thus, align it to 4k. This can be done only if user requested a TVM. However, initrd usually much bigger (in MBs at least). Thus, aligning to a page for everything should not matter much. Signed-off-by: Atish Patra --- riscv/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/kvm.c b/riscv/kvm.c index d59e8bc..5f9b0d5 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -113,7 +113,7 @@ void kvm__arch_init(struct kvm *kvm) } #define FDT_ALIGN SZ_4M -#define INITRD_ALIGN 8 +#define INITRD_ALIGN SZ_4K bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline) { From patchwork Wed Apr 19 22:23:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217561 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 56264C6FD18 for ; Wed, 19 Apr 2023 22:24:25 +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=n2qQpppVZbzgl8aORqJ/H6fzIep2agBnpn0Qc8t+MjI=; b=SAaRoW6i35bNPV HRwUnkL5WiiJpNTJfxHGc6UxSMEV2XXnXdjzno7l5qAz0ni5/gOULzliNg3ff+hjnZazpzZ+LkGte CeWSdG5xo53lKamtEh2YcLmIb2Br7gsxJ+nLX13LmsAz629OiGHwp4LeRZ0iVoqWRV6RGHyoBKvA9 3VNHV/bSy97hnKInkWL11wajKBc5L/A6GSX57jQH8PLvAq0Kr6RWDUGvokq6PTDSzjWCKQ80RHKy6 CC9yN1DkfK9COGRKyRR3xoXDpPSQLknLt0n6GWzZIBmD4k87p48u3znEaNUcv80EBF6nQmz/Gx9l/ 4aFAnP+Xmdnor9n0TiXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDq-006Up4-3C; Wed, 19 Apr 2023 22:24:18 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDn-006Ue0-2d for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:24:17 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1a52667955dso5478005ad.1 for ; Wed, 19 Apr 2023 15:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943055; x=1684535055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZTLerH+RJ52lhodOQfma/DJulVaHZ1rN37E2HPQ1gqk=; b=a1bnzxGWwIOEAkq+19MIVfBP/ZCFCZqLmC1UeQSHZvEerwM1InrDlC+CNQjLasRYNY TG6B+BEbccXViq3GxUGM1S1bKt08GMbNh8cu2/7uvz8TADG5izCLZidY7kyXryOk8Cc+ amepc4YX9EhmwedHzdpQaI6iQRwH2jqt2DPucE98CEAfI6Pi8SQBLcJ1U0kFZji/jcS3 poVKHT9OeJbpVpJ3SjBehUYSR58tbT8ZMpTvtdSUCQHzPMMVlmcC1HTTyDhFywITeMq2 sEJhC6uIWIrcV3571Eqlwgn/Fm+q+fD6bbuTOkEai1g6rHX8oYaeAhJEcO5b4iPV/t6d oGlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943055; x=1684535055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZTLerH+RJ52lhodOQfma/DJulVaHZ1rN37E2HPQ1gqk=; b=cFqPj8FjY77+uYU+dKkM+cR39YjAhAUQ8ckXtf8TdTX6AZQ4bWC0+4j/RutquthpKM AUhwtH0J3fRSN71yeg8rlCSWU9lwRzUXzTp8Lxv0OrlEvnVX4P5cvH+7kpZVvrkL9jLf SR8c1Z9hmR8IY0eJB5Pc3AoMi8zJXQq/Virpp+C/1foCFtwRrierxLSXmk3rDAiMwQ0i CbtSSsbpd4E13WzGMdZmlp359lgMIWdu42izcP+kgLR9hTiv/eesuOWvD/3amRXWg737 OQMhauF4kCizfrINcH4rK9uoPi+t/Ht2/1aNgDYgK22YiDhDQJD+x5N+grB+415rl3aj VNIQ== X-Gm-Message-State: AAQBX9fqZ9/dZtAGzJTAsbWtsEJX6g2MgIaQG8WBFZ6jQj+okoQwioVV UZRwplWBKwNExQ87Ssj+Jmy2RQ== X-Google-Smtp-Source: AKy350biCI2sFr3cWCmld5tDykr7Z5GZPcCxF2zAi1qUg8p1jfhx7EqRslonbApZT3U9aoxz+Y7avQ== X-Received: by 2002:a17:902:e5c7:b0:1a8:1436:c892 with SMTP id u7-20020a170902e5c700b001a81436c892mr5044406plf.14.1681943055547; Wed, 19 Apr 2023 15:24:15 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:15 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 07/10] riscv: Define riscv specific vm_type function Date: Wed, 19 Apr 2023 15:23:47 -0700 Message-Id: <20230419222350.3604274-8-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_152415_867424_F89D208A X-CRM114-Status: GOOD ( 10.84 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V supports CoVE VMs now. It needs to setup correct VM type if the user requests it. Signed-off-by: Atish Patra --- riscv/kvm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/riscv/kvm.c b/riscv/kvm.c index 5f9b0d5..e728790 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -39,6 +39,18 @@ u64 kvm__arch_default_ram_address(void) return RISCV_RAM; } +int kvm__get_vm_type(struct kvm *kvm) +{ + if (kvm->cfg.arch.cove_vm) { + if (__riscv_xlen == 64) + return KVM_VM_TYPE_RISCV_COVE; + else + die("CoVE VM is not supported in RV32\n"); + } else { + return KVM_VM_TYPE; + } +} + void kvm__arch_validate_cfg(struct kvm *kvm) { } From patchwork Wed Apr 19 22:23:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217660 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 76150C6FD18 for ; Wed, 19 Apr 2023 23:05: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=ZklIoBE+g1DOzmpDd4VP+5VmBEsfbMY7o8lPh7gYoUU=; b=GpVJjAi/KrCh+k jBMvVTC2ZXr4EOmqmoPKs2L5QBz/LAgHfRF9aZOsKX1VpbIRYIt5fBpeoyNMP4qImvjp13/GoDCD2 6z6lg4/cEzwb3iPQpTCRCYU6yhUilqjfoXpNGZztDHuyayjdXzOvETVrdwbF3kSf1QadNU07BtIFP 9++n3OYbBKzjJsQt2N+6OGI/dgXAMTIK1WvvuEW8Vsn7hGn0Z+dc/H3g7zIj8tY+z7Sy8Jkyi+clw PDEIvG7ABydqFRu/AwFSLVmpT+FG49YkkAO7RxHCZHpr4lhYTw/K26a2EbX/n6E8y6Fg5KZEVw9Ur h7ls1AqDMx7M+XywSlQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGrh-006bp2-1C; Wed, 19 Apr 2023 23:05:29 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGrg-006boS-0P for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 23:05:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=dIdaC7GG/0BZjgqx7ZDjq1teF0 TnAvA8zD57TnoDj0deXjCbJUhCFPO//2HIZ7DQ+Wl4VbBI7P9UiUQMpQrNlytI++2d9gxZv8DlJqb hhvYxMrBuarNvK9knSPRlFOhiCVe35MJRuc3H3OwgVd5L+GIKIoJPACPSRnlQOndPddGWA0bBB7hv 51KvkbkDh06mXas3siZvifQcJMbB0ZR8glMRfRn7ct9vlkS1tSauM4saAXgYpTak6ikmyXijMkxFU UxVuWxcMUEgUMfoy7+qNU7yQxP1woanqyFEl+93mspiVR0gCk9W/cUuaTp9OAZLXKymbOrqBzVIM5 LS7ekTxQ==; Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDr-0021gN-1L for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:26:30 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1a920d4842bso4275955ad.2 for ; Wed, 19 Apr 2023 15:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943057; x=1684535057; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=KlF0beSBSA6VLstvFDlAYMs9lpg8gvRR8zucHEopsyriEw6o1h2sLsqbVwcFiW8cZ2 ykz4DGeTyhjIF7TUhCvkjoQIqDlNYfhLHbuIW6A6Nze2qZg8Mjs4XhacrR2YEsP5YvVC RlKM3D/qrtizTZ3hrz+4hH+4HBcHwt4wDVgzIrtDMMjRIhDdPS70B4ffIp/QcNwVpgLh l3tvN+FDLmm6WxBLSXFEB5UUmHWn5q2p7Y1BPq6qQBjKBoxl/p2sw2H5TvKzZwP4jWXj /BG7zkngU3fOCCHkdBXlJJfXlhrBn1uWDICB+9I2KRJvOa60PVK4lOGzawO9HJcdv8/2 2Ciw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943057; x=1684535057; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=HnG69vtJJaxG204uQJ34qy1xxYKgzWQfTwEgrC4dyjqGPULd13WvvxmWeWnuXVOx/s nSNdXAh530pPlVkqRG/dLsz+kSfsfJplht+nKSI3mpejpI7yHCRN49tW7A+51EprROU7 rRDpDkOxYKo7VqLZ/To2PGHIn22ydjoifgqLK0vs0jAkBrs866amDmRL4oA/LMkPJ0Ny vhINHLvA5JUO9/6ya8JAtxGGkUA/4SM12sFXcPO459hpO7AMX0Wn8yp8gNld+L8nCIRD /6gq4I/DnuN9V+OQ2ZmdGjpJ4Kw8asPIpTn4IPfMp0rJB+Akc2dz8q/WooAazJdMyGKy fzKg== X-Gm-Message-State: AAQBX9djzJKtN6hNzoY0+U9KpGwCEnOV8A2NEpBFLovGtNG7YWNfuzbM ZbWCBvWmfZ8GjMBRViGCiJIBRQ== X-Google-Smtp-Source: AKy350YmjLuFNHpdbGKVUxtLnNGDTOqZujizSNNxdVNVjL7P36ZiZ6Z6Phv1PaiPaoxLg0i7OBeTQw== X-Received: by 2002:a17:902:d505:b0:19d:778:ff5 with SMTP id b5-20020a170902d50500b0019d07780ff5mr7467330plg.15.1681943057246; Wed, 19 Apr 2023 15:24:17 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:17 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Uladzislau Rezki Subject: [RFC kvmtool 08/10] riscv: virtio: Enforce VIRTIO_F_ACCESS_PLATFORM feature flag. Date: Wed, 19 Apr 2023 15:23:48 -0700 Message-Id: <20230419222350.3604274-9-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_232622_234917_B8E700BC X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Rajnesh Kanwal VIRTIO_F_ACCESS_PLATFORM feature tells the guest that device will be using DMA for transfers. This forces the guest to use DMA API to allow the host to successfully access guest memory as needed. This is needed for CoVE VMs. Signed-off-by: Rajnesh Kanwal --- riscv/kvm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/riscv/kvm.c b/riscv/kvm.c index e728790..aebb6bd 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -7,6 +7,7 @@ #include #include #include +#include struct kvm_ext kvm_req_ext[] = { { DEFINE_KVM_EXT(KVM_CAP_ONE_REG) }, @@ -224,5 +225,14 @@ int kvm__arch_setup_firmware(struct kvm *kvm) u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) { - return 0; + u64 features = 0; + + /* CoVE VMs mandate VIRTIO_F_ACCESS_PLATFORM feature to force use of + * SWIOTLB bounce buffers through DMA API. Without this device probe + * will fail for CoVE VMs. + */ + if (kvm->cfg.arch.cove_vm) + features |= (1ULL << VIRTIO_F_ACCESS_PLATFORM); + + return features; } From patchwork Wed Apr 19 22:23:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217663 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 33DB5C77B73 for ; Wed, 19 Apr 2023 23:10: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=x8KEAdP8j+OHYJXz7wp4HiSz8Pib/2Q4IQispVDCbpA=; b=rcoGUAu2jXRgsq c0U0M4ctKfztB5mhcImnomK3PP4PmOG6FMKDzDOd9cd1z7e9h5sV1ZoI86KCRvexY6E192u0KbYEU kXrfOms4XNRjhiEzHugrPS55Nw+KSY4cASciYnnfDR0BYzmCY8zXpIf4Mb2hySui/Nwb+uMZmFMNJ 1FV7vrOitTiBcw49boYMLNHSaXSnB9teqRsP2w6gwucwM8hkSNY0FZaRG5oVj5uloX9vX32bO50BT XAsiIpjrDonoABJuyQaUJOu6u8wUb5ywB2tvU0AUxswF4c0li8zSSA8NlyG72Xqw7gy3dhPCiURcR ETp7ZovxxdysRBRw3f0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGw9-006cLP-1G; Wed, 19 Apr 2023 23:10:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGw7-006cKh-2A for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 23:10:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=92JmYNvjI4h3x1v84zDdO04a6NNcBv03E/psDBTJE8A=; b=oLN9j+16qeTREB8Ezpv9iZDTKe y1IiIWpPtl4uOk0wJ0pSMPCGFB2fNIcfmalpHS3ZrpvMTjFg+BOf9iOvSwedJ8qSVBSpe9zfSBzOQ NMLqwNewm9F21iogFaUFXRkPMGbnRs5uPLmaifsDgZ1SPriFTKPJE56EIYOfIsjup1Gxv8TeqLg/g 9nB5wIduSfruLuYP4EPh+mVxhoWGSzY9zs3HHh2X737xQYWlhsDBPNlKu/LmQNcoBX3rykxNFh34s NUBp1Ss7xUVo29XhHI+Z9Ca6oW4Pfd3scbJAcuNqdD0FOs6pZqvUldBPtrWHq8z8o+nO7Uz4spa1h KVu5haEQ==; Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDt-0021gO-0U for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:26:28 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-517bb01bac9so218156a12.0 for ; Wed, 19 Apr 2023 15:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943059; x=1684535059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=92JmYNvjI4h3x1v84zDdO04a6NNcBv03E/psDBTJE8A=; b=nUPF7sXfdzfSW6QquvIfaq4GAfSYyZeAk0mT1xklq8pqmC8JoWNIvCjy+zgsODVUHq O1IjPJuK8sxnkfCXOFdrW+u9RpzMDpy7y7UdhAG0oCuYW3dH8GSGsOh9ODDRIxw2eaFz bkM34qwDSq7IzfX047RwYqZPP8OQknDg9R1karBknWrofSn/KUs6wUf/rHdpra1bOATf rzsEvtKv0XMZjsFArXphtLo3X7lGUkjGEGkW6yljl786vgCvygViLOvHooAc3u8hDTWy WbwJ4EH+yr+KTGNMLcFTkEfYKE8eHBN2A40w7EVpD08O7tCunWfP2Fwi90JATCfWffYG bUcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943059; x=1684535059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=92JmYNvjI4h3x1v84zDdO04a6NNcBv03E/psDBTJE8A=; b=CXTVLi/LYFaS3mfIrpwcFyah7YgAWjUc5duR7mteYDiu0wkZXpW4HYLEhExNBfNtos vT1by08/IKA/uwfsNy+rDzNdrNJzanUswMdJ0gDl8uGdNYEvy2w+CpaWwbJivAOGE5pP ROSTFxvXAbYiJKYqUqgs6NzWaiHuaIYUUTIE2/7iJvLP9H6yhlQnSvLzL0ds613jZgxe Zj8WnftQj5dq8J8ZBomfZUvXCPHWrfyiWn6rVJKx7eVYzeXTWh3AfsgMvUAjrMESloO5 P3GJxhRt6Sr82Z9OaSpIgXHSs+Mzu0crg5ob66CErnNfEeV/yAdIwXKxoCvgiDd0hS9l SNxg== X-Gm-Message-State: AAQBX9euHGc3YB3vM351Sllp32WnzHstrZv1vstgheATfzhFh5pFANMU YgVRbo6wguNiGERkgDtQF7sDqo8pVIZMYGhNRho= X-Google-Smtp-Source: AKy350Z85naSstLXZzvY5D57utZL9LkLhfRNOpeuO+9VtZ6rJWlxmJ/TTxgn/rQUXeeW25YB/WTEcw== X-Received: by 2002:a17:90a:cf81:b0:247:1f35:3314 with SMTP id i1-20020a17090acf8100b002471f353314mr3406729pju.48.1681943059019; Wed, 19 Apr 2023 15:24:19 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:18 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Uladzislau Rezki Subject: [RFC kvmtool 09/10] riscv: Don't emit MMIO devices for CoVE VM. Date: Wed, 19 Apr 2023 15:23:49 -0700 Message-Id: <20230419222350.3604274-10-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_232622_050554_B8F05A34 X-CRM114-Status: GOOD ( 10.57 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Rajnesh Kanwal The CoVE VMs do not support MMIO devices yet. Do not emit MMIO device nodes for CoVE VMs. Signed-off-by: Rajnesh Kanwal --- riscv/fdt.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/riscv/fdt.c b/riscv/fdt.c index 07ec336..a7d32b3 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -210,22 +210,25 @@ static int setup_fdt(struct kvm *kvm) riscv_irqchip_phandle)); _FDT(fdt_property(fdt, "ranges", NULL, 0)); - /* Virtio MMIO devices */ - dev_hdr = device__first_dev(DEVICE_BUS_MMIO); - while (dev_hdr) { - generate_mmio_fdt_nodes = dev_hdr->data; - generate_mmio_fdt_nodes(fdt, dev_hdr, - riscv__generate_irq_prop); - dev_hdr = device__next_dev(dev_hdr); - } + /* CoVE VMs do not support MMIO devices yet */ + if (!kvm->cfg.arch.cove_vm) { + /* Virtio MMIO devices */ + dev_hdr = device__first_dev(DEVICE_BUS_MMIO); + while (dev_hdr) { + generate_mmio_fdt_nodes = dev_hdr->data; + generate_mmio_fdt_nodes(fdt, dev_hdr, + riscv__generate_irq_prop); + dev_hdr = device__next_dev(dev_hdr); + } - /* IOPORT devices */ - dev_hdr = device__first_dev(DEVICE_BUS_IOPORT); - while (dev_hdr) { - generate_mmio_fdt_nodes = dev_hdr->data; - generate_mmio_fdt_nodes(fdt, dev_hdr, - riscv__generate_irq_prop); - dev_hdr = device__next_dev(dev_hdr); + /* IOPORT devices */ + dev_hdr = device__first_dev(DEVICE_BUS_IOPORT); + while (dev_hdr) { + generate_mmio_fdt_nodes = dev_hdr->data; + generate_mmio_fdt_nodes(fdt, dev_hdr, + riscv__generate_irq_prop); + dev_hdr = device__next_dev(dev_hdr); + } } /* PCI host controller */ From patchwork Wed Apr 19 22:23:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217650 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 B2591C77B75 for ; Wed, 19 Apr 2023 23:00: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=168o51THYW3bEtvqjsr8ApLNm9UI5TIS1Mr6/r1fTm0=; b=NB6aRboFvDp4ft hZleL5heWvHp11uwdyUATRQPYMQTSev/uY9nYtOYJ7fvDIAaNQb/M6iZePbk4I+ZiHDa5N4fYAPh8 sJRR+rIi5iHosWCZ72hcAn5WlXSIykPUjF28WJ/GhFtgYGTjNFmv2OkCdpB947a40xYEwrOQLyQNs 6zbVxo2/qwXSqft4tL39SaxyCA1cZ59nkv0WkyHL+lUPQ52c0YPI+A7rhs0DuxO1PpD82ezD1YeY5 cCFP408m4vLVL+l1f3FDDqdvCgkCY2g2gAzwc9s3lmyzck4JqYF5NklbdQczgkcKbBLxXCtr4RQHI MgexzHig3jhJWzQgrBKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGmf-006a8K-1G; Wed, 19 Apr 2023 23:00:17 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGlz-006Zbz-38 for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 22:59:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=RuMtDFX8GnL6K6Zpet1XjkQo7h 1wSk6DGXh9ShDL7SSDdt13hHW/8KhsJqurHYotnYgrW6ECkU3SbXxEjlDuoe+W3dmf0hp/M3pc+bs sQXAFi+doc8v/qZZvqPBROIrA7GHZbBNk0kjhB1bZ6ttHi3AQdr53P2NuRFa4Z6/gw51mnxG7H728 WPTs7FfuUw0SAk4BGnvXQmfsXa+wxRE7Wf+s/+tKEUgRFRNqj1Et4zwhxOwa34i2PiCC9xXhVWxCr 1UvRdxZVuZ6jp0M4GdRny3uDCFh/c+EWcHQvzzdWqIlmUBSARTaqsTcIypQErz5MiXFr+mzcnRwk5 gEfgSTVg==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGDv-0021gV-18 for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 22:26:30 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a6817adde4so5472365ad.0 for ; Wed, 19 Apr 2023 15:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943061; x=1684535061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=Hy5Vjaj1GFlfqXFgFU4Wk7wYhL+AdW+GISShF7pbpQzBCAzoyX06mKj9riDONUvoTu KJygh5nscsoyPvItPChqrHSXQPxDp5bYRAnKsEvFqcmijRhCw38xeSwetTsF9AvkbUYf hVmE7FSAH4Q4wrzRD6pw23VK9AaSnKgovUSlZ9QXs++6xGQZcPVEtNzbYKNpDmb7ydxL pihm7AbjTblUz+nkMI32xYxKW27gseqDrV0RGKN4T43bczPSmCXLp3fRh/utmO9YHtoB Sey/VFplr9PE2lySTaLRpT3t0lbZnm/yfBcOsJhGI8vtN1zAVWuoZu9OzywwnPC3RL4n V1wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943061; x=1684535061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=gBjkH+A8yVRujOu9uVH3EEyQE8omoHfXUjHcBG+xnR0Z3iUYK9No36DvEff+t0W06x cFeTwHqTvZDWB1+rF+2JtR2WdVx3R+wA1+TdgPRJNWzhTtAOhRXU1gwUILLZTryA80yl xV4PUu50AuLyo4s7BlH4UZzOzA8adGIKWfFC9Ne3zq3b8QGMQpkBRkOG6XWvlvTaAXqo zFZcGf8Z2mhq0DZKdwPD4Yk9ZqzF/Z3nUH0jwe4KMXIRiJ4rCToCCWv0Ic0ADcVUk43P 6gznSTGZ2X34x7w4HIIG7MTCbFCq84wgd/axdIFYiz6ED3KsT49uHHX08OqkzMznf7Zg E3tw== X-Gm-Message-State: AAQBX9f/2rkhyjchGXG6vLLLKqqX6F+nK/mui9NYNpkXMSSCCW0F5+PN 80TBXn2oCpImDc2ItRLBqUGWaQ== X-Google-Smtp-Source: AKy350bpDV/yb/MMXonhLvjhCzwnd1ozKuOFojavKdcbbpka5zKY4L/5Rw/zrIiOtje9GuJuXPaRMw== X-Received: by 2002:a17:902:7891:b0:1a1:bf22:2b6e with SMTP id q17-20020a170902789100b001a1bf222b6emr6634040pll.43.1681943060762; Wed, 19 Apr 2023 15:24:20 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:20 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Uladzislau Rezki Subject: [RFC kvmtool 10/10] riscv: cove: Don't emit interrupt_map for pci devices in fdt. Date: Wed, 19 Apr 2023 15:23:50 -0700 Message-Id: <20230419222350.3604274-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_232623_921438_4073E012 X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Rajnesh Kanwal CoVE VMs don't support pin based interrupts yet as APLIC isn't supported. Signed-off-by: Rajnesh Kanwal --- riscv/fdt.c | 2 +- riscv/include/kvm/kvm-arch.h | 2 +- riscv/pci.c | 83 +++++++++++++++++++----------------- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/riscv/fdt.c b/riscv/fdt.c index a7d32b3..115ae17 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -232,7 +232,7 @@ static int setup_fdt(struct kvm *kvm) } /* PCI host controller */ - pci__generate_fdt_nodes(fdt); + pci__generate_fdt_nodes(fdt, kvm); _FDT(fdt_end_node(fdt)); diff --git a/riscv/include/kvm/kvm-arch.h b/riscv/include/kvm/kvm-arch.h index 08ac54a..9f6967f 100644 --- a/riscv/include/kvm/kvm-arch.h +++ b/riscv/include/kvm/kvm-arch.h @@ -104,7 +104,7 @@ void aia__create(struct kvm *kvm); void plic__create(struct kvm *kvm); -void pci__generate_fdt_nodes(void *fdt); +void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm); int riscv__add_irqfd(struct kvm *kvm, unsigned int gsi, int trigger_fd, int resample_fd); diff --git a/riscv/pci.c b/riscv/pci.c index 9760ca3..31ea286 100644 --- a/riscv/pci.c +++ b/riscv/pci.c @@ -17,7 +17,7 @@ struct of_interrupt_map_entry { u32 irqchip_sense; } __attribute__((packed)); -void pci__generate_fdt_nodes(void *fdt) +void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm) { struct device_header *dev_hdr; struct of_interrupt_map_entry irq_map[OF_PCI_IRQ_MAP_MAX]; @@ -67,51 +67,56 @@ void pci__generate_fdt_nodes(void *fdt) _FDT(fdt_property(fdt, "reg", &cfg_reg_prop, sizeof(cfg_reg_prop))); _FDT(fdt_property(fdt, "ranges", ranges, sizeof(ranges))); - /* Generate the interrupt map ... */ - dev_hdr = device__first_dev(DEVICE_BUS_PCI); - while (dev_hdr && nentries < ARRAY_SIZE(irq_map)) { - struct of_interrupt_map_entry *entry; - struct pci_device_header *pci_hdr = dev_hdr->data; - u8 dev_num = dev_hdr->dev_num; - u8 pin = pci_hdr->irq_pin; - u8 irq = pci_hdr->irq_line; + /* CoVE VMs do not support pin based interrupts yet as APLIC isn't + * supported. + */ + if (!kvm->cfg.arch.cove_vm) { + /* Generate the interrupt map ... */ + dev_hdr = device__first_dev(DEVICE_BUS_PCI); + while (dev_hdr && nentries < ARRAY_SIZE(irq_map)) { + struct of_interrupt_map_entry *entry; + struct pci_device_header *pci_hdr = dev_hdr->data; + u8 dev_num = dev_hdr->dev_num; + u8 pin = pci_hdr->irq_pin; + u8 irq = pci_hdr->irq_line; - entry = ((void *)irq_map) + (nsize * nentries); - *entry = (struct of_interrupt_map_entry) { - .pci_irq_mask = { - .pci_addr = { - .hi = cpu_to_fdt32(of_pci_b_ddddd(dev_num)), - .mid = 0, - .lo = 0, + entry = ((void *)irq_map) + (nsize * nentries); + *entry = (struct of_interrupt_map_entry) { + .pci_irq_mask = { + .pci_addr = { + .hi = cpu_to_fdt32(of_pci_b_ddddd(dev_num)), + .mid = 0, + .lo = 0, + }, + .pci_pin = cpu_to_fdt32(pin), }, - .pci_pin = cpu_to_fdt32(pin), - }, - .irqchip_phandle = cpu_to_fdt32(riscv_irqchip_phandle), - .irqchip_line = cpu_to_fdt32(irq), - }; + .irqchip_phandle = cpu_to_fdt32(riscv_irqchip_phandle), + .irqchip_line = cpu_to_fdt32(irq), + }; - if (riscv_irqchip_line_sensing) - entry->irqchip_sense = cpu_to_fdt32(IRQ_TYPE_LEVEL_HIGH); + if (riscv_irqchip_line_sensing) + entry->irqchip_sense = cpu_to_fdt32(IRQ_TYPE_LEVEL_HIGH); - nentries++; - dev_hdr = device__next_dev(dev_hdr); - } + nentries++; + dev_hdr = device__next_dev(dev_hdr); + } - _FDT(fdt_property(fdt, "interrupt-map", irq_map, nsize * nentries)); + _FDT(fdt_property(fdt, "interrupt-map", irq_map, nsize * nentries)); - /* ... and the corresponding mask. */ - if (nentries) { - struct of_pci_irq_mask irq_mask = { - .pci_addr = { - .hi = cpu_to_fdt32(of_pci_b_ddddd(-1)), - .mid = 0, - .lo = 0, - }, - .pci_pin = cpu_to_fdt32(7), - }; + /* ... and the corresponding mask. */ + if (nentries) { + struct of_pci_irq_mask irq_mask = { + .pci_addr = { + .hi = cpu_to_fdt32(of_pci_b_ddddd(-1)), + .mid = 0, + .lo = 0, + }, + .pci_pin = cpu_to_fdt32(7), + }; - _FDT(fdt_property(fdt, "interrupt-map-mask", &irq_mask, - sizeof(irq_mask))); + _FDT(fdt_property(fdt, "interrupt-map-mask", &irq_mask, + sizeof(irq_mask))); + } } /* Set MSI parent if available */