From patchwork Wed Dec 3 20:05:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 417532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3AF191400E7 for ; Thu, 4 Dec 2014 07:07:41 +1100 (AEDT) Received: from localhost ([::1]:43147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGD5-0008V4-9g for incoming@patchwork.ozlabs.org; Wed, 03 Dec 2014 15:07:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGBw-0006mc-BM for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwGBp-0003Uw-Jc for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:28 -0500 Received: from mail-oi0-f54.google.com ([209.85.218.54]:48602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGBp-0003Us-FS for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:21 -0500 Received: by mail-oi0-f54.google.com with SMTP id u20so11319318oif.13 for ; Wed, 03 Dec 2014 12:06:21 -0800 (PST) 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=JAmGP0/09W3yMGqp/jKfelrtJ6sxssPvuiNUYzFfAW4=; b=X+sJ0otwEbxJt2VHBIMMHAvOlMxaidwTxo6JcnG/KD+btVWm8esYJoIztNlBh6+TA3 vRG38gIM5RHS/MuxyaFo3ZR7FLrjFgjL78DrIDmH7raZXgZXuZWGkzGFfF+ysJuutz8q N13v1HQ+GyK9A7nKlfL6/+KlKKsSMF+aw/cKdLxqOMTK5d7IwJdm0isQ9c+ihU/zwzJQ TO6LQx4LniTiGNVcSWrPvfqnU7L9TOntv7A3wQsjG96IxXSUnb212WaKABBAkSK3btCt rn3p+EiL7hAEm2o3r2QUYYpsKMkgEEqGrxv2mzC4Vn9aD1xY1NT8YL5099r4YT0JgqPe xwlA== X-Gm-Message-State: ALoCoQlGtuR7xCNxve9usx+HnA4UECx4V7jftGElhANVGKbRtWbqZJR1/qxkoIF8Eyle2GlG0ntQ X-Received: by 10.60.131.202 with SMTP id oo10mr4359732oeb.72.1417637181176; Wed, 03 Dec 2014 12:06:21 -0800 (PST) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id mq4sm11787321obb.22.2014.12.03.12.06.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:06:20 -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: Wed, 3 Dec 2014 14:05:59 -0600 Message-Id: <1417637167-20640-6-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1417637167-20640-1-git-send-email-greg.bellows@linaro.org> References: <1417637167-20640-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.218.54 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH 05/13] target-arm: Add vexpress machine 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add "secure" Vexpress machine specific property to allow override of the default secure state configuration. By default, when using the QEMU -kernel command line argument, Vexpress machines boot into NS/SVC. When using the QEMU -bios command line argument, Vexpress machines boot into S/SVC. The secure state can be changed from the default specifying the secure state as a machine property. For example, the below command line would enable secure state on a -linux boot: aarch64-softmmu/qemu-system-aarch64 -machine type=vexpress-a15,secure=on -kernel ... Signed-off-by: Greg Bellows --- hw/arm/vexpress.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 4a38a82..6dc5d3b 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -164,6 +164,7 @@ typedef struct { typedef struct { MachineState parent; + bool secure; } VexpressMachineState; #define TYPE_VEXPRESS_MACHINE "vexpress" @@ -701,6 +702,41 @@ static void vexpress_common_init(MachineState *machine) arm_load_kernel(ARM_CPU(first_cpu), &daughterboard->bootinfo); } +static bool vexpress_get_secure(Object *obj, Error **errp) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + return vms->secure; +} + +static void vexpress_set_secure(Object *obj, bool value, Error **errp) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + vms->secure = value; +} + +static void vexpress_instance_init(Object *obj) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + /* All Vexpress machine instances have a secure property + * Determine whether to start in a secure state or non-secure state based + * on whether we are directly booting a kernel ("-kernel" option). If we + * are, then we default to booting into non-secure state. Otherwise, we + * default to the machine default which is secure EL1/SVC. + * This may be overridden by the "secure" machine property. + */ + if (qemu_opt_get(qemu_get_machine_opts(), "kernel")) { + vms->secure = false; + } else { + vms->secure = true; + } + + object_property_add_bool(obj, "secure", vexpress_get_secure, + vexpress_set_secure, NULL); +} + static void vexpress_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -738,6 +774,7 @@ static const TypeInfo vexpress_info = { .name = TYPE_VEXPRESS_MACHINE, .parent = TYPE_MACHINE, .instance_size = sizeof(VexpressMachineState), + .instance_init = vexpress_instance_init, .class_size = sizeof(VexpressMachineClass), .class_init = vexpress_class_init, };