From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932485AbdBVLj2 (ORCPT ); Wed, 22 Feb 2017 06:39:28 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35169 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932387AbdBVLjS (ORCPT ); Wed, 22 Feb 2017 06:39:18 -0500 Date: Wed, 22 Feb 2017 12:39:04 +0100 From: Christoffer Dall To: Jintack Lim Cc: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 16/55] KVM: arm64: Forward VM reg traps to the guest hypervisor Message-ID: <20170222113904.GJ26976@cbox> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> <1483943091-1364-17-git-send-email-jintack@cs.columbia.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483943091-1364-17-git-send-email-jintack@cs.columbia.edu> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 09, 2017 at 01:24:12AM -0500, Jintack Lim wrote: > Forward virtual memory register traps to the guest hypervisor > if it has set corresponding bits to the virtual HCR_EL2. I was a bit confused about the subject of this patch. I would recommend calling it something like "Respect virtul HCR_EL2.TVM and HCR_EL2.TRVM settings" > > Signed-off-by: Jintack Lim > --- > arch/arm64/kvm/sys_regs.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index b8e993a..0f5d21b 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -90,6 +90,23 @@ static bool access_dcsw(struct kvm_vcpu *vcpu, > return true; > } > > +static bool forward_vm_traps(struct kvm_vcpu *vcpu, struct sys_reg_params *p) > +{ > + u64 hcr_el2 = vcpu_el2_reg(vcpu, HCR_EL2); > + > + /* If this is a trap from the virtual EL2, the host handles */ > + if (vcpu_mode_el2(vcpu)) > + return false; > + > + /* If the guest wants to trap on R/W operation, forward this trap */ > + if ((hcr_el2 & HCR_TVM) && p->is_write) > + return true; > + else if ((hcr_el2 & HCR_TRVM) && !p->is_write) > + return true; > + > + return false; > +} > + > /* > * Generic accessor for VM registers. Only called as long as HCR_TVM > * is set. If the guest enables the MMU, we stop trapping the VM > @@ -101,6 +118,9 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, > { > bool was_enabled = vcpu_has_cache_enabled(vcpu); > > + if (forward_vm_traps(vcpu, p)) > + return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu)); > + > BUG_ON(!vcpu_mode_el2(vcpu) && !p->is_write); > > if (!p->is_write) { > -- > 1.9.1 > >