From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 2146BC4708F for ; Wed, 2 Jun 2021 01:34:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C0563613D1 for ; Wed, 2 Jun 2021 01:34:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0563613D1 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 5E4446B0071; Tue, 1 Jun 2021 21:34:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BB676B0072; Tue, 1 Jun 2021 21:34:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45B6E6B0073; Tue, 1 Jun 2021 21:34:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 10AF86B0071 for ; Tue, 1 Jun 2021 21:34:31 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A116A180AD80F for ; Wed, 2 Jun 2021 01:34:30 +0000 (UTC) X-FDA: 78207063900.12.D42C10D Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf23.hostedemail.com (Postfix) with ESMTP id 446C9A000248 for ; Wed, 2 Jun 2021 01:34:19 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id r11so849247edt.13 for ; Tue, 01 Jun 2021 18:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yzQRMvD+3GTyeQsWjmhKf7su1vPqupNvqasfaYdmnEM=; b=Tlie0Y+iuMMFltqLLt6YrYeS9DGu33VbHvstCQYs0hOXeC8JSYpuPKLjS6qY/pDd7d W7QTp7v8Ma7NUoSNrDNqAwaxaG9AkEwtBZaDJ1ArEdzn+3T6a3w6OKYElLElx/+W7vsP ZuzJq+uZJ+LNJ6GOs7htiUpOUh5L16uZHgLdhRO3w0qIUokTYCUkfKWeWn/NFoe7Sa2/ bUJCGx7Dt43t2aSovWG8oiDfV134+gkAdW3aqBmba8550lahmzQ3ToqQKog9UKi1VhpI LX1Ld2YyU9oExkI5gvEDMBVMtPKNVflrmybQq3ULmADrtL5HsajbOK6y8FyiMshojfVE XRVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yzQRMvD+3GTyeQsWjmhKf7su1vPqupNvqasfaYdmnEM=; b=JTH9Y7eCixZePIkmjo71jxgO3g5Ro4S/YmaIOG8SfGyxm2ojfilbrlcpkwsJ1QZYTk Y7dpxRD2vaSOg9oYBWuCVkfdXj47Ok75jaIjZNo9DkXSjjHgBy/3ZQHorNPpUN1vlGLy tjuMnNmpNHhNBACiUUqEmGSBZAqY/ec9CxvchDTmEcobVu6AYnRKdZfq0F+rqWJl1u6H qbV+7aU5cVw5aOUK2yfYikVeuETPAtZT33V6iWfK3d+uIXQebwAyICIfuxmJwWCYpUqh /eWIZJwzKmOL9R5IiNcUpIzobb/gqewZQ3SkRf+3uc1a0jxSuAKQSoPU5IGui3zBvcGS cDtw== X-Gm-Message-State: AOAM530Vehnfhc8RbI2duoUDpFaWVltCkUwzsvW64KPa46rfUjOifHA6 epcNWqSVZUW3a6XJl3c/DHkDwPBdpyLPfOd6i6X9Kw== X-Google-Smtp-Source: ABdhPJzJBLev2U/cTkcAahBZDqG98LlZAJfadAqq8754ugipQmIGWvT2RI9yxn+JEBFHT9mqfGvTyPSXtsPca+jZRrk= X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr35404936edd.26.1622597667909; Tue, 01 Jun 2021 18:34:27 -0700 (PDT) MIME-Version: 1.0 References: <20210527150526.271941-1-pasha.tatashin@soleen.com> <20210527150526.271941-5-pasha.tatashin@soleen.com> <87pmx52212.wl-maz@kernel.org> In-Reply-To: <87pmx52212.wl-maz@kernel.org> From: Pavel Tatashin Date: Tue, 1 Jun 2021 21:33:52 -0400 Message-ID: Subject: Re: [PATCH 04/18] arm64: kernel: add helper for booted at EL2 and not VHE To: Marc Zyngier Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Will Deacon , Linux ARM , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=Tlie0Y+i; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 446C9A000248 X-Stat-Signature: jaw9y5tw8d53sjwmfe8c6roj8aj8wt1o X-HE-Tag: 1622597659-527026 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: On Tue, Jun 1, 2021 at 8:38 AM Marc Zyngier wrote: > > On Thu, 27 May 2021 16:05:12 +0100, > Pavel Tatashin wrote: > > > > Replace places that contain logic like this: > > is_hyp_mode_available() && !is_kernel_in_hyp_mode() > > > > With a dedicated boolean function is_hyp_callable(). This will be needed > > later in kexec in order to sooner switch back to EL2. > > This looks like the very definition of "run in nVHE mode", so I'd > rather you call it like this, rather than "callable", which is > extremely ambiguous (if running at EL2, I call it any time I want, for > free). Hi Marc, Naming is hard. Are you proposing s/is_hyp_callable/run_in_nvhe_mode/ ? This is also not a very good name because it does not sound like a boolean, but instead that we know that there is nvhe mode available and we can switch to it. > > > > > Suggested-by: James Morse > > > > [Fixed merging issues] > > > > Signed-off-by: Pavel Tatashin > > --- > > arch/arm64/include/asm/virt.h | 5 +++++ > > arch/arm64/kernel/cpu-reset.h | 3 +-- > > arch/arm64/kernel/hibernate.c | 9 +++------ > > arch/arm64/kernel/sdei.c | 2 +- > > 4 files changed, 10 insertions(+), 9 deletions(-) > > > > diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h > > index 7379f35ae2c6..4216c8623538 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_callable(void) > > +{ > > + return is_hyp_mode_available() && !is_kernel_in_hyp_mode(); > > +} > > nit: consider switching the two members of the expression so that you > don't have extra memory accesses when running at EL2. Sure, I will do that. > > -/* Do we need to reset el2? */ > > -#define el2_reset_needed() (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) > > - > > Please keep the macro, as it explains *why* we're doing things (we > need to reset EL2), and replacing it with a generic macro drops the > documentation aspect. OK, I will keep the macro, and redefine it to use the common macro. Thank you, Pasha