Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp365936pxb; Wed, 11 Nov 2020 05:50:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxI6QoI1cvHGc7raYe3QJXRZ9p0WOx9Tk4NJLNXp5k7cQbAWyjgvUPZ82k/NvSEgUIYxuQ7 X-Received: by 2002:a17:906:d1c7:: with SMTP id bs7mr16485104ejb.434.1605102601895; Wed, 11 Nov 2020 05:50:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605102601; cv=none; d=google.com; s=arc-20160816; b=Jti6hfJpEFo0pNpLr6Z5O31Pqk+NZDfpSkgKHH8FIJp0cCXL0fBmqsY4+A00TkDYjS 0240qjM/UY7dbZctBQ2kB+kAHWHo/d6ePBWU/b89iN2QRInX7IhRwce6VTgILdUmz9n3 Y7xgWghxY1F78dhkz9PWk8fyRlIruVrSziouI8ERecIA88i3YJuX4FMjI8MqYU0sm98e HqW/8xfcm+h6cbmIEaVEDm2zmg3a2dkOKC4jHZBvdB2SF+HJ12aXiM71PLwycMT9CNea HK5WKf9SB0NCNuASELYXzSGY75IQkjpBUsHDAVvGyGIOp22R6Ujz0BBOH21nIeXcqSCW Rg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=uXOO6ahCkYmp59CYBCz/9TV9Rk3glGF4QIrnm87FL0A=; b=WLApP8rWNCr9BaXb2jxLPITzCFpNiRQDaPqSLDVpwW474flFCVVEC7TAi12TiI/i49 ayajH//lU9L0T4GYvd3EBGgdhO78YjToa3LEdHPzGawFOqNSTtJlVOk8jWKWvNjWug0J 0ydfm+CMvP07sHOIxu3Io3CEUH4qfC6EbS1YQv5NwoOPBd7uHb3A3KYJczekMRnBNEIt lqEmrBYcmmseyEQCAUA+mfaqVgGIB8pPK+szUmvn6MPXcfSD4fWph9/zm/XuMlthhdmJ vfnbZ7EY28V85fkoskvlGpt56cO8U5OScAtxyDipfcPBcndhAmEqjN2J4xm0VaOr3SdB j7dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s6qdkedV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si1438897edp.246.2020.11.11.05.49.38; Wed, 11 Nov 2020 05:50:01 -0800 (PST) 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=@kernel.org header.s=default header.b=s6qdkedV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727089AbgKKNsJ (ORCPT + 99 others); Wed, 11 Nov 2020 08:48:09 -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...