From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 528461AA780 for ; Tue, 5 May 2026 10:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777976685; cv=none; b=EeTvgA4LZNCmuItqmZxqcWlQSpoRJIpelwmD4Y51Z0BQkQNCjuNrnru8UxRp2pdoyaJVQ461FD48VHeUhdE7KyE7qV+SFFXjr/9crrgdvScTHHumcyhMkaDpZpktEDYq9m1cJ4Jxzazh9QwheXuh7niIXo62OxOAkf/+6EcX9xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777976685; c=relaxed/simple; bh=Qn2eQ6L4Y9qsumqAcaJkZYIC6ooO622j+zz0++lwB7c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TwYq/+Qiu+LBS93QMHx2PM5HDwEmB0xyZQPR36kZbWbMONTI4ihyvQMNte3sj433hATFn+lbe7birwXzxrRbKQzrb0b6Qfumaaa+VSyvIwa1tzssP4j4kF3PS9FEkMU+Dt9XQdpUMqMhDCG8KcdJKXjrv8FdI6qpfFTSPnJ8STA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=BvrneJcx; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="BvrneJcx" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so25861955e9.1 for ; Tue, 05 May 2026 03:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1777976683; x=1778581483; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=559/gDL5cAkgHSxRcisKiAuG+SV9lJdifh/D33J/iJ4=; b=BvrneJcxLzcn9tK+eR8J+FF2sEFe7Vu43guysbLu51k9PCQCotSDzRLsUaMzfAwGis wXFMJAL+qOnSy6aB/cVqki4/aZWO3W/uuBbc9K3YQ8agGOKbYzUQIUcjI/O+UScWRUSJ a2Sh8Dx01uO1h2CK/3neDLYkoxWYbaX2ml9Urog6kiOp5eyXsTmD4c7M4n6HzEpzpl16 NR9GolTHwOwUcjKxX6yJ5H4hey9JLTPmeZKsGJ02RF9tIAcsQtm04Jc3/zCU6QoiUyR9 khf/C1ajDyR14xo72MmPZeQev2cvYmcDI+tKHCOOBF0jFpVeLOCoWRxorKsoB0ESYHVb 95Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777976683; x=1778581483; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=559/gDL5cAkgHSxRcisKiAuG+SV9lJdifh/D33J/iJ4=; b=OrXN0FGnAqvR8b9JjAXmoO1gyXebpkhmd4EoOXsQ8HTGOrhQaf75fFFYnu0WUFE7Bq NvIxfXug612eV/UJVGJmjozipimr4/q/N9e9O6uPjjaHMFagcG9pV960YkzVxyqvrsAk o/L0zDd6lgedyRvQ9BqeM9qCG9WWPpvbzduzcSV4ELmpLLvQEL2bSKuVhJNmUGWQ3Qa+ r6QqsNkLQEVjtm8QUC+CaN4loQKvAsw/zFhOB/2EMOWteyR5rTJ7zpYe/qZtQ0N+Komw 73+pPLNd1vuKjR1DJDe1FJ0jUZlmDMSbXlWc0wtDxRNMdQFCDWGZmozLCraXrnADFnBc uUIQ== X-Forwarded-Encrypted: i=1; AFNElJ9lIb2nt4LCHoBVj55YLT59Pqxdoa2Fdl3s0mMkI09+XPeG7EexJcjqpOfGeUcKqo4BAA0K5vCgZ1Kh0Cg=@vger.kernel.org X-Gm-Message-State: AOJu0YxA7DvfC+fdParReNJ5i2z27zvUNIAqHdH8i3LKPnwkrxRZNpbP shDyGFGrix+Q+z9oW6C56X+I65iHDEZZPKb4Yd3iF0Es5he/smcQsHir3znQvXbltg== X-Gm-Gg: AeBDietob/n8METH85pReYPZDO+IJgIDDQzlkjugQn82o9mHRDXjcbYMXHRPdHeyqCg lYvFFlzQFIx6nJtUSG0KF7b5e0tyUMO5fUtkuEKwm6jcwV3o3LGbt/6muGG6T3/ZZxQnPEpSZB2 MdBfgmJRDYqame9yq+UH5ubgtsKD5khNm2bJjQOfbZYlhW74rHWqF03h5oCpVAULrc7HZ6pwZiK CC2WYbl1M9P9edDmOpzD0b12jK8iU02eUas6sZBO0dKB7qShn2ToRaqLjSm8RfITcOET5lSjs4L LtCJW3b6qczX2iSSr507AAri9RdApdE3LBsTsL6bML3yeRG8EfGaHkdHa5kN2J1ydMe43xq8aBc 2M406mdSA1NVuUBsRIdLyEypLc9uqNOmU+1A7QmCPALmoFplrdTXyYTJC5jFi+jLbB9Q2znLqIR pZQ3XsmTuzxE0iX0HgM01MwenVZpN2ZiLyZnf8K8NbZ0NK4JA/obPoXiRcFagcZeP6mCyPJUgTG EY/Ew8dHX/MChUzYAmmE9VO6g== X-Received: by 2002:a05:600c:3b2a:b0:488:a797:f0ac with SMTP id 5b1f17b1804b1-48d18cf637amr40888785e9.28.1777976682686; Tue, 05 May 2026 03:24:42 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a824f9f0dsm373141955e9.15.2026.05.05.03.24.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2026 03:24:42 -0700 (PDT) Message-ID: <29422b34-b33f-4a25-838f-de6078151e46@suse.com> Date: Tue, 5 May 2026 12:24:41 +0200 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] x86/xen: Fix a potential problem in xen_e820_resolve_conflicts() To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, x86@kernel.org References: <20260505080653.197775-1-jgross@suse.com> <6b241236-ed6d-4ada-beac-8f660bd55185@suse.com> <59b953ce-4b51-4a47-8dba-9895dea33d41@suse.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAU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ui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <59b953ce-4b51-4a47-8dba-9895dea33d41@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05.05.2026 11:13, Jürgen Groß wrote: > On 05.05.26 10:43, Jan Beulich wrote: >> On 05.05.2026 10:06, Juergen Gross wrote: >>> When fixing a conflict in xen_e820_resolve_conflicts(), the loop over >>> the E820 map entries needs to be restarted, as the E820 map will have >>> been modified by the fix. Otherwise entries might be skipped by >>> accident. >>> >>> Fixes: be35d91c8880 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory") >>> Signed-off-by: Juergen Gross >> >> First, while trying to review this, isn't there another issue in >> xen_e820_swap_entry_with_ram(), in that >> >> entry->addr = entry_end - swap_size + >> swap_addr - swap_entry->addr; >> >> >> really means to be >> >> entry->addr = entry_end - swap_size + >> swap_entry->addr - swap_addr; >> >> (affecting non-page-aligned E820 entries)? > > Yes, you are right. > >> >> Further, that function converts swap_entry to the page-aligned superset >> of the passed in range. How is it guaranteed that this new range won't >> overlap with the predecessor and/or successor one? Wouldn't that need >> to be conversion to the page-aligned subset instead? > > This is subtle. :-) > > We are converting to RAM (usable), so the type value is 1. e820__update_table() > will handle overlaps just fine, with higher type values "winning" against lower > ones. So any other region overlapping with the new RAM region will result in > another conflict in the next loop iteration. Oh, wow, and this is a property of the function that one can rely upon? > Using the page-aligned subset would result in possible memory holes, which would > be problematic (the kernel or page tables shouldn't have holes, after all). Aren't such holes normal to occur, e.g. on misaligned RAM/UNUSABLE boundaries? >> And then, is passing the page-aligned superset to xen_add_remap_nonram() >> really appropriate? Why would any leading or trailing space there be >> subject to remapping? > > How would you want to remap a sub-page physical memory area to another location > without affecting the rest of the page? We are reworking the final p2m map here. Well, first and foremost: xen_add_remap_nonram() takes and stores byte- granular addresses / sizes, with the sole requirement being that the offset-into-page be identical between both addresses. That check alone already indicates that non-page-aligned addresses are expected to be passed into here. Further, xen_acpi_os_ioremap() uses the resulting remap table, and is byte granular. With the physical address adjustment there, both mappings could (theoretically) coexist. But the problem I'm trying to point out is that by passing the page-aligned superset into xen_add_remap_nonram() you misguide xen_acpi_os_ioremap() (while at the same time xen_do_remap_nonram() will do suitable rounding to page boundaries even if exact addresses were passed). Jan