Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4109610ybb; Mon, 23 Mar 2020 13:43:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvjvtO6FEB6nm2ha7MhXcZJB64Mg+TUre0hKQS1+6w4365XpSldOrsjwoWdOAPnYtDZYqfO X-Received: by 2002:a4a:88eb:: with SMTP id q40mr978376ooh.87.1584996198935; Mon, 23 Mar 2020 13:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584996198; cv=none; d=google.com; s=arc-20160816; b=tzbtc2hSxXi4wdVPFoCEzUQoR29iiwMrYj/8M+9Q9x3mkJ02m76oVAtS/j+Nh2WnhH WucMlDFpBg3W3+e1BgkKeJhcI/GbuPuwnpTkVUTB4wRtNd+J5Mt9OuYd6TmnboRYn3HC MmMNicq1MEhqGoCj1x8BRs9lmau9XRuJUoSSaTeFmsjvsCU931J8A/7nXwshBLjvkirL xhFXUoI3qY1+s7Rh/OPp7aWKSnojq3qL8AHAohegI3GFJCE7+1eetQReS5UkIXZwNNJT PcpqFLBySGyzRiorchVz5hrmVor167GAbwYxfc4KsRxVi2CSZRdKQIuPdOF6v1FTNuqe NV3w== 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:organization:message-id:date:subject:cc:to :from; bh=c0k64L8mURdUzutUwi2V9g3NSDPCGCRjDdvoFo0TVPg=; b=Ua3iE3m1rTP5SU28niTnbH7xbzvgIj7LuYOqkjz0cn8xEFwSrsqU9DAMvFHVOUcUNB S9CmG0dhYKcMVlXJGQRNyBDI4b5zhXqpAp3Zab+HOilbyHYKpj+nSnimVTmFn7qpLxVU H7ZSl/IczpcTmWqrbwSUd9a/tewPR1AfQR00ZyHTIUUzZMA9Ttb8CtS4Puv5rremCtpW Z3xvi2n5LwFQaM7Akm1+Bj5GiwFYB08srEUicIUDIbngL6hhdrAMtuOpAj0ZlhwBSmq9 4AOMQEzbEBT2T6kzp7R766FOUHv6hRAvOVhirK3ZS1rR6Jsvax2bTKtsZp4sHpLlr+bj 1Qsw== 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 y7si9324487ote.303.2020.03.23.13.43.05; Mon, 23 Mar 2020 13:43:18 -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 S1725914AbgCWUme convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Mar 2020 16:42:34 -0400 Received: from poy.remlab.net ([94.23.215.26]:35310 "EHLO ns207790.ip-94-23-215.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgCWUme (ORCPT ); Mon, 23 Mar 2020 16:42:34 -0400 Received: from basile.remlab.net (87-92-31-51.bb.dnainternet.fi [87.92.31.51]) (Authenticated sender: remi) by ns207790.ip-94-23-215.eu (Postfix) with ESMTPSA id 991185FB11; Mon, 23 Mar 2020 21:42:31 +0100 (CET) From: =?ISO-8859-1?Q?R=E9mi?= Denis-Courmont To: Catalin Marinas Cc: Mark Rutland , will@kernel.org, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] arm64: clean up trampoline vector loads Date: Mon, 23 Mar 2020 22:42:30 +0200 Message-ID: <2067644.cOvikPKVsA@basile.remlab.net> Organization: Remlab In-Reply-To: <20200323190408.GE4892@mbp> References: <1938400.7m7sAWtiY1@basile.remlab.net> <20200323121437.GC2597@C02TD0UTHF1T.local> <20200323190408.GE4892@mbp> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le maanantaina 23. maaliskuuta 2020, 21.04.09 EET Catalin Marinas a écrit : > On Mon, Mar 23, 2020 at 12:14:37PM +0000, Mark Rutland wrote: > > On Mon, Mar 23, 2020 at 02:08:53PM +0200, Rémi Denis-Courmont wrote: > > > Le maanantaina 23. maaliskuuta 2020, 14.07.00 EET Mark Rutland a écrit : > > > > On Thu, Mar 19, 2020 at 11:14:05AM +0200, Rémi Denis-Courmont wrote: > > > > > From: Rémi Denis-Courmont > > > > > > > > > > This switches from custom instruction patterns to the regular large > > > > > memory model sequence with ADRP and LDR. In doing so, the ADD > > > > > instruction can be eliminated in the SDEI handler, and the code no > > > > > longer assumes that the trampoline vectors and the vectors address > > > > > both > > > > > start on a page boundary. > > > > > > > > > > Signed-off-by: Rémi Denis-Courmont > > > > > --- > > > > > > > > > > arch/arm64/kernel/entry.S | 9 ++++----- > > > > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > > > > > > > diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S > > > > > index e5d4e30ee242..24f828739696 100644 > > > > > --- a/arch/arm64/kernel/entry.S > > > > > +++ b/arch/arm64/kernel/entry.S > > > > > @@ -805,9 +805,9 @@ alternative_else_nop_endif > > > > > > > > > > 2: > > > > > tramp_map_kernel x30 > > > > > > > > > > #ifdef CONFIG_RANDOMIZE_BASE > > > > > > > > > > - adr x30, tramp_vectors + PAGE_SIZE > > > > > + adrp x30, tramp_vectors + PAGE_SIZE > > > > > > > > > > alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 > > > > > > > > > > - ldr x30, [x30] > > > > > + ldr x30, [x30, #:lo12:__entry_tramp_data_start] > > > > > > > > I think this is busted for !4K kernels once we reduce the alignment of > > > > __entry_tramp_data_start. > > > > > > > > The ADRP gives us a 64K aligned address (with bits 15:0 clear). The > > > > lo12 > > > > relocation gives us bits 11:0, so we haven't accounted for bits 15:12. > > > > > > IMU, ADRP gives a 4K aligned value, regardless of MMU (TCR) settings. > > > > Sorry, I had erroneously assumed tramp_vectors was page aligned. The > > issue still stands -- we haven't accounted for bits 15:12, as those can > > differ between tramp_vectors and __entry_tramp_data_start. Does that mean that the SDEI code never worked with page size > 4 KiB? > Should we just use adrp on __entry_tramp_data_start? Anyway, the diff > below doesn't solve the issue I'm seeing (only reverting patch 3). AFAIU, the preexisting code uses the manual PAGE_SIZE offset because the offset in the main vmlinux does not match the architected offset inside the fixmap. If so, then using the symbol directly will not work at all. > diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S > index ca1340eb46d8..4cc9d1df3985 100644 > --- a/arch/arm64/kernel/entry.S > +++ b/arch/arm64/kernel/entry.S > @@ -810,7 +810,7 @@ alternative_else_nop_endif > 2: > tramp_map_kernel x30 > #ifdef CONFIG_RANDOMIZE_BASE > - adrp x30, tramp_vectors + PAGE_SIZE > + adrp x30, __entry_tramp_data_start > alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 > ldr x30, [x30, #:lo12:__entry_tramp_data_start] > #else > @@ -964,7 +964,7 @@ SYM_CODE_START(__sdei_asm_entry_trampoline) > 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] > > #ifdef CONFIG_RANDOMIZE_BASE > - adrp x4, tramp_vectors + PAGE_SIZE > + adrp x4, __sdei_asm_trampoline_next_handler > ldr x4, [x4, #:lo12:__sdei_asm_trampoline_next_handler] > #else > ldr x4, =__sdei_asm_handler -- 雷米‧德尼-库尔蒙 http://www.remlab.net/