From patchwork Thu Oct 9 14:30:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 38514 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 905B6202E7 for ; Thu, 9 Oct 2014 14:30:37 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e51sf1042798eek.11 for ; Thu, 09 Oct 2014 07:30:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=58cQ92wjWaFrHKGzrb5aSS2vjYjk4B3UfOqAXL3Ghqo=; b=UzHNb63Xzq3skLlP07QJyN8aKY0h2YMe0cPAUQX/QhVKoMDF/dFebr+RSGMRsAIfaq tJ32XmO80E8TmGrB5hP3M+t9SwZmAozlmf+jhGLsi40MT27VysNVRH+9MX9WajzHO2vr /8mEt/eAh0nGYPST+Dk4nkNw3ZCAVeAW1fhRDW5WtlWa+9a2BiimCUntlwJfyhrmYOiy lo7YAqp7pkQ3k6C0Qg3GAlA8+No3cmE+FWBbw6ZOVBB7Ch8BJSyooWTZeis3jktSvw9l UaHzv4GPTclBgT133usHFUut+ipqkgwgYNV3ztg0z9OgON7GgQB85vRkNoLjtPGdiCyd lIqA== X-Gm-Message-State: ALoCoQkEFh7aQ0Dkx1Ow7F+U4JdzjAvoaL2jt8BeapJmQPf4dd2JYVVXuyCyxDGsHv1S3ywjodtM X-Received: by 10.112.190.40 with SMTP id gn8mr807034lbc.10.1412865034117; Thu, 09 Oct 2014 07:30:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.66 with SMTP id h2ls18409laa.58.gmail; Thu, 09 Oct 2014 07:30:34 -0700 (PDT) X-Received: by 10.152.25.165 with SMTP id d5mr832845lag.14.1412865034011; Thu, 09 Oct 2014 07:30:34 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id k1si4526910lam.96.2014.10.09.07.30.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Oct 2014 07:30:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so1343826lab.16 for ; Thu, 09 Oct 2014 07:30:30 -0700 (PDT) X-Received: by 10.112.164.71 with SMTP id yo7mr18195960lbb.73.1412865030035; Thu, 09 Oct 2014 07:30:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp258838lbz; Thu, 9 Oct 2014 07:30:29 -0700 (PDT) X-Received: by 10.180.21.227 with SMTP id y3mr4791639wie.54.1412865029370; Thu, 09 Oct 2014 07:30:29 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id gk5si515840wib.12.2014.10.09.07.30.28 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 09 Oct 2014 07:30:29 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XcEjc-0004cb-B5; Thu, 09 Oct 2014 15:30:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Ard Biesheuvel , Greg Bellows Subject: [PATCH v5 4/7] target-arm: Handle SMC/HVC undef-if-no-ELx in pre_* helpers Date: Thu, 9 Oct 2014 15:30:25 +0100 Message-Id: <1412865028-17725-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1412865028-17725-1-git-send-email-peter.maydell@linaro.org> References: <1412865028-17725-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , SMC must UNDEF if EL3 is not implemented; similarly HVC UNDEFs if EL2 is not implemented. Move the handling of this from translate-a64.c into the pre_smc and pre_hvc helper functions. This is necessary because use of these instructions for PSCI takes precedence over this UNDEF case, and we can't tell if this is a PSCI call until runtime. Signed-off-by: Peter Maydell --- target-arm/op_helper.c | 17 ++++++++++------- target-arm/translate-a64.c | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 03ac92a..5652096 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -392,10 +392,11 @@ void HELPER(pre_hvc)(CPUARMState *env) bool secure = false; bool undef; - /* We've already checked that EL2 exists at translation time. - * EL3.HCE has priority over EL2.HCD. - */ - if (arm_feature(env, ARM_FEATURE_EL3)) { + if (!arm_feature(env, ARM_FEATURE_EL2)) { + /* If EL2 doesn't exist, HVC always UNDEFs */ + undef = true; + } else if (arm_feature(env, ARM_FEATURE_EL3)) { + /* EL3.HCE has priority over EL2.HCD. */ undef = !(env->cp15.scr_el3 & SCR_HCE); } else { undef = env->cp15.hcr_el2 & HCR_HCD; @@ -429,13 +430,15 @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome) */ bool undef = is_a64(env) ? smd : (!secure && smd); - /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. */ - if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) { + if (!arm_feature(env, ARM_FEATURE_EL3)) { + /* If we have no EL3 then SMC always UNDEFs */ + undef = true; + } else if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) { + /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. */ env->exception.syndrome = syndrome; raise_exception(env, EXCP_HYP_TRAP); } - /* We've already checked that EL3 exists at translation time. */ if (undef) { env->exception.syndrome = syn_uncategorized(); raise_exception(env, EXCP_UDEF); diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 35ae3ea..b15261b 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -1485,7 +1485,7 @@ static void disas_exc(DisasContext *s, uint32_t insn) gen_exception_insn(s, 0, EXCP_SWI, syn_aa64_svc(imm16)); break; case 2: - if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_pl == 0) { + if (s->current_pl == 0) { unallocated_encoding(s); break; } @@ -1498,7 +1498,7 @@ static void disas_exc(DisasContext *s, uint32_t insn) gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16)); break; case 3: - if (!arm_dc_feature(s, ARM_FEATURE_EL3) || s->current_pl == 0) { + if (s->current_pl == 0) { unallocated_encoding(s); break; }