From patchwork Tue Jul 5 05:19:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Bobroff X-Patchwork-Id: 644533 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rkClY5JCWz9s8d for ; Tue, 5 Jul 2016 15:55:05 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rkClY2zpszDvgk for ; Tue, 5 Jul 2016 15:55:05 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rkByj4zwZzDr0w for ; Tue, 5 Jul 2016 15:19:41 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u655JUpe095536 for ; Tue, 5 Jul 2016 01:19:39 -0400 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0b-001b2d01.pphosted.com with ESMTP id 23x9t11p0e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 05 Jul 2016 01:19:39 -0400 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Jul 2016 15:19:35 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Jul 2016 15:19:26 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: sam.bobroff@au1.ibm.com X-IBM-RcptTo: linuxppc-dev@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 1FF692CE805C for ; Tue, 5 Jul 2016 15:19:26 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u655JQpd22544536 for ; Tue, 5 Jul 2016 15:19:26 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u655JPYA016617 for ; Tue, 5 Jul 2016 15:19:25 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u655JPHD016610; Tue, 5 Jul 2016 15:19:25 +1000 Received: from tungsten.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 01CB1A01E4; Tue, 5 Jul 2016 15:19:25 +1000 (AEST) From: Sam Bobroff To: david@gibson.dropbear.id.au Subject: [PATCH 3/3] spapr: Set ibm, pa-features HTM from KVM_CAP_PPC_HTM Date: Tue, 5 Jul 2016 15:19:24 +1000 X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <20160608022602.GU9226@voom.fritz.box> In-Reply-To: References: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070505-0008-0000-0000-000000A118CC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070505-0009-0000-0000-00000797CE45 Message-Id: <92f09cf433b816a88d94adc50cd9cb89b94131a3.1467695915.git.sam.bobroff@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-05_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607050049 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, aik@ozlabs.ru, anton@au1.ibm.com, agraf@suse.de, qemu-devel@nongnu.org, paulus@samba.org, qemu-ppc@nongnu.org, linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Advertise HTM support in ibm, pa-features if KVM indicates support when queried via a new capability (KVM_CAP_PPC_HTM). If KVM returns false for the capability (which may indicate that the host kernel doesn't support the capability itself) attempt to determine availability using a fallback method based on KVM being KVM-HV and HTM being available to the QEMU process. Signed-off-by: Sam Bobroff --- hw/ppc/spapr.c | 3 ++- target-ppc/kvm.c | 27 +++++++++++++++++++++++++++ target-ppc/kvm_ppc.h | 6 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 704aae7..e229532 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -606,6 +606,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : SPAPR_TIMEBASE_FREQ; uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000; + uint8_t htm = (kvm_enabled() && kvmppc_get_htm_support(env)) ? 0x80 : 0x00; uint32_t page_sizes_prop[64]; size_t page_sizes_prop_size; uint32_t vcpus_per_socket = smp_threads * smp_cores; @@ -635,7 +636,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, 0xf6, 0x1f, 0xc7, 0xc0, 0x80, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x00, 0x00 }; + 0x80, 0x00, 0x80, 0x00, 0x00 | htm, 0x00 }; uint8_t *pa_features; size_t pa_size; diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 884d564..f94ce3b 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -20,6 +20,7 @@ #include #include +#include "elf.h" #include "qemu-common.h" #include "qemu/error-report.h" @@ -1976,6 +1977,32 @@ uint32_t kvmppc_get_dfp(void) return kvmppc_read_int_cpu_dt("ibm,dfp"); } +bool kvmppc_get_htm_support(CPUPPCState *env) +{ + PowerPCCPU *cpu = ppc_env_get_cpu(env); + CPUState *cs = CPU(cpu); + + + if (kvm_vm_check_extension(cs->kvm_state, KVM_CAP_PPC_HTM)) { + return true; + } + /* + * Fallback test for host kernels that don't yet support KVM_CAP_PPC_HTM. + * This will be unnecessary when KVM_API_VERSION is incremented (to 13 or + * above) because that will remove the ambiguity between the host kernel + * lacking support for KVM_CAP_PPC_HTM and it having support but reporting + * HTM as unavailable (both of which return 0, above). + */ + if (kvm_vm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) { + /* Assume this means PR KVM, so no TM. */ + return false; + } else { + /* Assume this means HV KVM, propagate whatever host userspace sees. */ + unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); + return !!(hwcap2 & PPC_FEATURE2_HAS_HTM); + } +} + static int kvmppc_get_pvinfo(CPUPPCState *env, struct kvm_ppc_pvinfo *pvinfo) { PowerPCCPU *cpu = ppc_env_get_cpu(env); diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 20bfb59..b01c717 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -17,6 +17,7 @@ uint32_t kvmppc_get_tbfreq(void); uint64_t kvmppc_get_clockfreq(void); uint32_t kvmppc_get_vmx(void); uint32_t kvmppc_get_dfp(void); +bool kvmppc_get_htm_support(CPUPPCState *env); bool kvmppc_get_host_model(char **buf); bool kvmppc_get_host_serial(char **buf); int kvmppc_get_hasidle(CPUPPCState *env); @@ -90,6 +91,11 @@ static inline uint32_t kvmppc_get_dfp(void) return 0; } +static inline bool kvmppc_get_htm_support(KVMState *kvm_state) +{ + return false; +} + static inline int kvmppc_get_hasidle(CPUPPCState *env) { return 0;