From patchwork Wed Dec 3 20:06:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 41874 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4D3F25E88 for ; Wed, 3 Dec 2014 20:14:15 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id n15sf10018973lbi.4 for ; Wed, 03 Dec 2014 12:14:14 -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=IBepX23HIcu907/XoQa6ZgzTakbd0YqAHi+tdColgmQ=; b=Qz7FTaASI/j2LE7XzxHgIJ+tTUH2wA36v85yyswG0oLO4XexEcbFVtLNrgaEVClt75 Kg9FvKgw4O98CrobcwRRY1l+mKJS2iRP3Oe57Y8m3hpQENqlHlqw2lj3WLdZeUzUPgAf SbJaYGfWZ2elH324blxts2g4Z6mUxLbsfqxQG+tuHUN4Sl0MaqcSvaQf6Vi/I9sQjCts SHfKw/z7Arc5+iZ7rGxLSgoOZBjNI6xuJfJmPVthWVQFEunpwBFNMGZ30QP3ry12FIpt hXHyTKSMaX3krwm/OmG6uJEoz2PGSIrkAix2rokZP/z2dCoTyMw/i4hsdONJWsCCrdEa Uc8A== X-Gm-Message-State: ALoCoQkNGi/0hOGl3pPp14R6pGKH2z9NoPf2FulH8+kXb1j4MriJWR6mxw41toNcNodx9k1zCX9a X-Received: by 10.112.169.101 with SMTP id ad5mr1445275lbc.1.1417637654802; Wed, 03 Dec 2014 12:14:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.170 with SMTP id l10ls175852lah.18.gmail; Wed, 03 Dec 2014 12:14:14 -0800 (PST) X-Received: by 10.112.93.231 with SMTP id cx7mr5711073lbb.89.1417637654670; Wed, 03 Dec 2014 12:14:14 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id r2si15248548lar.126.2014.12.03.12.14.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:14:14 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so13076724lab.4 for ; Wed, 03 Dec 2014 12:14:14 -0800 (PST) X-Received: by 10.152.43.12 with SMTP id s12mr5773692lal.67.1417637654308; Wed, 03 Dec 2014 12:14:14 -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.184.201 with SMTP id ew9csp731729lbc; Wed, 3 Dec 2014 12:14:13 -0800 (PST) X-Received: by 10.181.13.242 with SMTP id fb18mr19824118wid.1.1417637653660; Wed, 03 Dec 2014 12:14:13 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id lj5si41540597wjc.60.2014.12.03.12.14.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:14:13 -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]:43218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGJQ-0001CJ-Ew for patch@linaro.org; Wed, 03 Dec 2014 15:14:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGBz-0006mo-Jd for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwGBs-0003Wq-Mv for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:31 -0500 Received: from mail-oi0-f48.google.com ([209.85.218.48]:44422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGBs-0003Wk-IQ for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:06:24 -0500 Received: by mail-oi0-f48.google.com with SMTP id u20so11190432oif.7 for ; Wed, 03 Dec 2014 12:06:24 -0800 (PST) X-Received: by 10.182.125.3 with SMTP id mm3mr4289555obb.7.1417637184284; Wed, 03 Dec 2014 12:06:24 -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.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:06:23 -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:06:02 -0600 Message-Id: <1417637167-20640-9-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.48 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH 08/13] target-arm: Add virt 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+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.215.45 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 Add "secure" virt machine specific property to allow override of the default secure state configuration. By default, when using the QEMU -kernel command line argument, virt machines boot into NS/SVC. When using the QEMU -bios command line argument, virt 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=virt,secure=on -kernel ... Signed-off-by: Greg Bellows --- hw/arm/virt.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b6bb914..ba034e4 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -93,6 +93,7 @@ typedef struct { typedef struct { MachineState parent; + bool secure; } VirtMachineState; #define TYPE_VIRT_MACHINE "virt" @@ -632,6 +633,40 @@ static void machvirt_init(MachineState *machine) arm_load_kernel(ARM_CPU(first_cpu), &vbi->bootinfo); } +static bool virt_get_secure(Object *obj, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->secure; +} + +static void virt_set_secure(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->secure = value; +} + +static void virt_instance_init(Object *obj) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + /* 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", virt_get_secure, + virt_set_secure, NULL); +} + static void virt_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -646,6 +681,7 @@ static const TypeInfo machvirt_info = { .name = TYPE_VIRT_MACHINE, .parent = TYPE_MACHINE, .instance_size = sizeof(VirtMachineState), + .instance_init = virt_instance_init, .class_size = sizeof(VirtMachineClass), .class_init = virt_class_init, };