Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5254842imm; Wed, 12 Sep 2018 03:28:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ5WC6keUydLHYeWTSG84pn4FfQPki1TyRWE5+Xy1l1hju7nA9HyRcPtG+tB6PN2DtD0PmD X-Received: by 2002:a63:eb53:: with SMTP id b19-v6mr1414723pgk.371.1536748133967; Wed, 12 Sep 2018 03:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536748133; cv=none; d=google.com; s=arc-20160816; b=RRWxZZtzAiZtKcaD/hWeHBrLX6wrSp+BjAnuSDcbtluTiL1ogzRtOVgXos1KX9B9yN dXaY3x5LjX/GUAAqNpmnCIZI7mxqk/QtuQEjB4OYPlLYpLuiuonKEbH68C0IxGs2uhyz S/1UYkhMtoDfzHVEprA0AIrAjgqvJ7MmoVMkh47K7grrXoPdokPRJKH1DpdY9fXZXXS+ WGDLC/tV4SJ33nC5oP+Qe5Os2gMwrmhubx7fl9ae24HVoEy2G4hjcaTTjpmldXoXruxG 7lzXoxGZyVQmKDnDZooTvD5pT2Df9FO9l6aSBbo5dhawIMcVR8fODP+nryr9x2gF5pY4 WbyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=mLUKDq/YeXtQTPM3yFy9L7BBbPsdmXuNmRsBuvFh3jA=; b=Lk4NDtolIiwaS4OpbMUeYLoYTlED/nTzc/iZ8lrXx1BGpmp036O4V/prmrW0Z6Doo7 PS29efFxOOip3dt/vRKHcR1GAF8eYMwk3OrOWlKSVGjgXIyzvI8O5c8lyr4ENBkka2iI 0GFFXQNzjmKZA1l7tNDQjergweP7Zh84kb4xIUiTPgQK/Yi1sirm4u7SWOK1jbUo7Fyx o+n7m5NvS7mJZj7mLGrS6TQq1j4FI2r7J3W88gXdyUrdiWTvESjHGYzi+jF+jDCDS18R cgs717qMIYzbG8N5ghfg0YMxDreOYI7L06nCMVvSwGo/m8NiTXWbauO+GJA0xWlhZ6YG NuuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8-v6si660580pli.355.2018.09.12.03.28.38; Wed, 12 Sep 2018 03:28:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbeILPcT (ORCPT + 99 others); Wed, 12 Sep 2018 11:32:19 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbeILPcS (ORCPT ); Wed, 12 Sep 2018 11:32:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E66BA7A9; Wed, 12 Sep 2018 03:28:24 -0700 (PDT) Received: from [10.4.12.81] (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 42C883F614; Wed, 12 Sep 2018 03:28:22 -0700 (PDT) Subject: Re: [PATCH v5 02/27] arm64: cpufeature: Use alternatives for VHE cpu_enable To: Julien Thierry , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, mark.rutland@arm.com, christoffer.dall@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Suzuki K Poulose References: <1535471497-38854-1-git-send-email-julien.thierry@arm.com> <1535471497-38854-3-git-send-email-julien.thierry@arm.com> From: James Morse Message-ID: <1d425320-aed3-b949-1ec5-f378248aac4d@arm.com> Date: Wed, 12 Sep 2018 11:28:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1535471497-38854-3-git-send-email-julien.thierry@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Julien, On 28/08/18 16:51, Julien Thierry wrote: > The cpu_enable callback for VHE feature requires all alternatives to have > been applied. This prevents applying VHE alternative separately from the > rest. > > Use an alternative depending on VHE feature to know whether VHE > alternatives have already been applied. > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 1e433ac..3bc1c8b 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1022,8 +1024,15 @@ static void cpu_copy_el2regs(const struct arm64_cpu_capabilities *__unused) > * that, freshly-onlined CPUs will set tpidr_el2, so we don't need to > * do anything here. > */ > - if (!alternatives_applied) > - write_sysreg(read_sysreg(tpidr_el1), tpidr_el2); > + asm volatile(ALTERNATIVE( > + "mrs %0, tpidr_el1\n" > + "msr tpidr_el2, %0", > + "nop\n" > + "nop", > + ARM64_HAS_VIRT_HOST_EXTN) > + : "+r" (tmp) > + : > + : "memory"); > } > #endif Catalin's preference was to keep this all in C: https://patchwork.kernel.org/patch/10007977/ , for which we need to know if 'the' alternative has been applied. I suspect there may be more registers in this list if we have to switch to another EL2 register using alternatives. (but I don't have an example). Could we make 'alternatives_applied' a macro that takes the cap as an argument? Thanks, James