From patchwork Tue Mar 21 03:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhaotianrui X-Patchwork-Id: 72670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1576793wrt; Mon, 20 Mar 2023 21:11:26 -0700 (PDT) X-Google-Smtp-Source: AK7set+vgP5aVnVvUG0HoDRmNeRAuN1vNrQGJkv6Z8Rf85n3Js40zwFIWtRYxaVM1Q+6zvvthAWl X-Received: by 2002:a17:90a:190e:b0:23b:3b26:c612 with SMTP id 14-20020a17090a190e00b0023b3b26c612mr670584pjg.20.1679371886498; Mon, 20 Mar 2023 21:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679371886; cv=none; d=google.com; s=arc-20160816; b=myudAt1Y2hc5ILI7z52RGPjg9BKHnnNv8+OTLjqg03rgBNQSSHQ2TlfIXvCi2rm/3c P/qOtSPiqcTeogLVgdDSA1Ta6OlGzvuaLtlqB8erX8Csnr0ZLyrdvRahgxkSZBkGchcl ogqr/XBtTQE4WeX+mUBHsRcICQ421tKsLso/a59Ifinw6wB57/vLqPKpZjz+D7hhtPJ0 SzL1EsJLRlh2TZS+WyS7CDXmbb2fnOXedJCEn4sBfNMWEM5NJYPGyNWHlP+UroKf7Q6h Q3PakxV/Jj9LQ9mCGPcd3K3ktkrs+Sc/n8cGg2jEN6/6jAz7QMe1biwwPh+6uKZ/u3kq ppzg== 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=MrmTWWrme99dZ7MmDRIJHoBz+470PwQiNPdy5DA5Zh4=; b=JcfV26p0UtHDCZfQK0CFpI27eCtSQIiDajpWXXrhalAvnY/o/ZrTODISNSb+hgKZaQ z8yIWVBxxdYAg+T2fWZkHfIkOzqY5psjpwpwpt1VnkN6jNztL0YWtOgJ3xY1IO9WYVV2 mltPHbkaNuZYqN4xJgvCzanutQZvInfdJhuW9IzLDvrcamUglwBw1Dbg3pfpYkUgn+6N rHF1QtbBKFZmk1Sd6A0tYLoaVhoJzRVSzaWpNCI71aocgNW50Bs3lGhJnK0QL08+7/zb AExFamMnhTckGwUF7hP01Ofv8AZylXyScu5cnF/EenDRZWM6DlqKjBGnyg2Fb2mrFpeE nM3Q== 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 d36-20020a17090a6f2700b0023d422d08c6si12539362pjk.27.2023.03.20.21.11.12; Mon, 20 Mar 2023 21:11:26 -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 S230193AbjCUD6l (ORCPT + 99 others); Mon, 20 Mar 2023 23:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbjCUD53 (ORCPT ); Mon, 20 Mar 2023 23:57:29 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1AE592E839; Mon, 20 Mar 2023 20:57:06 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxJMQRKxlkxjYPAA--.11035S3; Tue, 21 Mar 2023 11:57:05 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxD78EKxlkQB4IAA--.33942S24; Tue, 21 Mar 2023 11:57: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 v4 22/29] LoongArch: KVM: Implement handle idle exception Date: Tue, 21 Mar 2023 11:56:44 +0800 Message-Id: <20230321035651.598505-23-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 X-CM-TRANSID: AQAAf8DxD78EKxlkQB4IAA--.33942S24 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvdXoW7JrW5uFykWr43XF43Ww48Zwb_yoW3ZrX_XF Z7tas3WrWrX3W5Kas8t3Z8Ca43Ga1kXFy5ZF12vry3Gr1qyrW5GrWDWwn5ZryktrWUuF4Y q3yvv3s7Aw1UtjkaLaAFLSUrUUUUeb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 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.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?1760949055249370940?= X-GMAIL-MSGID: =?utf-8?q?1760949055249370940?= 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 f151cc2dd..6618a410a 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -190,3 +190,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; +}