Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3737073rwe; Mon, 17 Apr 2023 02:49:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ZUMGpXWu9A79CQHExajTMa78wUH3XAiOVjJmgELjAtAF5yGnPUkG5T/4hjFvp33DlJcp5Y X-Received: by 2002:a05:6a20:9389:b0:ef:cb4c:c23e with SMTP id x9-20020a056a20938900b000efcb4cc23emr3974277pzh.29.1681724960638; Mon, 17 Apr 2023 02:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681724960; cv=none; d=google.com; s=arc-20160816; b=LXAmVO/oVhcabBAzTR9KtK/+1ipDuxV2PU7fvZQM++bIcfMVV79HzoCkLP/vWdfkS4 72k3iUZf9GpM2KXgHyZneUa+mpzpzsFvd8K3V17KdrbtTdvaVUWhKdFUc7iglOwar7mU 39/zPOhXyOajGcPP2QW9UkmaUVgaPjcrVQWWLXONib5mNC91f/m7YYtMJz9PDRArPWiU Ux5rshFlF96gYfz+Sdfwp8uMVpI/Id8jgOpl/lfB+66BmeWBzSKvvEg8I4EDAzGc0UJd 98hDrVM0uH20WIFs+DZK0TRK4sRzvmP+WUNH/vZiVx4vEoaVw2+A8HoV4e/E/GFTVbeE SvcQ== 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=2fGi1MLbow74u9LCwuRCcYcOtcQgmOL5qVgQ1J+ydMI=; b=ZroWLKcNRES6uNfCLgGmOFEdp8NfqTvGH+pf4E31wqlKwJKjJWe+Yttg0hxYQNagp8 c162L0a6H8W/EzZDXRV/x6x9rc1bVcn0Dc8GJ4XsYIDuNZGGDcChLXUjp6pGVGcfoNtJ Wmuzolr6XR4tk4Sv4JlkeLM8mQfXnm7hGCzj7+dUdwoCBib5EBFAPT+3o6U3nJo5G7Y2 7smnUMWcsbkHOfknIH+LshjKS4mthecyZpe7yzr6s6VmRKGWnfoaKeofHj1eIl8VjJmn swXnhuFyJOW6tzeZnpHg8qp/gYMaGNlWlg1gVT8LRv6ntpSsqpx8nT7eKvGcrDfrqlft D/Mw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk11-20020a17090b33cb00b0024750453f25si7441956pjb.185.2023.04.17.02.49.06; Mon, 17 Apr 2023 02:49:20 -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 S231128AbjDQJsT (ORCPT + 99 others); Mon, 17 Apr 2023 05:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbjDQJr7 (ORCPT ); Mon, 17 Apr 2023 05:47:59 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71D8859C8; Mon, 17 Apr 2023 02:47:21 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxEk6OFT1kPuMdAA--.34790S3; Mon, 17 Apr 2023 17:46:54 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxtryKFT1kyagqAA--.47974S12; Mon, 17 Apr 2023 17:46:53 +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 v7 10/30] LoongArch: KVM: Implement vcpu ENABLE_CAP ioctl interface Date: Mon, 17 Apr 2023 17:46:29 +0800 Message-Id: <20230417094649.874671-11-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230417094649.874671-1-zhaotianrui@loongson.cn> References: <20230417094649.874671-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxtryKFT1kyagqAA--.47974S12 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Zw4fJr4xJrWUJF1rAr1kKrg_yoW8JFy3pF 4DCr90qr4rJrWxWwnxtws3Wr1aqrWkKr4xZF9rX3y5AF42kry5GF4FkrWDAFW5ta1rGF1S qr1rt3Wj9Fs8AwUanT9S1TB71UUUUjJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b4kFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6x kF7I0E14v26F4UJVW0owAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAq jxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E74AGY7Cv6c x26rWlOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4kS14v26r12 6r1DMxAIw28IcxkI7VAKI48JMxAIw28IcVCjz48v1sIEY20_WwCFx2IqxVCFs4IE7xkEbV WUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWDJVCq3wCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Cr0_Gr1UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvj4RKpBTUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 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 9ad6a285cbb4..e1e6167699de 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; -- 2.31.1