Message ID | 20230629075538.4063701-23-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9489692vqr; Thu, 29 Jun 2023 01:49:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+KldWkBTNhz7HwHD0jtGXcy5PbtgvAZv0MfQGMeqJvDhDonLwU3040q03AMJIJJ52lprN X-Received: by 2002:a05:6a00:138d:b0:67d:308b:97ef with SMTP id t13-20020a056a00138d00b0067d308b97efmr6727492pfg.2.1688028552756; Thu, 29 Jun 2023 01:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688028552; cv=none; d=google.com; s=arc-20160816; b=phueb5zdkrqybN0V4lWgI9R4Z5f9Y+x8ES5lOr5ByCuKrxS5SO74KZHrZTOUworNnd 72VCcn7iaajVxbnXJfLiC6wh28mklG9ivtXpTfOxZ4BUSd5+PyYQJkCNIjL0yPKL+Hq4 YKkxF+JDLnNk9sey6KtF/JZ710XkNXPlZEwJcVT9/7AiIQ5bw63WF3+EmaBr5mq7zuYU Folo9WviGrA6mEr42YIh1NSdDdieI4iFTfDNxm/Bub8JKy1rPCrzVXfI2LhA6i5JRSTU pKiOBvYlpOBmksflcyiMih0VS/IOtp3qPC4k1xpyh2BkfbcaDrUg8HwnGZCNxn2vwCtW TGDA== 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=WGxADIiFAVIQzJWVkF14hjD3AhDr9yfrIT8Ffbh+XCw=; fh=5MymQ7GIBp7zNXW64cKeokietRhKQkEhpOBaNYPDGGU=; b=NaEprUiyAEXaqPg7D6mTCWBYsat1rcF4khf+GktLbhs/BOxkrEdV3begdgKL4jpU7m guo+YX20gpQfvhf0BT97RFoGEP/HKZyUJ51T5BzFBCa50TePlgTuSGZBkHf7s6tIFB5Y o/HiuGvs/fc+epGFO4X8I4bW8kjp4+5ufvkyYWtaY1B1nxI0z2hotyx81OCclk7iWAaD dgzv0rr19Rz7mg19iLcf9NWeIGSgVBLKnwJOnzbS7qHJxMPvTOFC2UYbvIZkZC2K9iRC YuyPc+CS+wZ2Res70+HqJVqyhPnxtupWMQCMB/SXZ/7bmvL7CIZABXyuSPa0NpBpuHS1 GO3A== 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 cg23-20020a056a00291700b006634c05d13csi9820571pfb.172.2023.06.29.01.48.59; Thu, 29 Jun 2023 01:49:12 -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 S232777AbjF2IDk (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 04:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbjF2IAe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 04:00:34 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B919935BF; Thu, 29 Jun 2023 00:57:34 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxZ8UFOZ1kksUDAA--.6188S3; Thu, 29 Jun 2023 15:55:49 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxzyP6OJ1kYGYQAA--.18424S24; Thu, 29 Jun 2023 15:55:49 +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, tangyouling@loongson.cn, hejinyang@loongson.cn Subject: [PATCH v16 22/30] LoongArch: KVM: Implement handle idle exception Date: Thu, 29 Jun 2023 15:55:30 +0800 Message-Id: <20230629075538.4063701-23-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230629075538.4063701-1-zhaotianrui@loongson.cn> References: <20230629075538.4063701-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxzyP6OJ1kYGYQAA--.18424S24 X-CM-SenderInfo: p2kd03xldq233l6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1770026227725335574?= X-GMAIL-MSGID: =?utf-8?q?1770026227725335574?= |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
June 29, 2023, 7:55 a.m. UTC
Implement kvm handle LoongArch vcpu idle exception, using kvm_vcpu_block to emulate it. Reviewed-by: Bibo Mao <maobibo@loongson.cn> 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 32edd915ebcb..30748238c78c 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; +}