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=-4.0 required=3.0 tests=BAYES_00,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 D4128C07E94 for ; Fri, 4 Jun 2021 15:27:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B928E61405 for ; Fri, 4 Jun 2021 15:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbhFDP33 (ORCPT ); Fri, 4 Jun 2021 11:29:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbhFDP32 (ORCPT ); Fri, 4 Jun 2021 11:29:28 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1852361400; Fri, 4 Jun 2021 15:27:42 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lpBjY-005VVs-2h; Fri, 04 Jun 2021 16:27:40 +0100 Date: Fri, 04 Jun 2021 16:27:39 +0100 Message-ID: <87lf7ptztg.wl-maz@kernel.org> From: Marc Zyngier 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) In-Reply-To: <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> <87sg1xzqea.wl-maz@kernel.org> <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: shameerali.kolothum.thodi@huawei.com, 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@arm.com, linuxarm@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 04 Jun 2021 15:51:29 +0100, Shameerali Kolothum Thodi wrote: > > 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. And that's the bit I'm struggling to validate here. I guess it works because cur_idx is set to 1 in new_vmid(). > > > 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? Thanks, M. -- Without deviation from the norm, progress is not possible. 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=-4.0 required=3.0 tests=BAYES_00,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 F00F0C07E94 for ; Fri, 4 Jun 2021 15:27:54 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 6F67161402 for ; Fri, 4 Jun 2021 15:27:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F67161402 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C82A34B0FE; Fri, 4 Jun 2021 11:27:53 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wNBOKPRdXQnF; Fri, 4 Jun 2021 11:27:48 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AA8644B0FA; Fri, 4 Jun 2021 11:27:48 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B567D4B0EE for ; Fri, 4 Jun 2021 11:27:47 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PIbcQl6Vvv5M for ; Fri, 4 Jun 2021 11:27:43 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 4CB0C4B0EC for ; Fri, 4 Jun 2021 11:27:43 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1852361400; Fri, 4 Jun 2021 15:27:42 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lpBjY-005VVs-2h; Fri, 04 Jun 2021 16:27:40 +0100 Date: Fri, 04 Jun 2021 16:27:39 +0100 Message-ID: <87lf7ptztg.wl-maz@kernel.org> From: Marc Zyngier To: Shameerali Kolothum Thodi Subject: Re: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach) In-Reply-To: <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> <87sg1xzqea.wl-maz@kernel.org> <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: shameerali.kolothum.thodi@huawei.com, 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@arm.com, linuxarm@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: "jean-philippe@linaro.org" , "catalin.marinas@arm.com" , "linux-kernel@vger.kernel.org" , Linuxarm , "will@kernel.org" , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Fri, 04 Jun 2021 15:51:29 +0100, Shameerali Kolothum Thodi wrote: > > 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. And that's the bit I'm struggling to validate here. I guess it works because cur_idx is set to 1 in new_vmid(). > > > 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? Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 8E36AC07E94 for ; Fri, 4 Jun 2021 15:29:50 +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 5924861400 for ; Fri, 4 Jun 2021 15:29:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5924861400 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e+GGZg/keBpHzPHS6bMZB5fSkkmFIYr41WSHZv+c8d4=; b=LEypPcQ7v+6ask Xlfj94voyvz251SbeRaaVnYMzokewbNWxf4jCMDQPhpzxpTKkt8MFU96XdWDenzjTGjsgEJ224a5U FYhit5QQNeURNkXzvn2//nGDBRMidgPEDY4HBH1ehdUGM8YYcjuRll2vI0xdtobqRO84/+LCGoCzo DGbIemhWcjfPGzfE5+q8vU0kNdzJZTohxXir3NaEdrDhvCicXnvMoDmsWUWnf9WqguasOodkENC+F 7SiolQT2SNEBXtuwMMcsksS/XVlCauSqADYDEpdikTeYPi8A6PkWm3XQScHIGRv3ypQZD/Mx0Wgek CRmWQVzBCB5Ef0v6aWGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpBjm-00EA1n-Ei; Fri, 04 Jun 2021 15:27:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpBjc-00E9zk-HF for linux-arm-kernel@lists.infradead.org; Fri, 04 Jun 2021 15:27:46 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1852361400; Fri, 4 Jun 2021 15:27:42 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lpBjY-005VVs-2h; Fri, 04 Jun 2021 16:27:40 +0100 Date: Fri, 04 Jun 2021 16:27:39 +0100 Message-ID: <87lf7ptztg.wl-maz@kernel.org> From: Marc Zyngier 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) In-Reply-To: <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> <87sg1xzqea.wl-maz@kernel.org> <95bb84ffdb0f4db3b64b38cc3b651f90@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: shameerali.kolothum.thodi@huawei.com, 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@arm.com, linuxarm@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210604_082744_647539_8DF79717 X-CRM114-Status: GOOD ( 41.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 04 Jun 2021 15:51:29 +0100, Shameerali Kolothum Thodi wrote: > > 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. And that's the bit I'm struggling to validate here. I guess it works because cur_idx is set to 1 in new_vmid(). > > > 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? Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel