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 12A03C433F5 for ; Fri, 25 Feb 2022 13:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240150AbiBYNp6 (ORCPT ); Fri, 25 Feb 2022 08:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbiBYNp4 (ORCPT ); Fri, 25 Feb 2022 08:45:56 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 96FF0210D74 for ; Fri, 25 Feb 2022 05:45:24 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B8D6106F; Fri, 25 Feb 2022 05:45:24 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0EBA73F5A1; Fri, 25 Feb 2022 05:45:20 -0800 (PST) Date: Fri, 25 Feb 2022 13:45:45 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Jintack Lim , Haibo Xu , Ganapatrao Kulkarni , Chase Conklin , "Russell King (Oracle)" , James Morse , Suzuki K Poulose , karl.heubaum@oracle.com, mihai.carabas@oracle.com, miguel.luis@oracle.com, kernel-team@android.com Subject: Re: [PATCH v6 42/64] KVM: arm64: nv: Fold guest's HCR_EL2 configuration into the host's Message-ID: References: <20220128121912.509006-1-maz@kernel.org> <20220128121912.509006-43-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220128121912.509006-43-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi, On Fri, Jan 28, 2022 at 12:18:50PM +0000, Marc Zyngier wrote: > When entering a L2 guest (nested virt enabled, but not in hypervisor > context), we need to honor the traps the L1 guest has asked enabled. > > For now, just OR the guest's HCR_EL2 into the host's. We may have to do > some filtering in the future though. Hmm... looks to me like the filtering is already implemented via the HCR_GUEST_NV_FILTER_FLAGS. Or am I misunderstanding something? > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp/vhe/switch.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > index 0e164cc8e913..5e8eafac27c6 100644 > --- a/arch/arm64/kvm/hyp/vhe/switch.c > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > @@ -78,6 +78,11 @@ static void __activate_traps(struct kvm_vcpu *vcpu) > if (!vcpu_el2_tge_is_set(vcpu)) > hcr |= HCR_AT | HCR_TTLB; > } > + } else if (vcpu_has_nv(vcpu)) { > + u64 vhcr_el2 = __vcpu_sys_reg(vcpu, HCR_EL2); > + > + vhcr_el2 &= ~HCR_GUEST_NV_FILTER_FLAGS; > + hcr |= vhcr_el2; This makes sense, we only the guest to add extra traps on top of what KVM already traps, not remove traps from what KVM has configured. However, HCR_EL2.FIEN (bit 47) disables traps when the bit is 1. Shouldn't it be part of the HCR_GUEST_NV_FILTER_FLAGS? Thanks, Alex > } > > ___activate_traps(vcpu, hcr); > -- > 2.30.2 > 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 77175C433EF for ; Fri, 25 Feb 2022 13:45:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EBC554B966; Fri, 25 Feb 2022 08:45:28 -0500 (EST) 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 E+vf8cwiDcFZ; Fri, 25 Feb 2022 08:45:27 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7B4354B9D3; Fri, 25 Feb 2022 08:45:27 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 383294B9D3 for ; Fri, 25 Feb 2022 08:45:26 -0500 (EST) 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 M9NvGZGsH7d9 for ; Fri, 25 Feb 2022 08:45:25 -0500 (EST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F008F4B966 for ; Fri, 25 Feb 2022 08:45:24 -0500 (EST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B8D6106F; Fri, 25 Feb 2022 05:45:24 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0EBA73F5A1; Fri, 25 Feb 2022 05:45:20 -0800 (PST) Date: Fri, 25 Feb 2022 13:45:45 +0000 From: Alexandru Elisei To: Marc Zyngier Subject: Re: [PATCH v6 42/64] KVM: arm64: nv: Fold guest's HCR_EL2 configuration into the host's Message-ID: References: <20220128121912.509006-1-maz@kernel.org> <20220128121912.509006-43-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220128121912.509006-43-maz@kernel.org> Cc: kernel-team@android.com, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Chase Conklin , kvmarm@lists.cs.columbia.edu, mihai.carabas@oracle.com, Ganapatrao Kulkarni , "Russell King \(Oracle\)" , 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 Hi, On Fri, Jan 28, 2022 at 12:18:50PM +0000, Marc Zyngier wrote: > When entering a L2 guest (nested virt enabled, but not in hypervisor > context), we need to honor the traps the L1 guest has asked enabled. > > For now, just OR the guest's HCR_EL2 into the host's. We may have to do > some filtering in the future though. Hmm... looks to me like the filtering is already implemented via the HCR_GUEST_NV_FILTER_FLAGS. Or am I misunderstanding something? > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp/vhe/switch.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > index 0e164cc8e913..5e8eafac27c6 100644 > --- a/arch/arm64/kvm/hyp/vhe/switch.c > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > @@ -78,6 +78,11 @@ static void __activate_traps(struct kvm_vcpu *vcpu) > if (!vcpu_el2_tge_is_set(vcpu)) > hcr |= HCR_AT | HCR_TTLB; > } > + } else if (vcpu_has_nv(vcpu)) { > + u64 vhcr_el2 = __vcpu_sys_reg(vcpu, HCR_EL2); > + > + vhcr_el2 &= ~HCR_GUEST_NV_FILTER_FLAGS; > + hcr |= vhcr_el2; This makes sense, we only the guest to add extra traps on top of what KVM already traps, not remove traps from what KVM has configured. However, HCR_EL2.FIEN (bit 47) disables traps when the bit is 1. Shouldn't it be part of the HCR_GUEST_NV_FILTER_FLAGS? Thanks, Alex > } > > ___activate_traps(vcpu, hcr); > -- > 2.30.2 > _______________________________________________ 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 65535C433EF for ; Fri, 25 Feb 2022 13:55:21 +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=Fn9iWMgbtmtGLm6ZrW++hnJv8xuu5uTLBdGhjT4wv6I=; b=K+8Y40MaGPQwz5 VhnxQYC1AryXZiUCaqDH1K6LwK6f7xITf7a7QlrVb18vpTBZwclIvbwQBZjMqy8NescPivtEUwnpQ t226mMk+52/gIKyzpi6/xwXAgh2wpGjaCBxMQYAaZ2JnVHD3UZCCrPGzoVu8QlwxDXh78PSMsrX84 NF5uOiVmLKfPUr6yNIYVGAq9ODIP63qU1j29OePL628Ok1J0BEIFI+KZelr5+xGGMvc3FSYpxeidY 8RzRB2n8d9PuAQvOrrIgZdDECoMIYsbDLRUGCIMZcpT1q+GgOJjl+M7iOMscFHuswMN1QFO189593 943Q7P4M6v+sNNQEh9uA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNb2l-005FyM-8W; Fri, 25 Feb 2022 13:53:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNauV-005D7M-U5 for linux-arm-kernel@lists.infradead.org; Fri, 25 Feb 2022 13:45:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B8D6106F; Fri, 25 Feb 2022 05:45:24 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0EBA73F5A1; Fri, 25 Feb 2022 05:45:20 -0800 (PST) Date: Fri, 25 Feb 2022 13:45:45 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Jintack Lim , Haibo Xu , Ganapatrao Kulkarni , Chase Conklin , "Russell King (Oracle)" , James Morse , Suzuki K Poulose , karl.heubaum@oracle.com, mihai.carabas@oracle.com, miguel.luis@oracle.com, kernel-team@android.com Subject: Re: [PATCH v6 42/64] KVM: arm64: nv: Fold guest's HCR_EL2 configuration into the host's Message-ID: References: <20220128121912.509006-1-maz@kernel.org> <20220128121912.509006-43-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220128121912.509006-43-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220225_054528_076390_2C8DD78C X-CRM114-Status: GOOD ( 18.84 ) 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, On Fri, Jan 28, 2022 at 12:18:50PM +0000, Marc Zyngier wrote: > When entering a L2 guest (nested virt enabled, but not in hypervisor > context), we need to honor the traps the L1 guest has asked enabled. > > For now, just OR the guest's HCR_EL2 into the host's. We may have to do > some filtering in the future though. Hmm... looks to me like the filtering is already implemented via the HCR_GUEST_NV_FILTER_FLAGS. Or am I misunderstanding something? > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp/vhe/switch.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > index 0e164cc8e913..5e8eafac27c6 100644 > --- a/arch/arm64/kvm/hyp/vhe/switch.c > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > @@ -78,6 +78,11 @@ static void __activate_traps(struct kvm_vcpu *vcpu) > if (!vcpu_el2_tge_is_set(vcpu)) > hcr |= HCR_AT | HCR_TTLB; > } > + } else if (vcpu_has_nv(vcpu)) { > + u64 vhcr_el2 = __vcpu_sys_reg(vcpu, HCR_EL2); > + > + vhcr_el2 &= ~HCR_GUEST_NV_FILTER_FLAGS; > + hcr |= vhcr_el2; This makes sense, we only the guest to add extra traps on top of what KVM already traps, not remove traps from what KVM has configured. However, HCR_EL2.FIEN (bit 47) disables traps when the bit is 1. Shouldn't it be part of the HCR_GUEST_NV_FILTER_FLAGS? Thanks, Alex > } > > ___activate_traps(vcpu, hcr); > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel