Message ID | 20230321035651.598505-26-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1574169wrt; Mon, 20 Mar 2023 21:01:28 -0700 (PDT) X-Google-Smtp-Source: AK7set+T4F9HhY6G3ONVLXGfQ0t78MRoC+8XUoAa4la9KoxCX5E9V/INpmB54hrEM9JyzCyATp8/ X-Received: by 2002:a62:55c3:0:b0:626:658:c998 with SMTP id j186-20020a6255c3000000b006260658c998mr1235334pfb.10.1679371288173; Mon, 20 Mar 2023 21:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679371288; cv=none; d=google.com; s=arc-20160816; b=fA7XUPI8UuO962Jm0446iuGUcchsrXS3i6ifrzJAJzPQOYWuWLoAuFV5N8yBw0X8gk FA+wJlpLgE8He/6gDf+XJGEgHESjFj/ykzg1wZfbgKX5nSS+qXHkG9SaoOaaZc6Mjh27 KMLRIlFbo2D5hfk7HI1rM973MX0e0i2ZKK+KOnGtIhXbWioMY3V9hQ1i9XQ+l748SV+n J4spqoFruai6jZjk+vnmUVPSHBRrLEZ+q++4IbpGfen0ddGo/QUWKOSLEUlntRU4Zb3M qJJMbMeEHbctCPhfJ2d+mADNhC8Vk9aPjS/srOWyOPII4ZrWhB5kBC1TKdHM2J93SZGH Zcsw== 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=S9jmqEmW8FRtib5UlsCRWyaw+zjPvaXJQ9av9S1aNt0=; b=gvAkZmmQd9KY0D1APH0dgWaeDlKaV3AGF60s4miOWxYE82Phj1kpwpuYzUSOaK93q3 k9GL5DcU9Mq8O0tStPVlRMuNP5ySwoNNKml0mIrQwZIeueKkvl3t9R+1ObEr7rwUPI1B sSE25fPQE1pbkJoT1ZIDoUmWn0R2Q7iaVGbZfCGYUb8qHMnlTqkHuFFe0GaegEj0eMFO bLPP9u08MkeADYODEyAkMdmT5kGnlLGGbSTbhH986WDengh5vK+kxY/I9f/mW+K5mNZa lSLYLiA3/WL4cLbGtMwQPmHSig3SYDg4pqj2HGG6q3ELMNLIOXxxL6GXYNUUA/35g1b0 sdyA== 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 z13-20020a056a00240d00b005a81866ff8csi12013775pfh.319.2023.03.20.21.01.15; Mon, 20 Mar 2023 21:01:28 -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 S230250AbjCUD67 (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Mon, 20 Mar 2023 23:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjCUD5j (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Mar 2023 23:57:39 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C25C3928C; Mon, 20 Mar 2023 20:57:09 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8DxXNoTKxlk7jYPAA--.11040S3; Tue, 21 Mar 2023 11:57:08 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxD78EKxlkQB4IAA--.33942S27; Tue, 21 Mar 2023 11:57:07 +0800 (CST) From: Tianrui Zhao <zhaotianrui@loongson.cn> To: Paolo Bonzini <pbonzini@redhat.com> Cc: Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, 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> Subject: [PATCH v4 25/29] LoongArch: KVM: Implement handle fpu exception Date: Tue, 21 Mar 2023 11:56:47 +0800 Message-Id: <20230321035651.598505-26-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230321035651.598505-1-zhaotianrui@loongson.cn> References: <20230321035651.598505-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxD78EKxlkQB4IAA--.33942S27 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7trWDZrW7uw1UtrW8JFWDArb_yoW8JFyxpF WfAwnYkr48Wry7tanIy3WqqrsxC395Kry7Wr9Fk345Zw4Ut34rXF48KrWvgFy5Kr1rXa1S qr13KFn8uF1UA3DanT9S1TB71UUUUjJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bx8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4 AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aV CY1x0267AKxVWxJr0_GcWln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l 57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x8ErcxFaV Av8VWrMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv6cx26rWl4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_tr0E3s1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4UJVWxJr1lIxAIcVC2z280aV CY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0zR9iSdUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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?1760948428121913276?= X-GMAIL-MSGID: =?utf-8?q?1760948428121913276?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
March 21, 2023, 3:56 a.m. UTC
Implement handle fpu exception, using kvm_own_fpu to enable fpu for
guest.
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 8a5d39285..fc2152e09 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -625,3 +625,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; +}