From patchwork Thu Aug 20 10:34:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11726013 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 AE05313B1 for ; Thu, 20 Aug 2020 10:36:10 +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 84A9320639 for ; Thu, 20 Aug 2020 10:36:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Cpg2qpPD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="OVOsIi24" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84A9320639 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=X20X4/d09BFiJ3x0nvXV1baFoydNEWDAszW+rvVh7jk=; b=Cpg2qpPDDWvWZoflSmD/slRks U2sYy52s9pE+tbpaqJdywDklwcA3Hp2Ep+OvM0MqKaX5ycFkMvJoQBqslxW/XuuajDvTTX/NnDTok bLEDlvrGa+iuT/4UnvmJOJymHL9SyzqgxzGyt2cOie9EiaM6IQJm97z10RaY63hhzEhcpLX3A3BMv MZBTR9hlq342aDERF84Rdo8ZY7Ec/cLoohBKLESE5znY2GfdRhv/IHExgvTXybzR3pbmGSDT5tgx5 LKnPNkond2bgtVDncstw/ulJou58QH8e+7vrsWXEC2CKz9rAahYgSiYGEsiXGfkKngcQxUDOjcKuW UhFA8Tdgw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hvE-00025Y-Cl; Thu, 20 Aug 2020 10:35:52 +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 1k8huw-0001zN-OH for linux-arm-kernel@lists.infradead.org; Thu, 20 Aug 2020 10:35:35 +0000 Received: by mail-qt1-x849.google.com with SMTP id f59so1199536qtb.22 for ; Thu, 20 Aug 2020 03:35:32 -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=37zpMdjcndUFVD4+uS94TLYior1Sf4KsI6kIarwDjl4=; b=OVOsIi243JYWAw6YuRdKFan/r8KFf4/6BdxTaZjT8YwEKwQtJ5r/Z6afR6P88if59N 7NnrzuRZe4avYB6A+Sd1mx6qfnOjuDquokyWWQ5Jb767pbdR/cIbjoL5EDFda1xl2OsD Jr8mthVA/rvXcQjokli2Mji0sTQzKU/OFhSJdJ4Ght+3u9qyNgB3Hua6NJHY8LlpWxSR Y93B9rG5nCUn8j+LaXZbFX1e0jcPiGEAFntoNnvUIY8xw+xD8HXKAja1StYZZeRSUKFr HKyUN0MM7xD76isoBXYEOgFx9gxXIoyG4LztPBn2EyAFa3/dFmT90ZQqnyxbNltIkzZg RZBg== 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=37zpMdjcndUFVD4+uS94TLYior1Sf4KsI6kIarwDjl4=; b=BFFd++Z2StxCKpvrsqVnzlognreXWcx2cJlTZrEdb0CM8X+ZI14WbNLU06/kKVo9Kv 2PMmudiO68Y50k3hGVm7d6QZn4JVPX+FL/8mUiMv8YdT4t1A2r5U0uKRm9oCZs1YcyZz pb80AeSFOAL+sgPkHa1UeEZe5rwxcZYYY1AI3i6rJ+DmKU4iBgldAFOd9ApWxLDAogDo KcFXKmjwLLdaZQSuqeYiJPvAm6nL+Woq8Cnc/2mI/XBID1wA/Vcqjr7tYlHxXTcf3ra0 +bjeLYvVMJMs5+4KtaesMrdizENdQEKeWDu/0YEu6TAPEaEgo85rXf34HSLmY37MN56H Q0HA== X-Gm-Message-State: AOAM5329EN1Ys8vQgSSym3LiCqI2Hr/fMvqoxChm/y2ch64b2HrjW/5c YfcjnqSnDGsicDrWgAdq7ROZB3ucWYs= X-Google-Smtp-Source: ABdhPJzNjftrIqn+OHJCp1q4uT2Q7nzJdUixaBmiasMHtpSaYAECUIJZUnuTb3oQIgpS8hgiVikwnxhxk7Y= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a0c:ec01:: with SMTP id y1mr2212111qvo.167.1597919731182; Thu, 20 Aug 2020 03:35:31 -0700 (PDT) Date: Thu, 20 Aug 2020 11:34:31 +0100 In-Reply-To: <20200820103446.959000-1-ascull@google.com> Message-Id: <20200820103446.959000-6-ascull@google.com> Mime-Version: 1.0 References: <20200820103446.959000-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 05/20] 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-20200820_063534_841812_6193E0ED X-CRM114-Status: GOOD ( 15.22 ) 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] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 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_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.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 6b09c0f3365c..d779814f0da6 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 099bfa78011c..20ee901fd4ff 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);