Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1176185pxj; Fri, 4 Jun 2021 07:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJgxB1eGg7dM6jLG4IteyewlV2VflsrJzrfv38/diEJv2KCEX9mDXTYC8+Vea7letXdMwt X-Received: by 2002:a17:906:b855:: with SMTP id ga21mr4582392ejb.550.1622818373301; Fri, 04 Jun 2021 07:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622818373; cv=none; d=google.com; s=arc-20160816; b=MnOG7LtcYVQjJYqfdjAsL1WNphKz9XK+eZEuNfsDMW26SgS33bq9weais0JWRIttYo 9eVmScoJYUf/dagosm9LuJ//OYdEq/xY3LYMlOtLlMsYMgubMsO0/5FqSsZbGd6a7z/h LhwOqyGLd7/ade1jza8e/Ga4cTqTOzzYDRwqP5opfkOz0yHRxe17VyahX+v6sri39yrT tyX9dWsH+vg+gnuVLzbNreiP/rytONWqfB8gOXuW7mtIqrECsoypql9HawogBBpb4Fh5 ZFp7FfcYVs0VTz16pPiwJ+rJcc/V8XfBBQDbuA8Tj/9GyYJz2byoyMykKWZonyQWVR9K FzTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=R7JnuaVF32kGUYx364q4uY3q10yGSid6FDEziLNsnkA=; b=sHVVt1AJsCX/K/KrK7lHHoecPQz9B/szvUUDji+eF8NAojMkdT6QzCsLoNpnks/avh 0Iz6G58yQ9uCluL3zl8q5YO8LlfFcZjFiSM4CPkvaEKIf2476mMSvJaHh2I7RSfbCjzp WrLoZdP/YYZFrx6rFcFszbQLAAb4NWHJUHsnsXJLMgqIrb8yzBs3nDb6XX9cSvRmxcB2 JhEvKClDYE8sjBMJAivToYgfc8V5xlOL5xMx8OKXeFEiZYn6B6K3SkbsUXfTJzO9S7ry m/OC1wV4xsZ5lCqxsDFqS8np0ifyVe3cViQoYMOs3FbJUp5+uwuDCtfyRKJ05N6UUDKx Q0gg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di24si1919375edb.509.2021.06.04.07.52.30; Fri, 04 Jun 2021 07:52:53 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbhFDOxX convert rfc822-to-8bit (ORCPT + 99 others); Fri, 4 Jun 2021 10:53:23 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:4308 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbhFDOxX (ORCPT ); Fri, 4 Jun 2021 10:53:23 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FxQZZ31Y7z1BHbD; Fri, 4 Jun 2021 22:46:46 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 4 Jun 2021 22:51:32 +0800 Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 4 Jun 2021 22:51:31 +0800 Received: from lhreml710-chm.china.huawei.com ([169.254.81.184]) by lhreml710-chm.china.huawei.com ([169.254.81.184]) with mapi id 15.01.2176.012; Fri, 4 Jun 2021 15:51:29 +0100 From: Shameerali Kolothum Thodi To: Marc Zyngier CC: "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" , "jean-philippe@linaro.org" , Alexandru Elisei , Linuxarm Subject: RE: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach) Thread-Topic: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach) Thread-Index: AQHXQph5pwodb0a/4kShAMz7Pnc+rqsDq0rQgABREYCAABlY4A== Date: Fri, 4 Jun 2021 14:51:29 +0000 Message-ID: <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> <87sg1xzqea.wl-maz@kernel.org> In-Reply-To: <87sg1xzqea.wl-maz@kernel.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.47.88.52] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, > -----Original Message----- > From: Marc Zyngier [mailto:maz@kernel.org] > Sent: 04 June 2021 14:55 > To: Shameerali Kolothum Thodi > Cc: 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; jean-philippe@linaro.org; Alexandru Elisei > ; Linuxarm > Subject: Re: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd > approach) > > On Fri, 04 Jun 2021 09:13:10 +0100, > Shameerali Kolothum Thodi > wrote: > > > > Hi, > > > > > -----Original Message----- > > > From: Shameerali Kolothum Thodi > > > Sent: 06 May 2021 17:52 > > > To: linux-arm-kernel@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > > > linux-kernel@vger.kernel.org > > > Cc: maz@kernel.org; will@kernel.org; catalin.marinas@arm.com; > > > james.morse@arm.com; julien.thierry.kdev@gmail.com; > > > suzuki.poulose@arm.com; jean-philippe@linaro.org; Linuxarm > > > > > > Subject: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd > > > approach) > > > > > > This is based on a suggestion from Will [0] to try out the asid > > > based kvm vmid solution as a separate VMID allocator instead of > > > the shared lib approach attempted in v4[1]. > > > > > > The idea is to compare both the approaches and see whether the > > > shared lib solution with callbacks make sense or not. > > > > A gentle ping on this. Please take a look and let me know. > > I had a look and I don't overly dislike it. I'd like to see the code > without the pinned stuff though, at least to ease the reviewing. I > haven't tested it in anger, but I have pushed the rebased code at [1] > as it really didn't apply to 5.13-rc4. Thanks for taking a look and the rebase. I will remove the pinned stuff in the next revision as that was added just to compare against the previous version. > > One thing I'm a bit worried about is that we so far relied on VMID 0 > never being allocated to a guest, which is now crucial for protected > KVM. I can't really convince myself that this can never happen with > this. Hmm..not sure I quite follow that. As per the current logic vmid 0 is reserved and is not allocated to Guest. > 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. Thanks, Shameer > > M. > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h > =kvm-arm64/mmu/vmid > > -- > Without deviation from the norm, progress is not possible.