From patchwork Tue Feb 28 07:00:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 62300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2857876wrd; Mon, 27 Feb 2023 23:02:54 -0800 (PST) X-Google-Smtp-Source: AK7set/QFY/VNpZdvoH0G+oFv0HqaSMgvmbol6rlvcLS5na37xQqaZdSBho555m5pgQNpOwzSsli X-Received: by 2002:aa7:9833:0:b0:5a8:a420:72f7 with SMTP id q19-20020aa79833000000b005a8a42072f7mr1883321pfl.7.1677567774018; Mon, 27 Feb 2023 23:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677567774; cv=none; d=google.com; s=arc-20160816; b=fRShE0thn9h24CG9zSvL7Rjv42hXFt1vJ67ubrVKi7v/ygux44lJjpoDtQuqXDMDvc VpNhml4CRGQfz3v+MkRjNBxA1EuhvSGirWqmPcsZL+amA5BM/YKIGpHyYsTNu472wBmV v9sZSJO4P5aolP/3mlHSBzqft6HQZSwVGV4o64NC11M5wv9Rtp7CWx5Ak82LXot8yj+h gqAkqmIexg4Oa6qogOGtXBob69g0orZlQlDasfZ9C1/IUMcnFn+BJOjOrj4elp14l3qi S6ERJJ5aIAnOFSVMnkdldV9X/VDs+j0RmAWU6jD0/vwlPEn0yuR6bg7Qhpo1vgLakv20 1eJQ== 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=pvzb41fxYE91eZDT/gLdZRuwjj/aP2NqXt8RcF/hzQI=; b=j4mhX/BDI8QCq9biXgksIxR31uo7956Lia/LF1ogfLxdGKP1Y5ynxHInxfHUqr8vQ3 +TBAnea1uMxNSOUy3Td5wj98BAae0y+bbyNV87pPJsUhPNHn5ts3Qn6KTFeQkkVGYL7S tBRzybrOtuBd4gySFpm168fWjNzf0fmRBOj0IQE9HmMKtLk2LvRfFMqy1KHVUR2pIo6B AZKdQP0GRM37YPQKgqGGM9U4TvQOvWxHsJ94Acih3kK5YMc9Mkf45dWRM/xUacZhzZg0 zjC/ehktTQB5xMQkJp6BQhbOIRwx5KaEfFVAFDU6bKvZlaT/pjLmpuooEpODChRapbBE NIHQ== 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 n10-20020a63f80a000000b004fb81c96759si9038894pgh.698.2023.02.27.23.02.40; Mon, 27 Feb 2023 23:02:53 -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 S230509AbjB1HCM (ORCPT + 99 others); Tue, 28 Feb 2023 02:02:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbjB1HBI (ORCPT ); Tue, 28 Feb 2023 02:01:08 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3A6C1A648; Mon, 27 Feb 2023 23:01:06 -0800 (PST) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxlF2xpv1jBGEGAA--.6502S3; Tue, 28 Feb 2023 15:01:05 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxc+Wppv1jPG9AAA--.15462S24; Tue, 28 Feb 2023 15:01:04 +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 , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao Subject: [PATCH v3 22/29] LoongArch: KVM: Implement handle idle exception Date: Tue, 28 Feb 2023 15:00:49 +0800 Message-Id: <20230228070057.3687180-23-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228070057.3687180-1-zhaotianrui@loongson.cn> References: <20230228070057.3687180-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bxc+Wppv1jPG9AAA--.15462S24 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvdXoW7JrW5uFykWr43XF43Ww48Zwb_yoW3Zwc_XF WfJas3WrWrJ3W5K3WDt3Z8Ca43Ga1kXF98Za42vr9xGr1qyrW5CrWDWwn5ZryktrWDuF4a q3yvv3s7Aw1jyjkaLaAFLSUrUUUUeb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY 77CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6x kF7I0E14v26F4UJVW0owAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAq jxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E74AGY7Cv6c x26rWlOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4kS14v26r12 6r1DMxAIw28IcxkI7VAKI48JMxAIw28IcVCjz48v1sIEY20_WwCFx2IqxVCFs4IE7xkEbV WUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWDJVCq3wCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr1j6F4UJwCI42IY6I8E87Iv6x kF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7xRiTKZJUUUUU== X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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?1759057306090926978?= X-GMAIL-MSGID: =?utf-8?q?1759057306090926978?= 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 f02e2b9402f2..f0de0b638f31 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_idle(vcpu, KVM_TRACE_EXIT_IDLE); + if (!vcpu->arch.irq_pending) { + kvm_save_timer(vcpu); + kvm_vcpu_block(vcpu); + } + + return EMULATE_DONE; +}