Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp324085pxb; Wed, 11 Nov 2020 04:48:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqAb1LWxRRmbuW5OVXq1sjWZFnvxCc8TIsNJ5MPN/Lj/PxbdY37DTkuYi7QwaKNmP6+a+t X-Received: by 2002:a17:906:65b:: with SMTP id t27mr24536061ejb.74.1605098905340; Wed, 11 Nov 2020 04:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605098905; cv=none; d=google.com; s=arc-20160816; b=Q0oy82OzQ0+AmCES2yVW0rqBTAZSHpZpdirMkcnwPPhCfn8DYscFheftgsilUjpFCW 0wZ9LvLTxZowIjZJH8eh6E9LLD2a2sN4KjQhTqkFnUGCDxBuEII0wUKe7M4k7jwwvFvG 9IpFxzHAj1Nwl8/VLEZjTdXCogH9dZonFy4EN6I4h5/KMw+S5jBEyjWLFQUktKARTpN4 OLRl+zOjoF6Kg9ehTCg3IjwR5uw4HWYpYpVa8b6xuAkaW5D+cCxsOFBeMZXFQOjKYfQK x2hpUbqTg878WKAkyhnHK78U/A4RuifbuB/Opojwh7v/ff2YXZxbTk96eZIprI1mPogq WN1w== 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=Mp6D2vHsFyzOQuQ6Tm7joLU4hnuw7hM3b1jpTKfWnOw=; b=sXvHWuZC+9Q7qVVcLH6A4W0pTj7OkzYtYZZ70cSYipcKUur7cIcqaUsPNhsKvrg24a Tl8zsWP6j63RHbuSpR0+5U9wiLz//Or65aXWbWvguRCmhzhMA8nilh+NIs3SeC+LmjSK zo+6o0Kxf9iZI0MbaDXEJQGEokgoPatuOVZVOw0q+W/lhajVeKwhCIkivqZwcIC9sGkH Yre3IFmfKVp55kxxIK2KFfRGHDJJg6eqIOnSaRopdcXHyA2enxYshvkhyG6Fts8WxOhB 0/r0ja0xUnQrzZcjTAhn6Dj6iV7o0yJVBLENh0VZ63wz6yZ/mN0Pd1uB48hvXEzAajwy 1OUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="r9nWEq3/"; 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 q14si1274591edb.353.2020.11.11.04.48.00; Wed, 11 Nov 2020 04:48:25 -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="r9nWEq3/"; 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 S1726605AbgKKMqf (ORCPT + 99 others); Wed, 11 Nov 2020 07:46:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:48938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgKKMqe (ORCPT ); Wed, 11 Nov 2020 07:46:34 -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 D2AA520709; Wed, 11 Nov 2020 12:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605098793; bh=fgvFar5VH6U4VmS5tTBAQ11UfAbcAq37UA/xmP7e4uI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=r9nWEq3/jfTwQEjDuIXAGQ3H5G3m3fz1i1Uank6++ovoprns/8F8c+AJfmJKnfkV7 U9NlWyNw0S5q4V2xcpf3b2+tlqT2T4LDiaqsi1VnqngsXR8NZmG4TrZwTzJ7CAHd82 DHwKVfdZtvolrjK4/t4Wre1aIEKeFreUOxIC7ckM= 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 1kcpWA-009lDZ-KI; Wed, 11 Nov 2020 12:46:30 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 11 Nov 2020 12:46:30 +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 06/24] kvm: arm64: Support per_cpu_ptr in nVHE hyp code In-Reply-To: <20201111123222.ooevu6nryu3ncphv@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> <20201109113233.9012-7-dbrazdil@google.com> <20201111123222.ooevu6nryu3ncphv@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <52b47a4284aaff2e198385ef9acbe01f@kernel.org> 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-11 12:32, David Brazdil wrote: >> > + >> > + cpu_base_array = kern_hyp_va(&kvm_arm_hyp_percpu_base[0]); >> >> There is no guarantee that this will not generate a PC relative >> addressing, resulting in kern_hyp_va() being applied twice. >> >> Consider using hyp_symbol_addr() instead, which always does the right >> by forcing a PC relative addressing and not subsequently mangling >> the address. >> >> > + this_cpu_base = kern_hyp_va(cpu_base_array[cpu]); >> > + return this_cpu_base - (unsigned long)&__per_cpu_start; >> >> And this is the opposite case: if the compiler generates an absolute >> address, you're toast. Yes, this is just as unlikely, but hey... >> Same remedy should apply. > > Good point, and I'll probably keep forgetting about this in the future. > Now > that all .hyp.text is only executed under hyp page tables, should we > start > thinking about fixing up the relocations? Why not, if you can deal with the hypervisor text being mapped at a random location, and make sure that the kernel doesn't process the relocations for you. This would certainly save us a lot of runtime offsetting (which I'm adding to in a separate series). M. -- Jazz is not dead. It just smells funny...