Received: by 10.192.165.148 with SMTP id m20csp2428589imm; Sun, 22 Apr 2018 06:59:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YBW59NK+0XuWIYWpYb515MJ0ZhIEMovEDDi7uvcDQg462VmikrgEypVsnrmvYpmcrSJyk X-Received: by 2002:a17:902:2468:: with SMTP id m37-v6mr17848080plg.388.1524405540567; Sun, 22 Apr 2018 06:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405540; cv=none; d=google.com; s=arc-20160816; b=pCozQiPNnkE1rcw8NuLCFXlOzjNAyYaN0sVSnyGBzyeRomj7plOGrSEORwmbKPuPn7 F3oje/t82/tppCg0yvNh/XzflVb9g4zI2vfPFw/aSExkTRWrxL5dhYAYSd6bDs7wAVtZ kBMC9Y6ok+McGFnIg9wBryiS+SAaKUJimXvb4th605xsHibwjM2E0C+H1Fb7dDwee5/p 4Dj6WeFnKmqQRFuRPtuSgA3dymCw8AxiSK6LF3Tg8rSZWv7UjmBM2OIxh0+CSr4N7w9j 6xCJimTHqfA7fO21mRJEyHz9QzSAyJamEusN5wLIRf+AKAKWUBTPAzPef4JHF3hVSCXS C9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+1tHIaja6UMpqTXQ610ftGF9Bqt7/cMWgvBh15BW6N0=; b=PSOBLTZDzSYc+PROJUSfrWYudKjNUkTnBvWR6wCatpxYd6IFUx5Ukb7lMjdgdCv+XC zw61pKD57QpWZLqlNgplS7xxmJt+cxot1vQIDd3VNKhgC84nASavkxAYwUKi4DgEfvXn F0TlVlEYmVva9yvDFsBTQ858Q2+D4q3ZbBB1FhAy0AsT53tQNSuoqtFvHTTw1tNLO1Ch 7F9vSk45U7k2WNCF+ZqVh6K7YcxYJoDnTx/bscAXwniakIx7TNuUjcWkcmtwD6BTf2kM Lz3PX2bjTC4gDOE7Z2v1vQv5C9nkrfLOjpXagD88C0sTV9uHcpvYelQcPFHfMuuaYi2b Wq7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1-v6si9465977pld.108.2018.04.22.06.58.46; Sun, 22 Apr 2018 06:59:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753952AbeDVN5Q (ORCPT + 99 others); Sun, 22 Apr 2018 09:57:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45556 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753450AbeDVN5H (ORCPT ); Sun, 22 Apr 2018 09:57:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 781A5CCB; Sun, 22 Apr 2018 13:57:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Michael Ellerman Subject: [PATCH 4.16 062/196] powerpc/64s: Fix dt_cpu_ftrs to have restore_cpu clear unwanted LPCR bits Date: Sun, 22 Apr 2018 15:51:22 +0200 Message-Id: <20180422135107.452591280@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicholas Piggin commit a57ac411832384eb93df4bfed2bf644c4089720e upstream. Presently the dt_cpu_ftrs restore_cpu will only add bits to the LPCR for secondaries, but some bits must be removed (e.g., UPRT for HPT). Not clearing these bits on secondaries causes checkstops when booting with disable_radix. restore_cpu can not just set LPCR, because it is also called by the idle wakeup code which relies on opal_slw_set_reg to restore the value of LPCR, at least on P8 which does not save LPCR to stack in the idle code. Fix this by including a mask of bits to clear from LPCR as well, which is used by restore_cpu. This is a little messy now, but it's a minimal fix that can be backported. Longer term, the idle SPR save/restore code can be reworked to completely avoid calls to restore_cpu, then restore_cpu would be able to unconditionally set LPCR to match boot processor environment. Fixes: 5a61ef74f269f ("powerpc/64s: Support new device tree binding for discovering CPU features") Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/dt_cpu_ftrs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/arch/powerpc/kernel/dt_cpu_ftrs.c +++ b/arch/powerpc/kernel/dt_cpu_ftrs.c @@ -84,6 +84,7 @@ static int hv_mode; static struct { u64 lpcr; + u64 lpcr_clear; u64 hfscr; u64 fscr; } system_registers; @@ -92,6 +93,8 @@ static void (*init_pmu_registers)(void); static void __restore_cpu_cpufeatures(void) { + u64 lpcr; + /* * LPCR is restored by the power on engine already. It can be changed * after early init e.g., by radix enable, and we have no unified API @@ -104,8 +107,10 @@ static void __restore_cpu_cpufeatures(vo * The best we can do to accommodate secondary boot and idle restore * for now is "or" LPCR with existing. */ - - mtspr(SPRN_LPCR, system_registers.lpcr | mfspr(SPRN_LPCR)); + lpcr = mfspr(SPRN_LPCR); + lpcr |= system_registers.lpcr; + lpcr &= ~system_registers.lpcr_clear; + mtspr(SPRN_LPCR, lpcr); if (hv_mode) { mtspr(SPRN_LPID, 0); mtspr(SPRN_HFSCR, system_registers.hfscr); @@ -325,8 +330,9 @@ static int __init feat_enable_mmu_hash_v { u64 lpcr; + system_registers.lpcr_clear |= (LPCR_ISL | LPCR_UPRT | LPCR_HR); lpcr = mfspr(SPRN_LPCR); - lpcr &= ~LPCR_ISL; + lpcr &= ~(LPCR_ISL | LPCR_UPRT | LPCR_HR); mtspr(SPRN_LPCR, lpcr); cur_cpu_spec->mmu_features |= MMU_FTRS_HASH_BASE;