From patchwork Sun May 1 05:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568563 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp7707358map; Sat, 30 Apr 2022 23:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp0FEsZNvLvEMH/S6956mrqoX0fgc5LyS0zZAUd24raA3987w/1uLcWpfIEY2AE//Dk+jL X-Received: by 2002:a05:620a:989:b0:69f:c506:2ac1 with SMTP id x9-20020a05620a098900b0069fc5062ac1mr3375992qkx.645.1651387409941; Sat, 30 Apr 2022 23:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651387409; cv=none; d=google.com; s=arc-20160816; b=XnqvgJgOLAEu3fLNqiXaQFTT1qoIXwk92+QLBGK061VnTtM5zzB8+1oXZZU66TtQFQ IOdwV97zUrFt4QPVWEr1CCvQ9+i1USqYJOzKqGQKIczTlXmYzOMaXVkJW7rFlxBHMb+m qXpEg81cVRCyXkP2lQKim/hl8f/T3SgPmiLAEurlggaSLJjx49bfnOXz42tCtUIBwnQw Sggh9vHADjq7G1421uXBOVNGLI7X1+AQcpK7L5hCZSbKNfy7YlHEudHPC/FMdelqZIby OLXJj1ACF62MdJdl7pm3dxkM9i7iPo2wrYLNVRYFGVc8FZatYYj+N9FRknzoVGNB6ARe 985w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CHRhI+bX86VA6q/w81eljR54J64KB5RR2ukIj4TlNII=; b=jvHumDHBuZw/T7KYo9dFkj5TL2kNexSJn4kEPEgbL0g1ixuAUKYQTREv/5ikzzjhqe 2nfPw7w5smWQO7mpgiJSgtgAox/2MDt/7QvKzscsA/IX2gv+hr0x3cHkEtD6AP0Ftlno OWA8p2dhQaX0nBaqKt76NY+99YwoOmlNahgTl67bvIDv9EVcld3Rgo7X+xYrOpP6KWKT JvRU5DXjzI6Ou0kBuszxXwQh01kQ7OCULANaljpZ+gE9wOsIQhMgqud1EtzwXz23gvnc 4ZQg/GTSv91AGyVWb1hhwoxy/iTopC+Ynn/0Gq305wi8BSVwUbLMT7aoaysePCk9dWTn hdyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E3Q64BpJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f17-20020a05620a409100b0069f5219bc22si4903089qko.59.2022.04.30.23.43.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Apr 2022 23:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E3Q64BpJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl3In-0001C3-Hu for patch@linaro.org; Sun, 01 May 2022 02:43:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl2Tr-0006tK-9i for qemu-devel@nongnu.org; Sun, 01 May 2022 01:50:58 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35800) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nl2Tn-0001IH-AK for qemu-devel@nongnu.org; Sun, 01 May 2022 01:50:50 -0400 Received: by mail-pl1-x631.google.com with SMTP id d15so10293993plh.2 for ; Sat, 30 Apr 2022 22:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CHRhI+bX86VA6q/w81eljR54J64KB5RR2ukIj4TlNII=; b=E3Q64BpJDClA1H8nu5PtO0JbHilCY7GI4jNJie9eQs+c/PrJJHeBS4i2I9r8jnA23p KCTDp6gtpQUMFgmiDKpw4ktXBSERU4Pj2uBQj1jIRAufEygmbP9PGLbFhxaFBKf1AWLa sIL5Y0/wv/05ZG4EihItT71vVJd7uRfojwaIgg+avLjYmGzmksioD9vY6nthGRdiBw68 0y5X5mz1x4LnsWi8aA7SjxGJ4XS+ZZn7S3BArF2Z2Ut7Oy1RPk/VFVm5yE0Er/TBuE+z J96zR94OqoJX5Z6g22GMXO7qHTjnty14/r3qia857tOjU/W6IVvt1H4x7mZAVlXevXl/ 0CMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CHRhI+bX86VA6q/w81eljR54J64KB5RR2ukIj4TlNII=; b=jzoe0k6QQRtsI4+I54R5+XmjW9KVOnUwV84zweTpXTx8ysjLLcvu7YysEvXpStoIdq MtqJmMgD5O7eohmGQzfD7cgmW+umoFEo2NkUhnDo7QJog7awIhDgEhREXwlWATCGWNTJ 59PwJKduCw2rxwO2w4qBnmOdsQl8Xbs+9BKjh98dq7NdQhLPIpgc8go+2oqHuEO3kn/8 1E/uDNUhdNHCW4vJWENFPfi1sBtQuCe+9Xioxgm+KAnmp5Y5GSukw7p/CVXCiB8gf5Gn MnoEMYtD1dE28zf8vUFX0jUFCeclxkiMlAlTWp+0dvNkxyYevTpS+fYs2/zPC4QuLoA0 062Q== X-Gm-Message-State: AOAM531QNF4WR7W+JdQBvwEK//+5Jka+JJq2qAog70zwglXuwiA0z9rm H93DujgrW+c2V5uvhYcu0ds2YpNJg00WZQ== X-Received: by 2002:a17:90a:6501:b0:1ca:a7df:695c with SMTP id i1-20020a17090a650100b001caa7df695cmr7183277pjj.152.1651384246027; Sat, 30 Apr 2022 22:50:46 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id cm18-20020a17090afa1200b001cd8e9ea22asm17310342pjb.52.2022.04.30.22.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 22:50:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 17/45] target/arm: Perform override check early in add_cpreg_to_hashtable Date: Sat, 30 Apr 2022 22:49:59 -0700 Message-Id: <20220501055028.646596-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220501055028.646596-1-richard.henderson@linaro.org> References: <20220501055028.646596-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Perform the override check early, so that it is still done even when we decide to discard an unreachable cpreg. Use assert not printf+abort. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index f1fbbdb9e0..2ed07795d8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8538,6 +8538,14 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, g_assert_not_reached(); } + /* Overriding of an existing definition must be explicitly requested. */ + if (!(r->type & ARM_CP_OVERRIDE)) { + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); + if (oldreg) { + assert(oldreg->type & ARM_CP_OVERRIDE); + } + } + /* Combine cpreg and name into one allocation. */ name_len = strlen(name) + 1; r2 = g_malloc(sizeof(*r2) + name_len); @@ -8622,20 +8630,6 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, assert(!raw_accessors_invalid(r2)); } - /* Overriding of an existing definition must be explicitly - * requested. - */ - if (!(r->type & ARM_CP_OVERRIDE)) { - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); - if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { - fprintf(stderr, "Register redefined: cp=%d %d bit " - "crn=%d crm=%d opc1=%d opc2=%d, " - "was %s, now %s\n", r2->cp, 32 + 32 * is64, - r2->crn, r2->crm, r2->opc1, r2->opc2, - oldreg->name, r2->name); - g_assert_not_reached(); - } - } g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); }