From patchwork Mon Jul 22 11:19:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 169366 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7395753ilk; Mon, 22 Jul 2019 04:19:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyd6dbTS0jD6HDek7E19YqH2gWvaig/A1J/1a4/IIiSPjym106zNiBirV16B1ctgewoAF6b X-Received: by 2002:a0c:f8c5:: with SMTP id h5mr43395762qvo.12.1563794367832; Mon, 22 Jul 2019 04:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563794367; cv=none; d=google.com; s=arc-20160816; b=U7j0f2yMenH8L7EXxAccEyrfV8+T+Yep4tihyTV3JsYgE62Rm7qBtF7P0ZcrVRDzYe Updd5wkly9dKFA9HDmDcEncmE8s0BuR5fe+hUChXtaUU1S0V9xnYZLwRJPpGhngksnJE iWoysia9tpgFLHsXhB6zA0dN9vFwlYBUeQDpZczrpMJ0QNZVX4ZMpPYM8v8fok/8lxMD ar43SP6KRyoWlkvaeSAVZuKiKXr2C3Swfas/55mGCfdGk41qLrG7uHfD6k13pwm7+/Ok 3+Oobfta8O3QfrSrIpIk2i2W96DwdiFjW/VjBzXNNoEzFuwvlOoedcOBn0nCURK3K/c/ Z2mg== 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:message-id:date:to:from :dkim-signature; bh=ldvnOqlot+qdpEWUg3Q+YzBAvRrhAotsXklrj4ILSb4=; b=TxjFGDiLJbimIFEkhpQhZ0s3Svy6nDrMQZgaqWk536OSBqW5GPdOtdYpXOhNe0FfzS Ynq7+V950nObp0ZJ99Brsz2pQVrfd3BZoCEFY5Txq/oE4Itz17hcU1R0qb0e8sjMl+BT I9aISlvIhE23VAk/yVqD4weJmQTc8n9Rp8hB1JzGL8toVzMkiy9GXgMyh7+Mj0A2UPGT saFUNVB/vHbYMcSmcjX/52p5IR1j2UhQ1MI6jTZD+4lz/CrG23pH1xCIP2/5n5kTp+lr W/bq8+wA3XPXpm5GytQwoA0veY+pXDB4WaaTjgAdZvPF4cSf9DJTFwekh5HSHdWVyhjm ZG7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y2qGZhKB; 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 o8si25157052qkg.41.2019.07.22.04.19.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 04:19:27 -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=y2qGZhKB; 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]:60552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpWLn-0003xM-8v for patch@linaro.org; Mon, 22 Jul 2019 07:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46615) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpWLh-0003wz-UZ for qemu-devel@nongnu.org; Mon, 22 Jul 2019 07:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpWLg-0005Ua-Q5 for qemu-devel@nongnu.org; Mon, 22 Jul 2019 07:19:21 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:35741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpWLg-0005TY-GR for qemu-devel@nongnu.org; Mon, 22 Jul 2019 07:19:20 -0400 Received: by mail-wr1-x443.google.com with SMTP id y4so39021299wrm.2 for ; Mon, 22 Jul 2019 04:19:20 -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:mime-version :content-transfer-encoding; bh=ldvnOqlot+qdpEWUg3Q+YzBAvRrhAotsXklrj4ILSb4=; b=y2qGZhKBPAugpPF2oKkNPRH6ut8JLduHFB7e9PiJSklFjug8Iro8CZPKwjx6b/c/Ww TSLPZYeaiBukt8FOzQcUvYqxfIkwSzuYwgFaA6PBFI+4VoZjw5CcZ2cvm5iGnNJ+iASE BuMGkPAsXKKMUUb2w/u/0JR1YCdGYaFQj85KeRIFz0iHpWHdx20/ivIdDuPEpFzk8UzN /5GY2aps9QGLuuxmPF94akAZwV1CFlzFH3DpPECNmnWPXOYmf/mVdb2eatgvAjtayQ7W acoBD2HcbBJIgRZbz+BF5HS4c8yKi/izCRgIYTtxze6f+WT2nZi5g32lMl+XEMsWmpIg kuwg== 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:mime-version :content-transfer-encoding; bh=ldvnOqlot+qdpEWUg3Q+YzBAvRrhAotsXklrj4ILSb4=; b=MbTib31Ie1a7ESKDRh3BB5qblrKJeAin8N8x2IiZF1DqjnxxHm8NrM1LtirnXtG6nL uv0t75vxLgny95ETS8oucySgs5w3yhChU85xIIYZMTJifrAKDIFv1dR7+MtIeZ1L05E/ 3IKyC7w2IDZf4i1WUEeky3Yky7qfz6u10YcjSo6glKifBhjptGDhTwaKOjivwH/Pd/qz uTLtO9XbEA7Uw5EHNQ0ajxGJsQtR7pPa3uhPwMCopUuECMRXK/Du9knh42QmhzeadYiW dVKPeY1087yFcvKzGrPXZUlFWvi1E/R/L8yVUpXzaIVoUtKnsjkCaKc0mn1EzRkE6vFq 7Eig== X-Gm-Message-State: APjAAAVe3Bi7raIGPF3FXQ2E6JiNPmXJBdO1AGDaEKb/aS+AUnO058yl MR+8QNQHmwQHPlePLGb4uSIa3w== X-Received: by 2002:adf:8364:: with SMTP id 91mr74101423wrd.13.1563794359135; Mon, 22 Jul 2019 04:19:19 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y18sm38214088wmi.23.2019.07.22.04.19.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 04:19:18 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 323001FF87; Mon, 22 Jul 2019 12:19:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 22 Jul 2019 12:19:14 +0100 Message-Id: <20190722111914.28574-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 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] [RFC PATCH for 4.2] 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 , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 using the reserved value of 0 for the implementer and encoding the moving feast that is the QEMU version string into the other fields. Signed-off-by: Alex Bennée --- target/arm/cpu.h | 6 ++++++ target/arm/cpu64.c | 10 ++++++++++ 2 files changed, 16 insertions(+) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 7efbb488d9d..61eaef924e4 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, VARIENT, 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 b1bb394c6dd..c121d0b37e0 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -296,6 +296,16 @@ static void aarch64_max_initfn(Object *obj) uint32_t u; aarch64_a57_initfn(obj); + /* reset MIDR so our franken-max-cpu type isn't mistaken for a real one */ + t = 0; + t = FIELD_DP64(t, MIDR_EL1, IMPLEMENTER, 0); /* Reserved for SW */ + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); /* See ID_* for details */ + /* Encode QEMU version details */ + t = FIELD_DP64(t, MIDR_EL1, VARIENT, QEMU_VERSION_MAJOR); + t = FIELD_DP64(t, MIDR_EL1, REVISION, QEMU_VERSION_MINOR); + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, QEMU_VERSION_MICRO); + 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);