Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2679175rdb; Mon, 12 Feb 2024 12:39:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW90B1hbsxfBuD15+WiL+KQEE0ZydLidmR35ZG0D6H0BIX7/A/YNRU7VdgPZw43u1psWYE5r8mmOdmNqdqit/CooSwoN2MhHNaNKhBgkg== X-Google-Smtp-Source: AGHT+IE0CvI9KwDTKP4d+Tt3IjVS0qwJCup2jUh4AemCoZr121AQR/FqU7ZjM1bOuYDD8OCQy2gn X-Received: by 2002:a9d:6b12:0:b0:6e2:e50b:7ac5 with SMTP id g18-20020a9d6b12000000b006e2e50b7ac5mr4277677otp.17.1707770356542; Mon, 12 Feb 2024 12:39:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707770356; cv=pass; d=google.com; s=arc-20160816; b=NR9AsxiNS39anspnsp4SOueEiCV/glxrN8/NZqffGSGwjhKW8yScOdjQ3yL4IKhQPi Ew9R61Q0QAWUrezLxGe1PyisUOMYUDTkCy+D8Su/3Y2jBmRQfBfUmfyARzk0wFrKU1ZR KKo4GIiccT20WPKe9zhh186kKh1kVAxTmRn1eC4If8zp8KfVS1uBoY++qxqwQNIdVyil lYVioOC+dhI0wH+B9Uv+HUZbGteCpcsDBvdeVioWspUhM6pL+JwTPkF1ZGXP8gybFOYl Ly2B/XcXejvIEOfoNfJ+7EKsMmJ4IYpxgj/T0Otx8iejxJTl8KX9HCmVlrzC9Bz7gTKZ VHNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ftNmF3tZ+P3amd6e4QJsIAlImL4+aUhDn2omsstzILU=; fh=n4oS6PsMKwcbjGQiXjk6pILMJhlfUY/8f2kmyJrfYQQ=; b=fhq1wRS5ruQyDKNU3fi0cS1veeZdQc1Zs8ungqQSk4wL8cfMSSZew1VRh0Jk0stCw9 puasoUcprvnci5mR+8kP+5vwSe+cErW4ch/E6EPot81MvUBiUNDXaeaw8C30cHpVI/uF Y7eeNYXsdgfuvApKUXsHZF6NceAk7gdsHdjo7+MfnPAtN3XgR9UqKqdchceuNbHR6GVQ BA86vlmY+vxQ5VpSNCOhwPKjECW0V9Exyt/vZP+QgaCiAJvGiWThkYxRSRrtxPS0qO0v xS7IVKVHjj0bsSDSBrGWNW7Zd8i/zggPcjcy3DwGZ/RMZvkp3J2FFQ25Vd2trRGN4kiF kMdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-62347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXDb7iu9ow0cS/S5LBZh5FhVYoyRSc+KsIaP625OpC+Q4EgMofHiYwC0ANkMCdWqU+VL2YBpfThY1tbykPZG8WRxUfB2j7eFe4DLwGtbQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b19-20020ac86793000000b0042c66a8d6ccsi1170179qtp.218.2024.02.12.12.39.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 12:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-62347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4DD411C213B0 for ; Mon, 12 Feb 2024 20:39:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A226341C93; Mon, 12 Feb 2024 20:39:09 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C0B41DA5B for ; Mon, 12 Feb 2024 20:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707770349; cv=none; b=qtg0cKcjwL47AjgV1qp9sgP9ACAC4OEBStM/nXQT6sfNjjZVLG4huWrwh26BiThYM5ALLCwMOU8bv4IvGMtlgenrp+HnTdZxU52+3P2WdyIOa+7qF3IVOV/i0o5Uv7RPNh5SBioUwrQatL9jaBfKR2WYluBnT8KSp1W6Ypr+QOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707770349; c=relaxed/simple; bh=4n4tjW723V0IAbGF5or8C4v6NovmCSgEHxp3WKxnaao=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=traWz+FkjRS5gBmXOdXeiEkbguy1z3QjkC+M95Wwq1HQG+ncXVpv2TSRQGvMs7xfuG+sNhSxW9t1s1yB8rQmMlXd77FlJqLwd76rnjMGAw/afpFlSCxIEa9XSrCdP2WC42jjxi9kY9DdCUyJihnO14Uj2CCyvYQ09jowk7yBSOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 56446DA7; Mon, 12 Feb 2024 12:39:47 -0800 (PST) Received: from [10.57.78.115] (unknown [10.57.78.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C95403F766; Mon, 12 Feb 2024 12:39:00 -0800 (PST) Message-ID: <64395ae4-3a7d-45dd-8f1d-ea6b232829c5@arm.com> Date: Mon, 12 Feb 2024 20:38:59 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 19/25] arm64/mm: Wire up PTE_CONT for user mappings Content-Language: en-GB From: Ryan Roberts To: Mark Rutland Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-20-ryan.roberts@arm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit [...] >>>> +static inline bool mm_is_user(struct mm_struct *mm) >>>> +{ >>>> + /* >>>> + * Don't attempt to apply the contig bit to kernel mappings, because >>>> + * dynamically adding/removing the contig bit can cause page faults. >>>> + * These racing faults are ok for user space, since they get serialized >>>> + * on the PTL. But kernel mappings can't tolerate faults. >>>> + */ >>>> + return mm != &init_mm; >>>> +} >>> >>> We also have the efi_mm as a non-user mm, though I don't think we manipulate >>> that while it is live, and I'm not sure if that needs any special handling. >> >> Well we never need this function in the hot (order-0 folio) path, so I think I >> could add a check for efi_mm here with performance implication. It's probably >> safest to explicitly exclude it? What do you think? > > Oops: This should have read "I think I could add a check for efi_mm here > *without* performance implication" It turns out that efi_mm is only defined when CONFIG_EFI is enabled. I can do this: return mm != &init_mm && (!IS_ENABLED(CONFIG_EFI) || mm != &efi_mm); Is that acceptable? This is my preference, but nothing else outside of efi references this symbol currently. Or perhaps I can convince myself that its safe to treat efi_mm like userspace. There are a couple of things that need to be garanteed for it to be safe: - The PFNs of present ptes either need to have an associated struct page or need to have the PTE_SPECIAL bit set (either pte_mkspecial() or pte_mkdevmap()) - Live mappings must either be static (no changes that could cause fold/unfold while live) or the system must be able to tolerate a temporary fault Mark suggests efi_mm is not manipulated while live, so that meets the latter requirement, but I'm not sure about the former? Thanks, Ryan