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=-9.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 0AC64C432BE for ; Thu, 26 Aug 2021 12:26:29 +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 CF1A76108D for ; Thu, 26 Aug 2021 12:26:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF1A76108D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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=W7b4rMEAjYlkn47owMcQV+/BuIKxDpJEveKd4LW+28o=; b=Z0U3oVzuCctZ7z liHdHMWAo7nDdbFafQXKQPYaref963EqHGLHTQ/9u1OAxs9q3oWpZ6PkWIGgid+Q5TqAOB4r/EWJL KwjhXsTALt+ySjazwFdzZkbEP+ARqV6GkR4OHC4wG8nTv6GxomRV5JmpysTUg3gx4nkpfZ1LH9YtL b3GcHrZ5Vx09NZaYwv/T6gG4kVt9jWzl89IyqNPZ6mLRvH4SvzPxmpv7Jpp9mN6TgQKG51lF+fl60 fFnKJMAHN1T8NBmQBChR0/mKEHobDzXb8PX1FBVBRyuhutEw4ski8RrlOeSrNam2/A/tqN8gBuos7 eth/cXuuCq37AGjlKBxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJEQG-00A39J-CE; Thu, 26 Aug 2021 12:23:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJEQC-00A38z-Oq for linux-arm-kernel@lists.infradead.org; Thu, 26 Aug 2021 12:23:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C5FD61052 for ; Thu, 26 Aug 2021 12:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629980632; bh=cvYrsnjOHVQgnRerFtrCtxTvmUBbJvQfejLY10ddf9I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Hig01jmarUaIlix32FKJ7hUtwEEDF2qHRYBCovd4s5UZqSLm5hp3aPVzHltnufT6p IZv/aaIchSiIyNrdXf0OusMrrHggaBqrHZBUt1/1dYfxq2g9CfgT6FHSK5PpSq3nYm h64aoB6hYhEdZEp5jYhBDO6aBWxOG+IHUWtjV0BknQBgdqdBKqYY8FhZ1HdokPRJjg YdXpq4fteGZ23Dx9MspEPbJzMJOwjCV7nzKTUO9DJg0olvkaeEK7Y6UTFaISBPBV/0 t4s9EFMq5LgcC2zVUSCjZjvUYbKNKk8wn4m/36SFA0vlTMmbN2Zdq4qFhA9cMz/Ueo w0PfmjAqVx3FQ== Received: by mail-oi1-f176.google.com with SMTP id p2so4582294oif.1 for ; Thu, 26 Aug 2021 05:23:52 -0700 (PDT) X-Gm-Message-State: AOAM533cjFi8pX6+zf6IszuyXIwdNuCr9iki51R5PJLtm4jq39hOUDPq QqPMZNRqHuXZOUZREVMFkWX/YQqkZwE5OiXkMms= X-Google-Smtp-Source: ABdhPJwihYste07evNpfdS969cbpbV5Qh5qokJ6VZ45IHuV4UOcnu9DWm72vb2ZSeFYRVCB4+IO5t1qwgTX7Q2Wq3iA= X-Received: by 2002:aca:ea54:: with SMTP id i81mr2131402oih.174.1629980631336; Thu, 26 Aug 2021 05:23:51 -0700 (PDT) MIME-Version: 1.0 References: <20210810161244.84231-1-ardb@kernel.org> <20210824105920.GB22752@willie-the-truck> <20210826121623.GB30910@arm.com> In-Reply-To: <20210826121623.GB30910@arm.com> From: Ard Biesheuvel Date: Thu, 26 Aug 2021 14:23:40 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] arm64: mm: limit linear region to 51 bits for KVM in nVHE mode To: Catalin Marinas Cc: Will Deacon , Linux ARM , Mark Rutland , Marc Zyngier , Anshuman Khandual , Steve Capper X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210826_052352_879389_CBF6AD79 X-CRM114-Status: GOOD ( 24.73 ) 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 Thu, 26 Aug 2021 at 14:16, Catalin Marinas wrote: > > On Tue, Aug 24, 2021 at 02:56:22PM +0200, Ard Biesheuvel wrote: > > On Tue, 24 Aug 2021 at 12:59, Will Deacon wrote: > > > On Tue, Aug 10, 2021 at 06:12:44PM +0200, Ard Biesheuvel wrote: > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > > index 8490ed2917ff..542dad13e2fc 100644 > > > > --- a/arch/arm64/mm/init.c > > > > +++ b/arch/arm64/mm/init.c > > > > @@ -282,7 +282,21 @@ static void __init fdt_enforce_memory_region(void) > > > > > > > > void __init arm64_memblock_init(void) > > > > { > > > > - const s64 linear_region_size = PAGE_END - _PAGE_OFFSET(vabits_actual); > > > > + s64 linear_region_size = PAGE_END - _PAGE_OFFSET(vabits_actual); > > > > + > > > > + /* > > > > + * Corner case: 52-bit VA capable systems running KVM in nVHE mode may > > > > + * be limited in their ability to support a linear map that exceeds 51 > > > > + * bits of VA space, depending on the placement of the ID map. Given > > > > + * that the placement of the ID map may be randomized, let's simply > > > > + * limit the kernel's linear map to 51 bits as well if we detect this > > > > + * configuration. > > > > + */ > > > > + if (IS_ENABLED(CONFIG_KVM) && vabits_actual == 52 && > > > > + !is_kernel_in_hyp_mode()) { > > > > + pr_info("Capping linear region to 51 bits for KVM in nVHE mode on LVA capable hardware.\n"); > > > > + linear_region_size = BIT(51); > > > > + } > > > > > > Slight nit, but to avoid having to think about PAGE_END I think this would > > > be a little clearer as: > > > > > > if (IS_ENABLED(CONFIG_KVM) && !is_kernel_in_hyp_mode()) > > > linear_region_size = min_t(u64, linear_region_size, BIT(51)); > > > > > > > Fair enough. > > Ard, do you plan to post a new version? I can make the change myself > locally as well. > If you don't mind doing so, please go ahead. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel