From patchwork Thu Mar 17 13:20:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63990 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp464221lbc; Thu, 17 Mar 2016 06:20:31 -0700 (PDT) X-Received: by 10.98.7.81 with SMTP id b78mr14817278pfd.49.1458220830771; Thu, 17 Mar 2016 06:20:30 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id wb2si12460634pab.213.2016.03.17.06.20.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2016 06:20:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 593441A1E32; Thu, 17 Mar 2016 06:20:50 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F00B31A1E30 for ; Thu, 17 Mar 2016 06:20:48 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id l68so116904736wml.1 for ; Thu, 17 Mar 2016 06: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:in-reply-to:references; bh=3PGv082cUVNgFMXHCmjHO/5U3n8UHwhyQAgSp3Qo3kM=; b=XTkinTBVGqtJAzOa2mG0Ux7ZatkqZaj4mR0mF+XOmFRO8L29dPFXmdX8vfvJWjrrXX pUWRz7y2yT1NNUU1eeeYRpPgXiBxa8qsdFP7dYubvYFM4wSBsN/KON6KZxJzHHYgKwN8 iXyu67wplaTHkPmJqgUXiveokhSfokcBqrcts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3PGv082cUVNgFMXHCmjHO/5U3n8UHwhyQAgSp3Qo3kM=; b=fzp/0qYkCE+PwrJakh2knZ3tGKr0griE/Xexh1VIqlvS0AE0aBUJsW2fhvGS/8C8nF h9PEPzeDfsdp1Ox4UR/XOahDjtk9GNQN3Ysx6S5EiTKfMvGsG2RZ+ATby7nTC8waC6O7 T4INR7d6Zt3/Ip5IQNpME8VwLWDVS0ly2vCTPRuh0BmuSB5ETXTjWXdrn5C+9ibHNXoq 5fNJ8mioh4+x6JA/ZTkfQpID88OctpVI728Go5bpL/dMpBTB3ULLZ1PnZBJmpFkWNuu1 nTPY8IwJIxi20wrX19z4Tw/d0We6fBYArtDW/nCdg4DxeT2kbyzcGuxgWLhWDE42+qAa 9MZA== X-Gm-Message-State: AD7BkJIaEJkUb0y8AHdTuXEznNL7NGWAKpqSy4KqCupacOad/r/Z1/vcGzZqCO9MJhwwf7Ph X-Received: by 10.28.68.136 with SMTP id r130mr31371688wma.28.1458220827657; Thu, 17 Mar 2016 06:20:27 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id v5sm30198913wmg.16.2016.03.17.06.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Mar 2016 06:20:26 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, eugene@hp.com Date: Thu, 17 Mar 2016 14:20:09 +0100 Message-Id: <1458220815-6944-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458220815-6944-1-git-send-email-ard.biesheuvel@linaro.org> References: <1458220815-6944-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/7] ArmPkg/AsmMacroIoLibV8: remove undocumented assumption from ELx macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The macros EL1_OR_EL2() and EL1_OR_EL2_OR_EL3() allow conditional execution of assembly sequences based on the current exception level, by jumping to caller supplied labels 1f, 2f or 3f. However, the jump to 1f is actually a fallthrough, which means the EL1 code needs to follow right after the macro invocation, and the 1f label is ignored. So let's fix this by making all jumps explicit. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Include/AsmMacroIoLibV8.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h index a9f8491bc922..efc47d3bbbc7 100644 --- a/ArmPkg/Include/AsmMacroIoLibV8.h +++ b/ArmPkg/Include/AsmMacroIoLibV8.h @@ -25,9 +25,9 @@ mrs SAFE_XREG, CurrentEL ;\ cmp SAFE_XREG, #0x8 ;\ b.eq 2f ;\ - cmp SAFE_XREG, #0x4 ;\ - b.ne . ;// We should never get here -// EL1 code starts here + tbnz SAFE_XREG, #2, 1f ;\ + b . ;// We should never get here + // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1 // This only selects between EL1 and EL2 and EL3, else we die. @@ -36,11 +36,10 @@ mrs SAFE_XREG, CurrentEL ;\ cmp SAFE_XREG, #0xC ;\ b.eq 3f ;\ - cmp SAFE_XREG, #0x8 ;\ - b.eq 2f ;\ - cmp SAFE_XREG, #0x4 ;\ - b.ne . ;// We should never get here -// EL1 code starts here + tbnz SAFE_XREG, #3, 2f ;\ + tbnz SAFE_XREG, #2, 1f ;\ + b . ;// We should never get here + #if defined(__clang__) // load x0 with _Data