Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3484993imu; Sun, 11 Nov 2018 16:09:44 -0800 (PST) X-Google-Smtp-Source: AJdET5f5wWaMMSkewbvUDYA2NYeuddGenBDXU4s3bufMZ+cRKxKlXm2gJ0c9hY5y08MHCMokm+Ap X-Received: by 2002:a63:c503:: with SMTP id f3mr8137176pgd.431.1541981384656; Sun, 11 Nov 2018 16:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981384; cv=none; d=google.com; s=arc-20160816; b=pQ/9X/MW+j9ckiRrkWYd7/CpH8DAwr7DIpO+M1+b9WLARxy8l4AC73ef/p81Waip2t h5C4hjok+K6AJ6FC7K+UTgNeHQL+BWBIdI9RawMnnl2lyON4n3kBRYYN/Q5aArTfhMdT yNRpqq/1Qs+47jcSaPvdHAqqDqH/FKl7svj1zfed96af5urVla4VbcYpCscdj3etbxoB /MvYJpfthn8tK0IJ4HRdZBK3+gOEUmQLa1oDYysepEk8FEc3DZJee8yR0qtonC0QYlZl sKBuUj5FtT2EP/2lyLZCRtTG/CB3qyHlwEVRAQZYH5Ey8yrD5rHW86GJ+szuGW+y4fs/ h7tw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qPa+CQj6RzWG8PGeLdl9HvVlUf8gdJ3VCZqGQxzDXv4=; b=R7qPtVPjPC03NDPDfNSSyjfMj3N+akW11K7gU8wTu/p0TUzgs0GKaaFUor4K80Y3vn 1hYjyRwGf/Vl+Gs+yn3NiNlK/NhDfYvjHY6BjG2WVFtON2FcZI+m1VPmDhdkYr86NL/g Zj+RLuQYYI1MCByVKbUwH2ykWkPIh0DwVmgo7nl+0RKVVCB4AyGpBcTxTLJzMKBYGY1y fArxtLzkujsSEBzHkDNDAsrmXUpOlKouBZO2Wv9L/nHfKkr3/xtWWIwZhxSwCtqaqLCx 1chHlM1En3dGNNou0Yem73lBGM3PyqGjatolI2f0tkTAl8Nq0M9KOxFxENvVoOa8m8aq p4Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NYL8QAWy; 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 h3-v6si15683718plb.291.2018.11.11.16.09.28; Sun, 11 Nov 2018 16:09:44 -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=pass header.i=@kernel.org header.s=default header.b=NYL8QAWy; 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 S1731944AbeKLJ6X (ORCPT + 99 others); Mon, 12 Nov 2018 04:58:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731526AbeKLIRe (ORCPT ); Mon, 12 Nov 2018 03:17:34 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C987F214DB; Sun, 11 Nov 2018 22:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975258; bh=33PV/GUXeHGA8Ezr8WVCVruZi44fHfHLX7KvR6e9DoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NYL8QAWyGKm/ZIL0yaTWLqsYE64+a5xGtyJDDoVCRwJ0Wp3iGFepf0ewRo2MPIV7d UygEHCmkDmrYZyLs9iDfCtcSjcis4X0JEgiSxkpBdioOdJ6w0vMzz+7FuGbOI9f+aj sllQSIFBvCBNsCsiB7axwHtaeK+AHcfd54pnzdBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Catalin Marinas , Sasha Levin Subject: [PATCH 4.19 104/361] arm64: entry: Allow handling of undefined instructions from EL1 Date: Sun, 11 Nov 2018 14:17:31 -0800 Message-Id: <20181111221634.231771715@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon [ Upstream commit 0bf0f444b2c49241b2b39aa3cf210d7c95ef6c34 ] Rather than panic() when taking an undefined instruction exception from EL1, allow a hook to be registered in case we want to emulate the instruction, like we will for the SSBS PSTATE manipulation instructions. Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 2 +- arch/arm64/kernel/traps.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -589,7 +589,7 @@ el1_undef: inherit_daif pstate=x23, tmp=x2 mov x0, sp bl do_undefinstr - ASM_BUG() + kernel_exit 1 el1_dbg: /* * Debug exception handling --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -310,10 +310,12 @@ static int call_undef_hook(struct pt_reg int (*fn)(struct pt_regs *regs, u32 instr) = NULL; void __user *pc = (void __user *)instruction_pointer(regs); - if (!user_mode(regs)) - return 1; - - if (compat_thumb_mode(regs)) { + if (!user_mode(regs)) { + __le32 instr_le; + if (probe_kernel_address((__force __le32 *)pc, instr_le)) + goto exit; + instr = le32_to_cpu(instr_le); + } else if (compat_thumb_mode(regs)) { /* 16-bit Thumb instruction */ __le16 instr_le; if (get_user(instr_le, (__le16 __user *)pc)) @@ -407,6 +409,7 @@ asmlinkage void __exception do_undefinst return; force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc); + BUG_ON(!user_mode(regs)); } void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused)