Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp388013pxk; Thu, 3 Sep 2020 02:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+XHIOX82MFlAhvP5Yld6bfFP1dEFRIylXuzT4V2ryrAF1SciWQoP+MQtAwFNsDYJlt0p2 X-Received: by 2002:a05:6402:70f:: with SMTP id w15mr2130323edx.202.1599124844411; Thu, 03 Sep 2020 02:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599124844; cv=none; d=google.com; s=arc-20160816; b=UyqUcl1egCCoPiNGbO/o6G52v/Uou6EHmQZ90hcd7viBJEo54IsGojcnmKTo/x/v40 C0GA3WBtFkpmdwe3J1h5YEUlNPVhp7AjBjwujOJUC5ALzaTV/9IKCyjzvoY7O2b9V4yE hiMunJK3M/Q4fgTIP4HAMDijbx11UxkYxT11DaXVAXbDd3ROWbgDzbKHDchf9dVXkhsj DyO7Z4ryJo+HWARFtUPICMvUX88Ijahy7WAjZ7i4/2NEIvldUdbNVqdmB2sEiEt4EFqx WmUXz28gepo/n6tcCrA6kBlX1dE0eKtViMIeR8g8FQiO7kw4L8EUHy5dD6wppfnPP2Vy VA8w== 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=mwdRMAavqdTzOvo7Ir5BJvWRsG9Q05qSRw6OHtvkMgg=; b=k+poifbZ4LOEfHklXLj1mcMIYCyxq1BjWHd2c4b/9Ss+rRXli8ngnvAz0cDcM7KaSK /xPdSns+rMAJZIbbShjrbbtjPHoBeThwiuBx6V2hV4bL7ZxqFScPPH7NjhAhMHvr+ZIo JzlwtAnjU4ack+Dr1MgNgzLeBw2ypkFLIwgObackZl9h7dHNVxK20E8mUZxYcJGX9OqG NsZlmrOchEImRXhD6nt5gIKOOUQFlTdC4T/QdD/WcVzIkuqhSBEgTlDYisjuOcms/x39 VA72ctgyLqdJJfsXtCikUaKu96nLCnigfa+6Bm2xpXpkCs+ujLMjiSVVdrQUK/SNdgUZ nn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fSryvZyp; 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 z1si1468250eja.41.2020.09.03.02.20.21; Thu, 03 Sep 2020 02:20:44 -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=fSryvZyp; 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 S1726268AbgICJSt (ORCPT + 99 others); Thu, 3 Sep 2020 05:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgICJR5 (ORCPT ); Thu, 3 Sep 2020 05:17:57 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9376C061258 for ; Thu, 3 Sep 2020 02:17:51 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id z23so2763441ejr.13 for ; Thu, 03 Sep 2020 02:17:51 -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=mwdRMAavqdTzOvo7Ir5BJvWRsG9Q05qSRw6OHtvkMgg=; b=fSryvZypFiRayJ6qbXdHAuS+6FDnue70hvCWNO7yOK8m0hMkAwkbG1pA/JeNI0g4bP 6BM7jhcArJY2rH/F2rySk6k1pOyCgrpB3aynRg2CWQT9D+5Gdy/9FaJUCJgmN9O/SF3N 4+pQVl03npehC5dbcL3VFetoYyKoZjOs1/SuBZd8+sE6LrP6fd+64/cDg6RMPEfAHBdj yJWNrZ4eV4GH5S84SAX+WO2Nk68D36mOzVejo4YmLFm+B0tkHmYZu33yKfcuj2dtUon6 DM77MiypYG43OUNr5/rK0Bs6MkABNFfbRrRvyezu9uc+d9VeuHmo81HSmvyhD1Ku4Qg2 NVrw== 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=mwdRMAavqdTzOvo7Ir5BJvWRsG9Q05qSRw6OHtvkMgg=; b=uM1v5Xq2kskc3HaO1inhClzVASTfMS3iLLJzDcIbt5nFbSwLnaeWiw2jCrey9X2IMm 9eMkLHXP143w7ns11SxTPGb2nTxi0vSnYqv5ZD/hCtXYyaJ+RK4Bi8S8/jlnCIsaQp4U OUgOcW8WnJFxp/Ea4k0W70kLFVv/p2kJB8cej7wM+2QKBXJj9vOwO0VkRn5gYP4uEuK5 fFBZJywfkx+RxPqBxW5oT4ieUXjIn+/4QhCzUpASWydbddyK1NDTgA4eReo3LiWlZUvm Wu+Lk3MZGm7hJzZG0xQxUlI2t7T1bmnk+ASjjGTIqZT36Mn0QX6qu3x+tGlC3jGPcvKc wh8g== X-Gm-Message-State: AOAM53179E69/OOIzwLjUdmicQrc+Jpk3lNRD3bJnLXRenIHbc8s3qrV d/Vca5/EyFIBGfGQEz2b5SMkUw== X-Received: by 2002:a17:906:a1d8:: with SMTP id bx24mr1085448ejb.161.1599124670371; Thu, 03 Sep 2020 02:17:50 -0700 (PDT) Received: from localhost (dynamic-2a00-1028-919a-a06e-64ac-0036-822c-68d3.ipv6.broadband.iol.cz. [2a00:1028:919a:a06e:64ac:36:822c:68d3]) by smtp.gmail.com with ESMTPSA id l19sm2594526ejn.67.2020.09.03.02.17.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 02:17:49 -0700 (PDT) From: David Brazdil To: Marc Zyngier , Catalin Marinas , Will Deacon , 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@android.com, David Brazdil Subject: [PATCH v2 06/10] kvm: arm64: Duplicate arm64_ssbd_callback_required for nVHE hyp Date: Thu, 3 Sep 2020 11:17:08 +0200 Message-Id: <20200903091712.46456-7-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903091712.46456-1-dbrazdil@google.com> References: <20200903091712.46456-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 189839c3706a..9db93da35606 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 8982b68289b7..5fc5eadfb3e6 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 46dc3d75cf13..1bb960812493 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1549,7 +1549,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 cc4f8e790fb3..4662df6330d7 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.28.0.402.g5ffc5be6b7-goog