From nobody Tue Feb 10 12:42:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1586578669; cv=none; d=zohomail.com; s=zohoarc; b=FVhwN48EjEK5qbu6a6cQluKtA0LX2mjzw5nQU0Lt8YTaY4uywQw7plSBhQS9MbZAiSRX5Me+2n/k5aPne1iRNvgP9ItcnNpr0fr0t2gv54UjIsP7Dru6QNFPWDHBxdPyA/zXdsvRNI+YiKMEJqSERAnmBpBey1/+Up43RQS2Zp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586578669; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mJIH2bnq2jrMCWsxO2yiB6MhAzwyDV+/muluREKB3gc=; b=d1BBosoHjhXKmiOy4I0i7oAnI6SsCXWcvRS2DWLu4o7bUFkIkt3cmPSw+2xxBQZZEZjrm0Xh6yyttjFb6+NuUE4U7OA5Rs+bSNR2/PU9WrhR5G3ZcYVxbYQzoj+tPR+nUJgjhYbxG2elXf1QqMVa/bbrA7RvBzCZiAbtNxt9ePI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586578669946852.2987412422001; Fri, 10 Apr 2020 21:17:49 -0700 (PDT) Received: from localhost ([::1]:48550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN7aW-00023o-H2 for importer@patchew.org; Sat, 11 Apr 2020 00:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47218) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jN7Zf-0000Pg-51 for qemu-devel@nongnu.org; Sat, 11 Apr 2020 00:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jN7ZU-0006ME-0a for qemu-devel@nongnu.org; Sat, 11 Apr 2020 00:16:54 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3741 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jN7ZT-0006L6-MO; Sat, 11 Apr 2020 00:16:43 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 684BDB5DED9E6ACACEC5; Sat, 11 Apr 2020 12:16:40 +0800 (CST) Received: from huawei.com (10.173.222.107) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Sat, 11 Apr 2020 12:16:34 +0800 From: Yifei Jiang To: , Subject: [PATCH RFC v2 3/9] target/riscv: Implement function kvm_arch_init_vcpu Date: Sat, 11 Apr 2020 12:14:21 +0800 Message-ID: <20200411041427.14828-4-jiangyifei@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20200411041427.14828-1-jiangyifei@huawei.com> References: <20200411041427.14828-1-jiangyifei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.173.222.107] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.191 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: victor.zhangxiaofeng@huawei.com, zhang.zhanghailiang@huawei.com, sagark@eecs.berkeley.edu, yinyipeng1@huawei.com, kbastian@mail.uni-paderborn.de, anup.patel@wdc.com, Alistair.Francis@wdc.com, kvm-riscv@lists.infradead.org, palmer@dabbelt.com, Yifei Jiang , dengkai1@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 8c386d9acf..3e8f8e7185 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -38,6 +38,18 @@ #include "qemu/log.h" #include "hw/loader.h" =20 +static __u64 kvm_riscv_reg_id(__u64 type, __u64 idx) +{ + __u64 id =3D KVM_REG_RISCV | type | idx; + +#if defined(TARGET_RISCV32) + id |=3D KVM_REG_SIZE_U32; +#elif defined(TARGET_RISCV64) + id |=3D KVM_REG_SIZE_U64; +#endif + return id; +} + const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { KVM_CAP_LAST_INFO }; @@ -79,7 +91,19 @@ void kvm_arch_init_irq_routing(KVMState *s) =20 int kvm_arch_init_vcpu(CPUState *cs) { - return 0; + int ret =3D 0; + uint64_t isa; + RISCVCPU *cpu =3D RISCV_CPU(cs); + __u64 id; + + id =3D kvm_riscv_reg_id(KVM_REG_RISCV_CONFIG, KVM_REG_RISCV_CONFIG_REG= (isa)); + ret =3D kvm_get_one_reg(cs, id, &isa); + if (ret) { + return ret; + } + cpu->env.misa =3D isa; + + return ret; } =20 int kvm_arch_msi_data_to_gsi(uint32_t data) --=20 2.19.1