From patchwork Tue Jan 27 23:58:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 43866 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C5A623FFF for ; Tue, 27 Jan 2015 23:59:51 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d49sf9237847eek.2 for ; Tue, 27 Jan 2015 15:59:50 -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=LODAUk0ZucuZW3f8WST19GsgYAV+V5z8dfi08K4l/LM=; b=RIK1TJgN8AhLHaHjauqUSx4orxtRcY98khhAo71T4NlG3g7u1IvfwFut8jdYneKko0 fnrdTPv3e1mXGpDlmleAPssYRyv05T3E+iLYTbwA+AHrQDLCHhI+a2rV2s36KjOnxT+i LLBkfQ/IAyvxKM6OyNV6oif1NcNJ3NqXN+lzPmcn+7wM6313zoEa5Aia7xg9eqdnHccX tDBY7zUmAYVgZIkT2Fg+ohQYL0VUGlKvyeymbd9wMjthhjDzAUIuCxOG6SZ+UwqakgeM LtH/hiu1VMEe8nGQ2K0hvOv0HNS44Lr9jL8GKxkPza6c/yPlV5V8sDl/AMWumngeYhxa XNdA== X-Gm-Message-State: ALoCoQnDAa3X/n2TCJz6O9ETXbJPMt1Nt52DVJ49OT/tyEE3KO9Z9A3s3g7Fee1ifPtZFR2RGjbv X-Received: by 10.180.76.44 with SMTP id h12mr78700wiw.2.1422403190422; Tue, 27 Jan 2015 15:59:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.230 with SMTP id jr6ls101451lab.69.gmail; Tue, 27 Jan 2015 15:59:50 -0800 (PST) X-Received: by 10.112.8.41 with SMTP id o9mr4742978lba.40.1422403190269; Tue, 27 Jan 2015 15:59:50 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id n2si2718557lbs.48.2015.01.27.15.59.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 15:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id l4so15874479lbv.13 for ; Tue, 27 Jan 2015 15:59:50 -0800 (PST) X-Received: by 10.152.245.44 with SMTP id xl12mr4704796lac.81.1422403190151; Tue, 27 Jan 2015 15:59:50 -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.35.133 with SMTP id h5csp1261161lbj; Tue, 27 Jan 2015 15:59:49 -0800 (PST) X-Received: by 10.224.112.137 with SMTP id w9mr7709908qap.8.1422403188927; Tue, 27 Jan 2015 15:59:48 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q5si3776338qab.39.2015.01.27.15.59.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 15:59:48 -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]:50579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGG2u-0007rh-4W for patch@linaro.org; Tue, 27 Jan 2015 18:59:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGG22-0006oY-1R for qemu-devel@nongnu.org; Tue, 27 Jan 2015 18:58:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGG1x-0005TE-BY for qemu-devel@nongnu.org; Tue, 27 Jan 2015 18:58:53 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:50002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGG1x-0005T6-7K for qemu-devel@nongnu.org; Tue, 27 Jan 2015 18:58:49 -0500 Received: by mail-pd0-f169.google.com with SMTP id g10so21872269pdj.0 for ; Tue, 27 Jan 2015 15:58:48 -0800 (PST) X-Received: by 10.70.37.166 with SMTP id z6mr763443pdj.89.1422403128633; Tue, 27 Jan 2015 15:58:48 -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 nu5sm2679909pbb.79.2015.01.27.15.58.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 15:58:48 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org, alex.bennee@linaro.org Date: Tue, 27 Jan 2015 17:58:34 -0600 Message-Id: <1422403117-16921-2-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422403117-16921-1-git-send-email-greg.bellows@linaro.org> References: <1422403117-16921-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.192.169 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v3 1/4] target-arm: Add CPU property to disable AArch64 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.182 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 Adds registration and get/set functions for enabling/disabling the AArch64 execution state on AArch64 CPUs. By default AArch64 execution state is enabled on AArch64 CPUs, setting the property to off, will disable the execution state. The below QEMU invocation would have AArch64 execution state disabled. $ ./qemu-system-aarch64 -machine virt -cpu cortex-a57,aarch64=off Also adds stripping of features from CPU model string in acquiring the ARM CPU by name. Signed-off-by: Greg Bellows --- v1 -> v2 - Scrap the custom CPU feature parsing in favor of using the default CPU parsing. - Add registration of CPU AArch64 property to disable/enable the AArch64 feature. --- target-arm/cpu.c | 6 +++++- target-arm/cpu64.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 285947f..29ed691 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -514,13 +514,17 @@ static ObjectClass *arm_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; char *typename; + char *cpuname; if (!cpu_model) { return NULL; } - typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model); + cpuname = g_strdup(cpu_model); + cpuname = strtok(cpuname, ","); + typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpuname); oc = object_class_by_name(typename); + g_free(cpuname); g_free(typename); if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) || object_class_is_abstract(oc)) { diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c index bb778b3..5a59280 100644 --- a/target-arm/cpu64.c +++ b/target-arm/cpu64.c @@ -32,6 +32,11 @@ static inline void set_feature(CPUARMState *env, int feature) env->features |= 1ULL << feature; } +static inline void unset_feature(CPUARMState *env, int feature) +{ + env->features &= ~(1ULL << feature); +} + #ifndef CONFIG_USER_ONLY static uint64_t a57_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) { @@ -170,8 +175,32 @@ static const ARMCPUInfo aarch64_cpus[] = { { .name = NULL } }; +static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + return arm_feature(&cpu->env, ARM_FEATURE_AARCH64); +} + +static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + if (value == false) { + unset_feature(&cpu->env, ARM_FEATURE_AARCH64); + } else { + set_feature(&cpu->env, ARM_FEATURE_AARCH64); + } +} + static void aarch64_cpu_initfn(Object *obj) { + object_property_add_bool(obj, "aarch64", aarch64_cpu_get_aarch64, + aarch64_cpu_set_aarch64, NULL); + object_property_set_description(obj, "aarch64", + "Set on/off to enable/disable aarch64 " + "execution state ", + NULL); } static void aarch64_cpu_finalizefn(Object *obj)