From patchwork Fri Apr 7 01:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 80608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1429420vqo; Thu, 6 Apr 2023 19:02:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YEhUA3yn44Ei6Fhls3Q5+xFfn6QZ7OW90SQJbq0MVdE/Irjv6olKvgI6E+AB4nB75ATk9c X-Received: by 2002:a17:907:7f06:b0:92b:e330:a79e with SMTP id qf6-20020a1709077f0600b0092be330a79emr404180ejc.29.1680832976897; Thu, 06 Apr 2023 19:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680832976; cv=none; d=google.com; s=arc-20160816; b=n3MdC9C0FlLgMiPetdotea/PVxxKM4E1/kicCKIMxAnH6BoBtqWhfpnoEjXlIvl/Nn uLr9UimiIGTOsEhMh4qzBVCQlfoHNVnxtDAmq+4wR249g0QVmaiNxYLEQDtuQzUq122L qhtvPgXUOKkWdjSkuCWjXECeJWpjYhe/6ZPRy+cNoF47NjnnwmCLZV0JDstPgI5jeWV3 4dJH/X55bEkOTxihwNuBcITbWU+D+HK2EbyefKk1sqwqFbjd8A3O3995jw4T+xB0Sko+ MNo0ONyXGgdhJBr+zyzoxGIhIyOEQWm23vit30EbH+aXbOvEyis7Po6zv79u79I+yB7S tYIw== 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; bh=B3ROWaxyIsYuKzYKlOcCmhaFJGtMbp3WKlM1SH2N9EY=; b=dNPVnA8gaEgcu7sOhHc0Lxoqsd4YUUc27ABMyP0OafPqxHj6Tc7YIpFb2tOJq03YJm GSq4pY1f51dXxnQ/yN9u63PTDuuSrrcyWuV1aha6FsCywV5ot9oaieZIp+4Z7D5TK3/D OslID6w8aCBrkzX7bweIvUCCltVWJybav3eR79kAH5o11a+fkkS/3ZsZ+E1CpGukVPee KxNh+pVw9QmXfqub2F3f/WLlg7RelSQNBAT2SkhV7G9qvj8Cc5m99GkWNLE7yWsND3Bd UnOH2rweNQNk9rHRXuzayuXNWjxzJEyonhJm63CfWqLEIS5CQE037SIY8kQCrjCygZ6U ykAA== ARC-Authentication-Results: i=1; mx.google.com; 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 hf12-20020a1709072c4c00b00930e86db8fdsi1436167ejc.938.2023.04.06.19.02.33; Thu, 06 Apr 2023 19:02:56 -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; 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 S240080AbjDGCAw (ORCPT + 99 others); Thu, 6 Apr 2023 22:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239637AbjDGCAU (ORCPT ); Thu, 6 Apr 2023 22:00:20 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64B5A93F1; Thu, 6 Apr 2023 19:00:12 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxYU8qeS9k1aYXAA--.36781S3; Fri, 07 Apr 2023 10:00:10 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLL4jeS9k17sXAA--.23369S12; Fri, 07 Apr 2023 10:00:09 +0800 (CST) From: Tianrui Zhao To: Paolo Bonzini Cc: Huacai Chen , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao , zhaotianrui@loongson.cn Subject: [PATCH v5 10/30] LoongArch: KVM: Implement vcpu ENABLE_CAP ioctl interface Date: Fri, 7 Apr 2023 09:59:43 +0800 Message-Id: <20230407020003.3651096-11-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230407020003.3651096-1-zhaotianrui@loongson.cn> References: <20230407020003.3651096-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxLL4jeS9k17sXAA--.23369S12 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Zw4fJr4xJrWUJF1rAr1kKrg_yoW8JFyUpF srCr90qr4rtrWxWwnxtws5Wr1aqrWkKrs7ZF9rX3y5AF42kry5GF4FkrWDAFW5ta1rGF1I qr1rt3Wj9Fn8AwUanT9S1TB71UUUUjJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bxxFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aV CY1x0267AKxVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487 Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VCjz48v1s IEY20_WwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_ JF0_Jw1l42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxFaVAv8VWrMxC20s026xCaFVCjc4 AY6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26w1j6s0DMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8Jr0_Cr1UMIIF0xvEx4A2js IEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvj4RKpBTUUUUU X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS 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?1762481119162731140?= X-GMAIL-MSGID: =?utf-8?q?1762481119162731140?= Implement loongarch vcpu KVM_ENABLE_CAP ioctl interface. Signed-off-by: Tianrui Zhao --- arch/loongarch/kvm/vcpu.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index 9ad6a285c..e1e616769 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -187,6 +187,23 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) return 0; } +static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, + struct kvm_enable_cap *cap) +{ + int r = 0; + + if (!kvm_vm_ioctl_check_extension(vcpu->kvm, cap->cap)) + return -EINVAL; + if (cap->flags) + return -EINVAL; + if (cap->args[0]) + return -EINVAL; + if (cap->cap) + return -EINVAL; + + return r; +} + long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -210,6 +227,15 @@ long kvm_arch_vcpu_ioctl(struct file *filp, r = _kvm_get_reg(vcpu, ®); break; } + case KVM_ENABLE_CAP: { + struct kvm_enable_cap cap; + + r = -EFAULT; + if (copy_from_user(&cap, argp, sizeof(cap))) + break; + r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); + break; + } default: r = -ENOIOCTLCMD; break;