From patchwork Thu Sep 3 13:52:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11753639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE9B5109B for ; Thu, 3 Sep 2020 13:54:04 +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 B2DFD208B3 for ; Thu, 3 Sep 2020 13:54:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1kCP+ML7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="K9XziCEG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2DFD208B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VqQ1a/tbZbtdEOpGzAHONetiFAOz+eUIve1PZ8wrq0M=; b=1kCP+ML7Bqdo6gd/NPRmWDyv+ vfiD46SnTLVVPBcvF59k1yf2mz15SAos05X/sMDhGSYEPkug+Z33oYfMr7y6Cy/motcFAPMO6ZRxT JPiQDSKSYSSe6+oYo4KriETbKNoISIA3So9oF9YlKJUy+FVaTmMk0BxGugJypXf/NZtSQFcT9RR4M F4hayoz4dOWK/P97yQOTZd95yBv9o4KoJwM1IUc7tKmM/nh23iqcXhWhSWxxHyLGJziWWDkv1OyaB ZtZMJWnywyw/tOd41+tEqy1R2UpP6hOU88ZKZ0SCxkDEFtjpiImBP1ZY6OU0XYDgIXga8O7q0hfmF yIN2AV3Zg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpgQ-00024k-NK; Thu, 03 Sep 2020 13:53:46 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpg6-0001wB-IM for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 13:53:27 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id dj20so1824388qvb.23 for ; Thu, 03 Sep 2020 06:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=AwtXwoM2K8tOnbwwUhIWJJkJf6xiR3Qg++wLNHJKzAw=; b=K9XziCEGbV7pUGY/HBFMcEewUYae1cZqrqx7z+71k9vDrAXE8z2V4VbpueUSf6lBYK Ao5SmLRXSopY81N3w4qHh7hMzgC/cLoA4BiAdMvVyzQ7w9mZ4ICCff8t6yhGIW2xp5tK dQvtreMwcf7bQLT1/rX7x3ttdeiVQaYHB3Aq/VBk5iATp9E8kpSTuIdtq2nlO2spr/lP DvrPbIxX820OcdXZW81K/b237s7hsFNP4fw6S+3/95bM06QwQQO3aozWO2qZHzuiFUai Za4xAx6UVVN3ib0A10IXFqpDzTu1nQrZz3ZJc0gJ1l3mCL8moDxXKE1isagHTIzCnLNV SOKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AwtXwoM2K8tOnbwwUhIWJJkJf6xiR3Qg++wLNHJKzAw=; b=ChABBpK8UCRb4PmqJM/9249xVHS3nG3vyqV2p98GlPgVCLiDBQ5dEyBrQBrU49kuce 2P/YWhRKTeeGn57STrPL1t+I0pHizDUpE7JEZhhZJlIlckMS8XAlVOMgvCnmOTThoCxj QUeEqd4kWZFQbSNTKRmSVjv8DlY09pO/HnM4Ojb3ObJX3U4/rwt8D+/UW7iLWiVFLeiQ 1YdXl94RgsEqq1Z6KqdO/i6gr66W794whm6ZiIVcG8LE7xK7k+vhucYg9fUlkrsvnquv vIdpxjQWNLeTOiMogTgKq6j0oCzkmEhaJzKKVyIm2e5kanwjdYGqH6HepQxOU/VPHWBf 57vA== X-Gm-Message-State: AOAM533TQHFBieIXReNDknXVVLQTdJ2rNG90ucXS1w9riYJdvXMhuFMH vGWfIsUmaw7y6G6O54YhOKXHYxtIDsc= X-Google-Smtp-Source: ABdhPJz5oGR6ixw8aIc+X0oj1sX69tKg2ggKVOyAhbPBb8ACL2USx9VWiURftSkpHoyl0zy3WQzoCtvG6Qs= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a0c:ca87:: with SMTP id a7mr2972588qvk.17.1599141202305; Thu, 03 Sep 2020 06:53:22 -0700 (PDT) Date: Thu, 3 Sep 2020 14:52:54 +0100 In-Reply-To: <20200903135307.251331-1-ascull@google.com> Message-Id: <20200903135307.251331-6-ascull@google.com> Mime-Version: 1.0 References: <20200903135307.251331-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH v3 05/18] KVM: arm64: Save chosen hyp vector to a percpu variable From: Andrew Scull To: kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_095326_670012_7DB47416 X-CRM114-Status: GOOD ( 15.44 ) X-Spam-Score: -8.2 (--------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-8.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:f4a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.5 DKIMWL_WL_MED DKIMwl.org - Medium sender 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: linux-arm-kernel@lists.infradead.org, kernel-team@android.com, suzuki.poulose@arm.com, maz@kernel.org, Sudeep Holla , james.morse@arm.com, Andrew Scull , catalin.marinas@arm.com, will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce a percpu variable to hold the address of the selected hyp vector that will be used with guests. This avoids the selection process each time a guest is being entered and can be used by nVHE when a separate vector is introduced for the host. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_hyp.h | 2 ++ arch/arm64/kvm/arm.c | 5 ++++- arch/arm64/kvm/hyp/vhe/switch.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h index 3de99b323061..1e2491da324e 100644 --- a/arch/arm64/include/asm/kvm_hyp.h +++ b/arch/arm64/include/asm/kvm_hyp.h @@ -12,6 +12,8 @@ #include #include +DECLARE_PER_CPU(unsigned long, kvm_hyp_vector); + #define read_sysreg_elx(r,nvh,vh) \ ({ \ u64 reg; \ diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 1af4c77feda2..77fc856ea513 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -47,6 +47,7 @@ __asm__(".arch_extension virt"); #endif DEFINE_PER_CPU(struct kvm_host_data, kvm_host_data); +DEFINE_PER_CPU(unsigned long, kvm_hyp_vector); static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); /* The VMID used in the VTTBR */ @@ -1276,7 +1277,7 @@ static void cpu_init_hyp_mode(void) pgd_ptr = kvm_mmu_get_httbr(); hyp_stack_ptr = __this_cpu_read(kvm_arm_hyp_stack_page) + PAGE_SIZE; - vector_ptr = (unsigned long)kvm_get_hyp_vector(); + vector_ptr = __this_cpu_read(kvm_hyp_vector); /* * Call initialization code, and switch to the full blown HYP code. @@ -1309,6 +1310,8 @@ static void cpu_hyp_reinit(void) cpu_hyp_reset(); + __this_cpu_write(kvm_hyp_vector, (unsigned long)kvm_get_hyp_vector()); + if (is_kernel_in_hyp_mode()) kvm_timer_init_vhe(); else diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index 835c2dfc7a9f..7e99a7183320 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -59,7 +59,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu) write_sysreg(val, cpacr_el1); - write_sysreg(kvm_get_hyp_vector(), vbar_el1); + write_sysreg(__this_cpu_read(kvm_hyp_vector), vbar_el1); } NOKPROBE_SYMBOL(__activate_traps);