From nobody Fri Nov 22 08:03:12 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=1718198215; cv=none; d=zohomail.com; s=zohoarc; b=FBc69qx4YNHORf9VNEfTE1QDe4eX/ia8s0H0mD9pV35ZaeweDxbCc3pA31FBmBAeVZ3Ml41drcJAr69BBfEFLsw2mrOVSp0GsH5bKSnTFh3TSQWAAbFAS/orz47Wa+M753ylO7dgnxVLg8xmcebrMRs0aV8tgrsiI6q+k5EACWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718198215; 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=IIBq/heXgaX7T28VY8MGlPRmzmqXncKPkrU8y33t/6Q=; b=PeCqBFiIXYzxU8NnjTipiTm1XW47beIJLbwlwEIbrGk5LJp1XY4BlyZ85MnjK2KyhZf788EMC37PpjYlJQ2B5P2PHOrWzZqLn1ibzWqEQ8sBVfgTDOodim+aB0dR9FM3AJQqSwyvp/KrRacfUpcoBeoDuyk0DMGiVDN+sFZz8aE= 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 1718198214971291.33998080035667; Wed, 12 Jun 2024 06:16:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.739322.1146323 (Exim 4.92) (envelope-from ) id 1sHNqD-0000J4-RN; Wed, 12 Jun 2024 13:16:41 +0000 Received: by outflank-mailman (output) from mailman id 739322.1146323; Wed, 12 Jun 2024 13:16:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sHNqD-0000Ix-Om; Wed, 12 Jun 2024 13:16:41 +0000 Received: by outflank-mailman (input) for mailman id 739322; Wed, 12 Jun 2024 13:16:41 +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 1sHNqC-0000Ir-Ur for xen-devel@lists.xenproject.org; Wed, 12 Jun 2024 13:16:40 +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 01116f7b-28be-11ef-90a3-e314d9c70b13; Wed, 12 Jun 2024 15:16:40 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a6f1dc06298so287400666b.1 for ; Wed, 12 Jun 2024 06:16:40 -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-a6f1c99d8f1sm426917466b.175.2024.06.12.06.16.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jun 2024 06:16:39 -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: 01116f7b-28be-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1718198199; x=1718802999; 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=IIBq/heXgaX7T28VY8MGlPRmzmqXncKPkrU8y33t/6Q=; b=Mmh7EiEOBFRwDyV91f2ap5XTMIEWo3YTypsleYMGQq48N5g/fWTtGxLmmNYp1rozSo UVcZOKQzihLQM4ul+x5MJweNkukTQrgXmdtj+jdLgDQWQHwWgXIMTFtDtQ48rWKUb8GW yf+KDfcHXdKeXi9/p+Qyo0ATyAWwFxhZyUH6jIFs8CP5DBX4fMd8kMoKf0LsF0YsboN8 d0GEYo3ABWaoVkqDeYiyMzAMwpSDeN+dzFMbMlLd9uCXfRcWYdhLOCfOaBcqwXoaHgrw s0HJOcQXF7ygNGhXDq79hLFJn8vkCo0dZYGQP0T9/p5WmyRHSkonaecVMMeflWuvbTam 0kZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718198199; x=1718802999; 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=IIBq/heXgaX7T28VY8MGlPRmzmqXncKPkrU8y33t/6Q=; b=dbugReXPgfwlbgbsTeqCh6qlCxC+iWIqKY4zwDeo8dgi1RyFZK9qt/VaWHNjHEwJ6z xxiXtjFF+eWPgWlog1wPqnIkrX8l4hObP9frktUBYGj/6koFz/juj+TLz/yyrNxY1kF7 XDAhKFlLt26y7BTXdRXd+xOpjAR9hY/lr75Ji84TvQpqkao6ljCVDxuenspnJzEgLZ7f pRXwN5pdpNyQTJp8iZCwGNHj4TG2MRLhA7UfLyBVRMmHXgx4UDFqNvcAFI9GkDlUaD64 gz73X19f+oFZQw03SZKGpXYQv4h2eNBwL+nezhyONF82t4NsiVRUnhQZE8KjSdxyq/7w obzg== X-Gm-Message-State: AOJu0Yx4hbdML/XNA2gvAGDI079bLlhWWCHfYLL43Hcj2o2Dng0cue9E aczJgGNl2OnbQnp3UN/ojiCHK2FXniy75RronRELkxKCKijxlChjUp+DQXxEO7tN5PfiYzgLlyA = X-Google-Smtp-Source: AGHT+IGa7qIcGL9sb6ucqx2qnH+S/tl++sd2dtseLK+/TzKRMt3cKSekBFUIbqMltkXqp/I+pnl8CQ== X-Received: by 2002:a17:906:d972:b0:a6f:6ef:225 with SMTP id a640c23a62f3a-a6f47c9c2dcmr115080166b.19.1718198199385; Wed, 12 Jun 2024 06:16:39 -0700 (PDT) Message-ID: <175df1a2-a95f-462b-ad49-3a0fef727658@suse.com> Date: Wed, 12 Jun 2024 15:16:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 for-4.19 1/3] x86/EPT: correct special page checking in epte_get_entry_emt() 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+zF2jG5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0cl0HVJuQKC+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: 1718198215745100001 Content-Type: text/plain; charset="utf-8" mfn_valid() granularity is (currently) 256Mb. Therefore the start of a 1Gb page passing the test doesn't necessarily mean all parts of such a range would also pass. Yet using the result of mfn_to_page() on an MFN which doesn't pass mfn_valid() checking is liable to result in a crash (the invocation of mfn_to_page() alone is presumably "just" UB in such a case). Fixes: ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages") Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- Of course we could leverage mfn_valid() granularity here to do an increment by more than 1 if mfn_valid() returned false. Yet doing so likely would want a suitable helper to be introduced first, rather than open-coding such logic here. --- v2: New. --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -519,8 +519,12 @@ int epte_get_entry_emt(struct domain *d, } =20 for ( special_pgs =3D i =3D 0; i < (1ul << order); i++ ) - if ( is_special_page(mfn_to_page(mfn_add(mfn, i))) ) + { + mfn_t cur =3D mfn_add(mfn, i); + + if ( mfn_valid(cur) && is_special_page(mfn_to_page(cur)) ) special_pgs++; + } =20 if ( special_pgs ) { From nobody Fri Nov 22 08:03:12 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+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+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 ) From nobody Fri Nov 22 08:03:12 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=1718198276; cv=none; d=zohomail.com; s=zohoarc; b=HqqGIWF3ChMUOLJkjotyusmK++R502MK8GPJd0VzgYNO6R3YeoCeUH8+5PIBxQyEUdX4kR59lQlPb5lweb5Z8M+vwVJzvCgwkU9DFujBOlwN/Se9SXEsrLHm9JyANlEhk8qtwI806C2om6qSOAFa9xHZMPjPYdwPjvLCeEODpi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718198276; 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=OE6BxbFhz/GuABFcUaV8g29dJf9tmzpd1oPgGPbHYps=; b=Cs7OXCtXyjhfoWonDACHylx2yuM6NnKPO3WIwSyT2T/b7TriMCZfzEdS8Yj+dV2IdsjvcglYuo1I1tbKg0g8UVtbsK4bFIAJlpZkESZkKLYo8KuhjHfvQg3sn7J5HWfAhEsV92W4ygWOyA4nK3sKS/8dQPWFOsB5ImlgGI6XCUc= 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 1718198276977309.4932756623966; Wed, 12 Jun 2024 06:17:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.739333.1146343 (Exim 4.92) (envelope-from ) id 1sHNrE-0001WF-AL; Wed, 12 Jun 2024 13:17:44 +0000 Received: by outflank-mailman (output) from mailman id 739333.1146343; Wed, 12 Jun 2024 13:17: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 1sHNrE-0001W8-7Z; Wed, 12 Jun 2024 13:17:44 +0000 Received: by outflank-mailman (input) for mailman id 739333; Wed, 12 Jun 2024 13:17:42 +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 1sHNrC-0000uE-LP for xen-devel@lists.xenproject.org; Wed, 12 Jun 2024 13:17:42 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 254f252c-28be-11ef-b4bb-af5377834399; Wed, 12 Jun 2024 15:17:40 +0200 (CEST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57c6011d75dso2660444a12.3 for ; Wed, 12 Jun 2024 06:17:40 -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 4fb4d7f45d1cf-57cab3f4741sm1100360a12.22.2024.06.12.06.17.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jun 2024 06:17: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: 254f252c-28be-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1718198260; x=1718803060; 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=OE6BxbFhz/GuABFcUaV8g29dJf9tmzpd1oPgGPbHYps=; b=IdT5xownBC46L/4jUwkqJEUgl/IaPfATr8M6Qktcslfs2X6nIHuxs17YgMi6Q3TW53 nYBw0Pdag5wunGCTYySK8wZSDPFUpuVnVXRlYjOolCYSJRYNeOlngdOC/o2R8rLme38b 75yzHJUJp7FDuirLm6t5Y+pu7ElogOvKScWJDWFVrENlBAuHvyc9BPUmrt0XvM7d2ROH HOs4XAq1itfNuTkxSWrHtq/J78ScZQ1YEkAuEfdMSyfFVBMkU9kQ7yH5uMGe9tq8GTgH U3KkZr4XnIHQzDCKVyHu6/qBWzNDjyA2ch0wYvSYyapERaOHBeN0f6iAtcd8a1nl0n3a xdYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718198260; x=1718803060; 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=OE6BxbFhz/GuABFcUaV8g29dJf9tmzpd1oPgGPbHYps=; b=o9uYJJF7IRPbodYg3l2mYdm9EjvpKQguEJJfyCtViYMT6DwiuHupGltAJOOxxd2FEU 9pOTlhi3K0DFo61VI7HjpXm8rrODl0SD1wxFJK/AbXOL8QKPZyESzW9VocU+jTHBja69 UaKuZ0NbxyosZ+W6wxSwKrsDDKOXyJoNEGCeB+uKtEeJMov5OEfLb3VkWwZG2Tx/MPPH ZQPH0VjOkK69/oaYcOYk9bhD1L2SgvcKwzPWk8KCxPRVIk/K4JuwzCpX//OE37xfYyjm +rRjEcpyK7r70pTH7kNnMIImHpvATDtRQjToj1T5hXEX7eJJ/D/tk6/QypvL3blvgr/r tbqA== X-Gm-Message-State: AOJu0Yxu3LmDJRkQspSUlUq8LTkQt370nbN7kxK6IMvT76rl7GC/XAsU xqq30HANwZ6riLSRPZQ/4s241Gns40+MA38S5V4w+Eq7Ug4I8UwSA+DG26OH4mY6Kr0OUoDqOgA = X-Google-Smtp-Source: AGHT+IGsMdg4tUyavdeBHQOEiXhnoC90DvTKudxzlW25vpQM2p+VKF34nC8unmxL9isU1dg41/8w2w== X-Received: by 2002:a50:8acd:0:b0:57c:6f0a:bc57 with SMTP id 4fb4d7f45d1cf-57caaae520bmr1225185a12.36.1718198260234; Wed, 12 Jun 2024 06:17:40 -0700 (PDT) Message-ID: <7607c5f7-772a-4c49-b2df-19f32ec2180b@suse.com> Date: Wed, 12 Jun 2024 15:17:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 for-4.19 3/3] x86/EPT: drop questionable mfn_valid() from epte_get_entry_emt() 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 /0tbFCzD2h20ahe8rC1gb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aRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+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: 1718198278044100001 Content-Type: text/plain; charset="utf-8" mfn_valid() is RAM-focused; it will often return false for MMIO. Yet access to actual MMIO space should not generally be restricted to UC only; especially video frame buffer accesses are unduly affected by such a restriction. Since, as of ???????????? ("x86/EPT: avoid marking non-present entries for re-configuring"), the function won't be called with INVALID_MFN or, worse, truncated forms thereof anymore, we call fully drop that check. Fixes: 81fd0d3ca4b2 ("x86/hvm: simplify 'mmio_direct' check in epte_get_ent= ry_emt()") Signed-off-by: Jan Beulich Release-Acked-by: Oleksii Kurochko Reviewed-by: Roger Pau Monn=C3=A9 --- Considering that we've just declared PVH Dom0 "supported", this may well qualify for 4.19. The issue was specifically very noticeable there. --- v2: Different approach (and hence different title and description). --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -501,12 +501,6 @@ int epte_get_entry_emt(struct domain *d, return -1; } =20 - if ( !mfn_valid(mfn) ) - { - *ipat =3D true; - return X86_MT_UC; - } - /* * Conditional must be kept in sync with the code in * {iomem,ioports}_{permit,deny}_access().