From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0D86EB64D7 for ; Wed, 28 Jun 2023 21:31:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEcl8-000292-Ey; Wed, 28 Jun 2023 17:31:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEcl4-00027O-Ve for qemu-riscv@nongnu.org; Wed, 28 Jun 2023 17:31:28 -0400 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEcl3-00084j-Af for qemu-riscv@nongnu.org; Wed, 28 Jun 2023 17:31:26 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-563531a3ad2so281039eaf.3 for ; Wed, 28 Jun 2023 14:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1687987884; x=1690579884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zsw0pJ1ZMaa7pJqxBp9+XWOi9ryOdYncMUElEND8Y8o=; b=kyQK/YTsrh/WmEj6I/YnsbjccVlqtiEVUy6xajB3VPA0zb4XBIn5sgM706svEH5Go4 8dyvcgXAgDC+SKJfVbE9/6+uaNfXSC8fyloDVnsobk0cBAeNinM5TaUXW+tTWoQ+qqlJ C7ounHRLHR1bZBdRLMo7OQdZ6vpUjsW8gOuXnfqHnOjGEtyu4m976EN9/biupg7tXNCz uzV4m6yBsxmBFh2pGXBJ9W5XsGAIznstlKu+VYZ6AGVdo/qt/UDvLsOP0Ikbr5C8Pck/ x6pohjCh0DguxLRmWP8PF4OOhnImMGzRqtxV2BO34ul6PBdT7JDPf0PTYwkZUWEh5tSv wiag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687987884; x=1690579884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zsw0pJ1ZMaa7pJqxBp9+XWOi9ryOdYncMUElEND8Y8o=; b=lHWcV8Tq2ZdrvV1s2NlkTTZ1tlkDcVKmNrKyfOMN8eZEZ1t+I9AQ+FCGc0zK7dc7/i +/O0GxdfsCkWzxFS7s28rTfm7Tz7LSSAvk2u/oRnpFIpuSVvgUEd2DXztxIAUELJCi3K JpFgKnGqvoIuK/fe3kFb57YlW9tMqZBH8KbAI4Ib9kyC7J5bD8yta7dsh1Ez9Wj/59j8 BFze4pEpN+pWN6tqFORyJitj6jTMATJPor0rN9OgsC9dBG5F7Y6+H/VePZDofQfmu2oQ 4mvIt3nBK6MDKP4FtLrURUbGdRFMaGgXU7kuwT1USbMX4A6X8N5Ip4BrDB7Ehb3Z0maM KhmQ== X-Gm-Message-State: AC+VfDwX9tAtWhe3T15jy9O1MlX0ipIP5OwvnE/ryB+jccenz745BhiE 0+J+TVQRWJvlVuKdGwxWxkYhzg== X-Google-Smtp-Source: ACHHUZ7ma3u63LdWigthFSdh7vsxC461vF7PEhkNL7Ibbiq1xIuELJ9aie+OWUNT3s2XnEyqgSIH5g== X-Received: by 2002:a4a:e1a5:0:b0:562:f872:3b8c with SMTP id 5-20020a4ae1a5000000b00562f8723b8cmr15604351ooy.3.1687987884291; Wed, 28 Jun 2023 14:31:24 -0700 (PDT) Received: from grind.dc1.ventanamicro.com (201-69-66-110.dial-up.telesp.net.br. [201.69.66.110]) by smtp.gmail.com with ESMTPSA id y17-20020a4a4511000000b0056084a91c74sm832892ooa.24.2023.06.28.14.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:31:23 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, philmd@linaro.org, Daniel Henrique Barboza Subject: [PATCH v6 07/20] target/riscv: read marchid/mimpid in kvm_riscv_init_machine_ids() Date: Wed, 28 Jun 2023 18:30:20 -0300 Message-ID: <20230628213033.170315-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628213033.170315-1-dbarboza@ventanamicro.com> References: <20230628213033.170315-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::c29; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Allow 'marchid' and 'mimpid' to also be initialized in kvm_riscv_init_machine_ids(). After this change, the handling of mvendorid/marchid/mimpid for the 'host' CPU type will be equal to what we already have for TCG named CPUs, i.e. the user is not able to set these values to a different val than the one that is already preset. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis --- target/riscv/kvm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 37f0f70794..cd2974c663 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -378,6 +378,22 @@ static void kvm_riscv_init_machine_ids(RISCVCPU *cpu, KVMScratchCPU *kvmcpu) if (ret != 0) { error_report("Unable to retrieve mvendorid from host, error %d", ret); } + + reg.id = kvm_riscv_reg_id(env, KVM_REG_RISCV_CONFIG, + KVM_REG_RISCV_CONFIG_REG(marchid)); + reg.addr = (uint64_t)&cpu->cfg.marchid; + ret = ioctl(kvmcpu->cpufd, KVM_GET_ONE_REG, ®); + if (ret != 0) { + error_report("Unable to retrieve marchid from host, error %d", ret); + } + + reg.id = kvm_riscv_reg_id(env, KVM_REG_RISCV_CONFIG, + KVM_REG_RISCV_CONFIG_REG(mimpid)); + reg.addr = (uint64_t)&cpu->cfg.mimpid; + ret = ioctl(kvmcpu->cpufd, KVM_GET_ONE_REG, ®); + if (ret != 0) { + error_report("Unable to retrieve mimpid from host, error %d", ret); + } } void kvm_riscv_init_user_properties(Object *cpu_obj) -- 2.41.0