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=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 EF5E5C433DB for ; Fri, 5 Feb 2021 18:02:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9CCB964E43 for ; Fri, 5 Feb 2021 18:02:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CCB964E43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.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=qfLxnNSfc7LTxoPenHl5l/gBCyuLImm1x/2v9zD/ld8=; b=W3Fn8aQE1XqKydF1Y+fgUh4qm dDS7o4Y50dmzWYGdz0fDccg5t2s7+loXW3Yw0nkZhA6ChRcmD0IZwK8LN00pnG8YCDe5zMhGzizBC GM5rQE8TmkRRX39yK8hId3SGtI5uibEdQafBqDjCWTHwDtzECiAHLEjJHDgBkGp/wYT1D/L9DgNEM Cb9yoLkkaW10R4XPFFuVr6ctVYPd49O9I5pKs6lTPGUMAk/zQ4Kj6K46i4FDYPr4JqLmygb9Z+Qjo 8ga2oZWjwkQw8W34NiH6VJxH/u2mSq/GT14iosQZdnPpVT+VX/vXWe1L3g2YuPWmsWg5cprOZqUDv Yldyi9D1g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l85Q4-0001wi-VA; Fri, 05 Feb 2021 18:01:25 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l85Q0-0001vg-Hz for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 18:01:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD84E64E36; Fri, 5 Feb 2021 18:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612548079; bh=Bjw+NwhSJiekA9yibIou0xtFz7GFWwM2qh2Z7IfduJs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b4HZizp8pcHVlwOrLYNlzVCFECExmAgpMYBpIaotN429mrIqldMuX+mLpVm+aS0MU /V8FUuY+jMnKmzgliriV7vFHvHSDdRrB8O7sl8iIcS3DDvZ9Jn6/+4+AE5HsLPiDFa aZf9s7FitOkxgvJsmohm0hF9W22GJ/tPEdghM93av/wBi2rIe7vdocYCiN8k9I/F5W h0awdwpj52CjngapeMwPC6oNTlGcBYp5NsB6DfbRNsKt4xNz0+K3z4rIhwCQWz7UpE 1oIzVZLqhPRqap54FS7ZwNWgovFJ+/tTDAZcctOzyDyKEtr2R3rnAwbldU4Vbjg3bp p4UY6ypiDH6SA== Date: Fri, 5 Feb 2021 18:01:13 +0000 From: Will Deacon To: Quentin Perret Subject: Re: [RFC PATCH v2 17/26] KVM: arm64: Elevate Hyp mappings creation at EL2 Message-ID: <20210205180113.GH22665@willie-the-truck> References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-18-qperret@google.com> <20210203153138.GB18974@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_130120_785208_78DD13A5 X-CRM114-Status: GOOD ( 25.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, kernel-team@android.com, Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Frank Rowand , kvmarm@lists.cs.columbia.edu, Julien Thierry 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 On Thu, Feb 04, 2021 at 11:08:33AM +0000, Quentin Perret wrote: > On Wednesday 03 Feb 2021 at 15:31:39 (+0000), Will Deacon wrote: > > On Fri, Jan 08, 2021 at 12:15:15PM +0000, Quentin Perret wrote: > > > @@ -1481,7 +1486,10 @@ static void cpu_set_hyp_vector(void) > > > struct bp_hardening_data *data = this_cpu_ptr(&bp_hardening_data); > > > void *vector = hyp_spectre_vector_selector[data->slot]; > > > > > > - *this_cpu_ptr_hyp_sym(kvm_hyp_vector) = (unsigned long)vector; > > > + if (!is_protected_kvm_enabled()) > > > + *this_cpu_ptr_hyp_sym(kvm_hyp_vector) = (unsigned long)vector; > > > + else > > > + kvm_call_hyp_nvhe(__pkvm_cpu_set_vector, data->slot); > > > > *Very* minor nit, but it might be cleaner to have static inline functions > > with the same prototypes as the hypercalls, just to make the code even > > easier to read. e.g > > > > if (!is_protected_kvm_enabled()) > > _cpu_set_vector(data->slot); > > else > > kvm_call_hyp_nvhe(__pkvm_cpu_set_vector, data->slot); > > > > you could then conceivably wrap that in a macro and avoid having the > > "is_protected_kvm_enabled()" checks explicit every time. > > Happy to do this here, but are you suggesting to generalize this pattern > to other places as well? I think it's probably a good pattern to follow, but no need to generalise it prematurely. > > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > > > index 3cf9397dabdb..9d4c9251208e 100644 > > > --- a/arch/arm64/kvm/mmu.c > > > +++ b/arch/arm64/kvm/mmu.c > > > @@ -225,15 +225,39 @@ void free_hyp_pgds(void) > > > if (hyp_pgtable) { > > > kvm_pgtable_hyp_destroy(hyp_pgtable); > > > kfree(hyp_pgtable); > > > + hyp_pgtable = NULL; > > > } > > > mutex_unlock(&kvm_hyp_pgd_mutex); > > > } > > > > > > +static bool kvm_host_owns_hyp_mappings(void) > > > +{ > > > + if (static_branch_likely(&kvm_protected_mode_initialized)) > > > + return false; > > > + > > > + /* > > > + * This can happen at boot time when __create_hyp_mappings() is called > > > + * after the hyp protection has been enabled, but the static key has > > > + * not been flipped yet. > > > + */ > > > + if (!hyp_pgtable && is_protected_kvm_enabled()) > > > + return false; > > > + > > > + BUG_ON(!hyp_pgtable); > > > > Can we fail more gracefully, e.g. by continuing without KVM? > > Got any suggestion as to how that can be done? We could also just remove > that line -- that really should not happen. Or downgrade to WARN_ON. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel