Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3089963pxj; Mon, 7 Jun 2021 01:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOjAgxaNO1wwR4kqFUOuBQkaHTiSxkBpq3A90tq6iFYMnjrjgDuSSi9FJCW7/JnJtZ+yFX X-Received: by 2002:a17:906:1299:: with SMTP id k25mr16701262ejb.139.1623055964219; Mon, 07 Jun 2021 01:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623055964; cv=none; d=google.com; s=arc-20160816; b=wkywY6v6B66onU2nW6Ix/BjCwi8V1yKUTFu43yvssY7Z6OiD6mAJJPU3BmNaKZ/0iP OX/zyiRmdf9V6oz03hANeu9qL/4sT7nXHwNmkUp5zPttdllg/TvKZcYwXcv1p+ahzvKr 9o/ZOb6tyrSlGLRtkNg35AdCTcA8LxBtPsekZ34rLA3oh+yi+eKb0fAL6Wir4pl6U8s2 x1wTeC7tdNuDgtGahkiP4+oaKLNdSMzg8qKhOZXSljwlPHxZxs+1Ak8kDEB5cGq55r5b jqhqQYlQreXHYC3jFlxzltSSC/lAdiwDE9KSYJHoFak7fX+kCS4QvehJsH9DFSQpML8z oAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R2ZopsQZZdXEYjl6azm31E2MzYfojsymg///Se/cAKM=; b=gcrE9DCwsJ1Kaj4XbSrtNA4n/dZUfMvZfGt53zHtBGjUU3dKlHugpCKrxf1cy6F4Fn /bXCVNynS4TotxTVl9qVUuzHZfe/fOm7lO5lMxKbAv5Z9/bz6c62lOORzHkrwmF3HRnY 0r/GLpzKxMojSDlkJq9rA46DgfmIoFD+75bvk/AbRWJkzaCwCG1C2y/DeyiIL6Q/gF65 oLClVIiq5pydKatdixsC5C3RgFDtdwLD599waCLKKnJuKh8gcDIvuXKydpyUWsxjVVBz 1YfmvzCkUhBSJQ8nPejk6U6PFmbS9Ear7pBpeXeL+w8NoHEdKbED2qDyI5lhJZ2i3Y8k eroA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxBciWEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si12348958edt.160.2021.06.07.01.52.21; Mon, 07 Jun 2021 01:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxBciWEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbhFGIwH (ORCPT + 99 others); Mon, 7 Jun 2021 04:52:07 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]:53119 "EHLO mail-wm1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbhFGIwG (ORCPT ); Mon, 7 Jun 2021 04:52:06 -0400 Received: by mail-wm1-f46.google.com with SMTP id f17so9492469wmf.2 for ; Mon, 07 Jun 2021 01:50:15 -0700 (PDT) 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=R2ZopsQZZdXEYjl6azm31E2MzYfojsymg///Se/cAKM=; b=RxBciWEa0mOrwTDqwBl7XhVt1Z3tGfff3KVAXfjjxbhvucwuitAYpCjW2AiOfmc4hY MW0YwzUHKGA/WeKdlYLraPeOhx4a5uKzxp6v4lLraANt7WimKeIInnK9T/6eWrQjXCT9 WjObcZ+HYZ3Go8GMia3x24cyu5tbYPVgn1JDv/sRYAPZlA5vtodNND9A/q6x8y8UnXk6 SuJuhS9v8M4MwoSC+c+Tx7H+ePDwkcKPvy620Tt8pc5u8pj0IFei8NsOk08p/27eHLhl SoI75OyhpQKO1uzn4yXdmbM/CqtG6q0nD58HzKEwZj7xuk0c/z3vpR8i7Mvpj1PS7VyY r5YA== 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=R2ZopsQZZdXEYjl6azm31E2MzYfojsymg///Se/cAKM=; b=TsLJEUBkOTahCEJ9jNfL1+wRKACI4I7lEz5VAyCknDom0jJJH29TPptmiW57XyY+sB 4mHbO903aBUg1iUrwzpoKmRBEsyIgi9rsrrmRiFmp/j0Ax4j1pGKXb2ufEHe2vGarNE5 xrPazUf5Ln1O7GDlps9Tj8ZYgm9mU5DClssToue1FwtbPbcyRMJOhzxtqOLCA325aSZ+ ZmsImDIs1+2Q4chw8d1l9daazon2tFflGj+seHp412MxuKhD4f4u3QK3mysQ8EQFJWCr 1fC+8frYsmyG6H/YJ/fBDFmrcMiG5ykADg3SvCqK3dYVpVEZEcYjwtm68C7LVIRPlGSd apyw== X-Gm-Message-State: AOAM5306lvFN/WdGvc8nV/PUOEaOwa3+6J1zWf3jJqJtKpqXMlw14JUA ml4YzMyyAs9LaLXrLjI/JnwTXw== X-Received: by 2002:a05:600c:21d1:: with SMTP id x17mr15424695wmj.167.1623055754959; Mon, 07 Jun 2021 01:49:14 -0700 (PDT) Received: from myrica (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id o18sm5415514wrx.59.2021.06.07.01.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 01:49:14 -0700 (PDT) Date: Mon, 7 Jun 2021 10:48:55 +0200 From: Jean-Philippe Brucker To: Marc Zyngier Cc: Shameerali Kolothum Thodi , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "linux-kernel@vger.kernel.org" , "will@kernel.org" , "catalin.marinas@arm.com" , "james.morse@arm.com" , "julien.thierry.kdev@gmail.com" , "suzuki.poulose@arm.com" , Alexandru Elisei , Linuxarm Subject: Re: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach) Message-ID: References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> <87sg1xzqea.wl-maz@kernel.org> <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> <87lf7ptztg.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lf7ptztg.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 04, 2021 at 04:27:39PM +0100, Marc Zyngier wrote: > > > Plus, I've found this nugget: > > > > > > > > max_pinned_vmids = NUM_USER_VMIDS - num_possible_cpus() - 2; > > > > > > > > > What is this "- 2"? My hunch is that it should really be "- 1" as VMID > > > 0 is reserved, and we have no equivalent of KPTI for S2. > > > > I think this is more related to the "pinned vmid" stuff and was borrowed from > > the asid_update_limit() fn in arch/arm64/mm/context.c. But I missed the > > comment that explains the reason behind it. It says, > > > > ---x--- > > /* > > * There must always be an ASID available after rollover. Ensure that, > > * even if all CPUs have a reserved ASID and the maximum number of ASIDs > > * are pinned, there still is at least one empty slot in the ASID map. > > */ > > max_pinned_asids = num_available_asids - num_possible_cpus() - 2; > > ---x--- > > > > So this is to make sure we will have at least one VMID available > > after rollover in case we have pinned the max number of VMIDs. I > > will include that comment to make it clear. > > That doesn't really explain the -2. Or is that that we have one for > the extra empty slot, and one for the reserved? > > Jean-Philippe? Yes, -2 is for ASID#0 and the extra empty slot. A comment higher in asids_update_limit() hints at that, but it could definitely be clearer /* * 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. */ Thanks, Jean