Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1252124ybt; Thu, 25 Jun 2020 01:13:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1kHfsbEVO6ngP1+kt1KXXSg2XgzBZUOFcVeBDLIpOiSvPN/g6xvma9LhsbWK5B7TuQqMh X-Received: by 2002:a17:906:6d15:: with SMTP id m21mr18297456ejr.209.1593072838522; Thu, 25 Jun 2020 01:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593072838; cv=none; d=google.com; s=arc-20160816; b=YPi9aShouS772kqOo0wiQQTNgbh3ErXoCqrRmVivjDyrI831MnPP6RpKu+oHgB/Cf1 5HfJvCZ9H/4nNEE8fLji7BeCElpAVk6gCJYAG5UvfNDbhl7u9/yp6DcB0f7HLtxdBLGU fmtPGMNMeK/pw9cUYlxFXXMvQWYLE7FumCJZyOfyR3mX4jdNP/7TTRzcCrcRxfR8JJjZ L+/8kwyrU+BGmWn6wFRJqA7v9Ynp9cMSV6YluibluHo5DC+X0de9wNnLk8aB2pqIInRE OsnNjeIoVbP8aGz6o7e5mp5FIsOkzkA3xvjsDvijvX+vCS1qGOPrMqNh23AEL7CHrGds 0KXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=t3fSEvStNbu7Ju1yXEQ9C/s8OGYnGloMnMhcMQL9ctI=; b=f25O1DjJwreZRi59QwiFv/zuSmOMfGo9fGAIFLkpFVgI0fllPixo1viyPdjcJOweZR DiL26dxIep6/qNTsd1tfRD6daIbgF9+wFJJmg1kqn46OVon5PqAtfNeM8bsaZvAre5o3 O6tusiSZZq0uis7EVoi08ujLFMawHRMasTNqkQCuntRMPRafG3RJdelqbIS30MBOEiSK PlozYiYgVsniY181Ch91u+unpQRD6dEemsGPDwPSw3xDlBM9T/ELuQf6gBHaaG4qFQFN 8vUvMkMn3hSZAE2wJPizKiB1G07woqpZD9Oz+E/pMh3H/zUJrv0qXPvCMzIv5OrRiEn7 XNFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wajtMIDF; 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 rn3si679421ejb.165.2020.06.25.01.13.34; Thu, 25 Jun 2020 01:13:58 -0700 (PDT) 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=wajtMIDF; 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 S2390491AbgFYIMx (ORCPT + 99 others); Thu, 25 Jun 2020 04:12:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:38558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgFYIMx (ORCPT ); Thu, 25 Jun 2020 04:12:53 -0400 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 4FFDB2067D; Thu, 25 Jun 2020 08:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593072772; bh=hFDSF6sOyHk09xBbSGXCSJ7Em905+sQZ3Jw5UdSgHV8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wajtMIDFxtK5LLIDrbKmwtzS9/M5CgCQN4zTXbE8/DDNcLXzi1STfYFv+j/nOtPfH ZFDQkMzjJ20GLc/xMuQOC0szrItUDL/GJ315KGMpP8iDpI40ybpQi787V/BTBo9yYP 76PYC2BW92IQ47rgvV3RC2Jmg+W+2lEEg8y5qn2c= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1joN06-006HRd-Mb; Thu, 25 Jun 2020 09:12:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 25 Jun 2020 09:12:50 +0100 From: Marc Zyngier To: David Brazdil Cc: Will Deacon , Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, kernel-team@android.com Subject: Re: [PATCH v3 05/15] arm64: kvm: Build hyp-entry.S separately for VHE/nVHE In-Reply-To: <20200622102041.myve2otyoj5q7j5s@google.com> References: <20200618122537.9625-1-dbrazdil@google.com> <20200618122537.9625-6-dbrazdil@google.com> <5029f8fb4a7816e11de7469c09347c79@kernel.org> <20200622102041.myve2otyoj5q7j5s@google.com> User-Agent: Roundcube Webmail/1.4.5 Message-ID: <491f3c8877897a4ac69d69fb7354c1cb@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, will@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On 2020-06-22 11:20, David Brazdil wrote: > Hi Marc, > >> > - void *dst = lm_alias(__bp_harden_hyp_vecs + slot * SZ_2K); >> > + char *vec = has_vhe() ? __bp_harden_hyp_vecs >> > + : kvm_nvhe_sym(__bp_harden_hyp_vecs); >> >> If we get this construct often, then something that abstracts >> the uggliness of the symbol duality would be nice... > > Agreed, I do hope that this will end up being limited to finding the > address of > the hyp-init vector once EL2 becomes self-contained. Even this vector > selection > can be done in EL2 where the symbol duality does not exist. > If we were to hide it, there is a trade off between code "elegance" and > clarity > of what's happening under the hood. I was thinking we could extract > this > `has_vhe() ? foo : __kvm_nvhe_foo` as a `#define foo` but I do worry > that > anybody debugging this code would be cursing my name. I would say that whoever is debugging this code better have an understanding of how things are supposed to work. Given that this is only a handful of people so far, I think your name is safe! ;-) > It would also not work > with other macros that take symbol names, notably kvm_ksym_ref. But > that can be > rewritten to accept a pointer instead. The more verbose but less magic > approach > is to have a bunch of different helpers for various situations, eg. > __pa_symbol_nvhe. What would be your preference? I'd be happy with the (maybe temporary) magic approach. It helps reasoning about things, and makes the transition smoother. Yes, bugs could crop up there, but given the static nature of obtaining a symbol's address, I'm fairly confident we'll get it right. The same cannot be said about pointers though. Thanks, M. -- Jazz is not dead. It just smells funny...