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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E56EC4360F for ; Thu, 21 Feb 2019 11:50:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1A2BB2148D for ; Thu, 21 Feb 2019 11:50:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k7BNNdmV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A2BB2148D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=v2YZkBEm4oUd0Cvm+o25BUHs32w0KB2AYkcNR5Sbpsg=; b=k7BNNdmVAmh1ki zJ0ryAbfm7IJJCvQF9+bUBJ0arGcfHzT/xNhBgrYRZo1FA0vKhHSKFgEPFHjGHQd0a7bM9ALjwISJ wKpzIN6sGmQUtF5agGpP9B3AcK6tXxF0DZ7PnGgx15Sd9Ld3ROpoeZvV1k2y3l7P8bFiNK9LNPZUZ 6O3J1q0McShXwg7Sgm9muywa2BJWio0+Nr6Q5S2381JT1QjWMKUqKmq6axNOuY+6uwCCfWB6W+4Ie ZlgFeJr7C/pO5A4rSixj0b5tSi8023mbrNcLBXz26yzkNR9tsWTptvmC0iew4sj716oFR544X2RZq TyiUtddPiVWjuus8qdbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwmsI-0006xt-2e; Thu, 21 Feb 2019 11:50:46 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwmsF-0006xW-Bz for linux-arm-kernel@lists.infradead.org; Thu, 21 Feb 2019 11:50:44 +0000 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 0667580D; Thu, 21 Feb 2019 03:50:43 -0800 (PST) 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 6C0E73F5C1; Thu, 21 Feb 2019 03:50:40 -0800 (PST) Date: Thu, 21 Feb 2019 11:50:34 +0000 From: Mark Rutland To: Amit Daniel Kachhap Subject: Re: [PATCH v6 1/6] arm64/kvm: preserve host HCR_EL2 value Message-ID: <20190221115034.GA33673@lakrids.cambridge.arm.com> References: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> <1550568271-5319-2-git-send-email-amit.kachhap@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1550568271-5319-2-git-send-email-amit.kachhap@arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190221_035043_416423_F315DD60 X-CRM114-Status: GOOD ( 22.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , linux-kernel@vger.kernel.org, Julien Thierry , Marc Zyngier , Catalin Marinas , Will Deacon , Christoffer Dall , Kristina Martsenko , kvmarm@lists.cs.columbia.edu, James Morse , Ramana Radhakrishnan , Dave Martin , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Tue, Feb 19, 2019 at 02:54:26PM +0530, Amit Daniel Kachhap wrote: > From: Mark Rutland > > When restoring HCR_EL2 for the host, KVM uses HCR_HOST_VHE_FLAGS, which > is a constant value. This works today, as the host HCR_EL2 value is > always the same, but this will get in the way of supporting extensions > that require HCR_EL2 bits to be set conditionally for the host. > > To allow such features to work without KVM having to explicitly handle > every possible host feature combination, this patch has KVM save/restore > for the host HCR when switching to/from a guest HCR. The saving of the > register is done once during cpu hypervisor initialization state and is > just restored after switch from guest. > > For fetching HCR_EL2 during kvm initialisation, a hyp call is made using > kvm_call_hyp and is helpful in NHVE case. > > For the hyp TLB maintenance code, __tlb_switch_to_host_vhe() is updated > to toggle the TGE bit with a RMW sequence, as we already do in > __tlb_switch_to_guest_vhe(). > > The value of hcr_el2 is now stored in struct kvm_cpu_context as both host > and guest can now use this field in a common way. > > Signed-off-by: Mark Rutland > [Added __cpu_copy_hyp_conf, hcr_el2 field in struct kvm_cpu_context] > Signed-off-by: Amit Daniel Kachhap > Cc: Marc Zyngier > Cc: Christoffer Dall > Cc: kvmarm@lists.cs.columbia.edu [...] > +/** > + * __cpu_copy_hyp_conf - copy the boot hyp configuration registers > + * > + * It is called once per-cpu during CPU hyp initialisation. > + */ > +static inline void __cpu_copy_hyp_conf(void) I think this would be better named as something like: cpu_init_host_ctxt() ... as that makes it a bit clearer as to what is being initialized. [...] > +/** > + * __kvm_populate_host_regs - Stores host register values > + * > + * This function acts as a function handler parameter for kvm_call_hyp and > + * may be called from EL1 exception level to fetch the register value. > + */ > +void __hyp_text __kvm_populate_host_regs(void) > +{ > + struct kvm_cpu_context *host_ctxt; > + > + if (has_vhe()) > + host_ctxt = this_cpu_ptr(&kvm_host_cpu_state); > + else > + host_ctxt = __hyp_this_cpu_ptr(kvm_host_cpu_state); Do we need the has_vhe() check here? Can't we always do: host_ctxt = __hyp_this_cpu_ptr(kvm_host_cpu_state); ... regardless of VHE? Or is that broken for VHE somehow? Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel