From patchwork Tue Jul 23 11:33:01 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: 169521 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8758964ilk; Tue, 23 Jul 2019 04:33:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwByh8dctgZ1A7YgN4NYjG/i17lPykhWtr15eN+rPMT6le0dDkbYCWjnEuPnW8lMo5PKSvY X-Received: by 2002:a17:906:418:: with SMTP id d24mr58275104eja.258.1563881595900; Tue, 23 Jul 2019 04:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563881595; cv=none; d=google.com; s=arc-20160816; b=pTcnJFIZ5j49y4n6ffrjopWpzyz3e5ujXEi06lyWXfe/ZHvxTPyYNamF28C3BbM2wx B1aTMgVy4h5NR8JNGV4eO5x3YCQ3mS/QVWzVU+tvQQcRET7XgomjaG2G+SnfiLhML/Wi 8pUIg4EhZlhkZsoO7Dy6ynLi5VfoN2myx2xhyFydLrjpGspq3ZOrh8dD+06piJFo66DG 2h/lKJBubC2+WMLdU8tSw7yPWhI3qibbeclb1zl0s7C/hHn6ohdm8cBxKnEv7VfluDpK Gw7K2bT0etLajzFoWA91jUxbU6QpjDRGika2/AapMOn+GK2QuQ+cbQQX8vRZgvgojfmq ACEA== 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=DWbDWaYfcxmkGXUdUBX0lMq0CUBdZuPA0MBGgprVLng=; b=mjVMpO2YXpwPAMgRsRtYUrsCU3mVoPV66rrxK61WZ2NZLspJfh7bVkt+aYtHIf/X/0 YZF7bdHqG5wCEtxHRSQAMLz8rq/VKxNo/M8gslx7o8JADlZDi7GW5UsN5RfgrRO47Ohm SaL1N3+8I1XJRRHwcldNNGfx0dMF9dW5UE3FBTMn8SN1xEz4dEuodX8IVmWmZHTSSVqN 9ufMUnqvSCn/JBW8/fRx6BXfW6BpdEf4n+po2h2ODA05dAp1iq/TYp0H/60T2RnKURFD 5wOjU1v/8xaa1bOS5/+KnvjGmhleG789UB+k5Pwq5F6v6xk8zIK9mYEgCRw4LkkSrNSy 92Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WRleVK1K; 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 n23si5787415ejy.60.2019.07.23.04.33.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2019 04:33:15 -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=WRleVK1K; 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]:41360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpt2g-0005W7-N9 for patch@linaro.org; Tue, 23 Jul 2019 07:33:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54880) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpt2b-0005QB-2b for qemu-devel@nongnu.org; Tue, 23 Jul 2019 07:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpt2Z-0000vJ-Td for qemu-devel@nongnu.org; Tue, 23 Jul 2019 07:33:08 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:47082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpt2Z-0000uY-Lp for qemu-devel@nongnu.org; Tue, 23 Jul 2019 07:33:07 -0400 Received: by mail-wr1-x441.google.com with SMTP id z1so42761913wru.13 for ; Tue, 23 Jul 2019 04:33:07 -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=DWbDWaYfcxmkGXUdUBX0lMq0CUBdZuPA0MBGgprVLng=; b=WRleVK1KsOtUXGCyav3mR2h3r66Z4gFEHcejcl+/2OUqs1FPk9J5bfo+829yTQktuf vJfxYnJOwZb3cJ4S7nRuBbXndljS+eoHAjoGY1VehSauOmAiMzv55PxpxMkuTcXlpy0C cnpDUN9wXsQBdX0HLy2Q8mzwPfe1Yl8pGGauSRgRYQDoW8hlnOiBTsGJgIR27ERH8GNq JPfFpTJ3CiaLE0mjxgafi4WfPRnDqIOco+S7XOqERcH6IvAhwBnm3qLZMgVLCP73VOBt YacWIqIZsE+Df/rovuOexV5Xahxx1H7TmOpAJzu8hrMzc6iqNmoHWM1pQvUEPElf27jI tlUQ== 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=DWbDWaYfcxmkGXUdUBX0lMq0CUBdZuPA0MBGgprVLng=; b=auq0Jtbxmlroitp8ip+IOM11gj+Qi7z3h3uBOlAgXHKSfF02v7MQK7JrbvNxKLh3CO zbyxuJaTaPm0EPXbDq9MnwSk3IRj08bqyHlH5mq21FV4jKzgfs2uKq2R0Ob5SKR1LbEH M3Ysx6d0Kgzp634D1zpWwDKzO+42bA+4MeRCp6gLScL47Hkjt7d72ZPe7a6ufJvZpvX9 zRXaSJGtl6GmiibEp7ulp8+dTxAXZbClKnqIZ5jtqlsLkiErGJsUWbCDtCAXdbzBSDA+ TNO+cc4rSLSu31MNjZnQFkuvoSJpEuy9Mc6Wk88yAkuqxdJ2KKHh6Jypfmg6n3BxF4df 9Kpw== X-Gm-Message-State: APjAAAXym/ElJ7Wi9ZzkDi6CaoU3tRvrgdTGA9CgkhL/BvpVPHkz2ZAE 8tpJbbh/DcHb0c+ML2EBj+aUUQ== X-Received: by 2002:adf:ab51:: with SMTP id r17mr54329617wrc.95.1563881586322; Tue, 23 Jul 2019 04:33:06 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e3sm38553746wrt.93.2019.07.23.04.33.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 04:33:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 59BBC1FF87; Tue, 23 Jul 2019 12:33:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 23 Jul 2019 12:33:01 +0100 Message-Id: <20190723113301.16867-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::441 Subject: [Qemu-devel] [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 telling kernels the ID registers should tell them everything they need to know. Signed-off-by: Alex Bennée --- v2 - don't leak QEMU version into ID reg --- target/arm/cpu.h | 6 ++++++ target/arm/cpu64.c | 6 ++++++ 2 files changed, 12 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..e88aadfd2fd 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -296,6 +296,12 @@ 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 = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); /* Reserved for SW */ + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); /* See ID_* for details */ + /* the rest is enigmatically empty lest kernels assume it means something */ + 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);