From patchwork Tue Feb 14 02:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 56624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2723612wrn; Mon, 13 Feb 2023 18:59:09 -0800 (PST) X-Google-Smtp-Source: AK7set+LHAN/87hr7YWPQFx+zwPGYb7ibjai3Kn1nPVGqUDF0PMOGmtekDFak82QPVavV2qaWkI3 X-Received: by 2002:a17:90b:1d87:b0:233:ee50:d27a with SMTP id pf7-20020a17090b1d8700b00233ee50d27amr842083pjb.5.1676343549450; Mon, 13 Feb 2023 18:59:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676343549; cv=none; d=google.com; s=arc-20160816; b=PfeSplzpSk3tbb64T4B/V7sTqw4rw4Uxr/mCXWW8ktbSwwQ9CSYA1IV72okygvp3zB PjoPRcwYXqf++z5EmmWxrulywCM4z4OFA4hJrQ0AfZZnFymy3tO9QBmsNKs+TeeJMbQn ZMF11SeorqDRPWDaZtXg9RZX0UeecsyQ08PKut0CJ1GnVxFceMTAxCsGbP0n4IjfKzbo h5vQ9jgj0RTIkXjHkLD6q2ybmDldIaDGZNXLhm+riGwENlHRfmzuZi1Sa0aSyjc4FHRE drAHfzvPDy0jrNByNoqs7OSxVZ/cKLb4i3AV3WhXMu7D/sno7f1KJOVFVzZE5Gvlz4rt 4MSg== 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=fZx5IZlIZtaY3u4UMj+eKGDfgof2Z9hvNdQxrag+KlE=; b=wRGpfeQe1G3nTUHXSCGuNyWpogn9x6jwNmaUdFiGMnmqKLD9qAwq+jT7WM9jbUsLXR O96brB6TqHI3Fv5c+sfRXGfK4tEvVDm4Y3mHZOb6h0CAY2CTZ0xLzTho4P11gfM6SOJV McmnAGEqmhevWP0/IOI8MaItbINRDex01EeHv4R0T1NzWSH15vV2jEhIZUEwanXu12GM koGWw6pzp3xPAA7sOtxN/ZDuiAF/nKRycJafmcK94jHHBN5RLEHmW2LDxyog2tRCEpcg aZmEPpveawMv5MCu/Vjnf5zmGo11Sbfk8fSj6sXo562FG0nYnX/8T5LnPF0s+ugwTjhS oirA== 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 j11-20020a17090a94cb00b00233b40ad95dsi9612689pjw.177.2023.02.13.18.58.56; Mon, 13 Feb 2023 18:59:09 -0800 (PST) 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 S231487AbjBNC5Z (ORCPT + 99 others); Mon, 13 Feb 2023 21:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjBNC47 (ORCPT ); Mon, 13 Feb 2023 21:56:59 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B376118B03; Mon, 13 Feb 2023 18:56:57 -0800 (PST) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxC9p4+Opjo1cAAA--.948S3; Tue, 14 Feb 2023 10:56:56 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axeb1w+OpjmZwyAA--.28802S19; Tue, 14 Feb 2023 10:56:55 +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 Subject: [PATCH v1 17/24] LoongArch: KVM: Implement handle idle exception Date: Tue, 14 Feb 2023 10:56:41 +0800 Message-Id: <20230214025648.1898508-18-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230214025648.1898508-1-zhaotianrui@loongson.cn> References: <20230214025648.1898508-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Axeb1w+OpjmZwyAA--.28802S19 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvdXoW7JrW5uFykWr43XF43Ww48Zwb_yoW3CwbEqF WfJas3GrWrJ3W5ta4Dt3Z8Ca43Ga1kXFy5ZF17Zry3Gr1DtrW5GrWDWwn5ZryktrWUuF45 t3yvv3s7Aw1UtjkaLaAFLSUrUUUUnb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY 27CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6x kF7I0E14v26r4UJVWxJr1ln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757773613183908606?= X-GMAIL-MSGID: =?utf-8?q?1757773613183908606?= Implement kvm handle loongarch vcpu idle exception, using kvm_vcpu_block to emulate it. Signed-off-by: Tianrui Zhao --- arch/loongarch/kvm/exit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c index f02e2b940..a6beb83a0 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -191,3 +191,15 @@ int _kvm_complete_iocsr_read(struct kvm_vcpu *vcpu, struct kvm_run *run) return er; } + +int _kvm_emu_idle(struct kvm_vcpu *vcpu) +{ + ++vcpu->stat.idle_exits; + trace_kvm_exit(vcpu, KVM_TRACE_EXIT_IDLE); + if (!vcpu->arch.irq_pending) { + kvm_save_timer(vcpu); + kvm_vcpu_block(vcpu); + } + + return EMULATE_DONE; +}