From patchwork Tue Jun 7 12:32:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 9161631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C44B660467 for ; Tue, 7 Jun 2016 15:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B60081FF65 for ; Tue, 7 Jun 2016 15:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA34821C9A; Tue, 7 Jun 2016 15:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21AED1FF65 for ; Tue, 7 Jun 2016 15:22:47 +0000 (UTC) Received: from localhost ([::1]:50938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAIq6-00046v-A1 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 11:22:46 -0400 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 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Jun 2016 22:33:30 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: anton@au1.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 3EF342BB005B; Tue, 7 Jun 2016 22:33:14 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u57CWwrJ5964280; Tue, 7 Jun 2016 22:32:58 +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 u57CWl16032447; Tue, 7 Jun 2016 22:32:48 +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 u57CWlTE032299; Tue, 7 Jun 2016 22:32:47 +1000 Received: from kryten (unknown [9.192.194.251]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 451BDA012A; Tue, 7 Jun 2016 22:32:11 +1000 (AEST) Date: Tue, 7 Jun 2016 22:32:10 +1000 From: Anton Blanchard To: Alexander Graf , Alexey Kardashevskiy , Michael Ellerman , Paul Mackerras , Benjamin Herrenschmidt , Michael Neuling , David Gibson 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> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060712-1617-0000-0000-000001299B9D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060712-1618-0000-0000-0000460585F0 Message-Id: <20160607223210.2b1b42ae@kryten> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-07_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606070146 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 X-Mailman-Approved-At: Tue, 07 Jun 2016 11:17:42 -0400 Subject: [Qemu-devel] [PATCH 2/2] spapr: Better handling of ibm, pa-features TM bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, linuxppc-dev@lists.ozlabs.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;