Message ID | 20230530015223.147755-11-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1877075vqr; Mon, 29 May 2023 18:53:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ztoFWFJV90YV/4GRnz/7q2srBh99wHm0Gfvy0VQ5i9rfBcUftmjKDpt/5waJsAQ2DKm58 X-Received: by 2002:a17:90b:1190:b0:256:6462:e399 with SMTP id gk16-20020a17090b119000b002566462e399mr7451652pjb.5.1685411636019; Mon, 29 May 2023 18:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685411636; cv=none; d=google.com; s=arc-20160816; b=cZS7JHM4WWV3J+o4Dz1Ir9OeCwfuBeq7b3h+ZtPz6SXLLNV/M59XpzYKm1EmTzcJ2z RGsyDs5vywNg2Jbg8PHD8/TYqEW7aoYq+bIh7yenzLTw8TtQQBexrp4UHbjzc7IsSi2v YMfDpzs3eGAKP2CFUxi1c84YxeUY7GJDsIQL2GXOJtpKK7sTO61kB+VxAiZcIfSXHfRl 5h9OtzssLTFO1Xjj/3fugk4qHbFgMjWuI5sB5e//Sb40sZMn2Zi79fCjTirChyZfMyPn E8IYW7BlKMk2J4IMPoCZQF0+E3X32KEnpZNHYPl5DURYZf72m0t0/fVRFbIHZSfsFO06 a5qA== 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=l/9x4rIjzXf7Y6CBSjV9tplSRvNTTDIOKcCrZgC/GTI=; b=m/Jd3ToHiIxopA4Mf6Vi4a/rHJ6VBgyHOb91dQSZLLYFfyg7vyr93g9VAioxHzr9bU WScUf8bcY5J9Mjj7gXe9Um/rI+gnf6QutIInBVkM0Xt0lYhCm/W0g6xFPqISY9rt3W0V QiMxg3d2xfsV2EgE8spBMvQITRnFNaFT7eZzuq46tjxCefwpfXisGdzOFvrdos2ZMEzg PnLir/iv040sjmKXcW2vFUgOW09BgJK5jyg9ciFtIeypQVk3CBg/ilP4BPvyWSCv7PRG w4CZYSzsAUk1UNue4B0GtlRwmF7Kd6mGzUsbL2DJHXSXNKdSADH60PW8C0Hd2nxYFQGu OpRQ== 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 f12-20020a17090a654c00b00250ab2f31besi2671757pjs.71.2023.05.29.18.53.44; Mon, 29 May 2023 18:53: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 S230104AbjE3BxG (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Mon, 29 May 2023 21:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbjE3Bwe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 29 May 2023 21:52:34 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB4E1F7; Mon, 29 May 2023 18:52:29 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxXuvcVnVkOWoCAA--.1158S3; Tue, 30 May 2023 09:52:28 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxQbTYVnVkQNZ_AA--.12077S12; Tue, 30 May 2023 09:52:28 +0800 (CST) From: Tianrui Zhao <zhaotianrui@loongson.cn> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini <pbonzini@redhat.com>, Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, loongarch@lists.linux.dev, Jens Axboe <axboe@kernel.dk>, Mark Brown <broonie@kernel.org>, Alex Deucher <alexander.deucher@amd.com>, Oliver Upton <oliver.upton@linux.dev>, maobibo@loongson.cn, Xi Ruoyao <xry111@xry111.site>, zhaotianrui@loongson.cn Subject: [PATCH v12 10/31] LoongArch: KVM: Implement vcpu ENABLE_CAP ioctl interface Date: Tue, 30 May 2023 09:52:02 +0800 Message-Id: <20230530015223.147755-11-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230530015223.147755-1-zhaotianrui@loongson.cn> References: <20230530015223.147755-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxQbTYVnVkQNZ_AA--.12077S12 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Zw4fJr4xJrWUJF1rAr1kKrg_yoW8JFy3pF srCr90qr4rJrWIgwn3tws3ur1aqrWkKr4xZFZrX3yYyF42kry5GF4FkrWDAFW5tw4rGF1I qw1ft3WUuFn8AwUanT9S1TB71UUUUjJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bx8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aV CY1x0267AKxVW8Jr0_Cr1UM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487 Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VCjz48v1s IEY20_WwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI0_ JF0_Jw1l42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxFaVAv8VWrMxC20s026xCaFVCjc4 AY6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26w1j6s0DMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWxJVW8Jr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0zR9iSdUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767282191537074174?= X-GMAIL-MSGID: =?utf-8?q?1767282191537074174?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
May 30, 2023, 1:52 a.m. UTC
Implement LoongArch vcpu KVM_ENABLE_CAP ioctl interface.
Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
arch/loongarch/kvm/vcpu.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
Comments
在 2023/5/30 09:52, Tianrui Zhao 写道: > Implement LoongArch vcpu KVM_ENABLE_CAP ioctl interface. > > Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> > --- > 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 278fbafc59b4..5a88f815c412 100644 > --- a/arch/loongarch/kvm/vcpu.c > +++ b/arch/loongarch/kvm/vcpu.c > @@ -186,6 +186,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; It is a little strange to check extension of the whole vm in enable vcap capability. can we change to usage like general architectures? > + if (cap->flags) > + return -EINVAL; > + if (cap->args[0]) > + return -EINVAL; > + if (cap->cap) > + return -EINVAL; Do we need check args[0] and cap here ? Regards Bibo, Mao > + > + return r; > +} > + > long kvm_arch_vcpu_ioctl(struct file *filp, > unsigned int ioctl, unsigned long arg) > { > @@ -209,6 +226,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;
在 2023年06月05日 21:12, bibo, mao 写道: > > 在 2023/5/30 09:52, Tianrui Zhao 写道: >> Implement LoongArch vcpu KVM_ENABLE_CAP ioctl interface. >> >> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> >> --- >> 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 278fbafc59b4..5a88f815c412 100644 >> --- a/arch/loongarch/kvm/vcpu.c >> +++ b/arch/loongarch/kvm/vcpu.c >> @@ -186,6 +186,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; > It is a little strange to check extension of the whole vm in enable vcap capability. > can we change to usage like general architectures? Thanks, I look up this interface of other archs and re-consider it, and I think it should be removed. Thanks Tianrui Zhao > >> + if (cap->flags) >> + return -EINVAL; >> + if (cap->args[0]) >> + return -EINVAL; >> + if (cap->cap) >> + return -EINVAL; > Do we need check args[0] and cap here ? > > Regards > Bibo, Mao No need, I will remove the two conditions. Thanks Tianrui Zhao >> + >> + return r; >> +} >> + >> long kvm_arch_vcpu_ioctl(struct file *filp, >> unsigned int ioctl, unsigned long arg) >> { >> @@ -209,6 +226,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;
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index 278fbafc59b4..5a88f815c412 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -186,6 +186,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) { @@ -209,6 +226,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;