Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5350237ybc; Wed, 27 Nov 2019 02:41:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwjjfPWfCwU7ZAA80vPr0YssTwQY/YyW8Xl6kmkjyQpzjPfQn9OyRztXImzylkn99RGCGZo X-Received: by 2002:a17:906:82ca:: with SMTP id a10mr354047ejy.40.1574851289559; Wed, 27 Nov 2019 02:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574851289; cv=none; d=google.com; s=arc-20160816; b=DeoINyk6b8hlNC05cKdtzx82RCk8Z1I8SExKSuEaa7HCyM3v2IqZCHhtM6XrR9ACdC R6Ys89aA238/PLcJy5oBQvTIsYLJbf55nq3WLcWi9REwhq1i6t4CkpSvTsBgynn4kdb+ eA7uiPKb1+tDhrVavDmvRq6OcHDygme8eCJ8enzMQ0WLW9V7uAYiPtETaSbXYdLF5v7S 1aTxfDjlY7qr5NmIp12g1H6W/I/9ole0FDmCyiRxw0O0jrHFn5yjmXcn9+AyVZp7Lutd LpPKntzEOypPb8KGfMwZ7ouYjxfF9kpqWatgo3S90dGsuq+JrytSbStlZv8gDZNvbuuI Y1UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Wjgc/0RiRw+tXTEn+ZTxfeMPNKCID/DhJUAaQKKaraA=; b=LWXEb+b4U52CBLg13Z/a2yiu/PJelWVBHbcZV93EKZaoiHx9OR1LmxxwgbHs/lYh6R QCu6twYvC/rvLInNqcijYnwsSqov9X8/9+9ZWlXmMAwcCkYg8QDOkHfw8kzNldTdoZbd fVktCwvqp0CF9CBGcItl7NfSP9d9CXw1LnM6KZH0rkCd2PFWAThWdLdFsTLGgmw6rrbP RwILBO59M2X7NTiBaWxswgDpIzRNEC0Fz0+hNa/0rPmj22esMsHYZcE4PqOeqygATa+S Pi3Ib+UWZwj9rmp1cbOtTfg5aruytY95Nwf4qnlr0U6kPT77on/D4D2ukkKtGUaeNu4w QzxQ== 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 f23si4084588edq.421.2019.11.27.02.41.05; Wed, 27 Nov 2019 02:41:29 -0800 (PST) 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 S1727182AbfK0Kjr (ORCPT + 99 others); Wed, 27 Nov 2019 05:39:47 -0500 Received: from mx2.suse.de ([195.135.220.15]:55420 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727125AbfK0Kjo (ORCPT ); Wed, 27 Nov 2019 05:39:44 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DD472B46D; Wed, 27 Nov 2019 10:39:42 +0000 (UTC) From: Michal Suchanek To: linuxppc-dev@lists.ozlabs.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Oleg Nesterov , Alexander Viro , Christian Brauner , Nicholas Piggin , Allison Randal , "Naveen N. Rao" , Michal Suchanek , Thomas Gleixner , Breno Leitao , Christophe Leroy , Claudio Carvalho , Russell Currey , Greg Kroah-Hartman , Mahesh Salgaonkar , Arnd Bergmann , Geert Uytterhoeven , Firoz Khan , Dmitry Vyukov , Masahiro Yamada , Hari Bathini , Andrew Donnellan , Nicolai Stange , Valentin Schneider , Diana Craciun , Daniel Axtens , Michael Neuling , Gustavo Romero , Mathieu Malaterre , "Steven Rostedt" , "Eric W. Biederman" , Heiko Carstens , David Howells , Brajeswar Ghosh , Jagadeesh Pagadala , David Hildenbrand , Andrew Morton , Madhavan Srinivasan , linux-kernel@vger.kernel.org Subject: [PATCH v2 rebase 16/34] powerpc/64s/exception: hdecrementer avoid touching the stack Date: Wed, 27 Nov 2019 11:38:52 +0100 Message-Id: X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Piggin The hdec interrupt handler is reported to sometimes fire in Linux if KVM leaves it pending after a guest exists. This is harmless, so there is a no-op handler for it. The interrupt handler currently uses the regular kernel stack. Change this to avoid touching the stack entirely. This should be the last place where the regular Linux stack can be accessed with asynchronous interrupts (including PMI) soft-masked. It might be possible to take advantage of this invariant, e.g., to context switch the kernel stack SLB entry without clearing MSR[EE]. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 1 - arch/powerpc/kernel/exceptions-64s.S | 25 ++++++++++++++++++++----- arch/powerpc/kernel/time.c | 9 --------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 08dbe3e6831c..e0107495c4de 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -24,7 +24,6 @@ extern struct clock_event_device decrementer_clockevent; extern void generic_calibrate_decr(void); -extern void hdec_interrupt(struct pt_regs *regs); /* Some sane defaults: 125 MHz timebase, 1GHz processor */ extern unsigned long ppc_proc_freq; diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 9fa71d51ecf4..7a234e6d7bf5 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1491,6 +1491,8 @@ EXC_COMMON_BEGIN(decrementer_common) INT_DEFINE_BEGIN(hdecrementer) IVEC=0x980 IHSRR=EXC_HV + ISTACK=0 + IRECONCILE=0 IKVM_REAL=1 IKVM_VIRT=1 INT_DEFINE_END(hdecrementer) @@ -1502,11 +1504,24 @@ EXC_VIRT_BEGIN(hdecrementer, 0x4980, 0x80) GEN_INT_ENTRY hdecrementer, virt=1 EXC_VIRT_END(hdecrementer, 0x4980, 0x80) EXC_COMMON_BEGIN(hdecrementer_common) - GEN_COMMON hdecrementer - bl save_nvgprs - addi r3,r1,STACK_FRAME_OVERHEAD - bl hdec_interrupt - b ret_from_except + __GEN_COMMON_ENTRY hdecrementer + /* + * Hypervisor decrementer interrupts not caught by the KVM test + * shouldn't occur but are sometimes left pending on exit from a KVM + * guest. We don't need to do anything to clear them, as they are + * edge-triggered. + * + * Be careful to avoid touching the kernel stack. + */ + ld r10,PACA_EXGEN+EX_CTR(r13) + mtctr r10 + mtcrf 0x80,r9 + ld r9,PACA_EXGEN+EX_R9(r13) + ld r10,PACA_EXGEN+EX_R10(r13) + ld r11,PACA_EXGEN+EX_R11(r13) + ld r12,PACA_EXGEN+EX_R12(r13) + ld r13,PACA_EXGEN+EX_R13(r13) + HRFI_TO_KERNEL GEN_KVM hdecrementer diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 968ae97382b4..e4572d67cc76 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -663,15 +663,6 @@ void timer_broadcast_interrupt(void) } #endif -/* - * Hypervisor decrementer interrupts shouldn't occur but are sometimes - * left pending on exit from a KVM guest. We don't need to do anything - * to clear them, as they are edge-triggered. - */ -void hdec_interrupt(struct pt_regs *regs) -{ -} - #ifdef CONFIG_SUSPEND static void generic_suspend_disable_irqs(void) { -- 2.23.0