Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4705028ybb; Tue, 24 Mar 2020 03:52:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrEZy9xPNmcWuri5TQ90Fu6ZKfZYzpUxKM0Q4DoPV+vJhZ1ZC637ajG8fOuHKvqLia4Tmi X-Received: by 2002:aca:5014:: with SMTP id e20mr3027680oib.34.1585047179232; Tue, 24 Mar 2020 03:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585047179; cv=none; d=google.com; s=arc-20160816; b=SYC89ol6QcI+sYPcLWiSMN/jThLvy8cBGOO4Uu7EeNdp5wCsbX0WA7/M6aiHW5e3dx HpSsl7RTLevalWe0POHYQoHNY0FZloKIB0B20bCLHn8FS++4JYBSRdS+gbd9WyR5wpqQ NUw/UrOLm/tqJhbxhJCrHpMel6G/xXm3F2lQYsW3hxqcLoD2my0UIya3mGDqFQD9Bu5+ lO6k9utArumTSpuaSDGjHHFn39fnAp03/RGbKHChonWLSAF5mH60e7dRK+kCd712Np10 BrT8wgsF7EVucYsTSW28e+/adFjyePRGBCqCKJg5D5+HV9IEI7sToQ1zF544PoHSJG2d FORQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hw07Jy57oyQWqR2VS74090h1McglNXMmejenl61Jx/Y=; b=hOYhWrcqwj7352lOducLlttVqawa+2PuUbNteV2rp6xMg4eikFJrUIPJ7RQi7KqmEk wA4GuBNGBCe1LNk78eaygohCdHVh9K83oU23kUN1Coyipgpn2C8AYm3MHe2wGHjQc6Lf DGUSj4xV4oK/HWm0/MKzFApawue6h3mOfgUvye1wcvBjGSf0V7CmJVCCKyfDEnpv5AhL b666PwuPkzHKJHbbmInVHMpbce+mAu5Rzq+R3rCtlSUTmSZYyQluhn8z1IY3QSIYbiej N0KtdyfQn//zT38a60VaYfjXJ+X4/z9gKhywLHdlOPzRZqHIvKSfZGcSVIfryHyKJ/ev kjLQ== 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 f29si721907ooh.85.2020.03.24.03.52.47; Tue, 24 Mar 2020 03:52:59 -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 S1727145AbgCXKw1 (ORCPT + 99 others); Tue, 24 Mar 2020 06:52:27 -0400 Received: from foss.arm.com ([217.140.110.172]:60636 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbgCXKw1 (ORCPT ); Tue, 24 Mar 2020 06:52:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AC0B330E; Tue, 24 Mar 2020 03:52:26 -0700 (PDT) Received: from C02TD0UTHF1T.local (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2425D3F792; Tue, 24 Mar 2020 03:52:24 -0700 (PDT) Date: Tue, 24 Mar 2020 10:52:17 +0000 From: Mark Rutland To: =?utf-8?B?UsOpbWk=?= Denis-Courmont Cc: Catalin Marinas , 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 Message-ID: <20200324105217.GA20256@C02TD0UTHF1T.local> References: <1938400.7m7sAWtiY1@basile.remlab.net> <20200323121437.GC2597@C02TD0UTHF1T.local> <20200323190408.GE4892@mbp> <2067644.cOvikPKVsA@basile.remlab.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2067644.cOvikPKVsA@basile.remlab.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 10:42:30PM +0200, Rémi Denis-Courmont wrote: > 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? I think this happens to work, but is fragile. Because nothing happens to get placed in .rodata between the _entry_tramp_data_start data and the __sdei_asm_trampoline_next_handler data, the __sdei_asm_trampoline_next_handler data doesn't spill into a separate page from the _entry_tramp_data_start data. If we did start adding stuff into .rodata between those two, there'd be a bigger risk of things going wrong. That was why I suggested a .entry.tramp.data section previously. > > 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. Indeed. I can't see a neat way of avoiding this right now, so should we drop these patches and leave the code as-is (but with comments as to the special requirements that it has)? Thanks, Mark.