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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 DDFEAC35DE1 for ; Tue, 25 Feb 2020 12:14:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9FC612084E for ; Tue, 25 Feb 2020 12:14:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MamjHYPY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aD+1nN5p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FC612084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.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=kedtJ14PJD+i5VO45lCZ5fe56g6qPELP7J256cxRtEE=; b=MamjHYPYF6NBkr IiBR+QYoycGSck2pF90xeHNXVqvwHkF/L1a2ZcNXVwPPEj76JiJSAsj4xv7DgPT/eO9tNIEMuuQJZ 7EWreS0JzPycQHe4kjb9FX66woDjkdlcgJ5lfBHxRpiJKfAu7erpWslZXN833hcmp/xYCDOfE25+d HkUOrbMKU/sr7+NIL7wiD99a47XiVcGsWt9ekXXhSznu02VFnTzufP7mq/u69aOcvoTk2z+hZTTJA isEys8nUG/QilgzeMUz3bE3g0S6p5XfmV/WratA8/mvkUnxAap41ns/1sSOsuy/7bpx5+KwEx2gyN 2fNGczCJLPDaO3VE960Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6Z69-00020f-Bf; Tue, 25 Feb 2020 12:14:01 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6Z64-00020G-9d for linux-arm-kernel@lists.infradead.org; Tue, 25 Feb 2020 12:14:00 +0000 Received: by mail-wr1-x441.google.com with SMTP id m16so14417053wrx.11 for ; Tue, 25 Feb 2020 04:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AVLS/LrGHwk8wOwGNZCE7HvyLw1lIGzfVxUbWhQxfBA=; b=aD+1nN5pODywESWQ6w2iuZuBmNImud/aDyubWHCBsbJUHtoVi93C9xqFgVAYNA+7DL YtKZpJWM2+TV3fOYxSQfjhYkHBQvRy9Egc8pyuws3MJkAdqMLmegWMTkpcbPNIhwgXFq tOVe7co9Jo2iVP85rXDl90KKbnUseqwLeEsK1G1y0b0hkc9dofd3puhFSVZLN+T518dg zU/qbywke1KclvEkxuHzjWl7epdqosUYxRQEtafJx8kM8zyTU7DjNFfH09Ow+DTPMOUv 64Pl8a+JIwQL4kGwdjg+kcHFo0Ij9zJLNDpbH2yE/WX+zQ54KnNjo1boXHoxMU5uPopo o73A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AVLS/LrGHwk8wOwGNZCE7HvyLw1lIGzfVxUbWhQxfBA=; b=VLyiYmaXgYU7EEF560lgkQiml1UY9UXpKENqM0KZoo3gGzxtWZRY0Y8iuyijjC2EDp jK15gZFv80uOsbzRfIdZxNdwXtHU+U2V4tuJeAPcSOUIlfc65XtzBHz2EqWH9QWq7ZO5 pUe/D//BPo0yfXfCQUjnAze9ODFjqd3K9jP0phtWvKH6X1x+RltxJZoVbOPJeqd44djN x8vxUuVxF4mFJIanbBb5POlRRa7XRYW4WPE+tdzyfDgHatu1fUTwW9X0lk66ACXt+v3x LlPXCAkeMaMCkS6lbaN6rmPgWih4A4lSmKRfFMBTVw/DmzmDqmsqIFqOpc6lZabOnB1c RQxg== X-Gm-Message-State: APjAAAX3+YUjJNpwx2j/V0D+83ypAYEox1e03ZWAznx3J3swFk7TbyuV RGKmxfJg+cvJbaLwqVsypIBWPQ== X-Google-Smtp-Source: APXvYqz5mF5185mtwL8kWbLIWmYs9AaHhjQli7yMxC+xYc6a1NT0z9QZvBXomlPnQDu2PasPTt9p+Q== X-Received: by 2002:adf:e546:: with SMTP id z6mr767400wrm.423.1582632830989; Tue, 25 Feb 2020 04:13:50 -0800 (PST) Received: from myrica ([2001:171b:c9a8:fbc0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id e11sm13067744wrm.80.2020.02.25.04.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 04:13:50 -0800 (PST) Date: Tue, 25 Feb 2020 13:13:43 +0100 From: Jean-Philippe Brucker To: Vladimir Murzin Subject: Re: [PATCH] arm64: context: Fix ASID limit in boot warning Message-ID: <20200225121343.GD375953@myrica> References: <20200224103934.137314-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200225_041356_359998_68D72074 X-CRM114-Status: GOOD ( 16.09 ) 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: catalin.marinas@arm.com, will@kernel.org, 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+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Vladimir, On Mon, Feb 24, 2020 at 11:06:43AM +0000, Vladimir Murzin wrote: > > static int asids_init(void) > > { > > + unsigned long num_available_asids; > > + bool kpti = IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0); > > + > > asid_bits = get_cpu_asid_bits(); > > /* > > * Expect allocation after rollover to fail if we don't have at least > > * one more ASID than CPUs. ASID #0 is reserved for init_mm. > > */ > > - WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus()); > > + num_available_asids = (1UL << (asid_bits - kpti)) - 1; > > + WARN_ON(num_available_asids <= num_possible_cpus()); > > atomic64_set(&asid_generation, ASID_FIRST_VERSION); > > asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map), > > GFP_KERNEL); > > @@ -280,7 +284,7 @@ static int asids_init(void) > > * caps are not finalized yet, so it is safer to assume KPTI > > * and reserve kernel ASID's from beginning. > > */ > > - if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) > > + if (kpti) > > set_kpti_asid_bits(); > > > > pr_info("ASID allocator initialised with %lu entries\n", NUM_USER_ASIDS); > > > > I agree with what you say about NUM_USER_ASIDS, yet looking at comment explaining > warning is seems that we may get extra ASIDs later on rollover, so warning might be > seen as false positive. Can we move the warning later on when we know how many ASIDs > we have after all CPU's are up? Yes I think that's better. I've stumbled upon the issue when reworking my ASID-pin patch [1], which will also need a precise maximum number of ASIDs available. > Maybe late_initcall? I guess arch_initcall might be more appropriate. Any init level except early should work since they are after smp_init(). Thanks, Jean [1] https://lore.kernel.org/linux-iommu/20200224182401.353359-8-jean-philippe@linaro.org/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel