Message ID | 20230522031217.956464-23-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1176505vqo; Sun, 21 May 2023 20:15:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yB0hZx1LQtlfW6dDb1CvQEDtW2yGbg8Z4aF/TDhaOIygRDCZFEYnpKNGH87Q+fFe6jt7D X-Received: by 2002:a05:6a20:a58f:b0:104:2200:8933 with SMTP id bc15-20020a056a20a58f00b0010422008933mr10306993pzb.62.1684725322565; Sun, 21 May 2023 20:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684725322; cv=none; d=google.com; s=arc-20160816; b=JJWSckiDZKtcQQSjwZxoGiU1vXlhrfXETdPI1Oi90nVX0AbqTGFhC/RROFTlFP4Ilq uw6ZO5mv2j7nLdjbEHKrg+pPKqhvWFD0AY6ZNJdMhaTb9WiG8aY5YfoZvDGW8Ssoiivj Lpx+RC6FL3qHOVg0rymxImK1p3r/AvZK9PS3VgSxYRyhoko5jPBWxYdHjWW6oikII7tw x25DEFjWYI3guW6BomXp9rUF5JR/4bBdMDiEy8NPtBZtz2SF1FDHruP6puwhfvOSKQMU IzmvcLOJuY+ZY9OWwg95RIKbccnDSjjmz8IIGuBld0rRy+tBbrHTTeivjGhNvEe1Dls3 S78g== 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=n7fAX5A5APQuXkMG5KfDqNHa4BNHTyIEZmSFodEaAmc=; b=X6ATW6AIliDbz9Qx5lgNxU5wCspBX3LCnFaMPRPFs2voac0lHaAAtN+sH0WmvfIU52 H62k6vsNrwiksjMq/7oOB2I4TrJxmtpnv4VY1LJVl3rbCjNb19ozhnkjExvmbgCpmcJi FJtHGItXItwFUzT//zzWhJu21H91SOcQnQYd4drCEUyRZmXOgKyT5Ba9IMR29aVzwdf5 tdS1TDA80a5Lt30NHLjG8TR59JtKEUplQOfK0Dk23WIPnYgpJRqf2R5T2GwO8lCtkELp 1m/DDijOFcSC02vHbF4i2C0Qno3jnNQXNDYV1ZIJy75pqad+vkNmcMk7RJxSoboii/qt vslA== 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 z22-20020a637e16000000b004df18fa49aesi3941762pgc.796.2023.05.21.20.15.09; Sun, 21 May 2023 20:15:22 -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 S231546AbjEVDOB (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Sun, 21 May 2023 23:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbjEVDM2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 21 May 2023 23:12:28 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3FC0AF1; Sun, 21 May 2023 20:12:26 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Cx_eqZ3WpkscsKAA--.18428S3; Mon, 22 May 2023 11:12:25 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxMMiR3WpkJIFuAA--.54000S24; Mon, 22 May 2023 11:12:24 +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 Subject: [PATCH v11 22/31] LoongArch: KVM: Implement handle idle exception Date: Mon, 22 May 2023 11:12:08 +0800 Message-Id: <20230522031217.956464-23-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230522031217.956464-1-zhaotianrui@loongson.cn> References: <20230522031217.956464-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxMMiR3WpkJIFuAA--.54000S24 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvdXoW7JrW5uFykWr43XF4UXFyUAwb_yoWkXrb_ZF Z7Jas5GFWrXFs8Ka4Dt345Ka4Ygw4kXFWY9FW7ury3GF1qyrWUC39rWw1DZrWkKFWUZFW5 K3yDZas7Z342qjkaLaAFLSUrUUUUeb8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 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.4 required=5.0 tests=BAYES_00,RCVD_IN_SBL_CSS, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <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?1766562539848464523?= X-GMAIL-MSGID: =?utf-8?q?1766562539848464523?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
May 22, 2023, 3:12 a.m. UTC
Implement kvm handle LoongArch vcpu idle exception, using kvm_vcpu_block
to emulate it.
Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
arch/loongarch/kvm/exit.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c index bd33fe0c6424..3fdb42939a05 100644 --- a/arch/loongarch/kvm/exit.c +++ b/arch/loongarch/kvm/exit.c @@ -188,3 +188,23 @@ 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 (!kvm_arch_vcpu_runnable(vcpu)) { + /* + * Switch to the software timer before halt-polling/blocking as + * the guest's timer may be a break event for the vCPU, and the + * hypervisor timer runs only when the CPU is in guest mode. + * Switch before halt-polling so that KVM recognizes an expired + * timer before blocking. + */ + kvm_save_timer(vcpu); + kvm_vcpu_block(vcpu); + } + + return EMULATE_DONE; +}