From patchwork Tue Feb 2 18:20:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8193361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ECE1EBEEE5 for ; Tue, 2 Feb 2016 18:21:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 626D8201F2 for ; Tue, 2 Feb 2016 18:21:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3D7D202D1 for ; Tue, 2 Feb 2016 18:21:02 +0000 (UTC) Received: from localhost ([::1]:58900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQfZW-0003Vl-2S for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Feb 2016 13:21:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQfZM-0003Sk-5N for qemu-devel@nongnu.org; Tue, 02 Feb 2016 13:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQfZL-0002vb-BG for qemu-devel@nongnu.org; Tue, 02 Feb 2016 13:20:52 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:57168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQfZL-0002tV-5H; Tue, 02 Feb 2016 13:20:51 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.84) (envelope-from ) id 1aQfZC-0002g6-PY; Tue, 02 Feb 2016 18:20:42 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 2 Feb 2016 18:20:42 +0000 Message-Id: <1454437242-10262-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::1 Cc: "Edgar E. Iglesias" , qemu-arm@nongnu.org, patches@linaro.org Subject: [Qemu-devel] [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We already modify the processor feature bits to not report EL3 support to the guest if EL3 isn't enabled for the CPU we're emulating. Add similar support for not reporting EL2 unless it is enabled. This is necessary because real world guest code running at EL3 (trusted firmware or bootloaders) will query the ID registers to determine whether it should start a guest Linux kernel in EL2 or EL3. Signed-off-by: Peter Maydell Reviewed-by: Sergey Fedorov --- When full EL2 arrives and we have the CPU property for it then this will expand a bit to look like the 'if (!cpu->has_el3)' condition just above it. target-arm/cpu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 6c34476..0cc075d 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -650,6 +650,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->id_aa64pfr0 &= ~0xf000; } + if (!arm_feature(env, ARM_FEATURE_EL2)) { + /* Disable the hypervisor feature bits in the processor feature + * registers if we don't have EL2. These are id_pfr1[15:12] and + * id_aa64pfr0_el1[11:8]. + */ + cpu->id_aa64pfr0 &= ~0xf00; + cpu->id_pfr1 &= ~0xf000; + } + if (!cpu->has_mpu) { unset_feature(env, ARM_FEATURE_MPU); }