From nobody Thu Nov 21 15:49:49 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1731665627; cv=none; d=zohomail.com; s=zohoarc; b=a99uQSNEzSetD4IFvZojYevgdjDOrFckZB3hC7bUqYK6Y3+nI0hEtNhbkr9l/GAe2gQcBd1OArmh63PxzAbo4Ss9oe9NDRUG2R5X1/Y40inQm4HupjEXHSwLDn9YpHdrNF5jZBpAB3u5vT99JJIhQ0Cqqs9p9iouwmKaQfANryQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731665627; 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=cosIWsB6OhzrFMvHBWxzUYafQjL8qHoH+ZKKxBA8zOc=; b=QpOPhPXDKHlcrst7GZfqqEj3n79JyouqevZoBZlhbKVArahoHKgExUaL7A2p5IDeyw0PaE4Dg9k9jTaAslwnwZb26nK6mOrkJQ9KPbgLJ0JtVAWedurDj//Y5+wIVYcFpaSq2/sMkrvKpcsggfaszNv7ef5JHhBywDkxrmo/hko= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1731665627408113.66546747759662; Fri, 15 Nov 2024 02:13:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.837033.1252941 (Exim 4.92) (envelope-from ) id 1tBtKE-0001gk-W6; Fri, 15 Nov 2024 10:13:14 +0000 Received: by outflank-mailman (output) from mailman id 837033.1252941; Fri, 15 Nov 2024 10:13:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tBtKE-0001gd-TY; Fri, 15 Nov 2024 10:13:14 +0000 Received: by outflank-mailman (input) for mailman id 837033; Fri, 15 Nov 2024 10:13:14 +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 1tBtKE-0001gS-B2 for xen-devel@lists.xenproject.org; Fri, 15 Nov 2024 10:13:14 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3754560d-a33a-11ef-99a3-01e77a169b0f; Fri, 15 Nov 2024 11:13:10 +0100 (CET) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5cb6ca2a776so2650595a12.0 for ; Fri, 15 Nov 2024 02:13:10 -0800 (PST) Received: from localhost ([213.195.123.63]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf79ba0774sm1420028a12.36.2024.11.15.02.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 02:13:09 -0800 (PST) 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: 3754560d-a33a-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo1MzIiLCJoZWxvIjoibWFpbC1lZDEteDUzMi5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6IjM3NTQ1NjBkLWEzM2EtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMxNjY1NTkwLjUzMTc3Mywic2VuZGVyIjoicm9nZXIucGF1QGNsb3VkLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1731665590; x=1732270390; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cosIWsB6OhzrFMvHBWxzUYafQjL8qHoH+ZKKxBA8zOc=; b=FoG5SbjuB9q/MZpi2tWM/sEaSU0Oi1tCERpmw4rHzwBUuQN6chU9A7cwIuJcaOkpa0 kdDKfDNGuA8LwIAL0df5c65jGiKAVC/n7pNC+8H+Bh++98TaE/npwC+xKuV83JU9JUlm 9a6XtRNkaTMT9IgSlxbCuUKwEFqHv/L2nmQa0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731665590; x=1732270390; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cosIWsB6OhzrFMvHBWxzUYafQjL8qHoH+ZKKxBA8zOc=; b=pW1DkNM+fbSJV2+S7NmDk85Wnsms9F4nibpF4BiYdp/kFqI8WaTUh1jC+LhGzRWk6C 3PfsMfi/8+YVyCg2IzTs6KE+wysePP/3pJuN+/jrJpfi0KFBnMmShvf6lCx3Ddtrdofb Pej6L+/cHiaCreqYMWhcbitUmfhDmhiWy2sXF4i42wDe57K8eqKToycw0vvFNGCuQQrt D+pZEJeDHR0ZT+K1SgV93gvrF613oiqL/DtcwuMgDB8UF77OhuIVa01dQtc9W0c5JHTI 849IYb9ujyVoMPh6BNjmuPp0cT+6sWtYdYZJZP2DtJgEbkvjbzMzf7P4mKFaqcr3lKJ1 vZLg== X-Gm-Message-State: AOJu0Yzy4gynlGlZpQEh3g4E8uNgNjp3PcreYTGw9Aa9ihfIgswPMqjX jh8aC+dhws6r7FwZizEbuRyI3ld5cjItG6kNvkaMxmUS296Jh4eJdrLxgXxlC+Rp+vTe5blPqcd 8 X-Google-Smtp-Source: AGHT+IFgE+Q+PGFNwiVaXlVX/XFvhmO5oh2P0rZvFaGdjZadAIahSfxU5wqze7H4mg1kuLybA0U0EQ== X-Received: by 2002:a05:6402:26cb:b0:5cf:9c4e:962f with SMTP id 4fb4d7f45d1cf-5cf9c4ea2f9mr205384a12.15.1731665589645; Fri, 15 Nov 2024 02:13:09 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH] x86/mm: fix alignment check for non-present entries Date: Fri, 15 Nov 2024 11:12:25 +0100 Message-ID: <20241115101225.70556-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1731665628946116600 While the alignment of the mfn is not relevant for non-present entries, the alignment of the linear address is. Commit 5b52e1b0436f introduced a regression by not checking the alignment of the linear address when the new entry was a non-present one. Fix by always checking the alignment of the linear address, non-present ent= ries must just skip the alignment check of the physical address. Fixes: 5b52e1b0436f ('x86/mm: skip super-page alignment checks for non-pres= ent entries') Reported-by: Andrew Cooper Suggested-by: Jan Beulich Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5d7e8d78718c..494c14e80ff9 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5525,7 +5525,7 @@ int map_pages_to_xen( ol3e =3D *pl3e; =20 if ( cpu_has_page1gb && - (!(flags & _PAGE_PRESENT) || IS_L3E_ALIGNED(virt, mfn)) && + IS_L3E_ALIGNED(virt, flags & _PAGE_PRESENT ? mfn : _mfn(0)) && nr_mfns >=3D (1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)) && !(flags & (_PAGE_PAT | MAP_SMALL_PAGES)) ) { @@ -5644,7 +5644,7 @@ int map_pages_to_xen( if ( !pl2e ) goto out; =20 - if ( (!(flags & _PAGE_PRESENT) || IS_L2E_ALIGNED(virt, mfn)) && + if ( IS_L2E_ALIGNED(virt, flags & _PAGE_PRESENT ? mfn : _mfn(0)) && (nr_mfns >=3D (1u << PAGETABLE_ORDER)) && !(flags & (_PAGE_PAT|MAP_SMALL_PAGES)) ) { --=20 2.46.0