From patchwork Wed Jan 9 15:24:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 155071 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp830305jaa; Wed, 9 Jan 2019 07:24:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6oqmeM3U5Gnm8TeGJuYCSU/mAS8Uk1G3rtRvH6qvYyIxI1iKCLIXtccfVlC2EBHiyhD2aX X-Received: by 2002:a1c:3c06:: with SMTP id j6mr5619480wma.27.1547047496519; Wed, 09 Jan 2019 07:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547047496; cv=none; d=google.com; s=arc-20160816; b=QdR0aZqF6W8NNpaAf/GKoGX/FUt8SwCCGHIV1qSUoRpsjUoRWqzNsHcGyIVE6VqLkt B0Dn4msnUrF/Faf8nb3L/Enr5V06CuXgsb7ktB8GdI0H9smEDvgfDLidQrKJdnj4X8i8 149wciLzaq9Byg6kKNGl7zbNxgfUxKzreuKkC4as39NMrg7TxTnU8dknfGsnhDtaD6b8 C0CHhrOL1j9ZmDEt+uehNl1AdVwQSN2L+5T1set0O8BCE9L0uzItMcUl/66m6AMB27Kh UBtnSGRS1niU8HW7Cop4Ge/yieHy6Mpb5e/LwgLYQOfFzBt7XSBR93eE3x0B9oQlHW6R 5Uzw== 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; bh=hy9zgKoMNOedk/uGX3dfIz/q0RLyoiwxL/mM8ashevY=; b=aAs+vVY+harxkB3y2hoQYeIOJaiXPQ1Vn4LFfS2i27wCpFJ1LZJgc8jUUwa6hkGl1H fzJmXtrArrCfHkW4FesbfD2Fwtc99JitpMe0Nny+hMJ6mVDk6NVGGIPLL/9xmmu1Z/aH C0hWJR0otXPg+BS11W5PG1YGTPKIutXkJsdIJyPzosbsuyiw76Y05xO2BGRyjdPuQHFj 4syThB6eIFFnHA0W3w8pvuFHlbYfKJJTC8efkQ4FvMWmVD61DtARZ4+6Csbti+fen5No F8LFHzX3TRPLI0WkJA9wIPwiumz9LDdqFXfssJ+z2Al9c7+PuNBNPq8jMtb+E07rp063 sh/g== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e18si43328069wra.391.2019.01.09.07.24.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 Jan 2019 07:24:56 -0800 (PST) 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; 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" Received: from localhost ([127.0.0.1]:41677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghFix-0003BX-H7 for patch@linaro.org; Wed, 09 Jan 2019 10:24:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghFie-0003AB-6P for qemu-devel@nongnu.org; Wed, 09 Jan 2019 10:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghFid-0007GD-Hh for qemu-devel@nongnu.org; Wed, 09 Jan 2019 10:24:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:39076 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghFib-0007DJ-Pp; Wed, 09 Jan 2019 10:24:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9E429AEDC; Wed, 9 Jan 2019 15:24:31 +0000 (UTC) From: Alexander Graf To: qemu-arm@nongnu.org Date: Wed, 9 Jan 2019 16:24:30 +0100 Message-Id: <20190109152430.32359-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCH] target/arm: Allow to switch from MON->HYP on AArch32 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: Tom Rini , Michal Simek , qemu-devel@nongnu.org, Stephen Warren Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In U-boot, we switch from S-SVC -> MON -> HYP when we want to enter HYP mode. This dance seems to work ok (hence it's there in the code base), but breaks with current QEMU. The reason seems to be that we try to see whether we are entering HYP mode from the NS side. However, MON is always considered secure, so we always fall into an error case when going MON->HYP and never manage to actually do the switch. Fix this by not using a different helper function that does not bork when we're in MON state, as that switch is supposed to work. Signed-off-by: Alexander Graf --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.12.3 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index f00c141ef9..9bf8fbd8f9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6297,7 +6297,7 @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type) return 0; case ARM_CPU_MODE_HYP: return !arm_feature(env, ARM_FEATURE_EL2) - || arm_current_el(env) < 2 || arm_is_secure(env); + || arm_current_el(env) < 2 || arm_is_secure_below_el3(env); case ARM_CPU_MODE_MON: return arm_current_el(env) < 3; default: