From patchwork Wed Jun 9 00:44:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12308453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05BD0C48BCF for ; Wed, 9 Jun 2021 00:44:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 84AE5613C3 for ; Wed, 9 Jun 2021 00:44:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84AE5613C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F49E6B006E; Tue, 8 Jun 2021 20:44:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 108086B0070; Tue, 8 Jun 2021 20:44:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFD436B0071; Tue, 8 Jun 2021 20:44:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id AE05F6B006E for ; Tue, 8 Jun 2021 20:44:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 583186D7D for ; Wed, 9 Jun 2021 00:44:24 +0000 (UTC) X-FDA: 78232339248.08.14AD885 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf13.hostedemail.com (Postfix) with ESMTP id 8EF44E000263 for ; Wed, 9 Jun 2021 00:44:20 +0000 (UTC) Received: by mail-qt1-f180.google.com with SMTP id l17so12591480qtq.12 for ; Tue, 08 Jun 2021 17:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gWxay37gJuUJcx+nxRsc6EljZGbCG+r7QOiRM4oSXXw=; b=XVTcMoxKQNpHAERlWFtpAWIkpNZdrKfflATOF4mJVjZ28fHCHXALrlRZKavWPEu/T4 F7rPyv0tFMiwq5YDEuNhRpmMxfXTtMrvxs9Uw7ZJhVRfssebxr9BrJIPhEcOVRmmTI8U sl62Z/+mIL4M2AC9o0ZMC/nj4a1udl7Qs6wM1kkgMmVvCApnCJBmSS1SJHjhs2ScpdXV 7A3Qe/Hs3AtbOFDmrbaym/wcQ10LG5aVf43LkrUVamE0ldR7HN/v1QUOgAsD6qAkKC/7 JzYTXc0mMucVZfhRyf6Qglt3tT+VeDNLE7o5/g3BtEPK7m+NwtIi2r2sWspJut84Gwlm ex2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gWxay37gJuUJcx+nxRsc6EljZGbCG+r7QOiRM4oSXXw=; b=QN4++SpI0UDT716Cs69dBwEDmeCq7L+4krBRdnzHh8NzXplHhXQjNpCVC9yKnrEDed ca4VWyNDafL61n6Fkd7GxqeO8/H5/EAmYqWk/nkI/0Zfc0VahxX+R6HPDpZfrWIJjnHj veYrNCeWWd40zWfXGy7rCNkNkPNfvVmoqMK27SNePYRdBHO7O42HCVTlj2T/cMBIb91O K0XZ5Po++SWfqrg4sQ1W6oFJpIq5BjaHDkJe4HIixb5Per+q6aVYYlskqaZTlMnj/B2m VCkn8s+o/xIK8S0B7qwws13MJH9u6+ux7JlB0UtRSUat60hJLMkYg0sLVDSv9XJEt/j8 z+mA== X-Gm-Message-State: AOAM532XkaRsezRMFjIEiExrxBriZ602GRxP1fJXiSMHr3LcO9uXqXvs AHLD5+oYtntN91Q5b2V9Zniq6g== X-Google-Smtp-Source: ABdhPJzeGFOwUM6YKiMqoMb6gKBWjIc1V8rc2G8wqLoy7ugeIsvgOGfXCBZV0ZKPy+a1WBOPcxSuAQ== X-Received: by 2002:ac8:684:: with SMTP id f4mr23920164qth.79.1623199463270; Tue, 08 Jun 2021 17:44:23 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id n194sm12869011qka.66.2021.06.08.17.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 17:44:22 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com Subject: [PATCH v15 01/15] arm64: kernel: add helper for booted at EL2 and not VHE Date: Tue, 8 Jun 2021 20:44:05 -0400 Message-Id: <20210609004419.936873-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609004419.936873-1-pasha.tatashin@soleen.com> References: <20210609004419.936873-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8EF44E000263 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=XVTcMoxK; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-Stat-Signature: qe71eu6gutfaswxbmd7htnbo87r9dx6k X-HE-Tag: 1623199460-80916 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replace places that contain logic like this: is_hyp_mode_available() && !is_kernel_in_hyp_mode() With a dedicated boolean function is_hyp_nvhe(). This will be needed later in kexec in order to sooner switch back to EL2. Suggested-by: James Morse Signed-off-by: Pavel Tatashin --- arch/arm64/include/asm/virt.h | 5 +++++ arch/arm64/kernel/cpu-reset.h | 3 +-- arch/arm64/kernel/hibernate.c | 2 +- arch/arm64/kernel/sdei.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h index 7379f35ae2c6..a9457e96203c 100644 --- a/arch/arm64/include/asm/virt.h +++ b/arch/arm64/include/asm/virt.h @@ -128,6 +128,11 @@ static __always_inline bool is_protected_kvm_enabled(void) return cpus_have_final_cap(ARM64_KVM_PROTECTED_MODE); } +static inline bool is_hyp_nvhe(void) +{ + return is_hyp_mode_available() && !is_kernel_in_hyp_mode(); +} + #endif /* __ASSEMBLY__ */ #endif /* ! __ASM__VIRT_H */ diff --git a/arch/arm64/kernel/cpu-reset.h b/arch/arm64/kernel/cpu-reset.h index 9a7b1262ef17..81b3d0fe7a63 100644 --- a/arch/arm64/kernel/cpu-reset.h +++ b/arch/arm64/kernel/cpu-reset.h @@ -20,8 +20,7 @@ static inline void __noreturn __nocfi cpu_soft_restart(unsigned long entry, { typeof(__cpu_soft_restart) *restart; - unsigned long el2_switch = !is_kernel_in_hyp_mode() && - is_hyp_mode_available(); + unsigned long el2_switch = is_hyp_nvhe(); restart = (void *)__pa_symbol(function_nocfi(__cpu_soft_restart)); cpu_install_idmap(); diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index b1cef371df2b..42b5d8105ab9 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -49,7 +49,7 @@ extern int in_suspend; /* Do we need to reset el2? */ -#define el2_reset_needed() (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) +#define el2_reset_needed() (is_hyp_nvhe()) /* temporary el2 vectors in the __hibernate_exit_text section. */ extern char hibernate_el2_vectors[]; diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c index 2c7ca449dd51..cf06929c44e3 100644 --- a/arch/arm64/kernel/sdei.c +++ b/arch/arm64/kernel/sdei.c @@ -200,7 +200,7 @@ unsigned long sdei_arch_get_entry_point(int conduit) * dropped to EL1 because we don't support VHE, then we can't support * SDEI. */ - if (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) { + if (is_hyp_nvhe()) { pr_err("Not supported on this hardware/boot configuration\n"); goto out_err; }