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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id F330EC00144 for ; Fri, 29 Jul 2022 19:28:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5784D4C1AF; Fri, 29 Jul 2022 15:28:21 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@linux.dev 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 UUL3j4FRDq26; Fri, 29 Jul 2022 15:28:19 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B941A4C18F; Fri, 29 Jul 2022 15:28:19 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EAD2E4C18F for ; Fri, 29 Jul 2022 15:28:18 -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 GftFzQpfYDyx for ; Fri, 29 Jul 2022 15:28:17 -0400 (EDT) Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 703F24C029 for ; Fri, 29 Jul 2022 15:28:17 -0400 (EDT) Date: Fri, 29 Jul 2022 19:28:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1659122895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hGAAQQims/x+aVkjeXh2pO3zuX49eGIs7h2PdGd4m9k=; b=rQXuzbUlhy1H2pl2MLh/fFzXumhLDJ1JmxPLp9XsRjxgk5EM2up8wOI94Wy6GEXKWBDCOu uqX9RQF/oULzk6hI2zFHjlgwyY+Yl6wrh35P6gVDjBNPYihBnycuHu99Gdw2aX1LmHSHiE Q6O8rTbFdMTQpb4uya6GSPgXVbjxsEA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Subject: Re: [PATCH v2 06/24] KVM: arm64: Unify identifiers used to distinguish host and hypervisor Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-7-will@kernel.org> <20220720181406.GA16603@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220720181406.GA16603@willie-the-truck> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Cc: Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Michael Roth , Catalin Marinas , Chao Peng , kvmarm@lists.cs.columbia.edu 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 Hi Will, Sorry, I didn't see your reply til now. On Wed, Jul 20, 2022 at 07:14:07PM +0100, Will Deacon wrote: > Hi Oliver, > > Thanks for having a look. > > On Wed, Jul 20, 2022 at 03:11:04PM +0000, Oliver Upton wrote: > > On Thu, Jun 30, 2022 at 02:57:29PM +0100, Will Deacon wrote: > > > The 'pkvm_component_id' enum type provides constants to refer to the > > > host and the hypervisor, yet this information is duplicated by the > > > 'pkvm_hyp_id' constant. > > > > > > Remove the definition of 'pkvm_hyp_id' and move the 'pkvm_component_id' > > > type definition to 'mem_protect.h' so that it can be used outside of > > > the memory protection code. > > > > > > Signed-off-by: Will Deacon > > > --- > > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 6 +++++- > > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 8 -------- > > > arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- > > > 3 files changed, 6 insertions(+), 10 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > index 80e99836eac7..f5705a1e972f 100644 > > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > @@ -51,7 +51,11 @@ struct host_kvm { > > > }; > > > extern struct host_kvm host_kvm; > > > > > > -extern const u8 pkvm_hyp_id; > > > +/* This corresponds to page-table locking order */ > > > +enum pkvm_component_id { > > > + PKVM_ID_HOST, > > > + PKVM_ID_HYP, > > > +}; > > > > Since we have the concept of PTE ownership in pgtable.c, WDYT about > > moving the owner ID enumeration there? KVM_MAX_OWNER_ID should be > > incorporated in the enum too. > > Interesting idea... I think we need the definition in a header file so that > it can be used by mem_protect.c, so I'm not entirely sure where you'd like > to see it moved. > > The main worry I have is that if we ever need to distinguish e.g. one guest > instance from another, which is likely needed for sharing of memory > between more than just two components, then the pgtable code really cares > about the number of instances ("which guest is it?") whilst the mem_protect > cares about the component type ("is it a guest?"). > > Finally, the pgtable code is also used outside of pKVM so, although the > concept of ownership doesn't yet apply elsewhere, keeping the concept > available without dictacting the different types of owners makes sense to > me. Sorry, it was a silly suggestion to wedge the enum there. I don't think it matters too much where it winds up, but something like: enum kvm_pgtable_owner_id { OWNER_ID_PKVM_HOST, OWNER_ID_PKVM_HYP, NR_PGTABLE_OWNER_IDS, } And put it somewhere that both pgtable.c and mem_protect.c can get at it. That way bound checks (like in kvm_pgtable_stage2_set_owner()) organically work as new IDs are added. -- Thanks, Oliver _______________________________________________ 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2B029C00144 for ; Fri, 29 Jul 2022 19:29:30 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=UhZO3rU5D1Dc1g4bcrrXNBQSWb8TKHYkxHgLwk8/m2A=; b=QwwHpEVwvNzK4r 1Znll4x309ix8E02oZp3l29mFlcRz8v3NrESzFo93oRucfISMeFCzGW8QmTk1KU18JSjI4wmP/9K8 G0MfXt+VZI305Vr+NxzsQiq7bULeBsIDo/1C8Hg/6FkJFDg1KRkR8242ru4icm8fLyV9Yq1oA8aL7 P5b/OArK9eHWDsp5Dzb/mhNG49bKWBxetPzaVfnvE5qNeIylORPgiYvriacEwvyVPwqzAh7RMQz4G 4vp4UZ/Kz8/froE9rWHhxDavg3WExuPWZYpmE4CX8CVimKb+QOjiZQfMpBKqkjcyGzDoOvbCmWx1I buu223ueIGIobQcxqNfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHVes-00BUjr-QQ; Fri, 29 Jul 2022 19:28:26 +0000 Received: from out1.migadu.com ([2001:41d0:2:863f::]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHVeo-00BUf7-1G for linux-arm-kernel@lists.infradead.org; Fri, 29 Jul 2022 19:28:24 +0000 Date: Fri, 29 Jul 2022 19:28:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1659122895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hGAAQQims/x+aVkjeXh2pO3zuX49eGIs7h2PdGd4m9k=; b=rQXuzbUlhy1H2pl2MLh/fFzXumhLDJ1JmxPLp9XsRjxgk5EM2up8wOI94Wy6GEXKWBDCOu uqX9RQF/oULzk6hI2zFHjlgwyY+Yl6wrh35P6gVDjBNPYihBnycuHu99Gdw2aX1LmHSHiE Q6O8rTbFdMTQpb4uya6GSPgXVbjxsEA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Sean Christopherson , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 06/24] KVM: arm64: Unify identifiers used to distinguish host and hypervisor Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-7-will@kernel.org> <20220720181406.GA16603@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220720181406.GA16603@willie-the-truck> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220729_122823_053228_C9AFDB8E X-CRM114-Status: GOOD ( 29.12 ) 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 Hi Will, Sorry, I didn't see your reply til now. On Wed, Jul 20, 2022 at 07:14:07PM +0100, Will Deacon wrote: > Hi Oliver, > > Thanks for having a look. > > On Wed, Jul 20, 2022 at 03:11:04PM +0000, Oliver Upton wrote: > > On Thu, Jun 30, 2022 at 02:57:29PM +0100, Will Deacon wrote: > > > The 'pkvm_component_id' enum type provides constants to refer to the > > > host and the hypervisor, yet this information is duplicated by the > > > 'pkvm_hyp_id' constant. > > > > > > Remove the definition of 'pkvm_hyp_id' and move the 'pkvm_component_id' > > > type definition to 'mem_protect.h' so that it can be used outside of > > > the memory protection code. > > > > > > Signed-off-by: Will Deacon > > > --- > > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 6 +++++- > > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 8 -------- > > > arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- > > > 3 files changed, 6 insertions(+), 10 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > index 80e99836eac7..f5705a1e972f 100644 > > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > @@ -51,7 +51,11 @@ struct host_kvm { > > > }; > > > extern struct host_kvm host_kvm; > > > > > > -extern const u8 pkvm_hyp_id; > > > +/* This corresponds to page-table locking order */ > > > +enum pkvm_component_id { > > > + PKVM_ID_HOST, > > > + PKVM_ID_HYP, > > > +}; > > > > Since we have the concept of PTE ownership in pgtable.c, WDYT about > > moving the owner ID enumeration there? KVM_MAX_OWNER_ID should be > > incorporated in the enum too. > > Interesting idea... I think we need the definition in a header file so that > it can be used by mem_protect.c, so I'm not entirely sure where you'd like > to see it moved. > > The main worry I have is that if we ever need to distinguish e.g. one guest > instance from another, which is likely needed for sharing of memory > between more than just two components, then the pgtable code really cares > about the number of instances ("which guest is it?") whilst the mem_protect > cares about the component type ("is it a guest?"). > > Finally, the pgtable code is also used outside of pKVM so, although the > concept of ownership doesn't yet apply elsewhere, keeping the concept > available without dictacting the different types of owners makes sense to > me. Sorry, it was a silly suggestion to wedge the enum there. I don't think it matters too much where it winds up, but something like: enum kvm_pgtable_owner_id { OWNER_ID_PKVM_HOST, OWNER_ID_PKVM_HYP, NR_PGTABLE_OWNER_IDS, } And put it somewhere that both pgtable.c and mem_protect.c can get at it. That way bound checks (like in kvm_pgtable_stage2_set_owner()) organically work as new IDs are added. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 783BBC19F2A for ; Fri, 29 Jul 2022 19:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238184AbiG2T2V (ORCPT ); Fri, 29 Jul 2022 15:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiG2T2U (ORCPT ); Fri, 29 Jul 2022 15:28:20 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA705C362 for ; Fri, 29 Jul 2022 12:28:18 -0700 (PDT) Date: Fri, 29 Jul 2022 19:28:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1659122895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hGAAQQims/x+aVkjeXh2pO3zuX49eGIs7h2PdGd4m9k=; b=rQXuzbUlhy1H2pl2MLh/fFzXumhLDJ1JmxPLp9XsRjxgk5EM2up8wOI94Wy6GEXKWBDCOu uqX9RQF/oULzk6hI2zFHjlgwyY+Yl6wrh35P6gVDjBNPYihBnycuHu99Gdw2aX1LmHSHiE Q6O8rTbFdMTQpb4uya6GSPgXVbjxsEA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Sean Christopherson , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 06/24] KVM: arm64: Unify identifiers used to distinguish host and hypervisor Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-7-will@kernel.org> <20220720181406.GA16603@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220720181406.GA16603@willie-the-truck> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Will, Sorry, I didn't see your reply til now. On Wed, Jul 20, 2022 at 07:14:07PM +0100, Will Deacon wrote: > Hi Oliver, > > Thanks for having a look. > > On Wed, Jul 20, 2022 at 03:11:04PM +0000, Oliver Upton wrote: > > On Thu, Jun 30, 2022 at 02:57:29PM +0100, Will Deacon wrote: > > > The 'pkvm_component_id' enum type provides constants to refer to the > > > host and the hypervisor, yet this information is duplicated by the > > > 'pkvm_hyp_id' constant. > > > > > > Remove the definition of 'pkvm_hyp_id' and move the 'pkvm_component_id' > > > type definition to 'mem_protect.h' so that it can be used outside of > > > the memory protection code. > > > > > > Signed-off-by: Will Deacon > > > --- > > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 6 +++++- > > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 8 -------- > > > arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- > > > 3 files changed, 6 insertions(+), 10 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > index 80e99836eac7..f5705a1e972f 100644 > > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > > @@ -51,7 +51,11 @@ struct host_kvm { > > > }; > > > extern struct host_kvm host_kvm; > > > > > > -extern const u8 pkvm_hyp_id; > > > +/* This corresponds to page-table locking order */ > > > +enum pkvm_component_id { > > > + PKVM_ID_HOST, > > > + PKVM_ID_HYP, > > > +}; > > > > Since we have the concept of PTE ownership in pgtable.c, WDYT about > > moving the owner ID enumeration there? KVM_MAX_OWNER_ID should be > > incorporated in the enum too. > > Interesting idea... I think we need the definition in a header file so that > it can be used by mem_protect.c, so I'm not entirely sure where you'd like > to see it moved. > > The main worry I have is that if we ever need to distinguish e.g. one guest > instance from another, which is likely needed for sharing of memory > between more than just two components, then the pgtable code really cares > about the number of instances ("which guest is it?") whilst the mem_protect > cares about the component type ("is it a guest?"). > > Finally, the pgtable code is also used outside of pKVM so, although the > concept of ownership doesn't yet apply elsewhere, keeping the concept > available without dictacting the different types of owners makes sense to > me. Sorry, it was a silly suggestion to wedge the enum there. I don't think it matters too much where it winds up, but something like: enum kvm_pgtable_owner_id { OWNER_ID_PKVM_HOST, OWNER_ID_PKVM_HYP, NR_PGTABLE_OWNER_IDS, } And put it somewhere that both pgtable.c and mem_protect.c can get at it. That way bound checks (like in kvm_pgtable_stage2_set_owner()) organically work as new IDs are added. -- Thanks, Oliver