From patchwork Wed Jul 31 20:38:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170270 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4483263ile; Wed, 31 Jul 2019 13:54:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgvG9e8iNJTiVECAhVSR7FB7H9AmJyaNrIXS+IwSmhuDXrdH2Tw5DX1vXb4uwBkW06j1AI X-Received: by 2002:a50:9ec3:: with SMTP id a61mr10365885edf.184.1564606498543; Wed, 31 Jul 2019 13:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564606498; cv=none; d=google.com; s=arc-20160816; b=zsflkLZaovki933QNtRHXLAKvyWHDQ6M5sYODJqTfs9cR19D45jnwy3N+sA92CaJBf Y+CuXGiEX87obQUuf5jmnu/y1WZpa2C4hWleOE9vM5hQ4AM4wV1PmbZoc0zswDT/wHwu MQncuUb5zV+afWkXxA/aTWQPyKiEZDV4yiBXICG8crT+OTQQy81wIiLPPDEnA7lAZSSk uy217pQ7DfSOSZlNcv1ULK1i8SlEU590BqrbWdcUx2S1zHA8XJWaidnUiGXCIGRcR7/0 pXDGa9hlzNsv82u5iEoD+b2Y4mpxqwgzTsJWqKdsOBSHzHlBoUFJZnMxtnLDOq1/iJiY CBdA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=mXFzu+riM40LTPYaleJMgiP+SHjfE12Lorh6SccQVg32LLyZF072BQYs15ej9HnxVD ksbeDChYDfHyi87y1GzzX/L4gxBGqlbzfbUS0pPRNWcxCY3bY7SyffExZFAR9sXCf5lT 27bOsa3aQjHwMvIgLSYkkDMTCxpUUdO+Rrt+AIn4uU9eJ7VGx4M+axK6LUmoQvTPBzKz mlGtAYuyQBqeKzM0YCiaq1HqY9t/Z63nyNQxKif15NoQKfTtjl6wwTXevbGoNGWgiT03 PsPbO4MwGRqxEV31CZOdsyBv0/YekyR3CDTAUyxszWqX/YvcmW9C8+9yzBKYASFhS8ne SqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DX5wfvfh; 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 y24si21128822edm.354.2019.07.31.13.54.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2019 13:54:58 -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=DX5wfvfh; 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]:44536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvcf-0005bR-Gd for patch@linaro.org; Wed, 31 Jul 2019 16:54:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33255) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvNI-0005eH-3Y for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvNG-0003t6-Ez for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:04 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41505) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvNC-0003pm-MM for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:39:00 -0400 Received: by mail-pg1-x542.google.com with SMTP id x15so22297600pgg.8 for ; Wed, 31 Jul 2019 13:38:55 -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=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=DX5wfvfhHx0n2P2s6jl6RwziKqDkDxXUOzDh7/6cIrZEbTQqGsEd+W+FyUdIZ0RkGw P5arA1F6Y8ZC6vw5DUFCrz/he4PxGXmFRQJF35Dw3jLQEFo+QFxAjy61gKKerwr2lk9Y TNewzFtsTvvoWeenZLzItpoSeulZVmILyKKjRMeSM81X+JANzAn3L9ivEeaDzkmGZVU3 3rj2vJoEBSFbi8KNDlqG0VZJJ8ZEzVM3H17Y25SD35h6qqPZIAjwffvfOAsThAcK2M+l N52mDMflXcUB5Yl1qa1LhqLtrlMBOvc6TFUfo1iJuI3xal2npnqXgi2PbtiyCOTWmc+n XvMg== 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:mime-version:content-transfer-encoding; bh=rCEnVED33NpbOad0FfG1c7z9lc80+f3mCsiBq0HqyvU=; b=D5Ph5Lqq7v4om4m69mw5sVFAuBjIf6rYqMISxjy3d0ocQUnHZrQAG8l/5pESu/W5oR ZKFgVwfbM1362/C4SPKef9G2LWj3CJ6/wpSEd06H4gJ7WGAc/xU6OGQm8D4mL1L28Toe pOt5tiXqzexTlXDhLPX+aszLwZgFx8xJubq6qxcRelb59mwM18q/jyaeB8jvWhwYjKVI FdUW2jhXbWX0DfgEWmBNd5faylPdZLJieBCzs20JZGPsaPgjhLNlv6qVvSY9gt13H+x8 P8W+Dg3bblOWOfeb0qqrvtSh1+veeclhziytXw1BW9yZm6tqWBtxR30N7gJmzIAePD/C 8fGw== X-Gm-Message-State: APjAAAUGvYcczvsuTI11/g7weyBzUZbCrE/oMvfBvIrQc3BBVOfJKExz OPezRvrs2aSg/ky5qjMrEa2vNxvPq1U= X-Received: by 2002:a65:430b:: with SMTP id j11mr113663987pgq.383.1564605534112; Wed, 31 Jul 2019 13:38:54 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:13 -0700 Message-Id: <20190731203813.30765-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 32/32] 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org 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: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/cpu64.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c41da1d791..bc9b6db9b4 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1605,6 +1605,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 b1bb394c6d..3a1e98a18e 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);