From patchwork Tue Sep 15 10:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11776137 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 33AC4618 for ; Tue, 15 Sep 2020 11:00:02 +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 25F6C218AC for ; Tue, 15 Sep 2020 11:00:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NkUyEAe0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="lY3tJHNQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25F6C218AC 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=Po0ySMmXkzfa4LxrZrkW3fGQHmFo0WQe2fQxEafREVw=; b=NkUyEAe00vQKrjdAoXkpoWHjy DuWWv/dVzEMuEEysm8j6NWl6RoFiRZEdgt0iYogYNC13219KWs+5cO9zJdK93ReoC3EljxHo4gCV6 Y7VHMYQ4Mh3xkMbMpvWNzLIF9YJCoP554ZfwyfbBBUlqld5d/9tLQlBMA8Q2PoC0/KN/3wdeddVkg RSN1LOD9dZnuS43D98qYP0XBnZ3jHHmYBCdsm5RhPb1a7Uv6o8hCXHLA+5UMfqXP1oRZbAwJLmehF eSHOykYwrsjgNOskljzdvDYD7vG1stlRxSW1vy3gVj8NK2xNIdB9+HkecN49seT577RjamKzaWAiU Eeji4yWEQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8dQ-0004nF-NH; Tue, 15 Sep 2020 10:56:28 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8UJ-0000os-Lu for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 10:47:04 +0000 Received: by mail-qt1-x849.google.com with SMTP id g1so2355811qtc.22 for ; Tue, 15 Sep 2020 03:47:01 -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=kK0Nkqlx97phlNkNVM0H3UdgORvFyISMUeZJPb6S9IQ=; b=lY3tJHNQX/YeaIb4NFdcRGBG4mX+8bQEy/7baEu+cgNLvQYxXRSEL+RcF5YHSwapVV o/CPDPYRrq9bilK03YOvO4S+o8+HEt6NRGfUnNHnbUuGNT38lCG91d7U99HzutLeLT4e hsxoC6XG9O4pb4cVFdxUH2ehUyEnfMSpL0IP8zyVQ206fjOxJgPGh1is+nVJSee2hppi Y7uwjqGtn2vBcLeUGcjOa0Ei+Dtk9IaUwffKfi4iKZCVSNpT4+KMwDg4q5X4NDZKKarn f+HMxSJa28/mIH2K80wbQjqPlqb2xxDwL5viENVIE2DL1sdFkm/GE4WmCcL8H2tMG9sJ NFpg== 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=kK0Nkqlx97phlNkNVM0H3UdgORvFyISMUeZJPb6S9IQ=; b=CF9+TijXNetw7dQOvSD/C7TgejKdc1AGvSw1We+NK+S3DydDHKudUzO/LAc9eIg1ZR VrNY+iaS9qbUqfLLITsbFpZ74AmPrbZQUgI++KA+e7RL9oUlc/khDGL6NWlmO8YnLzNH Ggeyd/+oVwvRWFp0Qh5YUVLHhM3xtFv20xSkfg0wr0PWFYZblBFcCA/14mVSWkEUdAfp cJf8ilvxT2rddfJCDl1NyNegUaOy34/PG0LgLgmUCOUqqLA7alM/LKaLM8SPxjRTuqbl HQgUhjhgc2lvTC0KJz+FXxgRvlO1wR2yF8DdATC3r4HNb3l4vhL8u2m3BxaThUxHJmra wJWQ== X-Gm-Message-State: AOAM531jbkVgif03ik5mZDj+dbOv9djbQxq72k4IK2QEyz00xgElO5RJ qu1XLg/iG+vvUiyl5ZRvrOGQ2meYzXA= X-Google-Smtp-Source: ABdhPJz1U5mFw04t/oZC/DN9ZXlVqPKd3B9ZGRx4Wei7AHsDj/ao/1HT3T88tmF9Nxqrv7NyykCCnUDC/rk= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:ad4:5a0e:: with SMTP id ei14mr2479891qvb.15.1600166819429; Tue, 15 Sep 2020 03:46:59 -0700 (PDT) Date: Tue, 15 Sep 2020 11:46:29 +0100 In-Reply-To: <20200915104643.2543892-1-ascull@google.com> Message-Id: <20200915104643.2543892-6-ascull@google.com> Mime-Version: 1.0 References: <20200915104643.2543892-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v4 05/19] 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-20200915_064703_764618_942C5389 X-CRM114-Status: GOOD ( 15.69 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 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:849 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_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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 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 c1fd47557713..b49cf53c11f0 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);