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 Patra X-Patchwork-Id: 85614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp710584vqo; Wed, 19 Apr 2023 15:47:02 -0700 (PDT) X-Google-Smtp-Source: AKy350aLy0srt6rgbVEHlNljUn2Gk8f+S4tncxam+5onVnwC4YGPuZl4WrDv0XugbSU1KZNY0R4W X-Received: by 2002:a17:902:f547:b0:1a1:e01e:7279 with SMTP id h7-20020a170902f54700b001a1e01e7279mr7898410plf.4.1681944422063; Wed, 19 Apr 2023 15:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944422; cv=none; d=google.com; s=arc-20160816; b=BUDkjQvmzTREAQCxao00I44c1uPVu0TBteEiSeGFIZSdm1hS06l4HOU8NPD8SPH2nU ROsrfFaj9Te6BRvr7FnATCaWOWdCihgXT1GtplpguAmEr4yUVH9b/QoD+52hI2w8O3G+ r50/xiE5147ZMH8P8+lvRYVZow/w3PjXpw0COBHBhdiK8lp9DH9IsR4/wmbwvjFl3sPu YmltsNaJpBEkvQ63v+wemipXVP8+KYGotp0FT4P1DYn94r0GfY5g7Z1inW2a/LQFqV0o SCTEch5c7HSLl7LqX2KN6bSo856zklWNkDaDQr6fFPcuNovRuJXat9Jf2oNAKf7sjRFm gc5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LXsqDGUR1sIAzl083YrDdeF8Dcz5MG5TcoJ+FCFYQPE=; b=le/XJXAJvqyNrmbWoZvSqTXVyeCmHyX3NO58TxIWqtT3dfcVNy9Pa8Br9sVc3BJYqz lQy4yrPRtjU3WOwH7t5vkV7ntTnUr8u9bzIMskCBU6yg63th3xpMXDda+M4NWJdPTY6S MMtHI4x9kJH81m8mzlUIQmfIZPEV8M+bAkWrCvnbpsgsEoOYIZK0mdFTkOKufSNDoBlT QLzT4PUi1pN5mnHZHmEv0+X661wSBjdilvPf5TFQbzxDpsFJA3eQeenFLaLxnlLxm8Zn fp+T69POYORXUlY8uZd49wORUTrqJGKLJQUfRERmQfXJ00tU+dPIW/AzZQLeVgeP2kwB YwkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ohOEHO7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w10-20020a1709027b8a00b001a6919158cbsi14888759pll.167.2023.04.19.15.46.49; Wed, 19 Apr 2023 15:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ohOEHO7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232659AbjDSW1M (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233603AbjDSW0t (ORCPT ); Wed, 19 Apr 2023 18:26:49 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B76231718 for ; Wed, 19 Apr 2023 15:25:22 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-517c840f181so185723a12.3 for ; Wed, 19 Apr 2023 15:25:22 -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=XLChwmomSLWahv32gZ9DP2qrZ/dG6goJJoGYSzi87VQZZI4ZO++CBz5x8xHW4tz3WF 5LAKW4NX0jUEt26FDWEwWMeVBvbAs4SH87Wup+6HmfJ/8sTTL1kPYXzNUoKKq9FLWNHx TRKRjYHgGPsmRj/9jvGMyHMyROp3HNmTf48/N1XIlQk+dot8+n0ErybwGD4rvMkhxEQu pm4m5kJrxvH/uQ7QyX48IfuUEdyjIVbeW0/1tCBMfED4IjMpD6x4fGMMX7tMqkCnople Nki7NvSkcwkTyAvyGGdCFZRs2BNiuZRd9Zz2PZUKszKZs5975PWq4tdn4X1VbVOXQXAk z9aA== X-Gm-Message-State: AAQBX9dvX68oOdiYksM5Oa0+8VUGMi8XcaWQ7U9te9DfPXSxdDhfOwHi +qDcZ8zj3U3Ez9p8av4V1box6wMwQZApmcqof44= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646554148711383?= X-GMAIL-MSGID: =?utf-8?q?1763646554148711383?= 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 Patra X-Patchwork-Id: 85620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp711129vqo; Wed, 19 Apr 2023 15:48:13 -0700 (PDT) X-Google-Smtp-Source: AKy350a+pKbhjCA2Y8hv8BxSczd7I774XjEqwpBfngc2qYc254CDo8lhmKC19BICNHZENXjM/cs8 X-Received: by 2002:a17:902:e751:b0:1a6:3a2d:e59d with SMTP id p17-20020a170902e75100b001a63a2de59dmr8651123plf.37.1681944493454; Wed, 19 Apr 2023 15:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944493; cv=none; d=google.com; s=arc-20160816; b=XB/18/TIeQ+sOHV3jwF7xp0IkXI6M39pAgVxIkyPXlA698xZGQUwtCVnSed0P0YTTL UOdbDWBDlokpt7xZzAC15TphjeXtP2EbuwQ6lODakT+YOSllllezQrExwNUtVSNmfFph dnL41y0QEnMoNzrpFZ1Nl0w6SW1AhNOWLsUYJdAJNLqO4gM4n8kSMc0HFUT6WLfpZjXz QfbkcKgSdcMDZYfxhvAvK6oC5AbL9GcvGou9ZJMwnfX1NRLqWRHFdDBri51Tl55Gx0G8 T1+r3MRhhRqAO7y6O5luUzgJi0QaraIu5JkZtigKxwP27iFZYEZO9SQYI0BMT4dODh7V JRVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nDYPek2GW62ZjpMwmsxfE9d0xDPaKHdBMm+cEZKc8s8=; b=oGIB6Xxc1EmUGTxO0QsIJYcG5CldZzzEK1SBrzSImYZhNclUe8pqoChuxLs1znRYp7 57zXVSyW25bH48vmxSIyQHnNfL5+wXaDMKvZ+5Z2PvM0tdMG2hl1V0hCSY0yFnNH83OB TvdAlVeoP/5Yh0sklrZWn4xza9SOqsnsAcAzIx7vNoV1hRQEnFANXkSGjrKlC4xSL3FO aLfcUJPX7TJR3Fw2e4rGbVFZNIZPRAc/ceH3jmvf6YkN42PO1eI+mWD98a/93IrIhHB9 j/A7n4smJ96nFbuRNmPrgYQs+fRmT2Kbr9yTCdW5Rap4Cy3rmxDG4x0OYBldp6ZlpU60 ptag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=gbm655ZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a170902ce8a00b001a9256e81ffsi1121060plg.262.2023.04.19.15.48.01; Wed, 19 Apr 2023 15:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=gbm655ZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbjDSW10 (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233644AbjDSW1C (ORCPT ); Wed, 19 Apr 2023 18:27:02 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC2DC166 for ; Wed, 19 Apr 2023 15:25:35 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-63b60365f53so485502b3a.0 for ; Wed, 19 Apr 2023 15:25:35 -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=UqlPQJJPA476YpPIaWiRiDAas3RfbK/8BVpd1wjONd8sI0PsmSyZ6O3THZHNBhHREf ZbjjLIdCCcSt8XKYSxtKBmZzOd6lW6bA0BK0HKeDD3d9dOsHCybqRPLxgznnoDrXcyw6 F6pGc8z8NBx79/9ImEy83oXVyYLFKoX/5abLkvSuVDW5yJKOHh8FxW4+WXW9JJ9tqIX9 F1QX3wH8to5ArkbFo9Eev67IhINU7iY4dig6WHnRdhQd+pBoNlIsjYdvS8EzqkT4qK0v x634p72iJKmBfxlKEe2SJoC9SbUDl4zyCF/UUMZCS6dDiuM2/EMJHLyvkDDorlM65Miy ChBA== X-Gm-Message-State: AAQBX9dGZydXxHV4/A7ylBib6pW07s+NgsPk/OM5siJReC3O4cIZypyQ 149vWrqftm+yYfj1/GvjjIr3CKihjEe/up2+RE0= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646629250332279?= X-GMAIL-MSGID: =?utf-8?q?1763646629250332279?= 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 Patra X-Patchwork-Id: 85617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp710947vqo; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) X-Google-Smtp-Source: AKy350YoLElUKZrLD+q2DPIQ02cSR7f1JgKQA/cyYm7jcoibXQzot+46HEZm8FAsFfxloN2bFThH X-Received: by 2002:a17:902:d48e:b0:19d:553:746b with SMTP id c14-20020a170902d48e00b0019d0553746bmr7523420plg.66.1681944470115; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944470; cv=none; d=google.com; s=arc-20160816; b=nkNynoz+wS12r5yqN9MD/Yn7j9diQdRpP1OlGGomkfCF591k5ewBtU6OFSIL4BPU1B J4cSDsWe8FwjFI1TwBB2YgVxBq9fnGUhpG4iFfBcLV1ykIUs8uACWe7XkwlZzlGPOj3V 3scSiEvBIF9M1jgQr+3gaJkT0Fte7Kju2XKTUUw+GYWW9C467qBoEKTexhL2enCInMIx oSGiqwXLhSrIVRfChZFmsRma02ivpiEkrbRJcp1NWJs7gEsIFUyhP8hBtt1BgzIPPQ+w 1YirIy1SfHUhFM/Io3upilogOmHeVGHfl4/N7JXyDZJEIT0XQHzz0buZQVtCMFMZWFE7 gVbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sx5yCGWct6pM6GpC/mvdByE459bnHS7kFRJEEmvmIAE=; b=AxS0kFXZqWhYRDDPHCnFNhHJOiVBVQrgUY8zijg89w/zqUEDotlSyYv1LofLuVCfoc IpR62BXRBLpCNeDBHJ7Gg2QWEB3rshn0fCQiJ/W2XaXnJ/A4YfumcrQIXgZI5F314N/J B5OM4vdWoLER9HNvy3L2mC4H1zuApaGRK/VGOtkgrVup+Qj3ByWmZ5OuGadH603NW/gO wlOWWLpJTXU/6soYN25wFltVPO0fWDicPVsWTAgXIujmlcD3LI8yJ9JHtpz3EHlbkbXJ HY/FAMXm+yuyOEmJLmOLOmFU/zKST5wHvj82ttIspI+sbF5y7il37popUp+kSokQLWrW Etpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=3p9iTgdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a170903124f00b001a19b69c7ebsi18627867plh.345.2023.04.19.15.47.17; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=3p9iTgdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233507AbjDSW1b (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233433AbjDSW1E (ORCPT ); Wed, 19 Apr 2023 18:27:04 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA18AF33 for ; Wed, 19 Apr 2023 15:25:39 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-51efefe7814so276569a12.3 for ; Wed, 19 Apr 2023 15:25:39 -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=bP+OVmy4eXmp6kn3kuFC5kl176yP7bARpQw/2fVSTIQcTMbQMnUhtfNfRboXbVkwGt dL0Cw2yGddY1QrSdxvQfyE0zS7aJUqTmGTjy1MIzL3RPgro6Owb6NtHHHNR+rUKYiLfc po/fq6IGpi1GjOhvLOz33Lvf35Ti16yKiQ4EnZVv22oU/2ZiPt7H/5eUsTWRmSCOWnBb KBm/DPIy1lPuv8hSz1heccB6XrdaHdnC2TqjRA3c1Yh05JiHAOxfjEcMxMzA0wfoI5Tw mHejY3doTfXh1ZpY7GKTzozmvESBbYVFEQTyTblCxfsAet7bgFqvlf8n8sY8zVG56TDK GafA== X-Gm-Message-State: AAQBX9cgfzVgYAgAWl3ADOHcldbWryts1OBAyYdKZTYS5O454sfk+pUh TCoq4WYi/hTp96glbAWSFlMArYsKV5rw82XlYrA= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646604632413218?= X-GMAIL-MSGID: =?utf-8?q?1763646604632413218?= 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 Patra X-Patchwork-Id: 85629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp712592vqo; Wed, 19 Apr 2023 15:51:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ZdgiNe9nk3mOtbaNtg9Xc715DIBnagJilqDPKgtgmufH3M5ZPeqMAOYnQsWChio9GPYvP7 X-Received: by 2002:a17:90a:9306:b0:246:61ae:2fbb with SMTP id p6-20020a17090a930600b0024661ae2fbbmr3984637pjo.41.1681944679945; Wed, 19 Apr 2023 15:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944679; cv=none; d=google.com; s=arc-20160816; b=kp5o77w7CBrW8pcH9SUfPl72un/PDBSAoa83mR0IXvHIvuRkk573ACzEPTxAA+qVWf 72R9we/FYaSDFMI1AFP+2rHi5q6FHRt5iNN2Qvlcj8DQ52x3u/VdU1B0vxvpwPHqB3G3 utF97lWgHZTtXo07zPJ15B1Yfrj/TanG1gIgawdFdm8ZTGg6dOx0XLZZfeKQEco21zDr 7ktcytamTrkHoK20q2bH+xX/T/Nb7hEmuPRRhGD2nr2V7XWfcLSvrgJn+uRsvT0Op8wh YYv1uIeo0/rpJnoZIY+ERFgMm2Nfok8LQ2Nxy3Idgu6f567uE7WTy870HG1QbzhimZhf uQcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DqxJzuQg4YHoKMLWmjQ5z9IqDd25T8M3gtHVASWlMsA=; b=EQqxFeRRAkpvY7tB5wEYbF0CJ/WpEzeERco+uw3Wh74k0MCwCusw+sPS9mft5S3zlt ttcSGLcUm6wT5Ifinv+/lGISPI7vdcCVrkwi9Ycz3oK1LefX13tCcouDF2BAtrMJfVGq T0aDYedReXd5BFE1Nf2+PJzyV4jmTSr6tj8Zyk+wlwm6eSz8de4aK8px4iwPrUMfgsGP tzKRRfXmuTf29LL2wi2cg156bp7Cw+2HhzZAcB07lANIn4OCWYlD6kd5Qw0+xe5YQYuI uoIuL4w8SQ7R02xAHAMug3goR8LXMwZ1zB72e10X5Hn46iWrwlJUIrVr602J7egyxEUq +rkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=CdFLGUbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a17090a551000b0023d12168087si78234pji.111.2023.04.19.15.51.07; Wed, 19 Apr 2023 15:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=CdFLGUbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbjDSW2a (ORCPT + 99 others); Wed, 19 Apr 2023 18:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233743AbjDSW2G (ORCPT ); Wed, 19 Apr 2023 18:28:06 -0400 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A8BCC23 for ; Wed, 19 Apr 2023 15:26:31 -0700 (PDT) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1a66b9bd7dfso5258405ad.2 for ; Wed, 19 Apr 2023 15:26:31 -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=XxT3LkhMh5joT4pqsE5N5pXV5rLC0qi18VoJxopSVtRiiASYtgCqDnsauEafjXscHU x+i/h/vXuRjZbOyOQZzQ9VULus4BKvgwmxtU7cUrWLTU7OiFrYBXE+sVjLRArtsGJxd/ kfMOFz8lpzCbbzwpDE/se+aH3c3AbCjPuEyE0SmU5OqqVDr0U/5b0EfownM2GO88Sjd1 nInvbpEcjH+ibsX6OtsIRB/qjgSckNWNPzKAqYsq4Kty96RJKAt/C1j6F0kZxy9TfuJB eH0QQ0NNFuYXT9cP7z2D06VuIUIO3OflOMnX/o0u1Rnn8qwYnG73jL4ZfA00JeFPWpQR /wkw== X-Gm-Message-State: AAQBX9cq/1hB7wfKc18JIGQyNX41Em2GhdYs1r3GXXg/jQ8F6tF82I6h OrQUlNJ8WnKsha1YwRjx1vGwn81H9v28DVN/db0= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646824610611300?= X-GMAIL-MSGID: =?utf-8?q?1763646824610611300?= 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 Patra X-Patchwork-Id: 85625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp712234vqo; Wed, 19 Apr 2023 15:50:35 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNVu755DUEJDT+hxjOQghN6ZQN3kBqgYgnvriF1nvNA7e3/PCnKbZ+O2pzxdEXGrw7tMEL X-Received: by 2002:a05:6a00:13a6:b0:63b:5c82:e209 with SMTP id t38-20020a056a0013a600b0063b5c82e209mr7065945pfg.10.1681944635507; Wed, 19 Apr 2023 15:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944635; cv=none; d=google.com; s=arc-20160816; b=o4vUBZXdgFJxuLUy5hiGDClwx/BkH+HtWiIhhzGbFsonY2njdS5CdlJaGgCgCpXx9z NhAm2gFVEukZHAduk5Q4kraf+dtvg1eOj/DcNaVxL1ydJMqBsL6/YSQW01XNjiJgWW2c o2T2m0vg+/jdIaNumSbAxAyimsS/1YP+3WjWGO3bAtlLlDnpUxAjFdL1ApKxzDtEbnfV 6Awcl4hiuAhc0cALoBIfjjEYG9EimWNlbMqbvMpW0xf683U4/2IC12dejHDy989Kb6Ih Xun5nErMQAzZzV3L3GeEv0Vy0aOVQO/2hL0GpDyKjf/sJ/h+PoFaVJtgZE1Fk0D1i23J HThw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E81F/sZHqFlmC4PTTDxmyvFtDAnkdcxCBJVjUmPx/Qw=; b=iyIC9FDccILDCXECP4fuEDIwCySDyHKoI+byD5jVrw7/sJH5qDM1+yz4Ox4QHSjfij 0eAtiMwt43rYsmGaQhGJdQPW/DCpW+zUjptwGw946LaCOP48pCNZG04ogmKow9a2vQhJ IdYqFx994OiFtK+YfCDuhyOiNUqAjFlGFkkMK1HadFwxzB/l89M9xong4UnzqS9qH+tJ DUXkve3Ehj4yBbZLOxsYrsG14m6r99EMiHGO48Y1ferJbNE7eIQheZhMmblXdgp5DcMa f8DXQlgvKUcEmzbRqA5dSCWab6c2cB32fT2fCz32l+N6GjvmNFVQ2t4G4jG00pXqKk4d v3Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=h8qvhmk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a655084000000b0051344de1eb8si16906336pgp.276.2023.04.19.15.49.58; Wed, 19 Apr 2023 15:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=h8qvhmk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbjDSW1R (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbjDSW0x (ORCPT ); Wed, 19 Apr 2023 18:26:53 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78DE3AD05 for ; Wed, 19 Apr 2023 15:25:31 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a6f0d8cdfeso4530655ad.2 for ; Wed, 19 Apr 2023 15:25:31 -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=Sme54IQGJLggHlHTzHh+EgKj2if5uYH+tMt/XmkUfoLOiElRO16dzGugw1z4x8Wtyt vbksSIZ2zsVeqk+b8NqbwF16jtY5a4GpV+/0df+OW2TwIL3YiHUItyv2WeDUvWLVWEBP lPAtZTx3zDmcJHtJQeq/GRTGbT+ZuaYw2RYOO6wm8c4jbUgFCmyEwMeVmog3j9owhPM6 6aqB85hcLaBAv+SbCSNYFIQhhti4LGrWly9vuj0Pxt5Tqqo95KDiUpLCdnsy7+cYZ4uu P6hIJPVcWiIzDUGBAV2OkI7nYaly9kg5HrUGTdCw+iy2CL/S78Cvdym6o5/EL/bUnkil gNsw== X-Gm-Message-State: AAQBX9daIKY+b78Nn2biQaJr+8FF4NCVpuJcFVGmBm9zNOqkn5hGI48L nbFtXYpITRwFOpYgOr/jxyAjdbuOanB/YkUWne4= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646778428541872?= X-GMAIL-MSGID: =?utf-8?q?1763646778428541872?= 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 Patra X-Patchwork-Id: 85658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp729696vqo; Wed, 19 Apr 2023 16:26:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmcPMYjMjpwGQrWuye760RVoRblc5K2Rob4DXhWOClR9+SFV55CKR6fppxXdYr0tVXAKVk X-Received: by 2002:a17:902:9b81:b0:1a5:1f13:67fc with SMTP id y1-20020a1709029b8100b001a51f1367fcmr6193985plp.31.1681946767458; Wed, 19 Apr 2023 16:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681946767; cv=none; d=google.com; s=arc-20160816; b=skQzR9AiInf61t71J3cW2IQv2iwiwT7DW5jKNzFinHrJ6KZR794lkeOM3rXTvScM1f mWNcw8evVwc/9inJ7XL1NxqtOHoheOUh3/tVzZtAk5oA35UBg28Jrq7ETD9yeDehPCKd EMrOUVyNuwNSBdxf55EQXtwQz2+0vXKsShIdB5tXruQu3F1KMceNLV8+JIhMtxYwqT7o hW7nGlD6RGk2SehQZ33UAJLZTdCwpE+3s/R2ZMBDyPtvu22DfETiq9oJ9X/PL6BQA680 Wq1d6J6ItMUN46+x96ceV7Fp97wllykEeCSWOn1/Y+M6i1MTXGvuYWaErmZE9hpONYtx 9FQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2k6fZhtBjuovD0xJN9/3Mss7sJpSj6M+Lhg1puIM9yQ=; b=rG2Iipud1S/j4/x0Bl6YCk9oRHYknzODeWm4kJqp4vDSTwSowDoflrmINEQy2U/Ax8 UGADFX1xfvVcO/cP+w5r9DDBtHSicxEdFsYkmCh7JXjbCvskHuIn1rDZsz8dKnitDJAR PN1B4urxWFGcfuuCdl19HYEMYTERRnpcBW65L0FTx+AtSWAfQkEbo3TOSeqoiPi+mLh1 w4duehqkEYqiEGe1FFTMs4KbqFEaeK8y+Hd55Zsl3r/ashyPgOqZSOro8CmXrGsK2Qyt 0gwDuPmWddRnNHmVaaNh6iQnCczDxcR5H6Ljr0KQXgh6n7GL5aexuy9rgt/oSxVO62lz RHYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=frHFpOgJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a170902bd8200b0019e6d80f948si16763778pls.485.2023.04.19.16.25.54; Wed, 19 Apr 2023 16:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=frHFpOgJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbjDSWbT (ORCPT + 99 others); Wed, 19 Apr 2023 18:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbjDSWbS (ORCPT ); Wed, 19 Apr 2023 18:31:18 -0400 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 296F37EC8 for ; Wed, 19 Apr 2023 15:30:45 -0700 (PDT) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1a69f686345so4562785ad.2 for ; Wed, 19 Apr 2023 15:30:45 -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=DtQq78e0t0UknBuuihtvDY2BaUAJkudksjIdfAzL51ZnZDOxUGKSeDkG3xMRlu+YRb 6tTQecTKjJrsXcJNOmxScq2vLPCSqWKB+NUm3x+w4dWcypSiuBGeffg29h9H2VbvWl58 2kuB8Oq2A9jOplZs26+F/LKfrSYSHjaDFko5l1vKWe7w+KmePS1CfOe72Uuioy3Xv3gN TOpjYp16+s4pFHhpfE706TQonNjGJWaN0CurZpDnTChghqdzaAHuHx9vHU6/Gi05HuAZ Qt3pM5s50nX+BcUfeztmaT5fBYpTWG1b7MVviMip5diBByFkC97MaP0poCHbUFszIrRW iElQ== X-Gm-Message-State: AAQBX9cbxvxc2knS2BWPmC653i4bkQddhXpfvgoIx1fLM4PZKdH7l75W tKIGeNApkwkNsPoIW5R7RpRHLqf1oURJSxHDYEg= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763649013859236328?= X-GMAIL-MSGID: =?utf-8?q?1763649013859236328?= 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 Patra X-Patchwork-Id: 85611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp709518vqo; Wed, 19 Apr 2023 15:44:45 -0700 (PDT) X-Google-Smtp-Source: AKy350ZepYo5oK1C84vkcYMjMs7PlOCQC/LQ8jzrHr5mJlr/tiflQJmyWunbx9cwuzzwvkcr7IjD X-Received: by 2002:a17:902:6bc1:b0:1a6:81fc:b585 with SMTP id m1-20020a1709026bc100b001a681fcb585mr6251628plt.41.1681944284825; Wed, 19 Apr 2023 15:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944284; cv=none; d=google.com; s=arc-20160816; b=icm2FGx1D/+n+jSGyUN1BVe7UsjKIIBhb9ybAlciEHzSQGYjJpXgRLrWlTKIMAu/6H qrA6fpcgSNCyl8QKoTKs/8kc2zyi9BxtuobvgWaEX86PgeIRTbwzCSLQTY9nhn3950Y4 cNOg+h2rbm1vcfyN3Xq2UD6H2Tj2FvMc0jH+Ey9CoPA4D1RFzakWKb5RezdC7UEXHgR4 UKzUf8kCWUfqjNVcUsc/Kvtl9mwyBkAxDbaMyrdVabo6d9L3S1QHwJrVMU7rANSkvzn/ oDSjlz0x7xHd+oQpYDL+EXSl64qiLXvQdlkypY7TvzUgc9x69xnirSARy/FXPZAxkTyI 9gug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZTLerH+RJ52lhodOQfma/DJulVaHZ1rN37E2HPQ1gqk=; b=CoFdK5wONXe7DcjTRcDdW77dFBQ+VsMa0EQZ17UdlciFhVK14TFdVGwDVPjyublbjC N20R8xh0wjFsgA/NYa1zmUUTvx2sBtWbDywN/jFDwHYEi1Z88W+FD4s+lchK5mIFFmym R2qUMaap+pzUfzHJcBuOJceZfw7Cex6tPwN77ZNHBJhdHsCOk4D6pjuL7Jm4ZoKhXNck ek7ZYvjmIbFgcE1jTfIcBaTbfDnrPgzCkyE4thPXDB6+beYJhXoGuTZ8RyGUFzq6ecyD /P5vBPmkwjT1rTqbgTUHKCPjb5cp+PY9ywTg/yH0qB2RIEPd/NwW1uUNSbHUrE9IRm5K kUVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=a1bnzxGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe2-20020a17090b4f8200b00246d179dc81si63636pjb.126.2023.04.19.15.44.32; Wed, 19 Apr 2023 15:44:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=a1bnzxGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233541AbjDSW2e (ORCPT + 99 others); Wed, 19 Apr 2023 18:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233076AbjDSW2H (ORCPT ); Wed, 19 Apr 2023 18:28:07 -0400 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5657CC143 for ; Wed, 19 Apr 2023 15:26:34 -0700 (PDT) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-63b8b19901fso453982b3a.3 for ; Wed, 19 Apr 2023 15:26:34 -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=CeCP21L96sPWFFlm6v7s/7xViI6nL1f6/BVcOA/8Hqm/dXcKUbu21B5caFrTrqXzSg kdForErWmMxvK9wWQg4KrMVbzhCAGjlOF0grOxzPuGus9hgC3LlOst5FEO7Zk7xQ+2cq b/dGbOph9MGypu5n7RkMhWN4xxcKhPz8iDQxc3qwcssm7dT3Quawk2YLTJq0f9Pwfpxq 5aJkBuR80jhhbpmH1qJ+DfDf+d9qRYJX5CgtAf5lMv020BCKorB3MInLeuXWgkhXwkDx sVC9LnELgFxsT56i96b3gCC+TjIOIPlpRtETavXFiAutgc4vbfjbdtqxVrPOHxXredd3 pfXQ== X-Gm-Message-State: AAQBX9fvNwRGGvT5eDaaxA/ZLeovliQ6T8Jh5Alp4bjHrBtdA96Hqi/B 7unyQH3qCWkJ7tExnxTXZaVX8gJDHX4hD2X2X0A= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646410247279803?= X-GMAIL-MSGID: =?utf-8?q?1763646410247279803?= 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 Patra X-Patchwork-Id: 85631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp713185vqo; Wed, 19 Apr 2023 15:52:37 -0700 (PDT) X-Google-Smtp-Source: AKy350acpanUWhWGASTmz0/jYybEt2sxHts+rGpI9x6SZYdH50pIZGvY/IoDSsvnOuM+QsgQi2tI X-Received: by 2002:a17:90a:aa8d:b0:24b:290a:fb2e with SMTP id l13-20020a17090aaa8d00b0024b290afb2emr2421342pjq.36.1681944757240; Wed, 19 Apr 2023 15:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944757; cv=none; d=google.com; s=arc-20160816; b=dF/33ZPH6SvNPAfjCRAVqU2sKSnP8UnpM3sp1C0KyVltjkpaWxqJ0rmxAPk0bL8aIn LKLpzn2oTtTaKJezhzXQdi2qgrDAE8/qSuxIipO2IhBnq/PDIQi/MisotzgbUgI8VUFm Yi3fEwT/Cz8DAfAko19JVzmm3tihUhLUyV8Nb9GIUaNP3lAoshs2Xl9imIw77Tu8aZ5o EHbxHH6jG9tmUAFkZ1FrqrZDGWtBE3yENl1cDU/bFkiK6zw27qaFnWA22m5A5SsqEPhQ tG1z2jmNYDpuevOlQ6nb0JhqprKcsoeDGXlkslT/YAVb/R2w/3X6IuFo9MjSLvq9RO5N Im4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=SpPPBdSmlAXptLQcjFFgUwhhJP0UGjqH20/oteDq7nXFkB5W9TU9wEezik7yUtjkA3 ZNbkQtQ6v/XsfjPmgD2Nf71XR3RT9JHXwHH9GWTh0TymBl9K8d8ct+eNDriRLbmxpQlW S2fDD6FfSDI3sanqZfsFbEYdXmITGCV4ZdUTNmC4fjuWAgSpcrRgb746P1f+z8MBSJPk 6xQiwVlto54ASzmkAb5SBOzqBwtqaWei2j8/eroClQue1haWGQjNylDvOrKiRBVNy/UF pLiIMM0Gy4cRe6UEOPQav9E3h5BGnuSwIn4WhdlO/fk7xEBFYNf0hpbJ10sg03Hfu2xD DDiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=1vPSyerq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a17090aa88100b0024730b93a6asi2567294pjq.147.2023.04.19.15.52.23; Wed, 19 Apr 2023 15:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=1vPSyerq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbjDSWf5 (ORCPT + 99 others); Wed, 19 Apr 2023 18:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232494AbjDSWfz (ORCPT ); Wed, 19 Apr 2023 18:35:55 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236131FF0 for ; Wed, 19 Apr 2023 15:35:23 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-74db3642400so4729885a.2 for ; Wed, 19 Apr 2023 15:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943660; x=1684535660; 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=1vPSyerqCt0Qvmv8hwWhHs7+2v7XZAr0KTtgrWL8gjgqfbN4dFPAoAdZKUnWg12ZG3 /YHqSNVuzXAc9b2HHwGH9LBzvgZToUvEu35LDcgR6A9q+XF7KMusQr66TDyHOeFfFrqL dYumZcibZ88UIV3XDd3fu8JgdSeCCADimOXm4NTSmIIENw4jPwsywDQ3Dvfh8vZnU/VF 2cQlWu4iJNzDcz9iAaE1D4BTPYin8nFfRQVUj76zTk1WFPDT9V13d7wvFhn1zjsBbPJz TBf25knHEobu9uNSG14nviJCdobDDbdi9UhzhOzvayqzCnYVdfHDjyFSJBIaB5RURPTv KQ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943660; x=1684535660; 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=L4w2dO7/4ZuIxP1G0+Wn9kt8CVgDVUi/gI0hkk8ojWwr6XeZzZv69dZYxSdLyq5qjG sBp6nF81qeei3SiuatExzpb+ZAjC/ig82w07KHTvwi5UELsuX1T/KL1ts/yCJSgdydK3 571fJAvscfbynHsIliNcEiMlkEhMzNpZXhGLGSNhfCJDG441qCCfZIFYI2394AN83yYR w8OsPRJ6cHGtGRqzY4U3eEFjDHi8/H2TdNB4myW962lpg8eP69MgrnNcMFDYIN+Be8Y0 VnJ64yJYj3jDuefIQIld0Ma64n3EJoiGgZ8+MgjmVpjFQ4Hzt7tbgMkyykEY8AuJmpU9 61Lg== X-Gm-Message-State: AAQBX9ccwH5NOh1fT91hVPy/TBb/yQydAVlP7gSQ2kWKzmSmWAoD8kkc +nYv2euUigyKNFoAH3GJQtVCTglKd2sdXD+kyjY= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646905743437056?= X-GMAIL-MSGID: =?utf-8?q?1763646905743437056?= 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 Patra X-Patchwork-Id: 85618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp710948vqo; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) X-Google-Smtp-Source: AKy350asPcM0kOKv2PO0r4XKdSxVlYpockfvZxwhp+CVHAgl/Y+1OYJ3B2/S6eoVS043ijdQtkMg X-Received: by 2002:a05:6a20:7f93:b0:d9:6650:ef14 with SMTP id d19-20020a056a207f9300b000d96650ef14mr170960pzj.31.1681944470433; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681944470; cv=none; d=google.com; s=arc-20160816; b=sZKffnbMA3LFjfL8jD5nBGA+L2uH8LkEdLLSDpjWWhPIkbjYI51Kl/hypiZu5VdOhd iXLbDMX9/CxxG3HFnqzXG6mEekcxj4/mKIKg4ZMc3u9XAKzjGHqVLKBPRDUVhESwer5A E2qowb5V5QjsRMRUl3wCG/DpVA1MEj8FAERgCeNf1t+ixAPRv4VQ+IphJzdL8dPsBDEp frlwZfySvEaGv8DVY0XxParDOKJtNIVH/dGnAm3zgoajuLeN6z43HVO65SOe2w4t1WNz PdowCPoEW+VDpYgK+/ho57qdck5u5uEJ3MI++17QdM/aVlDDyUckWjaFeYj4xUJjncyg pNNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=92JmYNvjI4h3x1v84zDdO04a6NNcBv03E/psDBTJE8A=; b=b2WvDe91Zv2wDQuG+HWkE1NWwR9cRJSh5eQT1lkuoEBVwVsCtpa/0GMjuvJ/0xP5X+ R6mVGtUGe7qK2Z3w3/Xw38LEe0UfQp+L/4MqEGgQqKz2+KFReLnafJqkKrb/jyTix6jr 5xmOh9v9Iqz3gijmiHGJ2g8r0s9j3xEtWP1QC6bGMTSeFffiYMATbiQaHVqJe0eQCFt7 yaU9U/TLKVNDxcKphYc1Ru3niOkhm10FQFHgNzHzt8NDK2KUb7NWJIHwPvSQRh7q7mkQ CiZz/WFd/rJNsIrajYbNqw3CN5JqC1uy5dQnj5SziZwhtdUt+CcIhpWU2BGt3SbzlFAc rZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=nUPF7sXf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n127-20020a632785000000b005245a7cb22esi368136pgn.674.2023.04.19.15.47.25; Wed, 19 Apr 2023 15:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=nUPF7sXf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233605AbjDSW1n (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbjDSW1J (ORCPT ); Wed, 19 Apr 2023 18:27:09 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1488D309 for ; Wed, 19 Apr 2023 15:25:46 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-517bb01bac9so218160a12.0 for ; Wed, 19 Apr 2023 15:25:46 -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=PJy43iOoVWJzAXxi8o0u5f+adRyFG3jb05p5qHkoaVwLMb908wQ5KgaqkOpZnAGTOF MtUoGNSk1LR86Ak9203U0qP1y3id+UX+Z0cFXSBrGjpqdqeat29woucCuVLa3cGN40G1 0Uiuvz5gRNW5b3f2nbzuufWezhBKOgQI01itUaLnoB8JjPN3vVo3MEPidXy7a7aYazLY zeIGFrgF/Ct7UrEdEvwsRG8F3vB6S6PkrzRakyWMVyH+kpqGncTx3XfwzlqQSrPhSqXb YaV83pC0yqMFbuxkN5aG73DQYApKPRESbv5bwLGRQeRcG8jhPvaSWW/tamP9do6EC6r9 YmOg== X-Gm-Message-State: AAQBX9czsD3FeNz2uTL4IbV2LFYfgpMwcTQ2CRAAL3riodDDJ2jZF5fV plt199bizFE6Be192qTDelu409b4z4rURw/BbBg= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763646605042085353?= X-GMAIL-MSGID: =?utf-8?q?1763646605042085353?= 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 Patra X-Patchwork-Id: 85654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp727866vqo; Wed, 19 Apr 2023 16:22:04 -0700 (PDT) X-Google-Smtp-Source: AKy350aqXwIdV4BE3Dx0V9J096njMjSgFfz6BlMPUSQnnfKXe/tTGX1lNNZTackm2REaEtgWIUMK X-Received: by 2002:a17:902:ea05:b0:19a:a520:b203 with SMTP id s5-20020a170902ea0500b0019aa520b203mr8109402plg.25.1681946524611; Wed, 19 Apr 2023 16:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681946524; cv=none; d=google.com; s=arc-20160816; b=hkt5af9gbMz3qlskMomkQNlJZq+KFtp5qbbumvtNq4dVN24zqth/XynON2KQw19Yas ua2psPjLIHO+TDEf+0H7r3R7JJAL2WHHeHmIt5CnhJ2Kk/ByPKAN7M70ZFV+XhohmELo tipUaafo5JjfivDdjBHZU2l0ArWjPpPYKiFON/fQXkocGwrgK45TBtHP0JY8ukx8DeAp USUiw9ah2xSFWsdNNcbuzppUwV/nBKpXs6EYcpaNsBAzWOlOeJdiH1QjdP6wgdCgOQ8X /N/Mcenj083gT/1JOPlzoyGOkixlhC9EkdPM7HVqLLvfmjV9kXhKVXcGLTmQq/CMISOz 8Fsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=UZh/PAtrTTs3FjrjliQaEKyDcJ4jFTOXGEn9WC1L0fW6317jAc5DDwi2AkhtUFOv42 x7h6iG3lRbnEZQ4HwwN8fmoBo9BL1C+jSjdlwL3kPWUHqTnsWGNjsmnnSGoPmQQ4Oo0m UVTmSVhocf35+AP1lPdiMNeMTM+Lf8HiU1Uqh7PZYNP6JlzZKQ4TA38bsiUNigBvbj0h PHOBu3H5Yi5/0/crbyHUNr1FoRQGxFQjzioeGn6Vg/r3QAp6ko4QYN/g8jkq2wkVf4CP Ennr6c2+eAaTUszLFsCpgt71rIDUYAh/JZemSflKzy07sEjjjjzboDyMaYtT4q6wMAJB SlCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ntvu7mkg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170902b28200b001a64c693836si16665625plr.477.2023.04.19.16.21.30; Wed, 19 Apr 2023 16:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ntvu7mkg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231698AbjDSWfK (ORCPT + 99 others); Wed, 19 Apr 2023 18:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233782AbjDSWe6 (ORCPT ); Wed, 19 Apr 2023 18:34:58 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1D5359C for ; Wed, 19 Apr 2023 15:34:29 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1a8097c1ccfso5411235ad.1 for ; Wed, 19 Apr 2023 15:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943592; x=1684535592; 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=ntvu7mkg4AjS+6jbV0G8nxsZY4v30uZ4L6H/4yKw7ILa4JZ8ImylR4y1268f4Z50RK yp3K3jByMPLCRLbHX4cBVCaB/0HMZJcwshCnzpnr/gUVuDntELj2Puzl5waJ86AQM7L9 davbmjlnfHoalz4Q2lB4J0u4kB5RV16Hhc3wzLWodVpXh3zvq8PFAGReDNP2mrS7xdGD s6Il5ZWD0yfr64TRt9aWFImjZVZA3EaV0LaCFlieNMHfOgF+upQm4kqT5dlP7kvhL/I4 rM96oHWIPJOoV8LegDMD0aG63ZYJqSc4uX4MGM5DeB8TnEBI9TTREJlSelnXxaSW74bU b1Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943592; x=1684535592; 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=hOOk/jX+yH6LOaMC7JHVHxwyPbhtYxz6YgtmyToDMzBBmFcErAK1A/IFsu+LuHvdsl 85ubGq5voclPx2YirW3foTJLratiY6R5027c617PsQnIrdueMKnOEaVzhNd6M7H+qgFw CS4XSahYNU9inRaWmhSrM/dp4y9rw9NpYV38rBfjaLOzFeHC+kOO0fizVqFM0O6EhCHf eG++myLFuNL1QNhHfmqhEOG9l+PoxrVr+IUHbFffiA+iCjnf3V5Y8AS3OF4qXP+29bW4 7lJ1NmN1SBE0E35IbxU2ZHoaC3LOe6JbdgTZV021LWYynwyk6IoEDlHhfYd8cPVQ/MtI 3Qtg== X-Gm-Message-State: AAQBX9eAavEsslDaK8TKn5DzL7IdIy3sbwzbt1G/dDXaoPHtvixbRots MTWtpxoZPg8CW93CxxGsUBMQAp9U5A1rqgXVVgo= 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763648758564760430?= X-GMAIL-MSGID: =?utf-8?q?1763648758564760430?= 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 */