Received: by 10.213.65.68 with SMTP id h4csp2720803imn; Mon, 9 Apr 2018 08:02:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx49eORU4TbNWIX2xM9W2TuovOthC69QXWODDdK+tCawS1Tju1KCpCuA+IsLVCd/owlywwKsF X-Received: by 2002:a17:902:1a4:: with SMTP id b33-v6mr39305173plb.303.1523286122020; Mon, 09 Apr 2018 08:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523286121; cv=none; d=google.com; s=arc-20160816; b=aS8p+iL0Awulbclu1GzZ70eRGJwLeAtirYbaTwKNsJkjqfMvGdbve5qOyyBD5yy+zi hCUqZMSZO7bggkpS5j8jNf08fEMfh2YHkrD4tGnrwJP/ECJcq1o/a43h0vXyLtuWnYSp Kd1NhR3GRptj2/6jayQhymfxfVrf9Th9hI2e6uS9sGkqtjJ4go4VIpmZQhEDKDu+AQAG Z5fOUOC/B8rKJgKZK3LYC/SSefjOHzlqZJZg0ztKIAo/WOtd7XuDfIUPc6yx/BtzGRVM XuHm3I4+fRGagOutLR9Q05z6urDqhMrAHVpN3pZcikaWGgWb3gIuZEmthj56eIPHSjAI dxRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=QXQ1VzYrNJdRV1vsZW+7/uAhEt3wPTP17A5KQ4I9aow=; b=X4gjD4kBKMmvO89qfMD1OSZkFBsJSLlaQcpAVsj5A5ib6j7izuw4t1LcZheZSp+VLV 2KA3rWNbnhuGFAckVwnx7Rin3PmB/QrH9y53qzmIuRA8ONDh5taBO12Eq/CNKXEOvlkW qqeWcZN3g3mz6KYqlnXGy/P4raIWWapUIAk9O4izkuWzM27abUTNP2669+BxwlLl1P83 +cEBefp+JGLIdv6L0ShwX2BmoHGhTKPCpzHd1bcusxo+Duh1ms7AZPh+iZzG0ff0x9Jz jjPPzt320aj92qcUGQmKgx6ShTgzYy2g/GcertCThy+ueVVWSxqa8ouKGIWfnzfAwLWI BC3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si339365pgn.46.2018.04.09.08.01.08; Mon, 09 Apr 2018 08:02:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752656AbeDIO5Q (ORCPT + 99 others); Mon, 9 Apr 2018 10:57:16 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57402 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbeDIO5O (ORCPT ); Mon, 9 Apr 2018 10:57:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 947A7F; Mon, 9 Apr 2018 07:57:14 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5FF833F24A; Mon, 9 Apr 2018 07:57:12 -0700 (PDT) Date: Mon, 9 Apr 2018 15:57:09 +0100 From: Mark Rutland To: Christoffer Dall Cc: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, catalin.marinas@arm.com, kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, marc.zyngier@arm.com, suzuki.poulose@arm.com, will.deacon@arm.com, yao.qi@arm.com, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, awallis@codeaurora.org Subject: Re: [PATCHv2 09/12] arm64/kvm: preserve host HCR_EL2 value Message-ID: <20180409145709.dneotb6xaznw44c4@lakrids.cambridge.arm.com> References: <20171127163806.31435-1-mark.rutland@arm.com> <20171127163806.31435-10-mark.rutland@arm.com> <20180206123915.GA21802@cbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180206123915.GA21802@cbox> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.