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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 72C0BC4708F for ; Wed, 2 Jun 2021 01:35:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BB25613CD for ; Wed, 2 Jun 2021 01:35:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BB25613CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cTLiHUiT3VJmgk84bJ4eKYECE8dib08I9jP7AjEHwwU=; b=NmQhyCeF4ceDlZ 26OZX5W6xaFUVbWg/u94qPfO47igkAvz6+JC+wPL3wcVedi7fxju0ew0L7aEt0RhgfIwanIWMAECh B9js7xGNXhwPBOXTRpRt7wz49/vdMDlUAe3Ls2EholcStkXN6BHzZ1tvCTEmZLIqpvuC/m9+ItDjL /XK+FyaFqnoKrh1nAHsMcsOjilgAOCef6JYbXoi3Ra6mRQMtvkCUlzCC6JJmyDZxVi1Vom8/j20oK /etGRYyeaCd8zoh4QaBXhC2JgEZlxkFdixuYYdhcN8XYR00irkovZm0lVYKVV/RCrc1rw6cumUpGe mnNDbpj8faP3whKH46Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loFmF-001UGs-7V; Wed, 02 Jun 2021 01:34:35 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loFm9-001UEU-EY for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 01:34:31 +0000 Received: by mail-ed1-x52d.google.com with SMTP id dj8so893350edb.6 for ; Tue, 01 Jun 2021 18:34:29 -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=Tlrnj0NZJGEz+LKwPsWDGX3QVpM7cEig/ewathllwMFIJb6BG9khc7D84V3/T+C7gM 2V5yJFP1CDIIX0GSp3S7oVFpqO1CN/eB80D2qbHRnpMC5VG5t8QqPcR1yxvgGA6aHzc6 T7HcvvXogesXJawhnoytSbPKyYcn8B8kX3BesDhiaymMTjf+tVAA5/mnu2wLxSDwUIoa 6nVG4uU4UI1cD/fAqJbEL6aTrdBVPhmSg+uzI+ZuvLjfj9oaUXb1Wer4azd8nz0zLZHW 3ssSCnEQAKzy/hk1MVpmxcRjk1xFqpGivUJitk+2Keu16sdgEnC4lrnet+IuPuCLwK3a j/9g== X-Gm-Message-State: AOAM530U3OgJJ1sEE8oZJnYkntAit4Yko5gKFOyQ54H4R7LPl/0IM8ky 8ieDv47SkDabKwTiROL2tkui9JFFLvE7edPrJ7DqaQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_183429_499155_51D2E686 X-CRM114-Status: GOOD ( 29.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel