From nobody Thu Nov 21 20:32:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1723549799; cv=none; d=zohomail.com; s=zohoarc; b=DaemU49e6HKz5vj04L4e1VHozk8WMQJOj+LiNIIPsjA7DTKgAi7G1OC4vqI029XnJzViIPQYrlXNYOTt183Vlrt3SVWJYYdDV1uyKzMQx0oHH98LV8D911l2//jbDWjEITjGIpHE1kM0o6rUNdMxyEYkXABpsswbCnmjhKQmHO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723549799; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+hkf4y+gpixNGnjs6JeKccrNDQA3i4qzSsHd16s5Lpg=; b=NU5300PvZl/J7RHa6HTqZ2zbsO1SIDue+J/ZtbFOveQn7HhOQswDHpmd21duUufqydFxUQU/T00+UegdI13Gmb5okywu/b4R5bcka+woYnZrO28pwFz1JQNP5MCTvwjptgGxGSsqs9wwnuT+P7O9nXO/DtbkR/Gvh950x08cGEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1723549799143867.7272846146378; Tue, 13 Aug 2024 04:49:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.776167.1186312 (Exim 4.92) (envelope-from ) id 1sdq24-0007Jn-Qa; Tue, 13 Aug 2024 11:49:44 +0000 Received: by outflank-mailman (output) from mailman id 776167.1186312; Tue, 13 Aug 2024 11:49:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sdq24-0007Jg-N6; Tue, 13 Aug 2024 11:49:44 +0000 Received: by outflank-mailman (input) for mailman id 776167; Tue, 13 Aug 2024 11:49:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sdq23-0007JY-DU for xen-devel@lists.xenproject.org; Tue, 13 Aug 2024 11:49:43 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2024c93b-596a-11ef-8776-851b0ebba9a2; Tue, 13 Aug 2024 13:49:41 +0200 (CEST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5b8c2a61386so6159637a12.2 for ; Tue, 13 Aug 2024 04:49:41 -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 a640c23a62f3a-a80f414e3basm63498266b.164.2024.08.13.04.49.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Aug 2024 04:49:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2024c93b-596a-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1723549781; x=1724154581; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=+hkf4y+gpixNGnjs6JeKccrNDQA3i4qzSsHd16s5Lpg=; b=Uu1qq+Aqh3+IsFEo33s5ZyfmGo769d6/FsgfyjGN7s7lrzLedq4TN6onTX0SQZzxw5 e+M6WoJamJrFgjhNxpgdqMoCxYyCyNNjB5eQ/EKEIKmJM5Q/JZKQJxoLAlIUOjtLL+gt rDpME7q+WE/Mt6VoNwrO/QzfXiINW1ONzfZz0u/TxnUniSEPXHYFdcXnUpEEYtdxIQmw XUPn14K3PeKCY5Tau/f1eNZrnFjtnjTz98vKBWgSPtu+WNpGPOVCzU3uqeeqK0kP6qu7 /jfcWWj6v07R9yCmqf0cvcYcHuP3E2/xR9r0cTEZ1uGE9oOgVFwYNJckVKlLcth7wOJN lYzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723549781; x=1724154581; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+hkf4y+gpixNGnjs6JeKccrNDQA3i4qzSsHd16s5Lpg=; b=lBAeGoD1+/9uTO/WA3unqXcC1D84S2r8q2cMQqtR0bTEECjqNYcDHsBskO9Qvlwks8 7Om0JtztfhurImAzqXdndRUaP2oti2B4m6CQn6zxL8MJfbWET4vTNq9vr+HSQOyXIOh/ cYUD4ykA++DFwyr1UCEuXjcTtSqUCvQLGlYHzuz0H+JEb19U4Myp7BJ1grnHRCusn3AY Czb3EmlEC8lgm6osbFp5UNOcgnqtnnUYxFL25SwFyySg09Hbo8rFKyufDUWPyfN890Wg U/wDGngAvsgjDyAbjE6YbShHt/Nrr7DulbXX8lsT/0qxkkCTiN0yI4nRh1FRNES0pcyI m9Cg== X-Gm-Message-State: AOJu0YzMpj4oDNrBZdYSGIKgX/Qnkv1ijWDbslrhjLZ/ay3LLQ/c0MTu iglx0zA4mNJ/DzI5tc3lekfw7uZVc6N79DwLeLeg7zxvdJa7fEztPdVP7HhBYmvE1Cb1UnHEOI8 = X-Google-Smtp-Source: AGHT+IFS4/5paSEhcDIDoSpuyx6/P2Ua++MbMsbnTk8oRa+7TrYJwRu8qOms77yo1eS/J7hRjwpGXA== X-Received: by 2002:a17:907:9801:b0:a7a:ab8a:386 with SMTP id a640c23a62f3a-a80ed2d496bmr222874166b.63.1723549780563; Tue, 13 Aug 2024 04:49:40 -0700 (PDT) Message-ID: <5b097aa2-7ced-4971-bd6e-96618bb6f2df@suse.com> Date: Tue, 13 Aug 2024 13:49:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Jan Beulich Subject: [PATCH v2] Arm: correct FIXADDR_TOP To: "xen-devel@lists.xenproject.org" Cc: Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jO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CfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1723549800832116600 Content-Type: text/plain; charset="utf-8" While reviewing a RISC-V patch cloning the Arm code, I noticed an off-by-1 here: FIX_PMAP_{BEGIN,END} being an inclusive range and FIX_LAST being the same as FIX_PMAP_END, FIXADDR_TOP cannot derive from FIX_LAST alone, or else the BUG_ON() in virt_to_fix() would trigger if FIX_PMAP_END ended up being used. While touching this area also add a check for fixmap and boot FDT area to not only not overlap, but to have at least one (unmapped) page in between. Fixes: 4f17357b52f6 ("xen/arm: add Persistent Map (PMAP) infrastructure") Signed-off-by: Jan Beulich Reviewed-by: Michal Orzel --- v2: Adjust FIXADDR_TOP instead. Add BUILD_BUG_ON() as suggested by Michal. --- a/xen/arch/arm/include/asm/fixmap.h +++ b/xen/arch/arm/include/asm/fixmap.h @@ -18,7 +18,7 @@ #define FIX_LAST FIX_PMAP_END =20 #define FIXADDR_START FIXMAP_ADDR(0) -#define FIXADDR_TOP FIXMAP_ADDR(FIX_LAST) +#define FIXADDR_TOP FIXMAP_ADDR(FIX_LAST + 1) =20 #ifndef __ASSEMBLY__ =20 --- a/xen/arch/arm/mmu/setup.c +++ b/xen/arch/arm/mmu/setup.c @@ -128,6 +128,12 @@ static void __init __maybe_unused build_ =20 #undef CHECK_SAME_SLOT #undef CHECK_DIFFERENT_SLOT + + /* + * Fixmaps must not overlap with boot FDT mapping area. Make sure ther= e's + * at least one guard page in between. + */ + BUILD_BUG_ON(FIXADDR_TOP >=3D BOOT_FDT_VIRT_START); } =20 lpae_t __init pte_of_xenaddr(vaddr_t va)