Message ID | 20230626084752.1138621-26-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 k13csp7335647vqr; Mon, 26 Jun 2023 01:53:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VMXKw3mMjGqo3/7g4u8AKpFs4vlX3iOiE4ns294tMJepj37bSo3CMPm5MXXPhfHGTvN45 X-Received: by 2002:a05:6a20:394c:b0:123:3f03:68f9 with SMTP id r12-20020a056a20394c00b001233f0368f9mr17171236pzg.61.1687769588640; Mon, 26 Jun 2023 01:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687769588; cv=none; d=google.com; s=arc-20160816; b=YvtCmq0Uid4QXCQmI/+21HPhel2fEW0uckeA02USU8m0e3g9MlQZbd4kcs3tiZRRFm bvA+6TrQ8emtQz3qdyMRBoDgOQZ3JsRvoBy94KoYJJYIbmAU8wfl5mVCH1aptrZPs/ZO gYjP9JW3nVem8uCffXOkmk3bojLb+e1iWbAqRb1viMtGjsFw2xsjGL3aKqop86vyZF87 cRO/gTvPIYHx1DM9hWAuwpEJMeFHs274rHMeb6XMTX2r5/XUTTi9z4a3boZ3R9Kn0heV n4+UwDHr1gbth0+aNLqxKTH5CkA63EEMgDcD6n+0y6yxhiy2seq5ejAHJPjOawT1wocI BSLw== 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=Oi1kwRffeA95yRnB5eJTr9VC8FTUO5MydfvkcggDLjk=; fh=FJJE1KfQOXNgUCxk/Gxke8tBG9gBLo3aFI+sNzAMBeU=; b=iU1uHWQ/bcJrFk6ZMLhaLWaochIDXExSskfZncPk4bx7sY7qlV/AEFubqFyMp2VYX4 6NedpWH+1iXru66IZS5xTf20y50eINApWN9b4g3MqfL/8JU3IwX68jy+MN2qLL0fxWYm v3GPFtmr4RHk2ppnTi89xzvA44VEUF8UubwLoz8dl1AyZ6LU6EYRP1IBq6Op7zgBv9P9 hv/+hbrS2VQ8+dwWS9TmQ1E0A/PLOOVkuzCTHMkii+lV2r0mt3xq9u3DuDDlbKPq57HY IZjbjseiBubGBdlX9F9eaEuaxhBneD5gE2evFrmwJgCFJXKBfUQP88J9Yw++mK9HIsPq FyRg== 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 w67-20020a636246000000b0055386e1eb92si4811928pgb.422.2023.06.26.01.52.55; Mon, 26 Jun 2023 01:53:08 -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 S231268AbjFZIu3 (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 04:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbjFZItu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 04:49:50 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E58021FD7; Mon, 26 Jun 2023 01:48:14 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8DxkfHEUJlkMzUCAA--.3338S3; Mon, 26 Jun 2023 16:48:04 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxxsy5UJlk4hQJAA--.19269S27; Mon, 26 Jun 2023 16:48: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, tangyouling@loongson.cn Subject: [PATCH v15 25/30] LoongArch: KVM: Implement handle fpu exception Date: Mon, 26 Jun 2023 16:47:47 +0800 Message-Id: <20230626084752.1138621-26-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230626084752.1138621-1-zhaotianrui@loongson.cn> References: <20230626084752.1138621-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Bxxsy5UJlk4hQJAA--.19269S27 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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?1769754684001321805?= X-GMAIL-MSGID: =?utf-8?q?1769754684001321805?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
June 26, 2023, 8:47 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 36a838607218..17e94ecec140 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -631,3 +631,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; +}