From nobody Fri May 17 08:39:28 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=1710154492; cv=none; d=zohomail.com; s=zohoarc; b=XfpD1M7YGUs76toVDCBcL+Q+2+rv6iJuzLXg6P5Rzz9g2jtoVTRbmbOB+6dpy9PRZLtd3gHaKPZp0oGi20Y7aVfOu2hoAPnrI3V5PeL9Tq2QmwNHaeHKVJ5ghIn1f+AKAOuYE6BvO0n3mnfkKziuSOiwia4Q8lC28koAB9ko0HM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710154492; 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=qFSbJRUt82khlam4F2vn9PAAVNAJOSdtfHu56s/6wSM=; b=Ffk2LIcPkL9V/3IYjJ9Xyhh49vS5Ng4VRqkXw01JhXtuya2VMHd7uiKsiZ3ub8JNyE6p5Gm9deoNMtoYCffyn0iSaRYgcXg2vggJWljGqbF4KG2F7jj3URlsOhTpBX7q5KBmiAAYzZK+IMdGtgLl07luH5ZfJl43FWW1faZlOLQ= 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 1710154492793174.82844128873865; Mon, 11 Mar 2024 03:54:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.691382.1077313 (Exim 4.92) (envelope-from ) id 1rjdId-00038M-Sl; Mon, 11 Mar 2024 10:54:31 +0000 Received: by outflank-mailman (output) from mailman id 691382.1077313; Mon, 11 Mar 2024 10:54:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rjdId-00038F-OT; Mon, 11 Mar 2024 10:54:31 +0000 Received: by outflank-mailman (input) for mailman id 691382; Mon, 11 Mar 2024 10:54:30 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rjdIc-000389-7c for xen-devel@lists.xenproject.org; Mon, 11 Mar 2024 10:54:30 +0000 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [2a00:1450:4864:20::333]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bc056e20-df95-11ee-afdc-a90da7624cb6; Mon, 11 Mar 2024 11:54:29 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4132c64fdceso2158835e9.3 for ; Mon, 11 Mar 2024 03:54:29 -0700 (PDT) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id j27-20020a05600c1c1b00b00412f83e0c11sm15195642wms.22.2024.03.11.03.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 03:54:27 -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: bc056e20-df95-11ee-afdc-a90da7624cb6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1710154468; x=1710759268; 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=qFSbJRUt82khlam4F2vn9PAAVNAJOSdtfHu56s/6wSM=; b=itgv/4mnIAW4XOYQ7E2ujHbGmoiIIj1m313EW3/B7+72JZlZcdLku0kkPsh4K3a+4+ 3JHV3q35QdORpYZTKJSLIrTGkIcwsqGRcggfYAM0780uC3G75raICAIMT65dsdomtcjh KVQ1Zaq9KH/s6mueXfCFr8GhQ+mcwr/WueX5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710154468; x=1710759268; 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=qFSbJRUt82khlam4F2vn9PAAVNAJOSdtfHu56s/6wSM=; b=ORE5+PYd3yHLzZsL3mcvEfrVk/29kv8nIx7GBb7KMBYUJ+/01KcFfI9PMQ90Jvj9CL vpMJe3Lfilj+u1I19+wqg3855iyBdGoYpNjJOy8i3KQFlSDAfPgWMZs6jUJ/ZVm6zkJR Ydd0wSYh+ZhzDp+f3LHMyU2ki6KraU3SXGcDICGpkoonQa5toea415RRhw2r5aX3wuk+ /Phxmy/+AeQTKDR+13nkHUcxkW7oUdEMWIZqZS8IocVsXIcWexOtVOINqmIrbGbIGG6T FvpJrOnkUOCVwIGMHOjMI1h8gpP2uHGPo2bw2xRUJPujMcm1N56dKBfyHEcsWDR+iiGG eewQ== X-Gm-Message-State: AOJu0Yz8eDJoGo0MF5Zeu0jdDt9eTReavTOwJ0doIQgP68pdqEKyPs1n XJk5LC362AN/0+viO9eR5H9M3ZS1hxQszCbs+sc5+1bAnLz4Il8s3lQVmCc92aeSWWSnM/TTbeN 0 X-Google-Smtp-Source: AGHT+IGiNELZqdLPiQLT4VoVaFfhmhTBYxmO60jlc4Sn12sHDUzMgsHvokkcLAwKi5bqGtHyYKQw1w== X-Received: by 2002:a05:600c:4449:b0:413:1f5c:baa6 with SMTP id v9-20020a05600c444900b004131f5cbaa6mr4765016wmn.30.1710154468051; Mon, 11 Mar 2024 03:54:28 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH] x86/mm: fix detection of last L1 entry in modify_xen_mappings_lite() Date: Mon, 11 Mar 2024 11:54:16 +0100 Message-ID: <20240311105416.4556-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.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: 1710154493700100001 The current logic to detect when to switch to the next L1 table is incorrec= tly using l2_table_offset() in order to notice when the last entry on the curre= nt L1 table has been reached. It should instead use l1_table_offset() to check whether the index has wrap= ped to point to the first entry, and so the next L1 table should be used. Fixes: 8676092a0f16 ('x86/livepatch: Fix livepatch application when CET is = active') Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Andrew Cooper --- This fixes the osstest livepatch related crash, we have been lucky so far t= hat the .text section didn't seem to have hit this. --- xen/arch/x86/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2aff6d4b5338..0c6658298de2 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5959,7 +5959,7 @@ void init_or_livepatch modify_xen_mappings_lite( =20 v +=3D 1UL << L1_PAGETABLE_SHIFT; =20 - if ( l2_table_offset(v) =3D=3D 0 ) + if ( l1_table_offset(v) =3D=3D 0 ) break; } =20 --=20 2.44.0