From patchwork Wed Apr 19 22:16:39 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: 13217494 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF2ABC77B7F for ; Wed, 19 Apr 2023 22:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231347AbjDSWSg (ORCPT ); Wed, 19 Apr 2023 18:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbjDSWSR (ORCPT ); Wed, 19 Apr 2023 18:18:17 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAC940D7 for ; Wed, 19 Apr 2023 15:17:54 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1a5197f00e9so4657725ad.1 for ; Wed, 19 Apr 2023 15:17:54 -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=jc4pizBfSkWIoUR7oVc9CnWhacekD3nFSIaG68iwbJo0MaqW5frRUYNU+LBdvIcKJa 6QvU4Xxad8UU8AZvwULjoa8JEG/cJ2F5Duy/ekgxWjkkA1eJxH+oFj9Jc1uZs/MgExuq Dr2Ke8ORwn9mPv6oo7gYCJe5KtEIImbPxPCo3GnModIhq7dpFrJSEYJ2iWqVioxTFAzN xbOKU03VXbn9NghUKNp24xBHs1iobw3FTlw/5f0OKDGx4bz0Lp4YcZS74Pleah4owS7v C9UoQpbqE+pgzHvWDHD/qT9lPgdVcjmoawkvKvvgE9nCBXKhMEf9yfCMdyL9qMMIv4KN MpNQ== X-Gm-Message-State: AAQBX9fjyyJmGnHLKHzMUuo+O2XZL9m2ha/MoVsgqzaOWvKTUAJROopL wzZIwpxC5y8SHG8NzN4IRZRy9A== X-Google-Smtp-Source: AKy350aOeQnqsiOOnUYsijZU0I/0P7RvEF6TJy/X0/H7ROAFo8Dof2s5JoE26B/8+FVZEZPKo3gc/w== 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?b?QmrDtnJuIFTDtnBlbA==?= , 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 Precedence: bulk List-ID: X-Mailing-List: kvm@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; + } + }