From patchwork Thu Oct 15 22:47:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFCF7C433DF for ; Thu, 15 Oct 2020 22:50:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 314E920678 for ; Thu, 15 Oct 2020 22:50:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mvBStUlO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 314E920678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTC5H-0006Ja-6v for qemu-devel@archiver.kernel.org; Thu, 15 Oct 2020 18:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTC2O-0002yx-3m for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:47:56 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kTC2M-0003IR-I8 for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:47:55 -0400 Received: by mail-wm1-x341.google.com with SMTP id d3so721727wma.4 for ; Thu, 15 Oct 2020 15:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=orbtnIXME7eI8Z8OOzrxbeZteV0enZumXvxzAJ1ns40=; b=mvBStUlOmmzXaP+CpCG4+QQweQYbgRyZVG54H4mOeypy+cHvOwS79ZtGgJdhNuIXPy i0SqA+mgmKgkBCuTloksurggqoZc4MsUvHkK9oR0t7atK3WVzbnadZUFVI6oP4/VjXkj dSj2FV/sBjEeBfqdZlgF6nndjWf7h9MZzrWUIP5Er6+fdMF+M8zSJB6SZG7yCMhuskXW rjjNJyQkvbUjHoDYqzUafKFYWAzwi9OIHAPMarX7QA/cW5NDkK4/nNfgYO5Elbp7Anlj sFHXufsWYwXGktYKZIaGPqOX/LqC8J3LbEZTafi0hI+euJdK1Ma8BQF/3cSshdDzMtv7 d3/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=orbtnIXME7eI8Z8OOzrxbeZteV0enZumXvxzAJ1ns40=; b=Q/3Y07H/5x2sOxZj73KHXBj7QxFsZU1sz64CS4UxCLsv0TWsWH1GGhVV0KDeKlvkd1 iY0oyScHsbX8lYybzXxoaxseIy0I6FsdDmN0L80nRsxoqtX/SWJn+Bvvj932ofRQ3nXB lfW1mOLNnqBvTSn/4SfSctFQ7fegr0FyfwL6hhzV/SoMA3o05zz/C4C6aIlmKC+W7LWP BtC3cCn6T1GV5auyyidF4X8hekcVShYR2S1TT6ePkUi1kkTpaaK7GZ1YHeoLlaJf8kSL lO+ZAMl1Hdpca7sR4yhaVoKbXMfaSAllOQ1vZ80cbezuyOW4LQOzn4wuWKc+hWV4UmY8 gJlA== X-Gm-Message-State: AOAM531CS7Q1XUbgo39y4U1W5XabvZzwlIxuPEPAW3BzDAiiXcEcSvDX hkypuitl1d09ceL5yZSj8KnagFhPnrs= X-Google-Smtp-Source: ABdhPJyOElQWwN6Xa/oUeoSaKoZF6IqcPxOX/nbZ1AtYj55PAwuv+ggx4j2/mtINeO8LQ0+wX2iwig== X-Received: by 2002:a1c:bd43:: with SMTP id n64mr741934wmf.113.1602802072889; Thu, 15 Oct 2020 15:47:52 -0700 (PDT) Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id h4sm1094738wrv.11.2020.10.15.15.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 15:47:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Victor Kamensky Subject: [RFC PATCH v2 1/4] target/mips: Make cpu_mips_realize_env() propagate Error Date: Fri, 16 Oct 2020 00:47:43 +0200 Message-Id: <20201015224746.540027-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201015224746.540027-1-f4bug@amsat.org> References: <20201015224746.540027-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Aleksandar Rikalo , Khem Raj , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Richard Purdie , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To be able to propagate error to our caller, make cpu_mips_realize_env() take an Error argument and return a boolean value indicating an error is set or not, following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"). Signed-off-by: Philippe Mathieu-Daudé --- target/mips/internal.h | 10 +++++++++- target/mips/cpu.c | 4 +++- target/mips/translate.c | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/target/mips/internal.h b/target/mips/internal.h index 7f159a9230c..c2b2e79c515 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -206,7 +206,15 @@ void mips_tcg_init(void); /* TODO QOM'ify CPU reset and remove */ void cpu_state_reset(CPUMIPSState *s); -void cpu_mips_realize_env(CPUMIPSState *env); + +/** + * cpu_mips_realize_env: Realize CPUMIPSState + * @env: CPUMIPSState object + * @errp: pointer to error object + * On success, return %true. + * On failure, store an error through @errp and return %false. + */ +bool cpu_mips_realize_env(CPUMIPSState *env, Error **errp); /* cp0_timer.c */ uint32_t cpu_mips_get_random(CPUMIPSState *env); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index e86cd065483..117c748345e 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -147,7 +147,9 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) return; } - cpu_mips_realize_env(&cpu->env); + if (!cpu_mips_realize_env(&cpu->env, errp)) { + return; + } cpu_reset(cs); qemu_init_vcpu(cs); diff --git a/target/mips/translate.c b/target/mips/translate.c index 398edf72898..4c9b6216321 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -31316,7 +31316,7 @@ void mips_tcg_init(void) #include "translate_init.c.inc" -void cpu_mips_realize_env(CPUMIPSState *env) +bool cpu_mips_realize_env(CPUMIPSState *env, Error **errp) { env->exception_base = (int32_t)0xBFC00000; @@ -31325,6 +31325,8 @@ void cpu_mips_realize_env(CPUMIPSState *env) #endif fpu_init(env, env->cpu_model); mvp_init(env, env->cpu_model); + + return true; } bool cpu_supports_cps_smp(const char *cpu_type) From patchwork Thu Oct 15 22:47:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C029BC433DF for ; Thu, 15 Oct 2020 22:50:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2B2A620678 for ; Thu, 15 Oct 2020 22:50:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OOcDO187" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B2A620678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTC4O-0005A9-UG for qemu-devel@archiver.kernel.org; Thu, 15 Oct 2020 18:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTC2S-00036F-PQ for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:00 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kTC2R-0003K5-7P for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:00 -0400 Received: by mail-wr1-x443.google.com with SMTP id t9so396611wrq.11 for ; Thu, 15 Oct 2020 15:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hI/5y4MeSKHx09W0hvgXkHn2lpXMMKn63dsyc85sJAk=; b=OOcDO187Kywse0gJ47gEc3Ulm/0TkXthkUXSoA0/H0E64Q7GFotZFSBeZksl9i8Aq/ BblEge7g0KvNCeVMG6JGE2XuKJyXgO79uQiJfVGRJbflZLXktQ7mShDqFfvwXiqvLvpS MKzpTX8grO9Ui52gJmZXDa2LFu4oZ3O7aoRMAGCOMZVkbhlhCdrmXNKrXwIy6iTpoQW1 VFVdGt/qzXiVHHcvGwInO9XlmKjbfDri68RRJfZIlIwLHOc3IImQqhR0vE9lT5LCyKQq HsStF/7E7pl3Qn7DXCzNcpu33rVQB+md/CPmTqPapoEQ6uPMll1vDUPYle7Pq1aIebc4 ixCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hI/5y4MeSKHx09W0hvgXkHn2lpXMMKn63dsyc85sJAk=; b=gecwQLjA7Hwykt+TSVDaLbX1uoPZu0X8z/UgOjaFeHrCgDTLjg/6sYkKnlZYZRLVIQ uiiKcU2zBnIODq+jKUhIOZ3+yCxIcV1Ecl3gIS1BBHPVOS/FdrKig20REHvXbnZEamgm MjFmzC073AUvyR9SXpEPptBLV8/QvVghXCIYJvEK1R+AP3FXJg3Qr/vLcJCK4BS1Wv5r 5Vsd5AbU3p4BlXTy5xsA80L/8Y6U9GgMM23dnkNJ6ot6hmxTYjUX6iLOXJEzbLhjZg4i R2dD6TNzp64RherU+03mQGMNzVFJzvt5Pc9n63Z4ytIhuY/BJAtiZHvyMI3GK1XSHaKI s8xQ== X-Gm-Message-State: AOAM53104xSJenYAKp6GDI7THIVWRCt5i/BYGdAs/XpoOmoTiP5K5hSt 2i3xCQ/1ovfSG5UXfanijNEtDu1WiPM= X-Google-Smtp-Source: ABdhPJyD9FSYzToFbTDw6huJMQ2u8zji949WW91+A8e3B/7jp1WUu0KbrmO3ua5gCrBgsPh2Bu9FLQ== X-Received: by 2002:a5d:5548:: with SMTP id g8mr498499wrw.364.1602802077481; Thu, 15 Oct 2020 15:47:57 -0700 (PDT) Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id j134sm619347wmj.7.2020.10.15.15.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 15:47:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Victor Kamensky Subject: [RFC PATCH v2 2/4] target/mips: Store number of TLB entries in CPUMIPSState Date: Fri, 16 Oct 2020 00:47:44 +0200 Message-Id: <20201015224746.540027-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201015224746.540027-1-f4bug@amsat.org> References: <20201015224746.540027-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Aleksandar Rikalo , Khem Raj , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Richard Purdie , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As we want to make the number of TLB entries configurable, store it in CPUMIPSState. Introduce the init_tlb_entries() helper which initializes it from the CP0C1_MMU config content. Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu.h | 1 + target/mips/translate.c | 13 ++++++++++++- target/mips/translate_init.c.inc | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 7cf7f5239f7..b84e9a8fcae 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1140,6 +1140,7 @@ struct CPUMIPSState { #endif const mips_def_t *cpu_model; + uint8_t tlb_entries; void *irq[8]; QEMUTimer *timer; /* Internal timer */ struct MIPSITUState *itu; diff --git a/target/mips/translate.c b/target/mips/translate.c index 4c9b6216321..698bcee8915 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -31316,8 +31316,18 @@ void mips_tcg_init(void) #include "translate_init.c.inc" +static bool init_tlb_entries(CPUMIPSState *env, Error **errp) +{ + env->tlb_entries = 1 + extract32(env->cpu_model->CP0_Config1, CP0C1_MMU, 6); + + return true; +} + bool cpu_mips_realize_env(CPUMIPSState *env, Error **errp) { + if (!init_tlb_entries(env, errp)) { + return false; + } env->exception_base = (int32_t)0xBFC00000; #ifndef CONFIG_USER_ONLY @@ -31357,7 +31367,8 @@ void cpu_state_reset(CPUMIPSState *env) #ifdef TARGET_WORDS_BIGENDIAN env->CP0_Config0 |= (1 << CP0C0_BE); #endif - env->CP0_Config1 = env->cpu_model->CP0_Config1; + env->CP0_Config1 = deposit32(env->cpu_model->CP0_Config1, CP0C1_MMU, 6, + env->tlb_entries - 1); env->CP0_Config2 = env->cpu_model->CP0_Config2; env->CP0_Config3 = env->cpu_model->CP0_Config3; env->CP0_Config4 = env->cpu_model->CP0_Config4; diff --git a/target/mips/translate_init.c.inc b/target/mips/translate_init.c.inc index 637caccd890..a426463c434 100644 --- a/target/mips/translate_init.c.inc +++ b/target/mips/translate_init.c.inc @@ -946,7 +946,7 @@ static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def) static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def) { - env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); + env->tlb->nb_tlb = env->tlb_entries; env->tlb->map_address = &r4k_map_address; env->tlb->helper_tlbwi = r4k_helper_tlbwi; env->tlb->helper_tlbwr = r4k_helper_tlbwr; From patchwork Thu Oct 15 22:47:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12F1EC433DF for ; Thu, 15 Oct 2020 22:49:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6117E20678 for ; Thu, 15 Oct 2020 22:49:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vp/qTnCZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6117E20678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTC3n-0004Se-9S for qemu-devel@archiver.kernel.org; Thu, 15 Oct 2020 18:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTC2X-0003A0-JF for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:05 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kTC2W-0003KL-5J for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:05 -0400 Received: by mail-wr1-x436.google.com with SMTP id h5so425128wrv.7 for ; Thu, 15 Oct 2020 15:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+UQ9QwYZAZfFcUZzRWl5ACf+Ossl/CGfr/vwWIb0pg0=; b=Vp/qTnCZf/9tvX54YkovcJ44R4EW3FcFyvOE7lVEcxOpxXm2xi4GSfisQiUkmzUcP1 Kmzpn81Il7+tDrxgR4D6rjMoqjS/FPXKuihjnE6JpHLY+MgTLZ6sOUOYU2amQGUV4lF9 XEpgMCsZ9NWiqoN+eA1N/hrSY5oqVvxi952OH0mDLnIDHxBnDkDBUJzL6GNzHm4tOl/5 FS6hXWXOX1kMQshUzhXyf/arUsSL1yceK1er796NfuNWVrhVPKTuYn+mw2xW2siEppt+ EZVmG2UPjmFPQdc4h93vCadbMIxegzkH5ygoOnLUXqqkgUC2oY2Kt0999g9f0w9lJaRo 35WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+UQ9QwYZAZfFcUZzRWl5ACf+Ossl/CGfr/vwWIb0pg0=; b=MYlXswkk0VxzKCDoMsvJt3HdGvfGyjbcMqVdHLfpTVNLHa6tgOApRId8fclu/giaiA porJxPtIgN0sRBV1eWglLvKHP7UdayL9Q2QbKrJcSFZNGX3fE83+wTWFn7mcKyxdII/o VW+nX5VZIcbdpuN3j1ndfuRh1BK8IBHiB6yQLpZlppqey79sklz6lXEswu7hBA30T49v XgQL2ASlbDFySR7AuRkZ4LQSonXgMf/hV29EDxTA//5tfSJE4SmpMJw3VFNThecrOuZX ELluDbzu0+eO7jpaXMx7wSJZIr+i3SWJCyxQqzRcxVe3hMxSMSOlwwp9WVruNQuNApmI jeyw== X-Gm-Message-State: AOAM5311BPFj29/T690xM3yq9YkbpB4ANNrTJN9TSde0xk1t4dmhF/HI Sw9//iRWpjYsgyxK41N9FSeKvkVD8EU= X-Google-Smtp-Source: ABdhPJwDVulSWTHWtsmlSAZnT4SsXYcGttmFdVZYlUn1HnOkJSJU9zS2OG9mo7nvnjUC+E2a566iBA== X-Received: by 2002:a5d:67d2:: with SMTP id n18mr506557wrw.310.1602802082567; Thu, 15 Oct 2020 15:48:02 -0700 (PDT) Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id u63sm622327wmb.13.2020.10.15.15.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 15:48:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Victor Kamensky Subject: [RFC PATCH v2 3/4] target/mips: Make the number of TLB entries a CPU property Date: Fri, 16 Oct 2020 00:47:45 +0200 Message-Id: <20201015224746.540027-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201015224746.540027-1-f4bug@amsat.org> References: <20201015224746.540027-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x436.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Aleksandar Rikalo , Khem Raj , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Richard Purdie , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Allow selecting the number of TLB entries from a preset array. Signed-off-by: Philippe Mathieu-Daudé --- target/mips/internal.h | 1 + target/mips/cpu.c | 8 +++++++- target/mips/translate.c | 26 ++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/target/mips/internal.h b/target/mips/internal.h index c2b2e79c515..34f82c6e842 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -29,6 +29,7 @@ struct mips_def_t { int32_t CP0_PRid; int32_t CP0_Config0; int32_t CP0_Config1; + const unsigned *CP0_Config1_MMU_preset; int32_t CP0_Config2; int32_t CP0_Config3; int32_t CP0_Config4; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 117c748345e..da31831368b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -26,7 +26,7 @@ #include "qemu/module.h" #include "sysemu/kvm.h" #include "exec/exec-all.h" - +#include "hw/qdev-properties.h" static void mips_cpu_set_pc(CPUState *cs, vaddr value) { @@ -183,6 +183,11 @@ static ObjectClass *mips_cpu_class_by_name(const char *cpu_model) return oc; } +static Property mips_cpu_properties[] = { + DEFINE_PROP_UINT8("tlb-entries", MIPSCPU, env.tlb_entries, 0), + DEFINE_PROP_END_OF_LIST() +}; + static void mips_cpu_class_init(ObjectClass *c, void *data) { MIPSCPUClass *mcc = MIPS_CPU_CLASS(c); @@ -192,6 +197,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) device_class_set_parent_realize(dc, mips_cpu_realizefn, &mcc->parent_realize); device_class_set_parent_reset(dc, mips_cpu_reset, &mcc->parent_reset); + device_class_set_props(dc, mips_cpu_properties); cc->class_by_name = mips_cpu_class_by_name; cc->has_work = mips_cpu_has_work; diff --git a/target/mips/translate.c b/target/mips/translate.c index 698bcee8915..f5815160fb6 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -39,6 +39,7 @@ #include "exec/translator.h" #include "exec/log.h" #include "qemu/qemu-print.h" +#include "qapi/error.h" #define MIPS_DEBUG_DISAS 0 @@ -31318,9 +31319,30 @@ void mips_tcg_init(void) static bool init_tlb_entries(CPUMIPSState *env, Error **errp) { - env->tlb_entries = 1 + extract32(env->cpu_model->CP0_Config1, CP0C1_MMU, 6); + const unsigned *preset = env->cpu_model->CP0_Config1_MMU_preset; + bool valid = false; - return true; + if (!env->tlb_entries) { + env->tlb_entries = 1 + extract32(env->cpu_model->CP0_Config1, + CP0C1_MMU, 6); + return true; + } + if (!preset) { + error_setg(errp, "Property 'tlb-entries' not modifiable for this CPU"); + return false; + } + while (!valid && *preset) { + if (*preset == env->tlb_entries) { + valid = true; + break; + } + preset++; + } + if (!valid) { + error_setg(errp, "Invalid value '%u' for property 'tlb-entries'", + env->tlb_entries); + } + return valid; } bool cpu_mips_realize_env(CPUMIPSState *env, Error **errp) From patchwork Thu Oct 15 22:47:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFEBCC433DF for ; Thu, 15 Oct 2020 22:52:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0E18220709 for ; Thu, 15 Oct 2020 22:52:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uHrWWtZK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E18220709 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTC72-0007LK-2L for qemu-devel@archiver.kernel.org; Thu, 15 Oct 2020 18:52:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTC2c-0003Bh-FK for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41975) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kTC2a-0003Kb-P6 for qemu-devel@nongnu.org; Thu, 15 Oct 2020 18:48:10 -0400 Received: by mail-wr1-x442.google.com with SMTP id s9so417035wro.8 for ; Thu, 15 Oct 2020 15:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cDFZKte6J1gmQ1RO0KbRzu5XwwyBiWwbpD2fweDsWn0=; b=uHrWWtZKQqXzXwkn7OL0eV6dFq5FvNmO38Hk+uIbEWOtNOYG8Io9fdepPQtXDEYoNR BNDStF4uEc3r49sme/ALGNRMD98S8PqxjpjdP8q27eUltKR8wzmSipO3UbnX+EBudbOD yvtjIa7f+do7UQt74an6eihZGckrnb3PvZJq1ilfKFIBusHd9AYa2ogII80OgPhLIy3q IdejQKmVqjVF0VOxB+OK+wtU/ujin+lI0u8JHQnzAPJChklFh3BaHZuffi2qYfiNLEZ6 aF2P9Md/vHhLyNoDk+K4ZCIeHP227aWX61oyVEEZb+p7u+agYEE54nNM/T2xN3Tu0OYx XSfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cDFZKte6J1gmQ1RO0KbRzu5XwwyBiWwbpD2fweDsWn0=; b=uPnf5smqK05TpN4/YZX8hNY6iYhtbQo4YlC2/ZFqjLJ7eID8DEbWgtLyzR8v7FD/an u5wPh19mAgoQUo+jTFuokTVjAaiCoZqvRadYFIh6hgUgqLB6Vm23Qr+VBnRzMlCCLweP yAXZJQah80EuXPx+FYDK+yEViC9NRpbtAiwz372x8SVd/Kyr2tn8iIZkPP9n8kYS7G3c yM++O2UkuexCfTUgIdIT3fib8JE8AU0ZGxXy3z6hHj6pcN20rY/We0HmDMHptqr7IWkR zcxFXt2wsQ+5lreKuqyojF9GCKqDnkEMBgeyGgMpI7nLq2h6VedAluKvpnmxFLjOM4gn xPUA== X-Gm-Message-State: AOAM53102o1NynErN0ymiNXdjrlIzr4PEeDNBm1IqsahqLTmV88XZMAf OYNSizRoort5TRuQNwyFVIi5jLsmmdo= X-Google-Smtp-Source: ABdhPJx2cwDQ8UOF8b6cTex9hA1/kT9gA+lvedbq6iyCIFjj8T1H1kTzjUGBO9b8VkQ4Sl+crSfj/g== X-Received: by 2002:adf:d84e:: with SMTP id k14mr513938wrl.251.1602802087290; Thu, 15 Oct 2020 15:48:07 -0700 (PDT) Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id o63sm602974wmo.2.2020.10.15.15.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 15:48:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Victor Kamensky Subject: [RFC PATCH v2 4/4] target/mips: Allow using the 34Kf with 16/32/64 preset TLB entries Date: Fri, 16 Oct 2020 00:47:46 +0200 Message-Id: <20201015224746.540027-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201015224746.540027-1-f4bug@amsat.org> References: <20201015224746.540027-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Aleksandar Rikalo , Khem Raj , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Richard Purdie , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Per "MIPS32 34K Processor Core Family Software User's Manual, Revision 01.13" page 8 in "Joint TLB (JTLB)" section: "The JTLB is a fully associative TLB cache containing 16, 32, or 64-dual-entries mapping up to 128 virtual pages to their corresponding physical addresses." Add these values to the CP0_Config1_MMU_preset array. Example to use a 34Kf cpu with preset 64 TLB: $ qemu-system-mipsel -cpu 34Kf,tlb-entries=64 ... This is helpful for developers of the Yocto Project [*]: Yocto Project uses qemu-system-mips 34Kf cpu model, to run 32bit MIPS CI loop. It was observed that in this case CI test execution time was almost twice longer than 64bit MIPS variant that runs under MIPS64R2-generic model. It was investigated and concluded that the difference in number of TLBs 16 in 34Kf case vs 64 in MIPS64R2-generic is responsible for most of CI real time execution difference. Because with 16 TLBs linux user-land trashes TLB more and it needs to execute more instructions in TLB refill handler calls, as result it runs much longer. [*] https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg03428.html Buglink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13992 Reported-by: Victor Kamensky Signed-off-by: Philippe Mathieu-Daudé --- target/mips/translate_init.c.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/target/mips/translate_init.c.inc b/target/mips/translate_init.c.inc index a426463c434..02500e696f4 100644 --- a/target/mips/translate_init.c.inc +++ b/target/mips/translate_init.c.inc @@ -258,6 +258,7 @@ const mips_def_t mips_defs[] = (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | (1 << CP0C1_CA), + .CP0_Config1_MMU_preset = (const unsigned[]){16, 32, 64, 0}, .CP0_Config2 = MIPS_CONFIG2, .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_VInt) | (1 << CP0C3_MT) | (1 << CP0C3_DSPP),