From patchwork Fri Nov 2 10:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 150020 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1901581ljp; Fri, 2 Nov 2018 03:30:57 -0700 (PDT) X-Google-Smtp-Source: AJdET5fS5GHjB+HbwRk5GyKVblYx+ToViEe+T3QRlPzK6ORyjK8JFTYNmpe6sHmyfljAsWOr2i3q X-Received: by 2002:a0c:aff9:: with SMTP id t54mr10180200qvc.93.1541154657722; Fri, 02 Nov 2018 03:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541154657; cv=none; d=google.com; s=arc-20160816; b=Z+PCrPNASJz2FS/AwV8D4tpc2UYDOzw0+N3HCEmNXRLduZRl3DKb7Ahhv1GQS4EsRF solCKLoLRQ1ock6s99mI7Cf7JudnHNG2P78mGCcXYPTdsitjq4ROrdClf4pCZt5jeWOZ XNqe3uREOIvRw6BkEJcXObYfTtpw57734ml5SyhkG6ryrSeXG3k+MzA5mCk9+1L9V2X8 Fg65fADkmjbXmVgJ2LcgfBiUqaCg/TnAX30gMO/QyEeQN+nUEC+48HZO17MGLL+J+P26 DoSTvS7hX+FC4UbdX5/GGMOK436OxQ8CfSr+BNwheZ2MOyyvLNLiI7MtxnTw11LjDqZq Q+6A== 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:message-id:date:to:from :dkim-signature; bh=z4kZgiFt7D0sJR9b8rabqidK/HB4MiDtEo2LV+nbsKg=; b=XlBQo6ExP4N/oxy0GsNQKi+s3pCBsUKDEfTY6EYffpbYspolnfonXtOmk3qFFy0EQA q2DoDML1NBCLE08fLzRDPo9hYAXElR9xm89OFKd1KgRYt3WxAokdp8QxaXr2XhF6vMNr rCt79khftUGJlVF9EMFmJh++rBgFOEjMtSgeyqmGSRJixpDLojJTRN6hPLAas/LfW8Sy Dqyv/WODewWCQvhlQ0+3o8qAdSs191RLfNUQjvZHzE/WrpM30SJA80Zcanig/KZ4JT1L 4ufwwdNJCqM2xQ2h0M+oYbRNUFRO90z9hHtvTm86xgH3yLVnYDJg3ciDvAc1ZhkBTbcC +gpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SO5X8uc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g4-v6si279qkc.228.2018.11.02.03.30.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 02 Nov 2018 03:30:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SO5X8uc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:50636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWjB-0001nr-4q for patch@linaro.org; Fri, 02 Nov 2018 06:30:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWhK-0007xf-Hw for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:29:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWZ6-0006qz-Cn for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:20:33 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38370) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gIWZ4-0006o3-DX for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:20:32 -0400 Received: by mail-wr1-x444.google.com with SMTP id d10-v6so1424598wrs.5 for ; Fri, 02 Nov 2018 03:20:28 -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; bh=z4kZgiFt7D0sJR9b8rabqidK/HB4MiDtEo2LV+nbsKg=; b=SO5X8uc2qq0gs0lfWjh/Ni65vqP4UkAwzkZD5WY3GAnkhQ8Pb1UNIIbaUTPeUfBhp0 FmMcPLv8RO2K/r9mUMXw1QgHMlDQLJ9EOU07EDcr91c4wfmAORydrsJS5gV3S+ECuwVR QVtS/j25hogy1XPJc7BldMSuin/v2ktn/iTJQ= 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; bh=z4kZgiFt7D0sJR9b8rabqidK/HB4MiDtEo2LV+nbsKg=; b=OTCUqBiDPzZAPXDi7jqDZcrkEjt2pCYwr7n4uINIIkwIOdnxkQTv7Q24mH5t4MUIQc uN7mCrXgO3R6MZKGh0H2vCRPK08WUm1rUPnnK0HYGg9JiMqA/SNiQXWLx8zqrT2ZiJV+ NabefPArSQOitJvFhO8NoWgIwZ3dfS8xyiV/De6gCkQ8OB5l4Onp7sn30F+UgKUEcd/N HmB42ZnkC5Dz1eDN5ZsDwaYNXTdIkQTNmuaSXo9bYaiF08itDhpG3fEO+IPR1tFmjIiw K4kE+PN9UHnKu4RIN4RNu5KFI99WyZJxfDEHFfPC7jb4sB4TzHomDIAiUCh45aV8ub5X p2pw== X-Gm-Message-State: AGRZ1gL97pwJkcRd4VC3DRr13RCl/z9zCYH0WlQpii3fNojuabSwSvsS SYGGN2GZTZQkVnu9VHv4lVyAUVs5OoE= X-Received: by 2002:a5d:63cf:: with SMTP id c15-v6mr9816709wrw.221.1541154027406; Fri, 02 Nov 2018 03:20:27 -0700 (PDT) Received: from cloudburst.Home ([2a02:c7f:504f:6300:a3de:88d8:75ae:bf4c]) by smtp.gmail.com with ESMTPSA id x8-v6sm82068816wrd.54.2018.11.02.03.20.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Nov 2018 03:20:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 2 Nov 2018 10:20:25 +0000 Message-Id: <20181102102025.3546-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2] target/arm: Conditionalize some asserts on aarch32 support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When populating id registers from kvm, on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either. Signed-off-by: Richard Henderson --- v2: Test aa64pfr.el0 >= 2; rename to isar_feature_aa64_aa32. Pull out realizefn test to no_aa32 bool; use it for jazelle as well. Alex, can you give this a test please? r~ --- target/arm/cpu.h | 5 +++++ target/arm/cpu.c | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) -- 2.17.2 Reviewed-by: Alex Bennée Tested-by: Alex Bennée diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 895f9909d8..5c2c77c31d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3300,6 +3300,11 @@ static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; } +static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2; +} + static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e08a2d2d79..d4dc0bc225 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -774,6 +774,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) CPUARMState *env = &cpu->env; int pagebits; Error *local_err = NULL; + bool no_aa32 = false; /* If we needed to query the host kernel for the CPU features * then it's possible that might have failed in the initfn, but @@ -820,6 +821,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) set_feature(env, ARM_FEATURE_V7VE); } } + + /* + * There exist AArch64 cpus without AArch32 support. When KVM + * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. + * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. + */ + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); + } + if (arm_feature(env, ARM_FEATURE_V7VE)) { /* v7 Virtualization Extensions. In real hardware this implies * EL2 and also the presence of the Security Extensions. @@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) * Presence of EL2 itself is ARM_FEATURE_EL2, and of the * Security Extensions is ARM_FEATURE_EL3. */ - assert(cpu_isar_feature(arm_div, cpu)); + assert(no_aa32 || cpu_isar_feature(arm_div, cpu)); set_feature(env, ARM_FEATURE_LPAE); set_feature(env, ARM_FEATURE_V7); } @@ -855,7 +866,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) if (arm_feature(env, ARM_FEATURE_V6)) { set_feature(env, ARM_FEATURE_V5); if (!arm_feature(env, ARM_FEATURE_M)) { - assert(cpu_isar_feature(jazelle, cpu)); + assert(no_aa32 || cpu_isar_feature(jazelle, cpu)); set_feature(env, ARM_FEATURE_AUXCR); } }