From patchwork Sat Aug 3 18:48:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170507 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2350814ile; Sat, 3 Aug 2019 12:03:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmvOCCq4ckAwrj6uV1dgTYbMrnSf4E+cmZgnmhiyZMPmwTLC1JtlXe2EJz2I/ifLFTOF6h X-Received: by 2002:a50:f982:: with SMTP id q2mr125564491edn.270.1564859000717; Sat, 03 Aug 2019 12:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564859000; cv=none; d=google.com; s=arc-20160816; b=LsZDqfFBu/p/1hD4D5y8UclpHk36L23ZSLZdRBlN9OBnKVzi/13gJIk/OvFV0pWc2u q5vUjv34vKHOeTb2yNSePbuQGp0qTi+NHdLidMwzydlPQiMNUYRAV1VguaTHfL3tWkWl vqasA9p9HiG+Tk5D9V4h8YTd+Fg3L449I55u+sz0ZiOjuSKYcqKM+feHsM95VwRJkBxJ 9iKV4r9Pn0gv9NAdXcKxHGDE44lms4KcgVgoduUWovaywtdFax/3aR2LBUhMPXcqOm5u d/SrlV9z4Pv2/tvon3JwqcBJmWDUosqAwSmZDx4EMQBx2BAVS1b1gzTyaAXMYsg3rjNv eZpA== 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=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=nQ34I4LSEyIwWpPtctrp88WYX5sBZjv6BVDvgjQkPrvNH/Rfx2L1sCWbRrFIODeGys Wb0+G37fnBwxoCfiVAxVaQH8EBfI5bH5lIrngCPWwGMInFPXx+7tH/S/F8pFQG3kDJLb w4Wnk/KCn57T8LYd+5BlQ103tNswS+QTHOPwX0CgI/akTY7RNshCfNW5DmJteULsmYze +eJ4PyXneDtXbvg9TwWhskfrmNEFN7wuCELGdJU9DXdTQW8VbllJ4mgxl5gDNKCFxeTV /6Rcbf6pV8d08IjQ4pnCPtRach/39LxtF3efiUoljQLzREKGbtoduVnpLTPVoyzQ2av3 Hw0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XUMdfYty; 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 c45si27425908eda.303.2019.08.03.12.03.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:03:20 -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=XUMdfYty; 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]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzJH-00062T-Nq for patch@linaro.org; Sat, 03 Aug 2019 15:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33007) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz5D-0006vq-Hg for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz5B-0007SW-L1 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:47 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz5B-0007Qu-EX for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:45 -0400 Received: by mail-pg1-x543.google.com with SMTP id n9so31447517pgc.1 for ; Sat, 03 Aug 2019 11:48:43 -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=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=XUMdfYtyP/dN0NvjiEKzLhQ81PX1aEG6yfDSVTntnAkC0mjiaPutVEuE/iwMSdBaoI W2BAVieKDVGUWnETHBzDpm1ZmGfk/R32ANvpX6bxCan8Oz3rTCsduFiqbjm7V8wqU8/b bMpmDhcVV6F2wWxm9nc7j2Bn/Ofi/Zs7IjN9iW/QZAMI2nSs5Wx6sAVyRWuS0BaY5UXm WQA5op6gMyyi/s9Nb5FAhiwqXDqXfizNoVCq7fWlZCVe/TUh3wfRLSGOd2CkAbw8Rm8S rFZi2TjdomMmBQLXmyScAFfk/5j0NKU2Smfhj+o1qrw/6SRBWfVSw12ecq7VZLD5gkW6 wutQ== 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=VZbb1rzI4zahnAL11h/DzkD7ar6WwiCPlhOLpT3N7ho=; b=bjbgNkLsAO9wuVUJHNrTXFf9vcsPcpIH0ArWblUGeH6I7RiO0Zp8GldTAufQOBDxyC XzlsmNF71GK5iruNxtdldeMq7W3EQk6Alxoo2kScjqL9jyffcLgcISJwtCecsZtZBI4Q J447CHAoltnNwfIaijU7zbpqPHLKL+Wfwoy74mME2QXGbl8MxO2j+lOMKJjjuv5I/UtW 95c+0MQHcoPdyQCl0lfnIZ6Acw/e2NuWWO3wkFVEw4+0ZMySaIxj3NeVE1o7nJAoQ7Za ayh8Hl3PTCBIqnfQHrCHq5jj7r5iDbOgT6zYN0iZiLuNWgKTyp78aoIK0ccrfvj99/hz MqhQ== X-Gm-Message-State: APjAAAWnBVr3vUvmn3nZ4bv5lnPbVxu142TKs2yprn/miMKxYZNKGz0u DJi5mrAOlFSjYy3ormgLVpH2/Alek9o= X-Received: by 2002:a17:90a:8a0b:: with SMTP id w11mr10351911pjn.125.1564858122529; Sat, 03 Aug 2019 11:48:42 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:48:00 -0700 Message-Id: <20190803184800.8221-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::543 Subject: [Qemu-devel] [PATCH v3 34/34] 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 d7c5a123a3..6e4c97d398 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);