From nobody Fri Nov 22 13:07:21 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=1718198238; cv=none; d=zohomail.com; s=zohoarc; b=C4Tac1bQ/ZTTFufqUlDVS5kZzGVoeDKKpqiKrtKG+tkYT5EiXFZNtC8ByqmXGo/skkzw8gYSYVDJn+dUhFfaOTHEk9mHXd13TonWTx34joyob/zdkTCfHiAI+F7m7zCaG/3dctrfDLFb9wUR9PuCWK4Fqc8OZJGnTeOTCWr1Twk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718198238; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YkdNjBOZ78Xa9HqoWeOu8L3vhUg6jdFS1CUj7DasUQM=; b=BVXX4sE0WRFQH7Y+y/7R689rXg5YLhJ4EQ/1/VCjf0m0UsDExy1S9t3LGBon6cgmtg9EA/xZ/JNtzjpSTd4FR6zguKeVRjhoLGVokynnVBrj28x465RH42/QaXmvV+koQxZOM/6PLRVliGsD2Rww2Ub5Zh289bgBrJ3MMmeTUw4= 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 1718198238516128.9391626294647; Wed, 12 Jun 2024 06:17:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.739324.1146333 (Exim 4.92) (envelope-from ) id 1sHNqa-0000j2-2k; Wed, 12 Jun 2024 13:17:04 +0000 Received: by outflank-mailman (output) from mailman id 739324.1146333; Wed, 12 Jun 2024 13:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sHNqa-0000iv-04; Wed, 12 Jun 2024 13:17:04 +0000 Received: by outflank-mailman (input) for mailman id 739324; Wed, 12 Jun 2024 13:17:02 +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 1sHNqY-0000Ir-A4 for xen-devel@lists.xenproject.org; Wed, 12 Jun 2024 13:17:02 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0e08868c-28be-11ef-90a3-e314d9c70b13; Wed, 12 Jun 2024 15:17:01 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a6e349c0f2bso680882466b.2 for ; Wed, 12 Jun 2024 06:17:01 -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-a6f0ffcbf38sm544927766b.142.2024.06.12.06.17.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jun 2024 06:17:00 -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: 0e08868c-28be-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1718198221; x=1718803021; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=YkdNjBOZ78Xa9HqoWeOu8L3vhUg6jdFS1CUj7DasUQM=; b=NaBF1Vd3LhQtM9NPdUWJtCNV8uRmGIGJEIu63CvWks+wmh2gqUKdzeqha3VuvSzabI Qi514K4khOxJAvsDvDrZBzMu/z7U8/yM2aL02WWwbW/nqT8eP0+9C9BYWwa4WaBie5b2 al8cXHxnSVjlOnfv7BciSqL04uUPEvyjKk5oQv53ysj5LYkvVpZsvc+TuA2puxi+SKgm CrRO4Ddj50rFK3iooxHVeDmf2BDXHSrLNpdNQMZhXnt1TmYqNbNtSedury+ozS/Ia4O5 6r5eqdBRa3Yw98ui2+FtCMzPMkg2iUYUatfhY1OIWSQXecFjl8SKRIxxxvPqM1LVNPs5 zM1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718198221; x=1718803021; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YkdNjBOZ78Xa9HqoWeOu8L3vhUg6jdFS1CUj7DasUQM=; b=ovsPzmrTegy20117T4lQ8rWC7qbEtUR0/X5eOnJEHefe90+QdlXwJxajW6pHE6aGw2 Xixhx/Fe65UPOumIxUY1VAc4ICTIZuAX6nPArjJ/9Lfnmqj+DnclYrBs+GvMLb1LsCff 67cDr3uehqX6qwOPCLa8+qIN48DUtWocUAXL0a3DV4BoNWwnPhbhR9p8oGkwZtt3BqQ5 lDYhr/IXf+AH7SCvZxS7qbEx3dGIgZRecD0fT10ObCYLsKx5aZ58D0eMLbBtF/IO9Uhg zV3bZ9/lOGwfgrFzIEJlg8IG3yubAIWr+Qn4s86RYXhm/YiYlLoZEWH4Xah2TLiAhL4J nyzA== X-Gm-Message-State: AOJu0YzcXq5FRgiwdmTOMgMKNUMXslgsu9PWqAiy1ibOfMf7mmOI2jog DopBcMJ6e4Ii6rXya4I4jFIwPsBwH9tAk2m6zWu7+dvIHfvkOLl6BhWA5gI/8OSJsBqj46i+kKo = X-Google-Smtp-Source: AGHT+IHq2OVHWuKZ/0M/6EvrW0HJ4JL2KtqF1J1urmoia2YhOyNoort1lZ3zhFA/wiaWN+QQ9uI9kA== X-Received: by 2002:a17:907:f81:b0:a6f:1972:7fd with SMTP id a640c23a62f3a-a6f480272c3mr110037866b.67.1718198220955; Wed, 12 Jun 2024 06:17:00 -0700 (PDT) Message-ID: Date: Wed, 12 Jun 2024 15:16:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 for-4.19 2/3] x86/EPT: avoid marking non-present entries for re-configuring From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Oleksii Kurochko References: <2936ffad-5395-45fd-877f-7fb2ca8b9dc8@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7Kl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+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <2936ffad-5395-45fd-877f-7fb2ca8b9dc8@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1718198239702100001 Content-Type: text/plain; charset="utf-8" For non-present entries EMT, like most other fields, is meaningless to hardware. Make the logic in ept_set_entry() setting the field (and iPAT) conditional upon dealing with a present entry, leaving the value at 0 otherwise. This has two effects for epte_get_entry_emt() which we'll want to leverage subsequently: 1) The call moved here now won't be issued with INVALID_MFN anymore (a respective BUG_ON() is being added). 2) Neither of the other two calls could now be issued with a truncated form of INVALID_MFN anymore (as long as there's no bug anywhere marking an entry present when that was populated using INVALID_MFN). Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- v2: New. --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -650,6 +650,8 @@ static int cf_check resolve_misconfig(st if ( e.emt !=3D MTRR_NUM_TYPES ) break; =20 + ASSERT(is_epte_present(&e)); + if ( level =3D=3D 0 ) { for ( gfn -=3D i, i =3D 0; i < EPT_PAGETABLE_ENTRIES; ++i ) @@ -915,17 +917,6 @@ ept_set_entry(struct p2m_domain *p2m, gf =20 if ( mfn_valid(mfn) || p2m_allows_invalid_mfn(p2mt) ) { - bool ipat; - int emt =3D epte_get_entry_emt(p2m->domain, _gfn(gfn), mfn, - i * EPT_TABLE_ORDER, &ipat, - p2mt); - - if ( emt >=3D 0 ) - new_entry.emt =3D emt; - else /* ept_handle_misconfig() will need to take care of this. */ - new_entry.emt =3D MTRR_NUM_TYPES; - - new_entry.ipat =3D ipat; new_entry.sp =3D !!i; new_entry.sa_p2mt =3D p2mt; new_entry.access =3D p2ma; @@ -941,6 +932,22 @@ ept_set_entry(struct p2m_domain *p2m, gf need_modify_vtd_table =3D 0; =20 ept_p2m_type_to_flags(p2m, &new_entry); + + if ( is_epte_present(&new_entry) ) + { + bool ipat; + int emt =3D epte_get_entry_emt(p2m->domain, _gfn(gfn), mfn, + i * EPT_TABLE_ORDER, &ipat, + p2mt); + + BUG_ON(mfn_eq(mfn, INVALID_MFN)); + + if ( emt >=3D 0 ) + new_entry.emt =3D emt; + else /* ept_handle_misconfig() will need to take care of this.= */ + new_entry.emt =3D MTRR_NUM_TYPES; + new_entry.ipat =3D ipat; + } } =20 if ( sve !=3D -1 )