From owner-svn-src-projects@freebsd.org Thu Oct 11 21:09:41 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB37010C7F93 for ; Thu, 11 Oct 2018 21:09:41 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4549B825E7; Thu, 11 Oct 2018 21:09:41 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: by mail-yb1-xb34.google.com with SMTP id p74-v6so4164772ybc.9; Thu, 11 Oct 2018 14:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QHylVfpsL33O4AkSTcwomLmbAmAvbzAeBbZQSyKDaew=; b=QqNSxrizXrjKu/gufMwgHGT6EiUVzvxeJkfUvxWqlGo6j7utO1EGIQ8zY7hmtmXZJN twgG7SmUIhv23IrPWezpFYqDnaGd9RXUMMRdcQbDTTAX9OxRKQjfZHC3Sr7fw0B2WQOz yVhpxdFNrt+xnH1EVMrb5qYuh0cKub3iAJzWViI7NKrU2oVnl9j9PlnOvX8OXw9hoxR7 3uTjMsJdYIw8n7RpVTKeoBz1Ln+A8fSGv0HInp0RzUOzD/do5BdNJF02/X3ondPCmtPQ ffegbE1lCVfo1+M3ki7mJNFO2b2IFcA/gEYk2xeOsKrz8hdO0xegmctz0LU2DkGb7mhf bt3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QHylVfpsL33O4AkSTcwomLmbAmAvbzAeBbZQSyKDaew=; b=drLoYjumLeZbcRDHnIhGttyLuUaVZ5IKW38yCPpZ/9MXbmP9DN7ZGJIPnhCPcsQ/VL 6htOuNeoQCoCEhHns9/2oUbaTSn0wAhQjhawprBca4LBM+IzvN9bOojq22HBPl/XUuFo jt3cnsGg1ZQytoK3Hji1ZW6lz866aY2Sd2zaDf0ChHzwD+gpansoDToZTMfwsRgn0H9J vGHh5meSsvw4Yzp1tK9bimBgQMz9arNu3NqLYrva4vkB66q6q7pt5TaxG6WMTahcmNYr evuULdwABce4cay1R9dgU+8fT1txUpAsEEfHWJc9K6dentGGzM/eucJjHkBv1LcryA9g o0QQ== X-Gm-Message-State: ABuFfoiXC9oNYIf4BhPLuoiTpShoCnWNq2hQK5gpS3apVQVuHRsHh5Pp Cccee03M3fWeGJD901Y8CJ5ZHP4Bfgtx9lBDLm0= X-Google-Smtp-Source: ACcGV61LqpzAdCJ9Nh9mf5pssvTAIjTwpyp9XQRWt6tJ3MKgHyUCX1gMvuxFzJ74hdXlV3CtR/ibGWJJkwVUysgJa5A= X-Received: by 2002:a25:54d:: with SMTP id 74-v6mr1778369ybf.350.1539292180528; Thu, 11 Oct 2018 14:09:40 -0700 (PDT) MIME-Version: 1.0 References: <201810111918.w9BJI6Ak067450@repo.freebsd.org> <20181011150805.7234d85c@ralga.knownspace> In-Reply-To: <20181011150805.7234d85c@ralga.knownspace> From: Leandro Date: Thu, 11 Oct 2018 18:09:29 -0300 Message-ID: Subject: Re: svn commit: r339316 - projects/power8_bringup_hacks/sys/powerpc/powerpc To: Justin Hibbits Cc: luporl@freebsd.org, src-committers@freebsd.org, svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2018 21:09:41 -0000 Ok, I'm done for today, but I'll get back to it on Monday. > At first I thought it was a fairly innocuous change, because "nothing" could be doing a PCPU_GET() for pcpu[0], right? Yes, there are some combinations of platforms/OFW where SPRG0 gets initialized before cpu_pcpu_init() being called, but that was not the case for POWER8/PowerNV/FDT. > So, with this change you're making a memcpy() overwrite itself (which, I hope, is a real nop in code?). Yes, with this change memcpy() is overwriting the same data, that doesn't make much sense and may not end up being turned into a nop in code (need to check that). The problem is that I'm not sure if removing this memcpy() won't break some other combo. Do you have any suggestion to detect this case and skip the copy? For a local POWER8 machine that I have access, this was causing kexec to hang most times. So my basic debug strategy was to place debug prints (with OPAL for early ones), flush them and check how far the boot would go before the machine hanged. Later I can give you more details on IRC if you are interested :) - Leandro On Thu, Oct 11, 2018 at 5:08 PM Justin Hibbits wrote: > On Thu, 11 Oct 2018 19:18:06 +0000 (UTC) > Leandro Lupori wrote: > > > Author: luporl > > Date: Thu Oct 11 19:18:06 2018 > > New Revision: 339316 > > URL: https://svnweb.freebsd.org/changeset/base/339316 > > > > Log: > > Initialize SPRG0 before its first possible use. > > > > Modified: > > projects/power8_bringup_hacks/sys/powerpc/powerpc/machdep.c > > > > Modified: projects/power8_bringup_hacks/sys/powerpc/powerpc/machdep.c > > > ============================================================================== > > --- > > projects/power8_bringup_hacks/sys/powerpc/powerpc/machdep.c > > Thu Oct 11 19:06:54 2018 (r339315) +++ > > projects/power8_bringup_hacks/sys/powerpc/powerpc/machdep.c > > Thu Oct 11 19:18:06 2018 (r339316) @@ -383,12 +383,12 @@ > > powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs if > > (platform_smp_get_bsp(&bsp) != 0) bsp.cr_cpuid = 0; pc = > > &__pcpu[bsp.cr_cpuid]; > > + __asm __volatile("mtsprg 0, %0" :: "r"(pc)); > > pcpu_init(pc, bsp.cr_cpuid, sizeof(struct pcpu)); > > pc->pc_curthread = &thread0; > > thread0.td_oncpu = bsp.cr_cpuid; > > pc->pc_cpuid = bsp.cr_cpuid; > > pc->pc_hwref = bsp.cr_hwref; > > - __asm __volatile("mtsprg 0, %0" :: "r"(pc)); > > > > /* > > * Init KDB > > > > Wow, that's quite some sleuthing! > > Consider this approved by me, and email re@ to get it into head. Then > hop on IRC and give me the play-by-play on how you figured it out. I'm > really curious! > > At first I thought it was a fairly innocuous change, because "nothing" > could be doing a PCPU_GET() for pcpu[0], right? Then I saw AIM's > cpu_pcpu_init() doing a memcpy() from PCPU_GET(aim.slb). So, with this > change you're making a memcpy() overwrite itself (which, I hope, is a > real nop in code?). > > - Justin >