From patchwork Fri Aug 16 13:16:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 171479 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp864740ily; Fri, 16 Aug 2019 06:18:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTVTf893rN+ydpg/6UhcOuNUxqFM7iAow/gJm0LEGJhBh3bzkSmwoTj27sf/KYnjhBJF4M X-Received: by 2002:aa7:d753:: with SMTP id a19mr3486006eds.284.1565961489540; Fri, 16 Aug 2019 06:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565961489; cv=none; d=google.com; s=arc-20160816; b=bBFFzOQ9H9teIHpfJMSqgYmKF766o9PbmYvjsRJZ8AbcSMNZuunzmwp0yZNzQ2CSnQ +TDBi9fKaj+OI2y5HfZO40inBGsFSQYriBVJ8C1W2wTLQjgrRuXK9Gn2DOqkSfySWl/3 8PRurLS4YZSEECwEm409+jwb9RdSRWysBupUuf68Ag7kyKo7YeJyUiMQJSeYvTocu3cD ia3HIzJtu6I3dP9tsHp+LDIj1H+PY1R3kvtWMMcmg/oRXQv73eVDEk7wp2XcV0ii7GPQ YrroOHMTTbH18C4PPNt8mkS8+w7nXl0/BJNjWxsNXy9pLleu7cB/texxezrDGjzyes/9 5fog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=0ZnJsA94N8X7Cu7kfm4dOD2XBmDpwblF2KvIbDAt0vg=; b=K10HfokthEgLNNkYlrtlLoFVfudyvQ/8R0mTDLaVAO3yz2fQdqaX2nzUcOPZVqrWuo x0x1MArOvn2eO8JAerTEfrJ3iCKXRGt3eeqTpsFaP0jnL1JGS9UAzRmfGyJxNtIa7uhN Wh35VjfIlqtlJM+Z7ieu5K7b8YOKhEKO/HLnQtOngyPbhCBTRd3X6etEUpRdA5D3vxXy ltbs4QueCO7ndFPw7xpJr9CTbauBUBSJ3lZfKkMdE5BLu+fKBJB6aEhv7b5hknBVDxsT PnhqsIMLTy7uhdNLqrPHTbKovyNvuTk7+opG7A2kdqSF7SDpa045jYtmyQFL8voc5sUu xL2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TBQBwkWy; 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=fail (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 g37si3288530edb.268.2019.08.16.06.18.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Aug 2019 06:18:09 -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=fail header.i=@linaro.org header.s=google header.b=TBQBwkWy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyc7L-0003LO-RQ for patch@linaro.org; Fri, 16 Aug 2019 09:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35122) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyc6i-0003Jo-IC for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:17:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyc6g-0005KT-73 for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:17:28 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44788) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hyc6e-0005Il-NS for qemu-devel@nongnu.org; Fri, 16 Aug 2019 09:17:24 -0400 Received: by mail-wr1-x443.google.com with SMTP id p17so1512037wrf.11 for ; Fri, 16 Aug 2019 06:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0ZnJsA94N8X7Cu7kfm4dOD2XBmDpwblF2KvIbDAt0vg=; b=TBQBwkWyuT6Stlizt1gHqQss/m5pVzDpeiWCTYtt/+L479Z1DkG+SdwtCM/DGxmg2Z vHTAuSYhijfBwHtcPEGqk2a6t3biEGyw8sjfPXXduoxB1GdldBAOdEtClXRdECr42cEH QQNCjxITB5r6ohTAWkW8lCQh+UZR0QvvYExaxMb6BRYfsLTqLSkuTdKmbVzFxYWbBvRG 957ggFtXni9KfqTiq3MjRrZiIE0XRY9BxKe87nndLOo7jGjfTV1u61CrqECd6YtY6Fzq wWCJlJIPw4/V6Gxm9gj+gS1laY2jHlIyshHLFtdLjW/+Vvlbj00t/fXJMsgC5OeCL5Ip 4BaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ZnJsA94N8X7Cu7kfm4dOD2XBmDpwblF2KvIbDAt0vg=; b=JUHMarBuAiRmKMqrPzAs2OucAxhKTHHwmKKmo9pWzi5Uw8Vz3l8vzaK+7slaTWv3ip BJjrxitGTtU+Pz3vp+CX9YwGCfxv2X3/Ob46GbM5FbLoYHHszMAta0kmDNNdncpa7Al7 uEgz84+Xt8Il33inrov8yt2PRIadWie6yQpv1VbH57DxGvYN7L7FhnNgz4ILXp9flO/v strMFb53FvgRMldaWw5UvTSFUZPn7j2p7Jb0knyv7AvBIw6eNb0EWkCe5kwSZ3S6Wv6+ +/gJBZ+DIiUrYy7eQUtE0H34dZAOm3cTEcTj/VmKT0VVRscESPdy1YqOgJiDuDk0bqsC clUA== X-Gm-Message-State: APjAAAV7980IWsQGhn89NQBygFExozNnNmsUvYq8Xuin7+r4WibJc0QU 7pM+dDWOKMGFwbSi5AyYRZ2ZbKEArU/0hA== X-Received: by 2002:a5d:518d:: with SMTP id k13mr11384527wrv.349.1565961442809; Fri, 16 Aug 2019 06:17:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 4sm8705796wro.78.2019.08.16.06.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 06:17:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 16 Aug 2019 14:16:51 +0100 Message-Id: <20190816131719.28244-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190816131719.28244-1-peter.maydell@linaro.org> References: <20190816131719.28244-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 01/29] target/arm: generate a custom MIDR for -cpu max 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée While most features are now detected by probing the ID_* registers kernels can (and do) use MIDR_EL1 for working out of they have to apply errata. This can trip up warnings in the kernel as it tries to work out if it should apply workarounds to features that don't actually exist in the reported CPU type. Avoid this problem by synthesising our own MIDR value. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190726113950.7499-1-alex.bennee@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 6 ++++++ target/arm/cpu64.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 94c990cddbd..67f2af0e169 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1611,6 +1611,12 @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) /* * System register ID fields. */ +FIELD(MIDR_EL1, REVISION, 0, 4) +FIELD(MIDR_EL1, PARTNUM, 4, 12) +FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) +FIELD(MIDR_EL1, VARIANT, 20, 4) +FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) + FIELD(ID_ISAR0, SWAP, 0, 4) FIELD(ID_ISAR0, BITCOUNT, 4, 4) FIELD(ID_ISAR0, BITFIELD, 8, 4) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1901997a064..ee55237a9b2 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -296,6 +296,25 @@ static void aarch64_max_initfn(Object *obj) uint32_t u; aarch64_a57_initfn(obj); + /* + * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real + * one and try to apply errata workarounds or use impdef features we + * don't provide. + * An IMPLEMENTER field of 0 means "reserved for software use"; + * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers + * to see which features are present"; + * the VARIANT, PARTNUM and REVISION fields are all implementation + * defined and we choose to define PARTNUM just in case guest + * code needs to distinguish this QEMU CPU from other software + * implementations, though this shouldn't be needed. + */ + t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); + t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); + t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); + cpu->midr = t; + t = cpu->isar.id_aa64isar0; t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);