From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DBEE19F121 for ; Sun, 7 Dec 2025 02:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765075147; cv=none; b=TP8roQhKZb7Cp0qi63eZTlN2PQd3WnJ2eka6Dmyp34xD2SCO7ncuQ5gSgwKjNFQPigpLQRd+799cMtQpcsatw4b2LsxOd328FLGJoPUnYQ7jllA6P/fJI0e/gROe71SUUHUtovLyApqkVJ/xu3CDTlX4E+POqAFNOAmsKCWB+YY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765075147; c=relaxed/simple; bh=TwUlzo7uA+1bTDj5DqHqOV+jiUpowAySDJyquSjitWE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=httCwzoJ8RrJAgYsElHI1Z0GUCm0Uw+oqjA5mGPGoCW/qm6dW1TakkvFHWiScQcYZIBe9pPdTggWe3MUkwo5rrpz5jWPtR8nqhGFCXxmigFc65G/w5ii1LiaunI/TlH9nzrmluqHSTp9ieCWtdBYbqn6/pUuMOJVbMbhmfK6zrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hWDKt1GW; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hWDKt1GW" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4779edba8f3so20203785e9.3 for ; Sat, 06 Dec 2025 18:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765075144; x=1765679944; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QdUYZZtVe1g6+/DJIWHKjvzLVo2HJueZhsIanvtN/+k=; b=hWDKt1GW28L2yXsQCrxPsG9dpG62fMAfJ5srIOOGo7nWx0U95NRgPBmMt9JPqwzH1o LXXZ6Uk/TvQauXMIKo16w987LiU6lh3IJhMQKnKBLxMPlLa/XEnDZ+VFtlJWUe3d5lZ8 kbLbNzTvP4S89tipCQFv/Zrv9PJfg9cgvacd96++c67m9QBcp9ys9Y4+wpR7/QoDzvPc Ri8zrL6mNkgUxTcHYrVP/9oggfVETiOeM2o64jCr/2I+srMo38SIsV6SDDDw4I398Ief 6kpbpIjTWpP37bmd2oL0mQoNsUIvIN2iuFiM8hVKGc/lRDrAiGhyqW+dtT/1GT2p+FOi PCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765075144; x=1765679944; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QdUYZZtVe1g6+/DJIWHKjvzLVo2HJueZhsIanvtN/+k=; b=lUBqRy1Cohbei1j7Nh/42LYBH9CkXhISBE0SdAhXGHwDOiQeD+YJWNanVPyCbOwsPQ xYC21xtFNLNWkfMVPmPa46La0wALnQnddt0P1mQOdcOa2XrTeI4MXMLL00390b4Xk47x +IEtuXR3uY2iwVTGn3IP0aPKzzOnA94xNvO94yGYXGvk7u1mK+lW5dO0zO3vSj2Dvufa IlEXR7lH0xjCBAOHO2PdK4NxfvEwDn/WcFL9npQM9LB/9170a2ITFNNRwpRPlRSMdRSf WE3XFwzbSqbL7hSVVW1hMXTHJjqHAwyxCcqw7t157tkRypz9I8wt11kra6ckmmkKm6VY AjZw== X-Forwarded-Encrypted: i=1; AJvYcCXQX3uggPGRcLfHet/uxJQpxsSb4Hxyo/vPAx1bkSFL2Amuix0bUqPMzurPypc8hRqRuJDaBaUnadb6K3g=@vger.kernel.org X-Gm-Message-State: AOJu0YxZeEoCVcUpDfAPlzlYyjU4CLnWco3sqJ6WfB7lkdXL7x+C+4E8 TmWMKu4W0FDKcXK89EZyIG/r/c54L4VmdeSGNRXS6ZIVtqgMuhFSrI0jLa8k/SECJlM7W6ZL89D Y74avi1JuXqpBCg== X-Google-Smtp-Source: AGHT+IH8ZNr0oTmP+2tBUdqDyAR6ATt92VU8QHhbilI1Enk7MEtJsera3rw/LUXqVVw4Xmw2E/taLlnKLzt8xg== X-Received: from wmbjj5.prod.google.com ([2002:a05:600c:6a05:b0:477:9654:b44c]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4689:b0:477:a21c:2066 with SMTP id 5b1f17b1804b1-47939df12c8mr34699315e9.5.1765075144615; Sat, 06 Dec 2025 18:39:04 -0800 (PST) Date: Sun, 07 Dec 2025 02:39:04 +0000 In-Reply-To: <84b2e7a3-7115-45fe-89ff-db8ee46729f2@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251003-x86-init-cleanup-v1-0-f2b7994c2ad6@google.com> <20251003-x86-init-cleanup-v1-2-f2b7994c2ad6@google.com> <20251127143501.GAaShhlVTH5iQpCdPM@fat_crate.local> <84b2e7a3-7115-45fe-89ff-db8ee46729f2@intel.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH 2/4] x86/mm: harmonize return value of phys_pte_init() From: Brendan Jackman To: Dave Hansen , Brendan Jackman , Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Content-Type: text/plain; charset="UTF-8" On Fri Dec 5, 2025 at 7:29 PM UTC, Dave Hansen wrote: > On 11/28/25 06:03, Brendan Jackman wrote: >> Before the patchset, the return value of kernel_physical_mapping_init() >> means something like: >> >> 1. The last physical address that was mapped. >> >> 2. ... This includes addresses that were already mapped before the call >> >> 3. ... UNLESS that pre-existing mapping was 4K. > > Yeah, the 4k thing certainly sounds like a bug. The *only* thing that > this influences is the add_pfn_range_mapped() call and it doesn't care > about 4k. > >> I think the right way to do this is to drop this patch (2/4) and >> evaluate the remainder against the claim that init_memory_mapping() >> doesn't care about the return value at all. So that would have to mean: >> >> a. It only calls kernel_physical_mapping_init() for physical ranges that >> exist. >> >> b. It always uses a page_size_mask that matches the alignment of the >> ranges it's passing. >> >> c. It doesn't operate on ranges that already have mappings. > > Yeah, that makes sense to go forward with. Instead of having the code > try to cope with all that stuff that we don't think is happening > _anyway_, let's just warn on those conditions and effectively not handle > them. I assume those conditions can arise in other cases than init_memory_mapping(). It's just that those cases already ignore the return value so it doesn't matter anyway. Anyway yeah will go ahead with this approach, minus the warnings. Probably after LPC as I am still not finished with my page_alloc stuff (yikes!).