Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5586100img; Wed, 27 Mar 2019 11:11:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyweGAKyrYcNf60K5BJFe2qEkAQhvdZitxBT0GycbwYHeDSor6TEkMsO2aR3xbA/Pymh3l X-Received: by 2002:a63:fb16:: with SMTP id o22mr34774476pgh.209.1553710265715; Wed, 27 Mar 2019 11:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710265; cv=none; d=google.com; s=arc-20160816; b=rqO1T+Jyx9GhVj2KKWBHdqfHtn3c22q/Zo4CYzQbl9p2HXG6MbvhnS1AjIMoL3O0lZ 0LJLodtGedxRhTDcfYYLmwhYEtXPzkEaX46Cg3+90gud4+GvOICAV1cqfNfo4570EOdV SEe+LyK7s8i33M5kqvXhvvWDtOkl6KKxZQey7FQqWL6KWdZrX9xTiLgbmTt2TjyN4QQ9 EG0Mzg8kXk7sibCDLC6rmrcbITC62t3t+gWWyJh4nudhbL6IZoEEzoKEv5kd2LP+mK2M ZeCjwP0iLI+uYbeOlS1/hD5QwHkg0lLRnpufIIU1jGV+ds5JyXfxg2jl70yV7Xp+OuNp DfzQ== 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 :dkim-signature; bh=JM3suIAUgAzFzEKdzGMC5zvLBp1Q2wAvxac1+zJbEJg=; b=EX0PExZIE6pBn34iHiuJ7uKjNLjbbV0/a9ZaLGA/FRyWRQ22hPWSx+LE1e+4qtFooK df2mvxE9UZDxBt3Gy+DqmKqFxLymcIU3MLxOZ/qH2jYrBqiBQvK1hL3exgdab3LyB6hH fJw6wJLpMh2RriV+9Y60eSgWcILrUgGR6x/2WVb46V8k2fd1MC0SgDY2tL/HkEPXWqg9 bLhO3ZK21zm18f38/0eCfwprdhKYLkXe0XveG4EbBHDTvHnjSWRWhWkGg9molYbT8fCt Rd0jZIxPqPNgSHgDZtTVwhka3Itse9ZHhyIifZFZjynvg6ids2V3bNRGivXTyVAQB6xD ZpOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZpfEw7EM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si12770970pgz.259.2019.03.27.11.10.50; Wed, 27 Mar 2019 11:11:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZpfEw7EM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731454AbfC0SIY (ORCPT + 99 others); Wed, 27 Mar 2019 14:08:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:50244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbfC0SIW (ORCPT ); Wed, 27 Mar 2019 14:08:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 676DD217D9; Wed, 27 Mar 2019 18:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710102; bh=c6wrt6aVr2BtVgHNYEeeZaenq++PWoe7P15e3GxKDGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZpfEw7EMYV+G9bWxs3JxgCrtjsdTUCIEf7na9jRfnII/4DqJx8ti9nHnct1/j3h9s 4atsYMZqaQRZoRxMwqZRbtNlh0Vd3JOG5G6l5gjY8wlqmDL9sUeuSiALTZW/EWBgr1 EcDlU5oCotUt94L/shVIEs0DjzbcD5UHnMhynZ7I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladimir Murzin , Russell King , Sasha Levin Subject: [PATCH AUTOSEL 5.0 196/262] ARM: 8830/1: NOMMU: Toggle only bits in EXC_RETURN we are really care of Date: Wed, 27 Mar 2019 14:00:51 -0400 Message-Id: <20190327180158.10245-196-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Murzin [ Upstream commit 72cd4064fccaae15ab84d40d4be23667402df4ed ] ARMv8M introduces support for Security extension to M class, among other things it affects exception handling, especially, encoding of EXC_RETURN. The new bits have been added: Bit [6] Secure or Non-secure stack Bit [5] Default callee register stacking Bit [0] Exception Secure which conflicts with hard-coded value of EXC_RETURN: In fact, we only care of few bits: Bit [3] Mode (0 - Handler, 1 - Thread) Bit [2] Stack pointer selection (0 - Main, 1 - Process) We can toggle only those bits and left other bits as they were on exception entry. It is basically, what patch does - saves EXC_RETURN when we do transition form Thread to Handler mode (it is first svc), so later saved value is used instead of EXC_RET_THREADMODE_PROCESSSTACK. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/include/asm/v7m.h | 2 +- arch/arm/kernel/entry-header.S | 3 ++- arch/arm/kernel/entry-v7m.S | 4 ++++ arch/arm/mm/proc-v7m.S | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/v7m.h b/arch/arm/include/asm/v7m.h index 187ccf6496ad..2cb00d15831b 100644 --- a/arch/arm/include/asm/v7m.h +++ b/arch/arm/include/asm/v7m.h @@ -49,7 +49,7 @@ * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01. */ #define EXC_RET_STACK_MASK 0x00000004 -#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd +#define EXC_RET_THREADMODE_PROCESSSTACK (3 << 2) /* Cache related definitions */ diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index 773424843d6e..62db1c9746cb 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -127,7 +127,8 @@ */ .macro v7m_exception_slow_exit ret_r0 cpsid i - ldr lr, =EXC_RET_THREADMODE_PROCESSSTACK + ldr lr, =exc_ret + ldr lr, [lr] @ read original r12, sp, lr, pc and xPSR add r12, sp, #S_IP diff --git a/arch/arm/kernel/entry-v7m.S b/arch/arm/kernel/entry-v7m.S index abcf47848525..19d2dcd6530d 100644 --- a/arch/arm/kernel/entry-v7m.S +++ b/arch/arm/kernel/entry-v7m.S @@ -146,3 +146,7 @@ ENTRY(vector_table) .rept CONFIG_CPU_V7M_NUM_IRQ .long __irq_entry @ External Interrupts .endr + .align 2 + .globl exc_ret +exc_ret: + .space 4 diff --git a/arch/arm/mm/proc-v7m.S b/arch/arm/mm/proc-v7m.S index 47a5acc64433..92e84181933a 100644 --- a/arch/arm/mm/proc-v7m.S +++ b/arch/arm/mm/proc-v7m.S @@ -139,6 +139,9 @@ __v7m_setup_cont: cpsie i svc #0 1: cpsid i + ldr r0, =exc_ret + orr lr, lr, #EXC_RET_THREADMODE_PROCESSSTACK + str lr, [r0] ldmia sp, {r0-r3, r12} str r5, [r12, #11 * 4] @ restore the original SVC vector entry mov lr, r6 @ restore LR -- 2.19.1