From nobody Sun Nov 24 18:01:53 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=1727911248; cv=none; d=zohomail.com; s=zohoarc; b=gHV4y7pdw7xp7R8JFB9EbIWXWl4HLUE4Vjavoq23MjSJyiW545dmWi4PXetA8BtzVXluzx7DvqZVXDqsSn8JJKm8pNJzD1SziTI1ocktG6lBhmJG1dQISlp/E2ovmgY2KTbotGuVqCY/B0SANHRENKZ9lEjAW4yOFoZ7wjA0eqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727911248; 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=8td8Tc/ZYMUVmIE4bZONjqFLPJlU2/yV07ZZf+6r1ZY=; b=dPAdscEssVpPMl/ObGzIpqj6UFga3nqxgK+sPengoHyhLo0mDcwEa+oVkH5eFJDdJoFGCsPwaPII0etxnW1ryH7uTDP+4UVJE5rphgDZM/AQEed0U8CFGgUnQrbMKeC1kvWAfFad6h3bw3Jp+uaUT34VO7Dowj/ih3gUY3NYKgs= 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 1727911248429194.63980794004578; Wed, 2 Oct 2024 16:20:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.809100.1221257 (Exim 4.92) (envelope-from ) id 1sw8dk-0007yX-2r; Wed, 02 Oct 2024 23:20:16 +0000 Received: by outflank-mailman (output) from mailman id 809100.1221257; Wed, 02 Oct 2024 23:20:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sw8dj-0007yQ-Uo; Wed, 02 Oct 2024 23:20:15 +0000 Received: by outflank-mailman (input) for mailman id 809100; Wed, 02 Oct 2024 23:20:14 +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 1sw8di-0007yK-5r for xen-devel@lists.xenproject.org; Wed, 02 Oct 2024 23:20:14 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id df9945dd-8114-11ef-a0ba-8be0dac302b0; Thu, 03 Oct 2024 01:20:12 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a8d29b7edc2so31614466b.1 for ; Wed, 02 Oct 2024 16:20:12 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93cd7a3609sm865623466b.211.2024.10.02.16.20.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 16:20:10 -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: df9945dd-8114-11ef-a0ba-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1727911211; x=1728516011; 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=8td8Tc/ZYMUVmIE4bZONjqFLPJlU2/yV07ZZf+6r1ZY=; b=LXPw4Pr+ekxQCDI2gCRpWzYA9tg5Y/zpIf/ipngXOhi+R7g2RywUIdfWE0kELr035d QmpjDaVYrXY1s232ySg7Kd2uIymR8Fp7CRD1Upb85D9s4Uc0zctw3gSCwYIg3cZRoIMU MaNSQvmeVRAIdVXX+k0yUR65ZzVvBmYuli5us= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727911211; x=1728516011; 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=8td8Tc/ZYMUVmIE4bZONjqFLPJlU2/yV07ZZf+6r1ZY=; b=oe9ipUHgxfS6LgorgIQYIOLvU3yl438lHbCH0f/MymE8sRDygvt/cqYOVgOIoG9yCV VEjL1ilddbMxwxsNKpI6Dr6yg4yC+GYR2AH1uaUmmdIFNAsKw+yNn2LblK3AErDTDaYp RfvGXcUWoNYt2OD6oNnM8sOtl0gOVrfXp93qGyUdc25Ms0ng4C4Wzyxa+G92EpWDdyQP oM0BSHpn2JlDMtjWgZflaEbbLvxLUf9ER9hzPfb6ja8gG9poikgu+FMUG3ZwCKCJVtQf 1z0gtTtqas3vnhYkkq8Y2uLZXm+qs4ghVszMlNmIeXUraC4bxe36GjkY6wR2qtiXlSCp lWAQ== X-Gm-Message-State: AOJu0YyV1Mc/3IwvOQJJLqSMjGyW0F/Urih+1p0+CH4zINRiAbQuEojO 2AassqVpsFW7xiKhCczvMlGKtDg8g/0a9pjhIq4CvpwHJmoQz9hLl0zh9Al1Jau57+oGwLVNg2r FIsk= X-Google-Smtp-Source: AGHT+IH83iAsi3X7NG94E2JYVXogLSALLm5LBtscW7WFcONDQQBwA8g6Ww0BqpV7nSaLAYZdgNp2SA== X-Received: by 2002:a17:907:d20:b0:a8b:6ee7:ba12 with SMTP id a640c23a62f3a-a98f8261dbamr377643766b.27.1727911211380; Wed, 02 Oct 2024 16:20:11 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH] x86/boot: Further simplify CR4 handling in dom0_construct_pv() Date: Thu, 3 Oct 2024 00:20:08 +0100 Message-Id: <20241002232008.1988682-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 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: 1727911250056116600 The logic would be more robust disabling SMAP based on its precense in CR4, rather than SMAP's accociation with a synthetic feature. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 v2: * Strip LASS changes back out. --- xen/arch/x86/pv/dom0_build.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 262edb6bf2f0..ee9ecdc2abbf 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -1057,6 +1057,7 @@ int __init dom0_construct_pv(struct domain *d, module_t *initrd, const char *cmdline) { + unsigned long cr4 =3D read_cr4(); int rc; =20 /* @@ -1064,19 +1065,19 @@ int __init dom0_construct_pv(struct domain *d, * prevents us needing to write construct_dom0() in terms of * copy_{to,from}_user(). */ - if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) ) + if ( cr4 & X86_CR4_SMAP ) { if ( IS_ENABLED(CONFIG_PV32) ) cr4_pv32_mask &=3D ~X86_CR4_SMAP; =20 - write_cr4(read_cr4() & ~X86_CR4_SMAP); + write_cr4(cr4 & ~X86_CR4_SMAP); } =20 rc =3D dom0_construct(d, image, image_headroom, initrd, cmdline); =20 - if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) ) + if ( cr4 & X86_CR4_SMAP ) { - write_cr4(read_cr4() | X86_CR4_SMAP); + write_cr4(cr4); =20 if ( IS_ENABLED(CONFIG_PV32) ) cr4_pv32_mask |=3D X86_CR4_SMAP; --=20 2.39.5