From nobody Fri Nov 7 09:09:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537028406615607.0926917713157; Sat, 15 Sep 2018 09:20:06 -0700 (PDT) Received: from localhost ([::1]:56098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1DIf-0005i2-PF for importer@patchew.org; Sat, 15 Sep 2018 12:20:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1DGY-0004Ue-5M for qemu-devel@nongnu.org; Sat, 15 Sep 2018 12:17:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1DGW-0003vP-73 for qemu-devel@nongnu.org; Sat, 15 Sep 2018 12:17:50 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:43018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g1DGU-0003rs-6u for qemu-devel@nongnu.org; Sat, 15 Sep 2018 12:17:46 -0400 Received: by mail-pg1-x52b.google.com with SMTP id v66-v6so5742937pgb.10 for ; Sat, 15 Sep 2018 09:17:44 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id k26-v6sm18648793pfb.167.2018.09.15.09.17.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Sep 2018 09:17:42 -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; bh=rwcYuZ5kPERbTjWG0XDUEgttRImNBrSZ5trQPvNeXok=; b=KBPJViXnbHycONNeMvaSvVeidbvRDpy9za0SgbjT+idTaFbdYuw+WLaWD2Zm5snySs R3Du6NIoIG3+oqpGc03cpRF3bDRFCCy99A+Ued/OUJ+kbkrXjJlt+tRIZ7/8p5cNfUkI jBf5ueu4vJQNk/lJEw16eHuoHY/yUGI6H9myY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rwcYuZ5kPERbTjWG0XDUEgttRImNBrSZ5trQPvNeXok=; b=eP/26tE6dXfFZ1iSjVKcETZI7a/FmYEn+YlZwxg7j/DvOXNVlsJYfT+4cKvQwXHi/9 9uCHdFpDch2X9KJioRqwn8DsImgUlTrrBEqS3VSXXHmf3sM9Yictl1Kdg9Q5mpLVM8YP W4ZfDBE12S/5sKm4gKsGKZHIEdHQ8M5gQ7C+k1sKMnUoxrMGUeDMQyQe5VmujDKiB43B PpPdX1hGpGkVy2BXmX0GMP7h/9oGLFhUY8gJEHUl3BUPRg0j9KbZzmEJ4BNo/n18uvUr CNW572Wx0fhwTp2kfw1f4slXSBRGlFUeHY6RC8s0nX8c5k6cvEfk9dyXP776mzcIlzuV 95Xg== X-Gm-Message-State: APzg51BEEXI72nSDkjA6Dv8ljLRI943nO2nFJZksehETrlT0OA9WDefT BC5Xzyg7upjhi+juag4YNWL1w+yr6sk= X-Google-Smtp-Source: ANB0VdZJlYbgdUGT7hWn9jdLRqJbINHvuZ1Aa0MrV9DtEVE7/yUvE2+SDcJMW3QXj39l43aszMWdGg== X-Received: by 2002:a62:7e93:: with SMTP id z141-v6mr18084537pfc.14.1537028263749; Sat, 15 Sep 2018 09:17:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 15 Sep 2018 09:17:27 -0700 Message-Id: <20180915161738.25257-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180915161738.25257-1-richard.henderson@linaro.org> References: <20180915161738.25257-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PATCH 02/13] target/arm: Derive id_isar0 from features X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" ??? Test with -machine none -cpu foo. ??? The assertion does fire for quite a lot of cpus, ??? but quite a few of them appear to be existing bugs. Signed-off-by: Richard Henderson --- target/arm/cpu.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 3bc7a16327..44483e3dea 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -756,6 +756,50 @@ static void arm_cpu_finalizefn(Object *obj) } } =20 +static uint32_t resolve_id_isar0(CPUARMState *env, uint32_t orig) +{ + uint32_t ret =3D 0; + + if (arm_feature(env, ARM_FEATURE_SWP)) { + ret =3D deposit32(ret, 0, 4, 1); /* Swap */ + } + if (arm_feature(env, ARM_FEATURE_V5)) { + ret =3D deposit32(ret , 4, 4, 1); /* BitCount */ + } + if (arm_feature(env, ARM_FEATURE_THUMB2)) { + ret =3D deposit32(ret, 8, 4, 1); /* BitField */ + ret =3D deposit32(ret, 12, 4, 1); /* CmpBranch */ + } + + /* + * Coproc -- generically, v5te has mcrr (3), v6 has mcrr2 (4), + * and v8 requires none (0). There does not appear to be a way + * to guess the value though, as some v6 and v7 cores also use none. + */ + ret |=3D orig & MAKE_64BIT_MASK(16, 4); + + if (arm_feature(env, ARM_FEATURE_V5)) { + ret =3D deposit32(ret, 20, 4, 1); /* Debug */ + } + /* Divide */ + if (arm_feature(env, ARM_FEATURE_ARM_DIV)) { + ret =3D deposit32(ret, 24, 4, 2); + } else if (arm_feature(env, ARM_FEATURE_THUMB_DIV)) { + ret =3D deposit32(ret, 24, 4, 1); + } + + return ret; +} + +static void resolve_id_regs(ARMCPU *cpu) +{ + CPUARMState *env =3D &cpu->env; + uint64_t orig; + + cpu->id_isar0 =3D resolve_id_isar0(env, orig =3D cpu->id_isar0); + g_assert_cmphex(cpu->id_isar0, =3D=3D, orig); +} + static void arm_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); @@ -1003,6 +1047,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) set_feature(env, ARM_FEATURE_VBAR); } =20 + resolve_id_regs(cpu); register_cp_regs_for_features(cpu); arm_cpu_register_gdb_regs_for_features(cpu); =20 --=20 2.17.1