From patchwork Mon Apr 17 09:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 84127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2009980vqo; Mon, 17 Apr 2023 03:17:15 -0700 (PDT) X-Google-Smtp-Source: AKy350bAIWWbqpQEQnaF7Fj5LxbA1i6eq5wE+e6HIGfzjlMvbqDubGN+fPIuScW9HXeKFa7iA1eY X-Received: by 2002:a05:6a20:a01c:b0:ef:8ee4:f0f3 with SMTP id p28-20020a056a20a01c00b000ef8ee4f0f3mr4182712pzj.3.1681726635173; Mon, 17 Apr 2023 03:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681726635; cv=none; d=google.com; s=arc-20160816; b=phPqkhfEFAjZ3bXCd9UK5J4dxZRwT3m06DiJGZ3y7GgGeYmL+cbWuCjP3NEyHGqxs2 6vXumxaE45OAwdKiFwSFhxUsviHEdnEP36246RfsOsGXeVvImg9tJeeckW8B2XsWTzVi Nj/u34d8MiIINFcsCsZobIkQxokapUr2KKfsQbX7etxlm40hHE4aAuihdGjEeWFbE/ao CyM85Rkd7DsjbIua5OkruPKtjLW+YqjoSM5+inJ0qYVs9afbnhaqcZgkoFimhZN4htya EyqZsezFlTaHY2qwTGKrFh9hKaFVLqBIa2sryPRe+GR/MYzV/T3K5LauZp0VcZG+ofp3 GXMQ== 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=EticSFMmJgDeCSrP9VpfLIwB0sSeu+mCgf3ta5bhAjQko4RHbjKCPSdYePWEyfThvq muouVmAZxaAfqAKVdiQRy6uo2LMDrgbHoveqwSeU1gl3A4kH2E5MZdolJnIYhwAsBqt+ Bm8JRMsesrBvXevayzpgbkF5g+AKBMaDgzQ82rEYN3XW6WPuV8rylmxaPH5OS4NXY+D7 7Vn7fa8LCJW0T7W4WPIyj5HCeyiCYLMbfvmsInAzJkpFHD6F+WyWnGf922/JgfioxQXX m9yRIzPdx07ysMrpxmgRbSg0tPlT8MLSXvchc9wA6Y4wFPBZjecF1MxG38YgJK3nODCe Ak1Q== 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 t22-20020aa79476000000b0063b8e26e438si2891930pfq.97.2023.04.17.03.17.00; Mon, 17 Apr 2023 03:17:15 -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 S230185AbjDQKBo (ORCPT + 99 others); Mon, 17 Apr 2023 06:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjDQKBX (ORCPT ); Mon, 17 Apr 2023 06:01:23 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 578DEE51; Mon, 17 Apr 2023 03:00:44 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8DxldiaGD1kOOYdAA--.51563S3; Mon, 17 Apr 2023 17:59:54 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx57yWGD1kua0qAA--.48254S12; Mon, 17 Apr 2023 17:59: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:59:30 +0800 Message-Id: <20230417095950.875228-11-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230417095950.875228-1-zhaotianrui@loongson.cn> References: <20230417095950.875228-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bx57yWGD1kua0qAA--.48254S12 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Zw4fJr4xJrWUJF1rAr1kKrg_yoW8JFy3pF 4DCr90qr4rJrWxWwnxtws3Wr1aqrWkKr4xZF9rX3y5AF42kry5GF4FkrWDAFW5ta1rGF1S qr1rt3Wj9Fs8AwUanT9S1TB71UUUU8DqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bcAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26F4UJVW0owA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7 CjxVAFwI0_GcCE3s1ln4kS14v26r4a6rW5M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF 6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x8ErcxFaVAv8V WrMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262kKe7AKxVW8ZVWr XwCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv6cx26rWl4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1l4IxYO2xFxVAFwI0_GFv_Wrylx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK 67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI 8IcVAFwI0_tr0E3s1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4UJVW0owCI42IY6xAIw20E Y4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr1j6F4UJwCI42IY6I8E87Iv6xkF7I 0E14v26F4UJVW0obIYCTnIWIevJa73UjIFyTuYvjxU42YLDUUUU 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763418188097733835?= X-GMAIL-MSGID: =?utf-8?q?1763418188097733835?= 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;