From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42741C388F9 for ; Wed, 11 Nov 2020 13:47:37 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 754032074B for ; Wed, 11 Nov 2020 13:47:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="s6qdkedV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 754032074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C049D4B70C; Wed, 11 Nov 2020 08:47:35 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k45sfdjwEazD; Wed, 11 Nov 2020 08:47:34 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9ED354B91D; Wed, 11 Nov 2020 08:47:34 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 55C024B85B for ; Wed, 11 Nov 2020 08:47:33 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cUOSHbhBDuec for ; Wed, 11 Nov 2020 08:47:32 -0500 (EST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 3BBF64B70C for ; Wed, 11 Nov 2020 08:47:32 -0500 (EST) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D74222072C; Wed, 11 Nov 2020 13:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605102451; bh=O75Cb/oSTOVEsh2cfT+C7Cb6UuFAt0jwxEEIDWUu0Yk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s6qdkedV3+4fsv9ewvPeAiOR1c16RxhYCj1bxqVcF8hYBi4cakLSoT6XUMMqSTaN4 CXEY3k1jZuMLQuGBUBc+i5/+4MQxW2NWjIkXf7oYbmQMiG7ZoybazDCyw0dRCQBTjz bk5cbgxOFOFRrOJSG862TzA8ZbBF3FvDVdFJCC+4= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kcqTA-009mCw-Hm; Wed, 11 Nov 2020 13:47:28 +0000 MIME-Version: 1.0 Date: Wed, 11 Nov 2020 13:47:28 +0000 From: Marc Zyngier To: David Brazdil Subject: Re: [PATCH v1 16/24] kvm: arm64: Add offset for hyp VA <-> PA conversion In-Reply-To: <20201109113233.9012-17-dbrazdil@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> <20201109113233.9012-17-dbrazdil@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, qwandor@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, Lorenzo Pieralisi , Andrew Walbran , Catalin Marinas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tejun Heo , Dennis Zhou , Christoph Lameter , Will Deacon , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 2020-11-09 11:32, David Brazdil wrote: > Add a host-initialized constant to KVM nVHE hyp code for converting > between EL2 linear map virtual addresses and physical addresses. > Also add `__hyp_pa` macro that performs the conversion. > > Signed-off-by: David Brazdil > --- > arch/arm64/kvm/arm.c | 15 +++++++++++++++ > arch/arm64/kvm/hyp/nvhe/psci.c | 3 +++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 28e3bc056225..dc7d43d7785a 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1484,6 +1484,20 @@ static inline void hyp_cpu_pm_exit(void) > } > #endif > > +static void init_hyp_physvirt_offset(void) > +{ > + extern s64 kvm_nvhe_sym(hyp_physvirt_offset); > + unsigned long kern_vaddr, hyp_vaddr, paddr; > + > + /* Check that kvm_arm_hyp_percpu_base has been set. */ > + BUG_ON(kvm_arm_hyp_percpu_base[0] == 0); Why is this dependent on the percpu base? Or is that just a convenient symbol? > + > + kern_vaddr = kvm_arm_hyp_percpu_base[0]; > + hyp_vaddr = kern_hyp_va(kern_vaddr); > + paddr = __pa(kern_vaddr); > + CHOOSE_NVHE_SYM(hyp_physvirt_offset) = (s64)paddr - (s64)hyp_vaddr; > +} It feels like this offset could be set at the point where we compute the hyp_va offset in va_layout.c, couldn't it? It would have the advantage of keeping all the ugly VA hacks together. > + > static void init_cpu_logical_map(void) > { > extern u64 kvm_nvhe_sym(__cpu_logical_map)[NR_CPUS]; > @@ -1688,6 +1702,7 @@ static int init_hyp_mode(void) > } > } > > + init_hyp_physvirt_offset(); > init_cpu_logical_map(); > init_psci(); > > diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c > b/arch/arm64/kvm/hyp/nvhe/psci.c > index 82d3b2c89658..b0b5df590ba5 100644 > --- a/arch/arm64/kvm/hyp/nvhe/psci.c > +++ b/arch/arm64/kvm/hyp/nvhe/psci.c > @@ -16,6 +16,9 @@ > /* Config options set by the host. */ > u32 kvm_host_psci_version = PSCI_VERSION(0, 0); > u32 kvm_host_psci_function_id[PSCI_FN_MAX]; > +s64 hyp_physvirt_offset; > + > +#define __hyp_pa(x) ((phys_addr_t)((x)) + hyp_physvirt_offset) > > static u64 get_psci_func_id(struct kvm_cpu_context *host_ctxt) > { Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 507ACC5517A for ; Wed, 11 Nov 2020 13:48:40 +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 CC9B12074B for ; Wed, 11 Nov 2020 13:48:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AO1S4KI0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="s6qdkedV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC9B12074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cadZQj5z/C2/Z7+Jy5tRp+/CfSlFqSa8Ykik64Y99ak=; b=AO1S4KI0JYQNbWwkU5WEV5Nzf LJNVW1qByhZ1QbGpC7aA2KgJpGNdLM+9Uren359nrbJn1S9WWf+HMlsN3zQXC/WoedjzPs/2OYdeY M4ahijFy+L4nLSp46RG3GNFpGdPNUYWLbbCLidw1nu6PjWvDZ26E7RpVrt3vLGPBi49mOd2mf/9p+ KZHXvzIa9a0LB3YhEGlgquNqIUVkpgHMv3xIU+w9KHYmygqFKakEFywgR3H9VJd9lWjjaZMp9TI2Q SAe+FZZbIHxBSS50cncbTexa6LcnINm4aeUuF5fGkUB5bxmdlNF0dJkJk+f2x1lBREjNTkQBa9SdO 8BqP5t9Nw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcqTG-0000Py-S8; Wed, 11 Nov 2020 13:47:34 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcqTE-0000PK-5l for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 13:47:33 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D74222072C; Wed, 11 Nov 2020 13:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605102451; bh=O75Cb/oSTOVEsh2cfT+C7Cb6UuFAt0jwxEEIDWUu0Yk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s6qdkedV3+4fsv9ewvPeAiOR1c16RxhYCj1bxqVcF8hYBi4cakLSoT6XUMMqSTaN4 CXEY3k1jZuMLQuGBUBc+i5/+4MQxW2NWjIkXf7oYbmQMiG7ZoybazDCyw0dRCQBTjz bk5cbgxOFOFRrOJSG862TzA8ZbBF3FvDVdFJCC+4= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kcqTA-009mCw-Hm; Wed, 11 Nov 2020 13:47:28 +0000 MIME-Version: 1.0 Date: Wed, 11 Nov 2020 13:47:28 +0000 From: Marc Zyngier To: David Brazdil Subject: Re: [PATCH v1 16/24] kvm: arm64: Add offset for hyp VA <-> PA conversion In-Reply-To: <20201109113233.9012-17-dbrazdil@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> <20201109113233.9012-17-dbrazdil@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, qwandor@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_084732_395808_6BCC1057 X-CRM114-Status: GOOD ( 21.99 ) 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: Mark Rutland , kernel-team@android.com, Lorenzo Pieralisi , Andrew Walbran , Suzuki K Poulose , Catalin Marinas , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Tejun Heo , Dennis Zhou , Christoph Lameter , Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry , Andrew Scull Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-11-09 11:32, David Brazdil wrote: > Add a host-initialized constant to KVM nVHE hyp code for converting > between EL2 linear map virtual addresses and physical addresses. > Also add `__hyp_pa` macro that performs the conversion. > > Signed-off-by: David Brazdil > --- > arch/arm64/kvm/arm.c | 15 +++++++++++++++ > arch/arm64/kvm/hyp/nvhe/psci.c | 3 +++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 28e3bc056225..dc7d43d7785a 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1484,6 +1484,20 @@ static inline void hyp_cpu_pm_exit(void) > } > #endif > > +static void init_hyp_physvirt_offset(void) > +{ > + extern s64 kvm_nvhe_sym(hyp_physvirt_offset); > + unsigned long kern_vaddr, hyp_vaddr, paddr; > + > + /* Check that kvm_arm_hyp_percpu_base has been set. */ > + BUG_ON(kvm_arm_hyp_percpu_base[0] == 0); Why is this dependent on the percpu base? Or is that just a convenient symbol? > + > + kern_vaddr = kvm_arm_hyp_percpu_base[0]; > + hyp_vaddr = kern_hyp_va(kern_vaddr); > + paddr = __pa(kern_vaddr); > + CHOOSE_NVHE_SYM(hyp_physvirt_offset) = (s64)paddr - (s64)hyp_vaddr; > +} It feels like this offset could be set at the point where we compute the hyp_va offset in va_layout.c, couldn't it? It would have the advantage of keeping all the ugly VA hacks together. > + > static void init_cpu_logical_map(void) > { > extern u64 kvm_nvhe_sym(__cpu_logical_map)[NR_CPUS]; > @@ -1688,6 +1702,7 @@ static int init_hyp_mode(void) > } > } > > + init_hyp_physvirt_offset(); > init_cpu_logical_map(); > init_psci(); > > diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c > b/arch/arm64/kvm/hyp/nvhe/psci.c > index 82d3b2c89658..b0b5df590ba5 100644 > --- a/arch/arm64/kvm/hyp/nvhe/psci.c > +++ b/arch/arm64/kvm/hyp/nvhe/psci.c > @@ -16,6 +16,9 @@ > /* Config options set by the host. */ > u32 kvm_host_psci_version = PSCI_VERSION(0, 0); > u32 kvm_host_psci_function_id[PSCI_FN_MAX]; > +s64 hyp_physvirt_offset; > + > +#define __hyp_pa(x) ((phys_addr_t)((x)) + hyp_physvirt_offset) > > static u64 get_psci_func_id(struct kvm_cpu_context *host_ctxt) > { Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4C02C388F9 for ; Wed, 11 Nov 2020 13:48:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BD0320795 for ; Wed, 11 Nov 2020 13:48:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="s6qdkedV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727164AbgKKNsL (ORCPT ); Wed, 11 Nov 2020 08:48:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:35958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbgKKNrb (ORCPT ); Wed, 11 Nov 2020 08:47:31 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D74222072C; Wed, 11 Nov 2020 13:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605102451; bh=O75Cb/oSTOVEsh2cfT+C7Cb6UuFAt0jwxEEIDWUu0Yk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s6qdkedV3+4fsv9ewvPeAiOR1c16RxhYCj1bxqVcF8hYBi4cakLSoT6XUMMqSTaN4 CXEY3k1jZuMLQuGBUBc+i5/+4MQxW2NWjIkXf7oYbmQMiG7ZoybazDCyw0dRCQBTjz bk5cbgxOFOFRrOJSG862TzA8ZbBF3FvDVdFJCC+4= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kcqTA-009mCw-Hm; Wed, 11 Nov 2020 13:47:28 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 11 Nov 2020 13:47:28 +0000 From: Marc Zyngier To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , Andrew Walbran , kernel-team@android.com Subject: Re: [PATCH v1 16/24] kvm: arm64: Add offset for hyp VA <-> PA conversion In-Reply-To: <20201109113233.9012-17-dbrazdil@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> <20201109113233.9012-17-dbrazdil@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, qwandor@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-09 11:32, David Brazdil wrote: > Add a host-initialized constant to KVM nVHE hyp code for converting > between EL2 linear map virtual addresses and physical addresses. > Also add `__hyp_pa` macro that performs the conversion. > > Signed-off-by: David Brazdil > --- > arch/arm64/kvm/arm.c | 15 +++++++++++++++ > arch/arm64/kvm/hyp/nvhe/psci.c | 3 +++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 28e3bc056225..dc7d43d7785a 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1484,6 +1484,20 @@ static inline void hyp_cpu_pm_exit(void) > } > #endif > > +static void init_hyp_physvirt_offset(void) > +{ > + extern s64 kvm_nvhe_sym(hyp_physvirt_offset); > + unsigned long kern_vaddr, hyp_vaddr, paddr; > + > + /* Check that kvm_arm_hyp_percpu_base has been set. */ > + BUG_ON(kvm_arm_hyp_percpu_base[0] == 0); Why is this dependent on the percpu base? Or is that just a convenient symbol? > + > + kern_vaddr = kvm_arm_hyp_percpu_base[0]; > + hyp_vaddr = kern_hyp_va(kern_vaddr); > + paddr = __pa(kern_vaddr); > + CHOOSE_NVHE_SYM(hyp_physvirt_offset) = (s64)paddr - (s64)hyp_vaddr; > +} It feels like this offset could be set at the point where we compute the hyp_va offset in va_layout.c, couldn't it? It would have the advantage of keeping all the ugly VA hacks together. > + > static void init_cpu_logical_map(void) > { > extern u64 kvm_nvhe_sym(__cpu_logical_map)[NR_CPUS]; > @@ -1688,6 +1702,7 @@ static int init_hyp_mode(void) > } > } > > + init_hyp_physvirt_offset(); > init_cpu_logical_map(); > init_psci(); > > diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c > b/arch/arm64/kvm/hyp/nvhe/psci.c > index 82d3b2c89658..b0b5df590ba5 100644 > --- a/arch/arm64/kvm/hyp/nvhe/psci.c > +++ b/arch/arm64/kvm/hyp/nvhe/psci.c > @@ -16,6 +16,9 @@ > /* Config options set by the host. */ > u32 kvm_host_psci_version = PSCI_VERSION(0, 0); > u32 kvm_host_psci_function_id[PSCI_FN_MAX]; > +s64 hyp_physvirt_offset; > + > +#define __hyp_pa(x) ((phys_addr_t)((x)) + hyp_physvirt_offset) > > static u64 get_psci_func_id(struct kvm_cpu_context *host_ctxt) > { Thanks, M. -- Jazz is not dead. It just smells funny...