Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp869612imj; Fri, 15 Feb 2019 08:08:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZdhmGWf9avZmdeE2aSbrI3SI7IIexTlJAs3E1T4g0Lor1HCh2HnAkhGJNd0KvsKL4OIBjJ X-Received: by 2002:a63:580f:: with SMTP id m15mr6064342pgb.342.1550246913918; Fri, 15 Feb 2019 08:08:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550246913; cv=none; d=google.com; s=arc-20160816; b=EDatlpN3iQOldgHO4qo9+e5Gix3K6fAMJ9Oghs4bCJICfhzX+IpGdC+9Z+2FEdIZ9t HAaevw/GH5Uv+30ACjNogdqsThUKpRJjdUxEduRc9VeJIYXT5feSE2KK42NFgJEna+7E aPmues2l5EJuSldvrZNWXSPWNCmgIHOYzgX8FUSwpsDUDFip304qFIAeHikaNssJaR+z 1HAd+9zhRrRDlh+k+IQSLog36PdbGygmW99SGtpm0G3NAZMPhXj/qhaSZkCZBqOF4GBJ 1a4HiYcSZv7WkcFlszfxueXilW0ptrynfETC6aoSgYUljNUwlRHtN48fsPhjp1lRZOc5 5+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=501FzV4X16xyWDAxYR0fi7Qd3PgVMP2PGh33Rb1ybeg=; b=aLe+vsvMbX0x9gWRPLoH/oQyMyjoQob3tL6L605sdxmOg7MCQiS5twaWFT0R545jFd 8INzncNtQg+83g6srSgMooj8LbVLrPm+n0wZZXnedkOxfoAk+A1gmKORQ6sZwJColPLa IYBUXGx9aspoMVl/qDwOlh9CVWESsI/L++iYttxYJgGP3vKFAYKY9TwHUuW+moxTkxQl YUFrJ4EjDpSZr3mmb1aLNcnt7EHNEBoU2GerRsxQoVnKZpyZY6dhO/yV2ORvujFXUCA9 dz0GBpEauoAhZktGdkJ2FbJHi5kh4pUjA3CW+zAO3rrHholUoe2UvTUBR8u8MJVLoo5U OZTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=KfNHIL2D; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si789518plr.439.2019.02.15.08.08.17; Fri, 15 Feb 2019 08:08:33 -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; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=KfNHIL2D; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393952AbfBOKdz (ORCPT + 99 others); Fri, 15 Feb 2019 05:33:55 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:60094 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393897AbfBOKdz (ORCPT ); Fri, 15 Feb 2019 05:33:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=501FzV4X16xyWDAxYR0fi7Qd3PgVMP2PGh33Rb1ybeg=; b=KfNHIL2DCI11X2i+bQ6axW+5l xg2W0aYmEVVRT+vo9IVR4XcvczHDeomypEHq77yHlxUSI8q7tjI6QS276cwSjWkgUpEsEVrZPD6zk +cIEe8GIzYDMQ7pxPs2gUHeLVw1lsGxcLGN1kDf5cyeUianoZhEPRF4zExqxP9PjKLquTPSURaPIE Ad1cjHGAHkdlQcSIZTfUOozHdvbpAFq8vHk67/nTHy/BiE+HpjdvjwKyVRhakbivrcQNdSDc0MxN+ KoY42WVu1WU5a9sB7waRxAeZyAKKIq+dXi7AXQZPphbFAI51gg7UPFluH6m++0qVRruZdqoicF6ub 01AMH4JCg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:51120) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1guaoY-0001rp-Vn; Fri, 15 Feb 2019 10:33:51 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1guaoV-0004W4-Hw; Fri, 15 Feb 2019 10:33:47 +0000 Date: Fri, 15 Feb 2019 10:33:47 +0000 From: Russell King - ARM Linux admin To: Marek Szyprowski Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicolas Pitre , Kevin Hilman , linux-samsung-soc@vger.kernel.org, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Marian Mihailescu , Seung-Woo Kim Subject: Re: [PATCH] ARM: pm: fix HYP/SVC mode mismatch when MCPM is used Message-ID: <20190215103347.nelbly5j7yibqtr3@shell.armlinux.org.uk> References: <20190214143114.24356-1-m.szyprowski@samsung.com> <20190214165807.eq34njmunqhrdvxx@shell.armlinux.org.uk> <7548bc35-caef-0737-be39-5ddb8e097f67@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7548bc35-caef-0737-be39-5ddb8e097f67@samsung.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 11:23:28AM +0100, Marek Szyprowski wrote: > > On 2019-02-14 17:58, Russell King - ARM Linux admin wrote: > > On Thu, Feb 14, 2019 at 03:31:14PM +0100, Marek Szyprowski wrote: > >> MCPM does a soft reset of the CPUs and uses common cpu_resume() routine to > >> perform low-level platform initialization. This results in a try to install > >> HYP stubs for the second time for each CPU and results in false HYP/SVC > >> mode mismatch detection. The HYP stubs are already installed at the > >> beginning of the kernel initialization on the boot CPU (head.S) or in the > >> secondary_startup() for other CPUs. To fix this issue MCPM code should use > >> a cpu_resume() routine without HYP stubs installation. > >> > >> This change fixes HYP/SVC mode mismatch on Samsung Exynos5422-based Odroid > >> XU3/XU4/HC1 boards. > >> > >> Fixes: 3721924c8154 ("ARM: 8081/1: MCPM: provide infrastructure to allow for MCPM loopback") > >> Signed-off-by: Marek Szyprowski > >> --- > >> arch/arm/common/mcpm_entry.c | 2 +- > >> arch/arm/include/asm/suspend.h | 1 + > >> arch/arm/kernel/sleep.S | 11 +++++++++++ > >> 3 files changed, 13 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c > >> index ad574d20415c..1b1b82b37ce0 100644 > >> --- a/arch/arm/common/mcpm_entry.c > >> +++ b/arch/arm/common/mcpm_entry.c > >> @@ -381,7 +381,7 @@ static int __init nocache_trampoline(unsigned long _arg) > >> unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); > >> phys_reset_t phys_reset; > >> > >> - mcpm_set_entry_vector(cpu, cluster, cpu_resume); > >> + mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp); > >> setup_mm_for_reboot(); > >> > >> __mcpm_cpu_going_down(cpu, cluster); > >> diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h > >> index 452bbdcbcc83..506314265c6f 100644 > >> --- a/arch/arm/include/asm/suspend.h > >> +++ b/arch/arm/include/asm/suspend.h > >> @@ -10,6 +10,7 @@ struct sleep_save_sp { > >> }; > >> > >> extern void cpu_resume(void); > >> +extern void cpu_resume_no_hyp(void); > >> extern void cpu_resume_arm(void); > >> extern int cpu_suspend(unsigned long, int (*)(unsigned long)); > >> > >> diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S > >> index a8257fc9cf2a..b856d183691e 100644 > >> --- a/arch/arm/kernel/sleep.S > >> +++ b/arch/arm/kernel/sleep.S > >> @@ -122,6 +122,11 @@ ENDPROC(cpu_resume_after_mmu) > >> > >> #ifdef CONFIG_MMU > >> .arm > >> +#ifdef CONFIG_MCPM > >> +ENTRY(cpu_resume_no_hyp) > >> +ARM_BE8(setend be) @ ensure we are in BE mode > >> + b 0f > > What if the kernel is built for Thumb? You'll be branching to thumb > > code at the '0' label - don't you need to do the same that > > cpu_resume_arm does below? > > Maybe yes, but I don't get how did it work so far. Current version of > the cpu_resume() doesn't check the CPU ARM/Thumb mode. Such version is > used by MCPM, blSwitcher and various suspend/resume code from > arch/arm/mach-*. The mode check is in the cpu_resume_arm(), which is > used only by two SoC drivers in drivers/soc). Does it mean that most of > the current cpu_resume() users are wrong? No, it means that the current cpu_resume users are aware whether they are calling into Thumb code or not (via bit 0 of the address.) This is not the case for the code you are introducing. You are adding code prefixed by .arm, and branching to code prefixed by .thumb. The branch instruction does not switch between ARM and Thumb mode. > I've didn't try building Thumb kernel so far to check that. > > >> +#endif > >> ENTRY(cpu_resume_arm) > >> THUMB( badr r9, 1f ) @ Kernel is entered in ARM. > >> THUMB( bx r9 ) @ If this is a Thumb-2 kernel, > >> @@ -135,6 +140,9 @@ ARM_BE8(setend be) @ ensure we are in BE mode > >> bl __hyp_stub_install_secondary > >> #endif > >> safe_svcmode_maskall r1 > >> +#ifdef CONFIG_MCPM > >> +0: > >> +#endif > > You don't need to conditionalise this. I'd also use a symbol rather > > than a numeric label given that safe_svcmode_maskall is a macro that > > also uses numeric labels. > > Okay. > > >> mov r1, #0 > >> ALT_SMP(mrc p15, 0, r0, c0, c0, 5) > >> ALT_UP_B(1f) > >> @@ -163,6 +171,9 @@ ENDPROC(cpu_resume) > >> > >> #ifdef CONFIG_MMU > >> ENDPROC(cpu_resume_arm) > >> +#endif > >> +#ifdef CONFIG_MCPM > >> +ENDPROC(cpu_resume_no_hyp) > >> #endif > >> > >> .align 2 > >> -- > >> 2.17.1 > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland > > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up