Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180409145709.dneotb6xaznw44c4@lakrids.cambridge.arm.com>
Date: Mon, 9 Apr 2018 15:57:09 +0100
From: Mark Rutland <mark.rutland@....com>
To: Christoffer Dall <cdall@...nel.org>
Cc: linux-arm-kernel@...ts.infradead.org, arnd@...db.de,
	catalin.marinas@....com, kvmarm@...ts.cs.columbia.edu,
	linux-arch@...r.kernel.org, marc.zyngier@....com,
	suzuki.poulose@....com, will.deacon@....com, yao.qi@....com,
	kernel-hardening@...ts.openwall.com, linux-kernel@...r.kernel.org,
	awallis@...eaurora.org
Subject: Re: [PATCHv2 09/12] arm64/kvm: preserve host HCR_EL2 value

On Tue, Feb 06, 2018 at 01:39:15PM +0100, Christoffer Dall wrote:
> On Mon, Nov 27, 2017 at 04:38:03PM +0000, Mark Rutland wrote:
> > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
> > index 525c01f48867..2205f0be3ced 100644
> > --- a/arch/arm64/kvm/hyp/switch.c
> > +++ b/arch/arm64/kvm/hyp/switch.c
> > @@ -71,6 +71,8 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
> >  {
> >  	u64 val;
> >  
> > +	vcpu->arch.host_hcr_el2 = read_sysreg(hcr_el2);
> > +
> 
> Looking back at this, it seems excessive to switch this at every
> round-trip.  I think it should be possible to have this as a single
> global (or per-CPU) variable that gets restored directly when returning
> from the VM.

I suspect this needs to be per-cpu, to account for heterogeneous
systems.

I guess if we move hcr_el2 into kvm_cpu_context, that gives us a
per-vcpu copy for guests, and a per-cpu copy for the host (in the global
kvm_host_cpu_state).

I'll have a look at how gnarly that turns out. I'm not sure how we can
initialise that sanely for the !VHE case to match whatever el2_setup
did.

Thanks,
Mark.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.