From patchwork Fri Aug 7 08:10:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247540 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2232822ilo; Fri, 7 Aug 2020 01:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwymb9CoeaEcwd1yDeraQOlPNLHPuEZI6dtf5Mil0vct+TBHPRoM/EiqI1K7/nkXXjHarTy X-Received: by 2002:a25:70c1:: with SMTP id l184mr15729710ybc.87.1596787960058; Fri, 07 Aug 2020 01:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596787960; cv=none; d=google.com; s=arc-20160816; b=N4pEGDoEqcUQzz8CaUP97+PHzwPdq+KUzrtMOwTGs1TqLC6O3wAVE5xTp3msmqWVg/ 0jd3s/lWJKOtLcMSXdwL642EU0kYD8rHllp/N0Zl5u95rWosdIHDMBrvQnfVkkO61XzY O0z0i2xXu270DVl/LZ6ubItoqxSfJK6vNAX/1j2s59IbW8R8Lk0W4Y6a7VqjFrYEf0gv DtyGgmruc3lPEX1xIjzPq9XEBDY2iKib1TI8AS1ULMAL9JCyT967bTmuSydLiKb0NDfi eHYrUdpScAxvaizDmpa+85TmwDlZ+wEz5oj2cJXYc7iJp+/Gv4GyIHBxTYjH02FK5Ybh eCaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=L/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=AIpSjMYfPDkuoDud/nsONawWf7rubRP7VN3eYh1r0ZveQagwh7hxCQt2dEjgEqpLW/ rshQ2WsJy8FPlXiF+RnBVKaTy4Vh1HmDp+EsEEYntluAfFii0UV8f2FcoGDfRbS0rl4P zT9DZxTv+S2yizhVGWWvekIBjFNCRiOkNwC3MbzcsIum29/25CrrkpkVeVB5aX+bgoRx INx7u26TYMsDT9pNC7+qeMZyIRj1DfmLvzlxmotldd5FJUdN300hoYLn01w1SUKGg7O6 VSZ7tySwy39Ooe43vro+YXv8rd1vP0GN5sZckM246cZKetRTY+VcpzJ3jnQBrFc5gF15 U7hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tTSRJKGf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r186si7434059ybc.113.2020.08.07.01.12.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tTSRJKGf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xUV-0000Yd-Gt for patch@linaro.org; Fri, 07 Aug 2020 04:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSg-00073T-PX for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]:39053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSd-0001hX-MH for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: by mail-io1-xd43.google.com with SMTP id z6so1063893iow.6 for ; Fri, 07 Aug 2020 01:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=tTSRJKGfAxOBsFsSTy7WUzO2js2DVnRgl7sVSHksknJ19BC/jkJYUodydEAAVkKYWZ qGaXvRoMm48WvYyGkCkfdBKN2MdKuk0XEa/SshlYAlzNljcrnmRIBG34Hh8WFlvLx6TS Z3pv+08BliwfJsSVGwTigJT+CF4wDpCbUAXDWr1BS2ehv1AmPa8JZFSCBYKCe4qvdoRk qfgqzNE2R8N99gXJp4XozOKp/FSmRjTunknJ4893vkgjdm8iyX7dFCwv4ACNyEMcU4Rb dX3aAiGjK7TOBsP+NCLmaB8KC2DTHa6OddcoqaC9NpOaeADYQae/LmwK2M1ygl4gvZGS oMYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=rndKWEOugFupsW1KXzKongMN5u6XSXIGwXutvoA/jt+sOUWYPzCRlNY5Vb5uMqCg+v PxSQY2zCH+jh5spEAfnkcVw/JTzaCeIl6ttumR8tg3IGkpZ+p6ZW9shYyOnn25ngSOws 8YczPIgzsKt+/FbMYm3OGO3H2QNnSX0+tPSK+OllKKNYRUPAUtZzxm+kg4qmYSM0Q/fF txi1zefPwodfB3HEJLbCpcxKy5/l874AXM/IecRDa9qliF48r93vBFJrtFjTfq4mbL2K xSiWS1ceH60C3motE5nMtWG4d3mUaKrIAKAPNto17wXQyrS7bzqPEFusKkBTMJfg3Vmc kq1g== X-Gm-Message-State: AOAM532glkTIUVZ0rk4gFzzSxWwDrIO5XUKIayECWWbBWsDLN/xMMFBz AU/Td6PXPMJFdQRkn3CuAjWO X-Received: by 2002:a5e:d519:: with SMTP id e25mr3334981iom.36.1596787842680; Fri, 07 Aug 2020 01:10:42 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:42 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 3/7] target/arm/cpu: spe: Add an option to turn on/off vSPE support Date: Fri, 7 Aug 2020 08:10:33 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::d43; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd43.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adds a spe=[on/off] option to enable/disable vSPE support in guest vCPU. Note this option is only available for "-cpu host" with KVM mode, and default value is on. Signed-off-by: Haibo Xu --- target/arm/cpu.c | 28 ++++++++++++++++++++++++++++ target/arm/cpu.h | 3 +++ 2 files changed, 31 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 111579554f..40768b4d19 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1122,6 +1122,29 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp) cpu->has_pmu = value; } +static bool arm_get_spe(Object *obj, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + return cpu->has_spe; +} + +static void arm_set_spe(Object *obj, bool value, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + if (value) { + if (kvm_enabled() && !kvm_arm_spe_supported()) { + error_setg(errp, "'spe' feature not supported by KVM on this host"); + return; + } + set_feature(&cpu->env, ARM_FEATURE_SPE); + } else { + unset_feature(&cpu->env, ARM_FEATURE_SPE); + } + cpu->has_spe = value; +} + unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { /* @@ -1195,6 +1218,11 @@ void arm_cpu_post_init(Object *obj) object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } + if (arm_feature(&cpu->env, ARM_FEATURE_SPE)) { + cpu->has_spe = true; + object_property_add_bool(obj, "spe", arm_get_spe, arm_set_spe); + } + /* * Allow user to turn off VFP and Neon support, but only for TCG -- * KVM does not currently allow us to lie to the guest about its diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9e8ed423ea..fe0ac14386 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -822,6 +822,8 @@ struct ARMCPU { bool has_el3; /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; + /* CPU has SPE (Statistical Profiling Extension) */ + bool has_spe; /* CPU has VFP */ bool has_vfp; /* CPU has Neon */ @@ -1959,6 +1961,7 @@ enum arm_features { ARM_FEATURE_VBAR, /* has cp15 VBAR */ ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ ARM_FEATURE_M_MAIN, /* M profile Main Extension */ + ARM_FEATURE_SPE, /* has SPE support */ }; static inline int arm_feature(CPUARMState *env, int feature)