From patchwork Mon Dec 15 23:09:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 42304 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AE97C26C6C for ; Mon, 15 Dec 2014 23:16:31 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf8212587eek.8 for ; Mon, 15 Dec 2014 15:16:30 -0800 (PST) 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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=ntgrL1QJCbtcjGrw7BlJhXczudsbWK6jxn3X1tIC/fw=; b=KHbI57aPB8+csELA7oslU8b3RSz5lLLvBDm2Mg7Ucngc5FJtrdpTnp5exo4p8HuGfo dsNdoefLk0+PVa7X0ykhsTm9D+91p1/chu6HKrB4Q8QQ+8+DZyFjBnqC5YYpvpJX6ZOA JU/HO7bw3WlKyoLMYqiZM+CoP0s8dVpIAmIziRNfpqJfvuuPWYXH+PSKBU1J+IZBI06d Z1UBh8ThjNZ9N8oAnVJHtvFanWd+Hw7JotFrTLgchRV9F7JW0QkMITKJaaJWKyGtNnE/ /jAbc0QHFtt9osI12uQb6thUfUnI4Sx9vedccAzusvmpaxDP1bmNNzADYY8hmoV+iVku bJLQ== X-Gm-Message-State: ALoCoQkYdwGl5/qdw9Q0x+GjLVwiaikZ9vKlRR5K5d7cVrXOfNXiUTJPRecJabZukoNaoL/+oAn+ X-Received: by 10.194.178.163 with SMTP id cz3mr5133168wjc.1.1418685390927; Mon, 15 Dec 2014 15:16:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.37 with SMTP id ll5ls902881lac.53.gmail; Mon, 15 Dec 2014 15:16:30 -0800 (PST) X-Received: by 10.112.14.6 with SMTP id l6mr10012033lbc.91.1418685390677; Mon, 15 Dec 2014 15:16:30 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id xr6si4692757lbb.1.2014.12.15.15.16.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 15:16:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so10182735lbd.34 for ; Mon, 15 Dec 2014 15:16:30 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr32828190laz.71.1418685390585; Mon, 15 Dec 2014 15:16:30 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp867170lbb; Mon, 15 Dec 2014 15:16:29 -0800 (PST) X-Received: by 10.140.20.104 with SMTP id 95mr31628519qgi.47.1418685388830; Mon, 15 Dec 2014 15:16:28 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t4si12482455qcq.0.2014.12.15.15.16.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 15:16:28 -0800 (PST) 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; Received: from localhost ([::1]:42362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0esN-0004a9-NI for patch@linaro.org; Mon, 15 Dec 2014 18:16:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0emW-0003hw-5e for qemu-devel@nongnu.org; Mon, 15 Dec 2014 18:10:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0emQ-0000gg-1N for qemu-devel@nongnu.org; Mon, 15 Dec 2014 18:10:24 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:46410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0emP-0000gZ-SA for qemu-devel@nongnu.org; Mon, 15 Dec 2014 18:10:17 -0500 Received: by mail-pa0-f46.google.com with SMTP id lf10so12169937pab.33 for ; Mon, 15 Dec 2014 15:10:17 -0800 (PST) X-Received: by 10.69.26.130 with SMTP id iy2mr50795362pbd.93.1418685017314; Mon, 15 Dec 2014 15:10:17 -0800 (PST) Received: from gbellows-linaro.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id uq15sm10402467pab.8.2014.12.15.15.10.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 15:10:16 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, serge.fdrv@gmail.com, edgar.iglesias@gmail.com, aggelerf@ethz.ch, peter.maydell@linaro.org Date: Mon, 15 Dec 2014 17:09:46 -0600 Message-Id: <1418684992-8996-10-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1418684992-8996-1-git-send-email-greg.bellows@linaro.org> References: <1418684992-8996-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.46 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v4 09/15] target-arm: Add ARMCPU secure property 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@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.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Added a "has_el3" state property to the ARMCPU descriptor. This property indicates whether the ARMCPU has security extensions enabled (EL3) or not. By default it is disabled at this time. Signed-off-by: Greg Bellows Reviewed-by: Peter Maydell --- v1 -> v2 - Added set of has_el3 to true when EL3 is enabled v2 -> v3 - Properly init has_el3 - Fixed typo --- target-arm/cpu-qom.h | 2 ++ target-arm/cpu.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index dcfda7d..ed5a644 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -100,6 +100,8 @@ typedef struct ARMCPU { bool start_powered_off; /* CPU currently in PSCI powered-off state */ bool powered_off; + /* CPU has security extension */ + bool has_el3; /* PSCI conduit used to invoke PSCI methods * 0 - disabled, 1 - smc, 2 - hvc diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 01afed2..069e090 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -388,6 +388,9 @@ static Property arm_cpu_reset_hivecs_property = static Property arm_cpu_rvbar_property = DEFINE_PROP_UINT64("rvbar", ARMCPU, rvbar, 0); +static Property arm_cpu_has_el3_property = + DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); + static void arm_cpu_post_init(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); @@ -407,6 +410,14 @@ static void arm_cpu_post_init(Object *obj) qdev_property_add_static(DEVICE(obj), &arm_cpu_rvbar_property, &error_abort); } + + if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { + /* Add the has_el3 state CPU property only if EL3 is allowed. This will + * prevent "has_el3" from existing on CPUs which cannot support EL3. + */ + qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el3_property, + &error_abort); + } } static void arm_cpu_finalizefn(Object *obj) @@ -476,6 +487,18 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->reset_sctlr |= (1 << 13); } + if (!cpu->has_el3) { + /* If the has_el3 CPU property is disabled then we need to disable the + * feature. + */ + unset_feature(env, ARM_FEATURE_EL3); + + /* Disable the security extension feature bits in the processor feature + * register as well. This is id_pfr1[7:4]. + */ + cpu->id_pfr1 &= ~0xf0; + } + register_cp_regs_for_features(cpu); arm_cpu_register_gdb_regs_for_features(cpu);