Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp912226rwr; Wed, 19 Apr 2023 15:19:41 -0700 (PDT) X-Google-Smtp-Source: AKy350Z6sZGDMi0BwIuuEk5MAf6L+9bw87V7sHbLX+PGb8lKSPvC9HxHGz4YwDwj2GxeluMWyJ34 X-Received: by 2002:a05:6a20:729a:b0:ec:c8c2:36b7 with SMTP id o26-20020a056a20729a00b000ecc8c236b7mr147681pzk.14.1681942781585; Wed, 19 Apr 2023 15:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942781; cv=none; d=google.com; s=arc-20160816; b=Zoglpc5TW/IsuPRx4valazyhE7bAZtv+0Z4QEFDG1KmMXwczTpScDhyBTgMsXfzzWQ u5Hh8+lvHoJVOASZ7/PA4qYlt45L39yMexTUIpYlYcvsrj+LhsrJ2qy6rStzBa3EaAQp LOdJq9OZT5PosWRzLUZT9lTOxYNKer8bH+fNmTMWcl7aBNgWfhtK5NanWByuJhgybdsP HqhvbyGoO57eY9GVTuQawLheqgi7yK3ZGs40jJQba+q55mjCdQLxUFeSUA7hO6Bq7GXv faCXCo5mURgivkH8w9PwBs327maQDBNKl3E6XAxWXzyxgF1beffHO29ejkXT0ngRwxpv Zn3w== 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=uwIdkHCarryXV50I6knz0ZklcYwS0nTZYHahvAAioGA=; b=PthpBKMzt5pjMKUiHCrmGa6c8uEmhsl0nLbWrjlQrHwOoAxaOAPSzgAukIzkrBzKw4 3QpBMh5r1s7cSNb6deSJSaywCnNzg+//apcGYh0pq9qPD4Q9luJB28RnBxOHpVChE8sh wA6IyFBlha+GyMsiOjdJuBVHcBwdLgGm66Nt3q3R92RGnTQRqGE7LiOLsamv+gMCk04i S8ZMD93GujWaUqFCNknmABpIkIULRC7DzsUuIEVK7QKTBU9ExjCglt+3xpRyylRwsKVF esOBNc9z2B0J4muDWqMkgdXgRN1IiietKRWbXAnB/jxniosJ0JkC5mzkSbmJ1mR52gCN HZ8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=JAfyJwlL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a625214000000b0063a149e3c85si14604659pfb.401.2023.04.19.15.19.28; Wed, 19 Apr 2023 15:19:41 -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=JAfyJwlL; 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 S232498AbjDSWSx (ORCPT + 99 others); Wed, 19 Apr 2023 18:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjDSWST (ORCPT ); Wed, 19 Apr 2023 18:18:19 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894EA6EB5 for ; Wed, 19 Apr 2023 15:18:00 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1a9253d4551so4764355ad.0 for ; Wed, 19 Apr 2023 15:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942674; x=1684534674; 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=uwIdkHCarryXV50I6knz0ZklcYwS0nTZYHahvAAioGA=; b=JAfyJwlLZTLpeO+0a9mP+Qz17gHyrei/u3hvU+Y1oEWg9aDIafnfffPw2WLQocmCE5 thEwftksAEQCxymE79XbmXlY3CV86W6kKDPWDlsoieUM1U98liDXsdwKh0TtzMRMco/6 2qgFOkWb8NmcTouc/FLGToAZLWlsyjEWM3W1S9eitYQ6PZtGjRV1E0Bh4dYyak7MqlLF NqImRVNGkomVidir55QeblFMKk81mgA2duY/+3llfMenErvbAqjZMXeQVvmExrFa536W fZATF/TIP+lPFweeamhhj205CiSSkghmiFgf4j0xA47+WlMqYFC57GJCbBbKkv5f7DR4 f0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942674; x=1684534674; 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=uwIdkHCarryXV50I6knz0ZklcYwS0nTZYHahvAAioGA=; b=JEkSGfaabKFZVPhtk2PPaS+7eEM9/u6xQzV//nqLwBCU4rD3DK7o99YSFAKKHmysQ6 624lqN5FuFq5d2i2GCcNx9E09TWH0eC6xWyZY0CaKYbLIB0a3yCL9ROqwmniflnj1fIl BlZ3C4k1ry/qot83RicDXIyJJn4VFu3WAudqWdGeeLAPVWD4VLpm7bsV6uieTw3TmH37 2vz3SEStAyjwVMzBqdSgo4/bq0030Mdhz80QIIqe4d8Ciu1+UQM3s8k/7s892aJFHq87 9y4BnlSX5MAAYdRu24lVxPGhlpuHmrFm392hYnAuq62lx2Xf1XyHeDxPwTvg3rTKgQI6 HsDQ== X-Gm-Message-State: AAQBX9dsOjo9Ky7pQuqi/NhozxvxJ4fCSzQDU1q26X6UEWRWEMK3vJh5 griDhacyI0IHCZqqHtGoQoAyLiBiG5qXOLzhpyg= X-Received: by 2002:a17:902:ce88:b0:1a1:f5dd:2dd5 with SMTP id f8-20020a170902ce8800b001a1f5dd2dd5mr8081414plg.13.1681942674035; Wed, 19 Apr 2023 15:17:54 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jn11-20020a170903050b00b00196807b5189sm11619190plb.292.2023.04.19.15.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:17:53 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC 11/48] RISC-V: KVM: Use the new VM IOCTL for measuring pages Date: Wed, 19 Apr 2023 15:16:39 -0700 Message-Id: <20230419221716.3603068-12-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419221716.3603068-1-atishp@rivosinc.com> References: <20230419221716.3603068-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The newly introduced VM IOCTL allow the VMM to measure the pages used to load the blobs. Hookup the VM ioctl. Signed-off-by: Atish Patra --- arch/riscv/kvm/vm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index 29d3221..1b59a8f 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -11,6 +11,7 @@ #include #include #include +#include const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_GENERIC_VM_STATS() @@ -209,5 +210,20 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { - return -EINVAL; + struct kvm *kvm = filp->private_data; + void __user *argp = (void __user *)arg; + struct kvm_riscv_cove_measure_region mr; + + switch (ioctl) { + case KVM_RISCV_COVE_MEASURE_REGION: + if (!is_cove_vm(kvm)) + return -EINVAL; + if (copy_from_user(&mr, argp, sizeof(mr))) + return -EFAULT; + + return kvm_riscv_cove_vm_measure_pages(kvm, &mr); + default: + return -EINVAL; + } + } -- 2.25.1