Message ID | 20230803022138.2736430-23-zhaotianrui@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp868153vqx; Wed, 2 Aug 2023 19:45:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/lGF4iIlxaMUuiwSxQeApST4EG5p0lBW1YVZiOVeqeo/5/sea7h2tkPbT40Frk0jrnPdI X-Received: by 2002:a5d:4b81:0:b0:317:5de0:8ba8 with SMTP id b1-20020a5d4b81000000b003175de08ba8mr11313197wrt.1.1691030721682; Wed, 02 Aug 2023 19:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691030721; cv=none; d=google.com; s=arc-20160816; b=jMvcKORTn6MRvDLRMp8dXRpRcx0K3ToTFRegmjxFHc1uWuyc2JVHnV0Qp0eKcU4CXg sBg7bDW8Z4aQ0qGnq+7hL7ffIN2KUt/CG1xzGR62wn75Tx+kTzsBUE4IOOPT/Q1oUdru SJE8Du/Func88/AMKW0GO2CweRDTmTx+yJm7R/a+CIEXCvql3CE2zOXV+OSEeqmbq+rG WENlpdGf96SATyR+xos0HmPr7Wdyz8hJ7Mb6DS5En9Q+7dIUmdJqH0J5eu+aB0vtjFaT BUZ6UIGCuneHN9rBtJNvt29PizTYg5+kNCayuObYa7nKpzlLPW41i01Yvvt4VDzHPb9X qHoQ== 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=RpX6KVNLZ/vEP6+tJRLZWmkQNStkfRxLfmS7doFdMcYvWsJGTn/6hcnyYpsn+nmAKh a1i0g5X2ZP3lQq+2mg0JfRHK9pRf4Y+Xpr4iBlEkXV/w2B8ZyPNyPiKmg3GJ1F4vMvch 1+n2CH4HPwdZMQwZsUJHgSEIpU6w8ePTMM1OX7++7sfHDOJPQES5YFeKKBmVq+MgCWwR UMbxrqTRmSp4SOGqbd7v/0V5znfLdjFyzgJNClAHbgdaodGyccXhs8MVEqDL5SkpdkPr Un3XTv455phLFJlKN4C42h6JoT8i4r6ECjn4GfN7m+8JtpXyO4AY21La/i1tfdEBdyYX Darw== 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 dk8-20020a170906f0c800b0099364d9f0e7si10964809ejb.543.2023.08.02.19.44.57; Wed, 02 Aug 2023 19:45:21 -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 S233594AbjHCCZe (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Wed, 2 Aug 2023 22:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbjHCCXl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Aug 2023 22:23:41 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F004244AB; Wed, 2 Aug 2023 19:22:25 -0700 (PDT) Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Dx6epYD8tkyGkPAA--.30400S3; Thu, 03 Aug 2023 10:22:16 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx_c4yD8tk8oNGAA--.51268S24; Thu, 03 Aug 2023 10:22:10 +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 v18 22/30] LoongArch: KVM: Implement handle idle exception Date: Thu, 3 Aug 2023 10:21:30 +0800 Message-Id: <20230803022138.2736430-23-zhaotianrui@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230803022138.2736430-1-zhaotianrui@loongson.cn> References: <20230803022138.2736430-1-zhaotianrui@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Cx_c4yD8tk8oNGAA--.51268S24 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: INBOX X-GMAIL-THRID: 1773174230287469786 X-GMAIL-MSGID: 1773174230287469786 |
Series |
Add KVM LoongArch support
|
|
Commit Message
zhaotianrui
Aug. 3, 2023, 2:21 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; +}