From patchwork Fri Aug 7 08:10:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247543 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2233958ilo; Fri, 7 Aug 2020 01:14:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI0upvNacH/wgbxYMbahE7VaSFIfiaXIjEKlwOrw5V8eb60gpJDVKGZtW1au6xkMihvtNu X-Received: by 2002:a25:cc46:: with SMTP id l67mr18183349ybf.283.1596788091797; Fri, 07 Aug 2020 01:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596788091; cv=none; d=google.com; s=arc-20160816; b=X8J3VoO9YCULFMsEefKG092/2DRd/2G13kfhjlB7auOvJm0Igx6/ZBfo0zgACBi6bB MsTvQaAnmOySNyFKkNf83WR118++14SzmL11I3YTK84k5zsd7l/6jxuCBkJzbQvaD6Ed FQTsHmLFto2PZ4dKSMV97OE3nDSMHY1DCKzmJUpdbhNZTiz/GrxR39WyEj2NAe61b+un D2Ns9c/TMpOfUxFuuExvotMzKsFAJMg9Wdh5awqWXpXgFnQAEz+/4SJrg3kX/0VynQRV qtvPwHnvh0Jyu1iR80iDascXDieHDlrMQ49qGf8glW68jnWLnVoILsdvxCdyRgKHjGZy obzw== 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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=XOAzJldVmaFnLtxN/6mcjEW5OvHbu9U0nl4cjRu2Ppx0Saq+U6IxGtUfZTt2dw8eLP lWDox4s07djIatfuMu2uhgthWGfZKTCySchH8GIeyr97MfdS3A9SfQq81hm08l2Vw1ZT H6nrEXrOy66dsGKMH+S7JFrcqYhnApxy9xkAgM9S6P9Si0x9xlkt61Jze3ubYTE8sKTO Y8sRgKX5MhGg1VkHy8Rnr2DMZJzTYdW3Litfcky4mpZvuj5seQpbP9iLaeK0amio/3ly e3j+/E0UaqYDzmJ8K1xoXVZ3EoWg/im4ynPXNCxKlOupmuinBPx1Xu5IE0iupuu/fYMw Mu0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NnLuiKB3; 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 a18si7349433ybs.331.2020.08.07.01.14.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:14:51 -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=NnLuiKB3; 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]:55734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xWd-00069u-7z for patch@linaro.org; Fri, 07 Aug 2020 04:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSk-0007CZ-1f for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:50 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]:38654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSh-0001iZ-L5 for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:49 -0400 Received: by mail-io1-xd44.google.com with SMTP id l1so1073662ioh.5 for ; Fri, 07 Aug 2020 01:10:47 -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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=NnLuiKB3M9BBUwK6Ivp+tfr1wgrcB2dVtHLFJLK3G5M7zD8ZVcpU+F8n1mLDr+8QX7 jEwIsOVdjpwqq5wwpQbmgBnzV9U+J6n+aoT8+z3R+iedUYm8Sgrymxsb4sBNMDm46jdi OoZtB/mh1L99BGq99JUGlHhsROt4PcYEyGGaM28kH99B8T7GiszCu9tlab4pn+VW/EfL wVFSfWlHzJo3TSK+b0IRS3cnNVCydf+zItie7bCmpjvdMlXCUc0kG1YCTTKelDnkvTPS CwnX+vWK8IdqIEcz306Dj+u4Kb37g7NJQM4pOaOZPN9RXzqzisygEg1OmHGLagiH4raL 5EHQ== 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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=eCkeMHQlsRwK2GbhnfZ53tysBvknBhSjT3G7pULUI7ZSbTMJgYnia6/wTGs/k0/k3R JVpSvMwbZWErBNSDuf1UCZmyghZcjlk6Yh6sU9d9q8Xid/sjOZ7YeJHoPrFIDQimmVyk Ln8Lhm4kQo0SERRpn7AOc4bqy3DpSuszE/p2HVgtlObWC18hbJTvjASSdbJ1z2uBlKMz arzeg035TmcrUeJHb03jluKrWaEZY54VfJGOv02A4OTRBkjKJYFw466H0n3BNBkD7UIj f/BgP7SSqZCQVKRmjwslCdlmUI1yq1G1SQuqOP7hnrnqiu76Ddrpfi1yamMQ1sL6joq7 2gZg== X-Gm-Message-State: AOAM530Pi+KJdrh7kXo1mA4X/87WaB9EFJYxFhYG6a3qRdsH7J875zXo URnix8KlKrxTsw+NWhs34799 X-Received: by 2002:a6b:5d05:: with SMTP id r5mr3266184iob.14.1596787846498; Fri, 07 Aug 2020 01:10:46 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:46 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 7/7] target/arm/cpu: spe: Enable spe to work with host cpu Date: Fri, 7 Aug 2020 08:10:37 +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::d44; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd44.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=unavailable 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" Turn on the spe cpu property by default when working with host cpu type in KVM mode, i.e. we can now do '-cpu host' to add the vSPE, and '-cpu host,spe=off' to remove it. Signed-off-by: Haibo Xu --- target/arm/cpu.c | 4 ++++ target/arm/kvm64.c | 9 +++++++++ 2 files changed, 13 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 67ab0089fd..42fa99953c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1719,6 +1719,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->pmceid1 = 0; } + if (!cpu->has_spe || !kvm_enabled()) { + unset_feature(env, ARM_FEATURE_SPE); + } + if (!arm_feature(env, ARM_FEATURE_EL2)) { /* Disable the hypervisor feature bits in the processor feature * registers if we don't have EL2. These are id_pfr1[15:12] and diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index be045ccc5f..4ea58afc1d 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -679,6 +679,7 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) features |= 1ULL << ARM_FEATURE_AARCH64; features |= 1ULL << ARM_FEATURE_PMU; features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; + features |= 1ULL << ARM_FEATURE_SPE; ahcf->features = features; @@ -826,6 +827,14 @@ int kvm_arch_init_vcpu(CPUState *cs) } else { env->features &= ~(1ULL << ARM_FEATURE_PMU); } + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_SPE_V1)) { + cpu->has_spe = false; + } + if (cpu->has_spe) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SPE_V1; + } else { + env->features &= ~(1ULL << ARM_FEATURE_SPE); + } if (cpu_isar_feature(aa64_sve, cpu)) { assert(kvm_arm_sve_supported()); cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;