From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAGCT-0002GE-V8 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAGCQ-0006Ec-Or for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:33:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55676 helo=mx0b-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAGCQ-0006EY-FG for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:33:38 -0400 Received: from pps.filterd (m0048827.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u57CTF5N047643 for ; Tue, 7 Jun 2016 08:33:37 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0a-001b2d01.pphosted.com with ESMTP id 23dwfuu760-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Jun 2016 08:33:35 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Jun 2016 22:33:33 +1000 Date: Tue, 7 Jun 2016 22:32:10 +1000 From: Anton Blanchard In-Reply-To: <20160607222842.4a745724@kryten> References: <20160404164457.539a55f0@kryten> <57021123.6050506@ozlabs.ru> <20160404204346.1cf44df8@kryten> <20160404210928.0d9ae644@kryten> <20160430104800.0a7c1d11@kryten> <20160607222842.4a745724@kryten> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20160607223210.2b1b42ae@kryten> Subject: [Qemu-devel] [PATCH 2/2] spapr: Better handling of ibm, pa-features TM bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf , Alexey Kardashevskiy , Michael Ellerman , Paul Mackerras , Benjamin Herrenschmidt , Michael Neuling , David Gibson Cc: linuxppc-dev@lists.ozlabs.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org From: Anton Blanchard There are a few issues with our handling of the ibm,pa-features TM bit: - We don't support transactional memory in PR KVM, so don't tell the OS that we do. - In full emulation we have a minimal implementation of TM that always fails, so for performance reasons lets not tell the OS that we support it either. - In HV KVM mode, we should mirror the host TM enabled state by looking at the AT_HWCAP2 bit. Signed-off-by: Anton Blanchard --- diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0636642..c403fbb 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -620,7 +620,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, 0x80, 0x00 }; + 0x80, 0x00, 0x80, 0x00, 0x00, 0x00 }; uint8_t *pa_features; size_t pa_size; @@ -697,6 +697,19 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, } else /* env->mmu_model == POWERPC_MMU_2_07 */ { pa_features = pa_features_207; pa_size = sizeof(pa_features_207); + +#ifdef CONFIG_KVM + /* Only enable TM in HV KVM mode */ + if (kvm_enabled() && + !kvm_vm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) { + unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); + + /* Guest should inherit host TM enabled bit */ + if (hwcap2 & PPC_FEATURE2_HAS_HTM) { + pa_features[24] |= 0x80; + } + } +#endif } if (env->ci_large_pages) { pa_features[3] |= 0x20;