From patchwork Wed Jul 11 13:56:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141751 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp321752ljj; Wed, 11 Jul 2018 06:57:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdF4N1Wc72m5lBz4xtrUftlLXt2VWI7cKoohWteXS2fPicroS1zjKybNztZ4NbiTeZU2+Oj X-Received: by 2002:a17:902:a60b:: with SMTP id u11-v6mr28753953plq.158.1531317473978; Wed, 11 Jul 2018 06:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531317473; cv=none; d=google.com; s=arc-20160816; b=VYKHqguloC9PPs2MGK3XBcWkbC7uqSRyCDcV5G3/GE4y65HwBAuHhFMd9uYZO7ZIXd zeduwLuPFwHYbB34QG0tKbmMIHYKvgbKbRzqQboQiSTj+Ld7cEjJH/63EPI8su5ix9Qz K+caOwuZkOZBn7wHTW8czteGQg/fLwfhD/hDTA4YttiEBsoS/ryWkbVxoF+zm+InA60+ p5Ej0B3D1n0B9nhPO3lF1VwHUEZL8YYjCxkjl0MDLkwAQ4HPtgHYYVc+ytM4S6oWIKcl oX6L+dqhNIp56yjXPgxofgdiORUX6SrYSiFwCXm4fiEw+TCoVNw99vl05H50FZTBs+wf J69w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CdNx5ytEQi1xOvCR88zjZ5/+eGrz52EcsN0dA4JQPRU=; b=ZX5gqOQCL3ooVppV+jG7erzvCrqcwA431tDTeO4O3QVe/fftYQFt/Kxbw1pPMlc3vN gWcgvhpw4ZluxiqZIS9Azq52uqS0CRyYPfweuBaiEVdfrcorPooqQQSAbSx6OxllP0Uh Z0kM0j7B4EQwqLkoldajk/CsH0WSarc5VBwaGF4DBmo6kkfTxrGs+Rzrwt/WLZ8kZtyL of33TXPzH1pRqPrmPrvsZlDwEYfAAcey/zj7rLJ+TlFs22CeZZ3VGChofA3vkFzCh9iI vpODVM+/3ACrsNKB5ywAZJojmarIVGKGdfEziWjfObdfu94fTON2PygR/XpbyxHOFdMn 42Rw== 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 w19-v6si19544479pfn.160.2018.07.11.06.57.53; Wed, 11 Jul 2018 06:57:53 -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 S2388536AbeGKOCT (ORCPT + 23 others); Wed, 11 Jul 2018 10:02:19 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbeGKOCS (ORCPT ); Wed, 11 Jul 2018 10:02:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DD5322C7; Wed, 11 Jul 2018 06:57:51 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F19A23F5B1; Wed, 11 Jul 2018 06:57:48 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com Cc: catalin.marinas@arm.com, dave.martin@arm.com, hch@infradead.org, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk Subject: [PATCHv5 13/21] arm64: zero GPRs upon entry from EL0 Date: Wed, 11 Jul 2018 14:56:48 +0100 Message-Id: <20180711135656.20670-14-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180711135656.20670-1-mark.rutland@arm.com> References: <20180711135656.20670-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can zero GPRs x0 - x29 upon entry from EL0 to make it harder for userspace to control values consumed by speculative gadgets. We don't blat x30, since this is stashed much later, and we'll blat it before invoking C code. Signed-off-by: Mark Rutland Acked-by: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/entry.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 22b240da949b..d1440f84668b 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -53,6 +53,12 @@ #endif .endm + .macro clear_gp_regs + .irp n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 + mov x\n, xzr + .endr + .endm + /* * Bad Abort numbers *----------------- @@ -169,6 +175,7 @@ alternative_cb_end stp x28, x29, [sp, #16 * 14] .if \el == 0 + clear_gp_regs mrs x21, sp_el0 ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear, ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug @@ -176,7 +183,6 @@ alternative_cb_end apply_ssbd 1, x22, x23 - mov x29, xzr // fp pointed to user-space .else add x21, sp, #S_FRAME_SIZE get_thread_info tsk