From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D407C433DF for ; Fri, 9 Oct 2020 09:45:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E5A62225B for ; Fri, 9 Oct 2020 09:45:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R4C5wrJr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E5A62225B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JjTgQhX60GwL9mYvCmmzN2RWu2pvoWe0uY0u/rqbBCo=; b=R4C5wrJr+FxUtdGKbU7HoNvN6 yxlKYvzWAh3w8UtQbMnoRhvn/Mi543KvwK5Lol0hAaO59hHPzTrPBuzf8J56mcnlldOTGC/jJJfXX Yd7xGQFSzCD0eIejXmW51VRu/Jrf/u/Ulk82W5Lvu9uHZVuS0emRhHqsWo7hvAJv1r4ENWWFSINcW IO8e4twV0IL+jrzU+4FgHkcz7NqUHavpfHbd+MpFNHrJYk3VI8wHVckGCwo8SXagUh3a5vuRcXvU9 I565G8zCZ6S1UU658rzcPXb9eJG7tRz//ZCuenhEQqpc6v2g3/RtZGoNNDv4RJZax9iZcXGbQS3dZ mgm2KqHJQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQow7-0003xK-Ep; Fri, 09 Oct 2020 09:43:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQow3-0003vl-NC for linux-arm-kernel@lists.infradead.org; Fri, 09 Oct 2020 09:43:36 +0000 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 B141ED6E; Fri, 9 Oct 2020 02:43:33 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.51.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB13A3F66B; Fri, 9 Oct 2020 02:43:31 -0700 (PDT) Date: Fri, 9 Oct 2020 10:43:18 +0100 From: Mark Rutland To: Will Deacon Subject: Re: [PATCHv2] arm64: initialize per-cpu offsets earlier Message-ID: <20201009094318.GA87530@C02TD0UTHF1T.local> References: <20201005164303.21389-1-mark.rutland@arm.com> <711bc57a314d8d646b41307008db2845b7537b3d.camel@redhat.com> <20201009085115.GC29594@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201009085115.GC29594@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201009_054335_848326_CD46A45B X-CRM114-Status: GOOD ( 25.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Rothwell , Qian Cai , Catalin Marinas , Linux Kernel Mailing List , Linux Next Mailing List , James Morse , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Qian, On Fri, Oct 09, 2020 at 09:51:15AM +0100, Will Deacon wrote: > On Thu, Oct 08, 2020 at 09:18:24PM -0400, Qian Cai wrote: > > On Mon, 2020-10-05 at 17:43 +0100, Mark Rutland wrote: > > > The current initialization of the per-cpu offset register is difficult > > > to follow and this initialization is not always early enough for > > > upcoming instrumentation with KCSAN, where the instrumentation callbacks > > > use the per-cpu offset. > > > > > > To make it possible to support KCSAN, and to simplify reasoning about > > > early bringup code, let's initialize the per-cpu offset earlier, before > > > we run any C code that may consume it. To do so, this patch adds a new > > > init_this_cpu_offset() helper that's called before the usual > > > primary/secondary start functions. For consistency, this is also used to > > > re-initialize the per-cpu offset after the runtime per-cpu areas have > > > been allocated (which can change CPU0's offset). > > > > > > So that init_this_cpu_offset() isn't subject to any instrumentation that > > > might consume the per-cpu offset, it is marked with noinstr, preventing > > > instrumentation. > > > > > > Signed-off-by: Mark Rutland > > > Cc: Catalin Marinas > > > Cc: James Morse > > > Cc: Will Deacon > > > > Reverting this commit on the top of today's linux-next fixed an issue that > > Thunder X2 is unable to boot: > > > > .config: https://gitlab.com/cailca/linux-mm/-/blob/master/arm64.config Sorry about this. :/ Will, to save you reading all the below, I think the right thing to do for now is to revert this. Building with that config, I see a boot time-hang on the primary CPU under QEMU TCG, with or without VHE (in both cases, a stuck in a recursive synchronous exception). With the patch reverted, the kernel boots. Looking at the assembly, task_cpu() gets instrumented (which puts this patch on dodgy ground generally and I think warrants the revert), but as it's instrumented with KASAN_INLINE that doesn't immediately explain the issue since the shadow should be up and so we shouldn't call the report function. I'll dig into this some more. Assembly dumps below; for init_this_cpu_offset the reference to page_wait_table+0x4d00 is generating the address for __per_cpu_offset, but objdump doesn't have enough info to resolve that nicely. | ffffa00011143bc0 : | ffffa00011143bc0: a9bf7bfd stp x29, x30, [sp, #-16]! | ffffa00011143bc4: d5384100 mrs x0, sp_el0 | ffffa00011143bc8: 910003fd mov x29, sp | ffffa00011143bcc: 97bb29b9 bl ffffa0001000e2b0 | ffffa00011143bd0: f0004ea1 adrp x1, ffffa00011b1a000 | ffffa00011143bd4: 913c6021 add x1, x1, #0xf18 | ffffa00011143bd8: f8605820 ldr x0, [x1, w0, uxtw #3] | ffffa00011143bdc: 97bb29b1 bl ffffa0001000e2a0 | ffffa00011143be0: a8c17bfd ldp x29, x30, [sp], #16 | ffffa00011143be4: d65f03c0 ret | ffffa0001000e2b0 : | ffffa0001000e2b0: a9be7bfd stp x29, x30, [sp, #-32]! | ffffa0001000e2b4: d2d40001 mov x1, #0xa00000000000 // #175921860444160 | ffffa0001000e2b8: f2fbffe1 movk x1, #0xdfff, lsl #48 | ffffa0001000e2bc: 910003fd mov x29, sp | ffffa0001000e2c0: f9000bf3 str x19, [sp, #16] | ffffa0001000e2c4: aa0003f3 mov x19, x0 | ffffa0001000e2c8: 91012000 add x0, x0, #0x48 | ffffa0001000e2cc: 52800062 mov w2, #0x3 // #3 | ffffa0001000e2d0: d343fc03 lsr x3, x0, #3 | ffffa0001000e2d4: 38e16861 ldrsb w1, [x3, x1] | ffffa0001000e2d8: 7100003f cmp w1, #0x0 | ffffa0001000e2dc: 7a411041 ccmp w2, w1, #0x1, ne // ne = any | ffffa0001000e2e0: 540000aa b.ge ffffa0001000e2f4 // b.tcont | ffffa0001000e2e4: b9404a60 ldr w0, [x19, #72] | ffffa0001000e2e8: f9400bf3 ldr x19, [sp, #16] | ffffa0001000e2ec: a8c27bfd ldp x29, x30, [sp], #32 | ffffa0001000e2f0: d65f03c0 ret | ffffa0001000e2f4: 9415af1f bl ffffa00010579f70 <__asan_report_load4_noabort> | ffffa0001000e2f8: 17fffffb b ffffa0001000e2e4 | ffffa0001000e2fc: d503201f nop | ffffa0001000e2a0 : | ffffa0001000e2a0: d518d080 msr tpidr_el1, x0 | ffffa0001000e2a4: d65f03c0 ret | ffffa0001000e2a8: d503201f nop | ffffa0001000e2ac: d503201f nop Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel