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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17C17C433F5 for ; Thu, 30 Sep 2021 11:59:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 665ED619F6 for ; Thu, 30 Sep 2021 11:59:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 665ED619F6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C4E5A94009D; Thu, 30 Sep 2021 07:59:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFD1B94003A; Thu, 30 Sep 2021 07:59:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC4AB94009D; Thu, 30 Sep 2021 07:59:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id 9AA4194003A for ; Thu, 30 Sep 2021 07:59:47 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 53ECB18411DCC for ; Thu, 30 Sep 2021 11:59:47 +0000 (UTC) X-FDA: 78644095614.32.853832B Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf13.hostedemail.com (Postfix) with ESMTP id E8BC91035429 for ; Thu, 30 Sep 2021 11:59:46 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id u18so24214977lfd.12 for ; Thu, 30 Sep 2021 04:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2urBgTbrDy1NbbFIzmr42ZFWl2s0KjeYzYyD5qhFrc4=; b=SeSsmgknghflT8KgWVilE0n1nVMjlidLm1JbPThgKYs00o83ve/58usCMiT1UJQiup TsViclsHEIjqkC02jlO4Fo9xh+Fon2nEPRsMqXTMUqDnbSOkeAzOWaIc2wuBnh4m4ZfW KTP0wXqe3cmarbNmH49O18Ib5hhePs2ARiuRzFWZvsP9ROZ0Y7JJIBlLWmG7OeWL0lzi atncENt5GodChMDXdPDp72rG2m4iaBygNIhXmMUFovdkQilKaLJSgy03GdNRKEV81j+C ZImf3vJa+omBvJeJRXFt0TRoQATw4nSvpUwPpupS6LofrSN9Jn9xO6hBhstGTXx0uqv/ ev0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2urBgTbrDy1NbbFIzmr42ZFWl2s0KjeYzYyD5qhFrc4=; b=yVXXCTKhtVgKU7i8rJScmezhDVMVyYfNxk5k9j2jOMF7huFx5qKRTfHft+2rhzx1ep d3taqETLHfKxRY4aMOWvpAVjHX9lqh3WZ8FvThtuc/Ei6rBpLlbBnmsqFvIxmIY7u0mA uKCgx2+KQeWxjwl9AcgfmZq+u5q/exDFhRurJbTWwe0uGesJ1qtJwt1e5ZzTgS72ax8Q M3XKpRkZUC6lw6wrW/YYEUN/e8TFEedqNabVAJQ4Qci3ws4SaxGNCDzvFc5ya0xfaT/t EQ1g3zpH8uSuiM56qOCNNboiaUqSc64y6P5B0vt56xXZ6CC2my0WCcZlxIGsoMONCjD/ liGg== X-Gm-Message-State: AOAM530Aw50tmqrKG3YetVhabvfGiYDh6uJ8SaLYzq00wNUSUpdYV4C2 mGZ4gHFt10BQdM1k/POhon4wcnnSeyysCDnmPDvzGg== X-Google-Smtp-Source: ABdhPJyOP0kOtwctz7szw16nkMPbZtUhsv6sIPeLPUqE+gW3MWhUQlbAU8CxYiYfN/IQGftPTZtDeD5NUdWLxalmNIY= X-Received: by 2002:a2e:160f:: with SMTP id w15mr5467653ljd.355.1633003185058; Thu, 30 Sep 2021 04:59:45 -0700 (PDT) MIME-Version: 1.0 References: <20210916231325.125533-1-pasha.tatashin@soleen.com> <20210916231325.125533-9-pasha.tatashin@soleen.com> <20210929123513.GC21631@willie-the-truck> <20210930081607.GA23250@willie-the-truck> In-Reply-To: <20210930081607.GA23250@willie-the-truck> From: Pasha Tatashin Date: Thu, 30 Sep 2021 07:59:07 -0400 Message-ID: Subject: Re: [PATCH v17 08/15] arm64: kexec: configure EL2 vectors for kexec To: Will Deacon Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Linux ARM , Marc Zyngier , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E8BC91035429 X-Stat-Signature: rpe3rjgxfwgb1yk8rw4b6fu8awggcau8 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=SeSsmgkn; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.167.44 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-HE-Tag: 1633003186-559902 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 30, 2021 at 4:16 AM Will Deacon wrote: > > On Wed, Sep 29, 2021 at 11:54:55PM -0400, Pasha Tatashin wrote: > > > > +/* Allocates pages for kexec page table */ > > > > +static void *kexec_page_alloc(void *arg) > > > > +{ > > > > + struct kimage *kimage = (struct kimage *)arg; > > > > + struct page *page = kimage_alloc_control_pages(kimage, 0); > > > > + > > > > + if (!page) > > > > + return NULL; > > > > + > > > > + memset(page_address(page), 0, PAGE_SIZE); > > > > > > Hmm, I think we might be missing barriers here to ensure that the zeroes > > > are visible to the page-table walker before we plumb the page into the > > > page-table. > > > > > > Usually, that's taken care of by the smp_wmb() in __pXX_alloc() but I > > > can't see that here. Is it hiding? > > > > Based on the comment in __pte_alloc() that smp_wmb() is needed in > > order to synchronize pte setup with other cpus prior to making it > > visible to them. This is not needed here. First, by the time these > > page tables are used the other cpus are offlined (kexec reboot code is > > single threaded). Second, we never insert any entry into a page table > > that is actively used by any cpu. > > I think the comment there is wrong, but the barrier is still necessary. > How else do you guarantee that the page-table walker reads the zeroes from > the memset? True, good point. We are still safe because we have the following: cpu_install_ttbr0() is used to load trans_pgd tables both in kexec and hibernate cases. cpu_install_ttbr0 has: local_flush_tlb_all() dsb(nshst); // Ensure prior page-table updates have completed __tlbi(vmalle1); // Invalidate the TLB dsb(nsh); // Ensure the TLB invalidation has completed isb(); // Discard any instructions fetched from the old mapping Pasha