Message ID | 20230915014949.1222777-25-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp744467vqi; Thu, 14 Sep 2023 18:53:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGb2eSEs6jaEBKsq142KCYZLxwExaAdsfR0ZE2Vmcl4d2A1wD2NqvwSo7WOdqGRJtfrjIHa X-Received: by 2002:a67:db82:0:b0:44e:d729:2a03 with SMTP id f2-20020a67db82000000b0044ed7292a03mr404665vsk.25.1694742838192; Thu, 14 Sep 2023 18:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694742838; cv=none; d=google.com; s=arc-20160816; b=UTfb13sMy88Nh7uUBQjMKXy9qu3PFseTCKwj57kTdoE1UO28CwKLr9nsYC+QQLzXri jvOjXAaeXVL5mXFNej5Lpx67gS5EpAMGVZuagIgv5h4/kzAIz8s9s0Rmprk2SOhyJqkR ujkjpILhUDjF2/G/NVLc9ddLs+fNK1TDgzd/FZzbj8W84a80obCb/27oySr5wr2FtkNx FnPGXCdKuRbSy1I7iYbx2bEefOXAxTb0u6nat+WQIM0tQPnNbF774FcPv4p6ggqeL57e ek6ztwpFSNmYWJ+N74NxmP5oAZ/O0Lna750c6dD9ZNHtSfgNldOh2Dvx8Z38QKj3S3oM 4wHg== 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=Ta/k1hzNa7zlxNwF4kuOedIHoFXR1zhVqF0Bb+Q4AEI=; fh=ejoaVAUUbBXsA/6jM/beuI9xCYtV2osdR9SpI7hjY84=; b=digB5iefcSvl40AIYm0ZfeS/CbCF1mUDqgxwS2j1Nd5tm9WP70jgILd9tQh5QpfCV/ Owg82sIcKIU51m1WIYzgQTImd6KByM51Nf3hlAcehg1yK+1ZoGwBJiFyiSWxF9wq/wUa ZssKTN60FdM8c1UowsKJV22eNGhzlJya6Tjgsv43j4glkWEZzmDg3GrUHM/EAI6xZIf0 P0mTRnll88GEB8P3ag+/euuBv06UA/Xh1qY7JGGBA3p7ypyZ74lPoTrO2zeIl0zahBL/ XQSaK8jhDI/xFuZ6+ycQKer/hjXPRBa7N/cQma/FOG2hvrrLfiUraJ6P7fuV9k8XGWfk 4doA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id az1-20020a056a02004100b0056a1ed17deasi2377454pgb.675.2023.09.14.18.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:53:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0673F8312283; Thu, 14 Sep 2023 18:53:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjIOBvP (ORCPT <rfc822;pwkd43@gmail.com> + 33 others); Thu, 14 Sep 2023 21:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231268AbjIOBuw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Sep 2023 21:50:52 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B2D135B5; Thu, 14 Sep 2023 18:50:15 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxJuhMuANlbf8nAA--.18113S3; Fri, 15 Sep 2023 09:50:04 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axndw9uANl+ioGAA--.11927S26; Fri, 15 Sep 2023 09:50:03 +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 v21 24/29] LoongArch: KVM: Implement handle fpu exception Date: Fri, 15 Sep 2023 09:49:44 +0800 Message-Id: <20230915014949.1222777-25-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915014949.1222777-1-zhaotianrui@loongson.cn> References: <20230915014949.1222777-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Axndw9uANl+ioGAA--.11927S26 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 18:53:24 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777066666070303660 X-GMAIL-MSGID: 1777066666070303660 |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
Sept. 15, 2023, 1:49 a.m. UTC
Implement handle fpu exception, using kvm_own_fpu to enable fpu for guest. Reviewed-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> --- arch/loongarch/kvm/exit.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c index 004b91055a..a91811918d 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -638,3 +638,29 @@ static int kvm_handle_read_fault(struct kvm_vcpu *vcpu) { return kvm_handle_mmu_fault(vcpu, false); } + +/** + * kvm_handle_fpu_disabled() - Guest used fpu however it is disabled at host + * @vcpu: Virtual CPU context. + * + * Handle when the guest attempts to use fpu which hasn't been allowed + * by the root context. + */ +static int kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu) +{ + struct kvm_run *run = vcpu->run; + + /* + * If guest FPU not present, the FPU operation should have been + * treated as a reserved instruction! + * If FPU already in use, we shouldn't get this at all. + */ + if (WARN_ON(vcpu->arch.aux_inuse & KVM_LARCH_FPU)) { + kvm_err("%s internal error\n", __func__); + run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + return RESUME_HOST; + } + + kvm_own_fpu(vcpu); + return RESUME_GUEST; +}