From patchwork Mon Apr 4 11:11:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 8740011 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 48525C0553 for ; Mon, 4 Apr 2016 11:11:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CD4620212 for ; Mon, 4 Apr 2016 11:11:48 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 057CB20204 for ; Mon, 4 Apr 2016 11:11:48 +0000 (UTC) Received: from localhost ([::1]:57908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an2Q7-0003M2-47 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Apr 2016 07:11:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an2Px-0003LF-V0 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 07:11:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1an2Px-0002Kt-31 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 07:11:37 -0400 Received: from hr2.samba.org ([2a01:4f8:192:486::147:1]:57372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an2Pw-0002KA-SF; Mon, 04 Apr 2016 07:11:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42627210; h=Message-ID:Cc:To:From:Date; bh=e5lNT6xJLcwRn5g0EECg1zKnY1n8Mj2YnSQ7/BOLRHI=; b=niqbtaoBh9iyAwdpfZeEvM6fDM/tICQx3stw7ohJgPBQ7oxcqACW4dIDZlrcVcpz58SFVmpJqOpmaW5uITpIhbtrQfWfuX6LL5wvobzxAznNE4EFN2TIBunpfwUYUJoGOTku/VuKzP12iM81b1Gkc9zgQw8g3SGPq4LtXlGCO1w=; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim) id 1an2Po-0007if-Bd; Mon, 04 Apr 2016 11:11:28 +0000 Date: Mon, 4 Apr 2016 21:11:12 +1000 From: Anton Blanchard To: Alexey Kardashevskiy , Michael Ellerman , Paul Mackerras , Benjamin Herrenschmidt , Michael Neuling , David Gibson , Alexander Graf Message-ID: <20160404211112.66b0756f@kryten> In-Reply-To: <20160404204346.1cf44df8@kryten> References: <20160404164457.539a55f0@kryten> <57021123.6050506@ozlabs.ru> <20160404204346.1cf44df8@kryten> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 2a01:4f8:192:486::147:1 Cc: qemu-ppc@nongnu.org, linuxppc-dev@lists.ozlabs.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] powerpc: Clear user CPU feature bits if TM is disabled at runtime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In check_cpu_pa_features() we check a number of bits in the ibm,pa-features array and set and clear CPU features based on what we find. One of these bits is CPU_FTR_TM, the transactional memory feature bit. If this does disable TM at runtime, then we need to tell userspace about it by clearing the user CPU feature bits. Without this patch userspace processes will think they can execute TM instructions and get killed when they try. Signed-off-by: Anton Blanchard Cc: stable@vger.kernel.org Reviewed-by: David Gibson --- Michael I've added stable here because I'm seeing this on a number of distros and would like to get it backported, but I'll leave it up to you if it should go there. diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index f98be83..98c6c86 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -822,4 +822,18 @@ static int __init disable_hardlockup_detector(void) return 0; } early_initcall(disable_hardlockup_detector); + +static int __init update_cpu_user_features(void) +{ + /* + * Firmware might have disabled TM by clearing the relevant + * bit in the ibm,pa-features array. In this case we need to + * tell userspace. + */ + if (!cpu_has_feature(CPU_FTR_TM)) + cur_cpu_spec->cpu_user_features2 &= ~(PPC_FEATURE2_HTM|PPC_FEATURE2_HTM_NOSC); + + return 0; +} +early_initcall(update_cpu_user_features); #endif