Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp656213ybh; Wed, 22 Jul 2020 09:48:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP2C/E0BfvaZQdkBMeBXMmHQyosp6Gh+/lRTD2HBBDFtXXg/subsj9mfig9FqSDeZ+xQiB X-Received: by 2002:a17:906:856:: with SMTP id f22mr395702ejd.245.1595436536603; Wed, 22 Jul 2020 09:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595436536; cv=none; d=google.com; s=arc-20160816; b=bl0rASPlHILlg18djVbgdQHlplLVrfHbd0xWSnHyZHd38YZpkH010ISl0Rjy6PRptW rh3haGwSxlAcJgq9iisRk1t3KnZiOnAPdcfRwCAsAGUuSHExeBmIED372Nk+Wb/BYgVa GURATw7XwnayerPGAFzvpFheBUFthTzrgUEBexsX5Zpztbkn8rudG5hqoxMECIhmiRGU cjF+wCQyZ3nl9VDaYGhP+2KRaEXlTwDiz3ue7/tog54VtPbEgqPf7psezsmUORBZaXk0 pdFF2L7W187Fvl2v5WKA+P3pJ8dQkhM2stbFuluE7lJ4HRIk47VoLVUg694lksCprLKi qvRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WoKr+d4xzFa2q5doiKo+Ma/Mr0IRgGSBGk/CKLNfxgY=; b=sbKJ8xTyYSnk+RYAi/wiz+e4nMlvBjI5HfjgNmrFB/CWBz5SvUl0WWp9gHAVPvuaE9 7k6wNdxCbYFHBRCizuIiqoIAAFyV0dgHuqGk+KLahYxbL05zZAb56mzfANmHgFb8Weit uQx1DxPUHH428OPujQm4RVuleRhjuTtfPuQLQ4bd4dF7iMI8R+AsWOCJSXMejcKgR4wm KOuReI+jQA9UnOTW3mb95ZvaZL/oRiVEP29SDatWBVdlpaN59Pa27GhyhX2brqvuYa5x Rv7f+hE/IDA+gPnw+FHLhMLaAhqmN4F+erCZhwGrz12ATofvqUnIuHyScYZWsknE8kTZ GCAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ktMgAg7h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t25si327339edr.537.2020.07.22.09.48.34; Wed, 22 Jul 2020 09:48:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ktMgAg7h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731569AbgGVQpb (ORCPT + 99 others); Wed, 22 Jul 2020 12:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731117AbgGVQpJ (ORCPT ); Wed, 22 Jul 2020 12:45:09 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77090C0619E0 for ; Wed, 22 Jul 2020 09:45:09 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id 9so2505574wmj.5 for ; Wed, 22 Jul 2020 09:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WoKr+d4xzFa2q5doiKo+Ma/Mr0IRgGSBGk/CKLNfxgY=; b=ktMgAg7h984Iz5zq71o5DN+J0+FK13F2J9HPBy4DmLuxJ090jgw+CMnoSZwyQY49Ma f6yJhxgSogcgx3bETDFW+KqXCwbYzTtFr6O5sgMkcsR2Hq6w19IrrZuEIpXicZJ3EGVV U78Tpy9fh1G98eE0Ys41it7n1SVaRQbQTvPQg94IRPQEXLYEtTYwgo1TOaoUoep+eDoZ H8rq8GLCnQ+9r8ihbCiMv+byr7bxzMtmDd5XPLTWCHHOKBCD5MR8gklAapKIjdYlZp+I wtYhzP8MLjT3vX1DeAvbZBQhzDpQKV5uegI4SY3ESoosnDFzNvhkcvlbO6uy2d3oSVQM fH5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WoKr+d4xzFa2q5doiKo+Ma/Mr0IRgGSBGk/CKLNfxgY=; b=EA8Xl5ydyL+hUoXtGplXDF/iqPzaNAwYsapcz0hWomiN5VMtc1ZHgHC++JHp+fXGYS KtraHOv1v5SQVrw2EKDJKqTZf6bA6xmq4b6UKayf4R/4iZ7QzlwOp0sY3qdvOf/hNVca u6R2GoAJwT7C8Vx4jPadg9IP2b+onOdz0tjZw7uKC4ffhRoedCQTYSx9NA8/s/8qe8mh pRECgOgw3XkO+qg30qBNa9U+KV+SPuWVe9+ybj2IM7NZBFW9G+zfNgs+dD35w+AhpREI zwwmVxJyLJahT6nsYLXWaaVYwsIsMZ7+qVFkePHfhrOBgVwpAX6wjMEDOk3jlipqfw3M hNSA== X-Gm-Message-State: AOAM532ihqiA8UY5Nj/7KJneMlOXhnBshUcuJQPiCDJpbB3m8bEs3iVg hXd+vtu8fyVxLwv2zTgUJrIq/Q== X-Received: by 2002:a1c:d8:: with SMTP id 207mr432561wma.81.1595436307978; Wed, 22 Jul 2020 09:45:07 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:b0ee:900a:e004:b9d0]) by smtp.gmail.com with ESMTPSA id g14sm538679wrw.83.2020.07.22.09.45.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 09:45:07 -0700 (PDT) From: David Brazdil To: Catalin Marinas , Will Deacon , Marc Zyngier , Dennis Zhou , Tejun Heo , Christoph Lameter , Arnd Bergmann Cc: James Morse , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, kernel-team@google.com, David Brazdil Subject: [PATCH 5/9] kvm: arm64: Duplicate arm64_ssbd_callback_required for nVHE hyp Date: Wed, 22 Jul 2020 17:44:20 +0100 Message-Id: <20200722164424.42225-6-dbrazdil@google.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722164424.42225-1-dbrazdil@google.com> References: <20200722164424.42225-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hyp keeps track of which cores require SSBD callback by accessing a kernel-proper global variable. Create an nVHE symbol of the same name and copy the value from kernel proper to nVHE at KVM init time. Done in preparation for separating percpu memory owned by kernel proper and nVHE. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_mmu.h | 10 +++++++--- arch/arm64/kernel/image-vars.h | 1 - arch/arm64/kvm/arm.c | 2 +- arch/arm64/kvm/hyp/nvhe/switch.c | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 22157ded04ca..e9e5875274cb 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -529,23 +529,27 @@ static inline int kvm_map_vectors(void) #ifdef CONFIG_ARM64_SSBD DECLARE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); +DECLARE_KVM_NVHE_PER_CPU(u64, arm64_ssbd_callback_required); -static inline int hyp_map_aux_data(void) +static inline int hyp_init_aux_data(void) { int cpu, err; for_each_possible_cpu(cpu) { u64 *ptr; - ptr = per_cpu_ptr(&arm64_ssbd_callback_required, cpu); + ptr = per_cpu_ptr_nvhe(arm64_ssbd_callback_required, cpu); err = create_hyp_mappings(ptr, ptr + 1, PAGE_HYP); if (err) return err; + + /* Copy value from kernel to hyp. */ + *ptr = per_cpu(arm64_ssbd_callback_required, cpu); } return 0; } #else -static inline int hyp_map_aux_data(void) +static inline int hyp_init_aux_data(void) { return 0; } diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h index 9e897c500237..034cf21e67ce 100644 --- a/arch/arm64/kernel/image-vars.h +++ b/arch/arm64/kernel/image-vars.h @@ -69,7 +69,6 @@ KVM_NVHE_ALIAS(kvm_patch_vector_branch); KVM_NVHE_ALIAS(kvm_update_va_mask); /* Global kernel state accessed by nVHE hyp code. */ -KVM_NVHE_ALIAS(arm64_ssbd_callback_required); KVM_NVHE_ALIAS(kvm_host_data); KVM_NVHE_ALIAS(kvm_vgic_global_state); diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 98f05bdac3c1..a53e87305fa0 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1547,7 +1547,7 @@ static int init_hyp_mode(void) } } - err = hyp_map_aux_data(); + err = hyp_init_aux_data(); if (err) kvm_err("Cannot map host auxiliary data: %d\n", err); diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index ddb602ffb022..8c2bd04df813 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -27,6 +27,9 @@ #include #include +/* Non-VHE copy of the kernel symbol. */ +DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); + static void __activate_traps(struct kvm_vcpu *vcpu) { u64 val; -- 2.27.0