Message ID | 20230817125951.1126909-23-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp1539446vqi; Fri, 18 Aug 2023 09:52:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9+y5le+UXqwbrXCcE29ikUB2oWWrim0dtNpSepv5mes9X24xuBc4ne7SfY9I0yUaBqv7W X-Received: by 2002:a17:907:2723:b0:99b:f3d1:7735 with SMTP id d3-20020a170907272300b0099bf3d17735mr2224917ejl.29.1692377529745; Fri, 18 Aug 2023 09:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692377529; cv=none; d=google.com; s=arc-20160816; b=hHhxn3IJZ8SFYKoNDDc6/nsqzm+/CTJDmE2HQsEK4hDiqg3GxtDjI6djmF/twXt5Dk iLp0Tdthx3C1QJTXfEVCpEm3m72278UQnreaIXMJOzPt9YRpXm0o3ZIdHpCHVQvgvehe Zz2dCbFCq+nWqBfFesCW2kSKPNPORdojChokGtPkeFA7cxSmc0gG0st8qlZwOQZPLssX li0sXwEZAbfIsVfXGflQ4ncscIgYZz3hvSn9LUfWFBoQh+ORGAGPmS+DZ7gidMH5AyBe E628PuIyN+yvHCBVTixXJv0TZ8y1CFpPbYCHxw+RotMbprGajjfoXl1J+YAY1nSbe8Xj Lj+w== 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=vBXozhnPXwSB3DJhjnKWz3f6luaN/KxHDpM6/QeZg4o=; b=f7XBiZxBAJugg6Q8rKdNfGJ2oSIAV8N/xJ9FETITx+1DsRFIKneFugZbcnWfuAJWSv vWXIwPtVja/tlOoNF6+wcqce4gaPdZIaBYoohDnWVNyKZ6Zg399dcB3aXgrk4H3c0ztF sNg+Clo7AZKHb5DDOrchaNyWXMjqmH4id6MQiMlSm5EfAUESJLJGEVSX6DKWZg9NuY6X W1zwk/qv3xI4vcER2gaIhggMIQUCJyeolO7qXCQzunY6/HaQID7dYBAzemJyyfRe+bIg d2SLO0JPgOpcLGDMJw6FCcS96R63E2g7Sm55j2QJUigA+5k1E6FXImDhukbcqcJMRJ7K eaRQ== 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 n20-20020a17090625d400b0099bc8c2fbcfsi1600233ejb.718.2023.08.18.09.51.44; Fri, 18 Aug 2023 09:52:09 -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 S1351097AbjHQNAW (ORCPT <rfc822;274620705z@gmail.com> + 99 others); Thu, 17 Aug 2023 09:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351117AbjHQNAL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Aug 2023 09:00:11 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55B0030D0; Thu, 17 Aug 2023 06:00:09 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxpPDPGd5kiIYZAA--.52360S3; Thu, 17 Aug 2023 20:59:59 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxniPIGd5kmchcAA--.55665S24; Thu, 17 Aug 2023 20:59:59 +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 v19 22/30] LoongArch: KVM: Implement handle idle exception Date: Thu, 17 Aug 2023 20:59:43 +0800 Message-Id: <20230817125951.1126909-23-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230817125951.1126909-1-zhaotianrui@loongson.cn> References: <20230817125951.1126909-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8BxniPIGd5kmchcAA--.55665S24 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, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774586460398217664 X-GMAIL-MSGID: 1774586460398217664 |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
Aug. 17, 2023, 12:59 p.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; +}