Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7257327imm; Tue, 28 Aug 2018 08:53:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYiV/jCdTMbF/7wICbYIJBWtvo73HD78ab/njYjnjU7MgMje6x1jnXgYF/5dtm9u4w82t+i X-Received: by 2002:a62:49d5:: with SMTP id r82-v6mr2174907pfi.245.1535471607638; Tue, 28 Aug 2018 08:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535471607; cv=none; d=google.com; s=arc-20160816; b=1Hjq1NqMfNLnXSnGpUuX7zDu+yDYVTqJdcJskVeypy1RVOjiA8Wiv0AwzPKvk0UINM 3Tq7x3sFEWoGA/BMFx0roHsEQL2vVr0TW9KdxnkZS7b1Ahb8Pzhz2ysPHIitcIQpNPZ/ y5XBNVjDYGKb61LHnO7vsmeAAviDO+RZYdvQFPqes3xzij2noXhgIP6k+2MWZUT/tJjC pog/cEGomm4sX87iZjSQPS6pTjqbQfC8kY72Dvzpk1dUcpywHP6orRH+KkkFo+9BWncv p8LA+UwnF9Qy1R/hr5wfI/jZZSt13rUW55O+GJ20AhW4DJ9ZBn55iB3pVWSCk2RZF2XH yfnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2FnpO4LXFE6ptlT9T4SJIGdOvS+HIQqDEtJH1x/Qepg=; b=PkPLVP1rwMKnJowG0LcBJJ4MEeEIrLenDn6K1hkuiROY465PtVCS2VHRKtpNmnMzOo 08iPEKA0VejiQES2ZCRhLoSaD0f+18nxB0ER5JmCVaHFHULAeSciYLfeof+R3pJ9NRXm 6Dt7N3XHAkn37axGo0kNrL8HGPUnyGUI/jGOLZzEFTEWdwBqOjzsy7TQw9hpT4e8zJbG jb9kR3OCzgXC7icpW7VuSGVCGdDkvuW2hyshAlWfch96RPhSCFn/URTpBlKCIS70W1mt aYPDp/4jY9QqRImY4RovLw8pAuz31kk7pUlHfJeOs2lfk5Qn4QIooTR+ml974Ux3ERfQ d8RA== 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 q17-v6si1331433pfi.183.2018.08.28.08.53.12; Tue, 28 Aug 2018 08:53:27 -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 S1727305AbeH1ToL (ORCPT + 99 others); Tue, 28 Aug 2018 15:44:11 -0400 Received: from foss.arm.com ([217.140.101.70]:40920 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbeH1ToJ (ORCPT ); Tue, 28 Aug 2018 15:44:09 -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 A444A15BF; Tue, 28 Aug 2018 08:51:53 -0700 (PDT) Received: from e112298-lin.Emea.Arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 430903F557; Tue, 28 Aug 2018 08:51:51 -0700 (PDT) From: Julien Thierry To: 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, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Thierry , Suzuki K Poulose , Marc Zyngier , Christoffer Dall Subject: [PATCH v5 02/27] arm64: cpufeature: Use alternatives for VHE cpu_enable Date: Tue, 28 Aug 2018 16:51:12 +0100 Message-Id: <1535471497-38854-3-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535471497-38854-1-git-send-email-julien.thierry@arm.com> References: <1535471497-38854-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Julien Thierry Cc: Catalin Marinas Cc: Will Deacon Cc: Suzuki K Poulose Cc: Marc Zyngier Cc: Christoffer Dall --- arch/arm64/kernel/cpufeature.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 @@ -1014,6 +1014,8 @@ static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int __unused static void cpu_copy_el2regs(const struct arm64_cpu_capabilities *__unused) { + u64 tmp = 0; + /* * Copy register values that aren't redirected by hardware. * @@ -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 -- 1.9.1