[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with pat_enable() and commit 72cbc8f04fe2


  • To: Andrew Lutomirski <luto@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>
  • From: "Michael Kelley (LINUX)" <mikelley@xxxxxxxxxxxxx>
  • Date: Mon, 9 Jan 2023 18:28:15 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EILYjBVO3TVH8Ko5wjRUBk5n4pb4VQ0+5EcJsTroldY=; b=cw0pz7bapB1x5b2tnwxJ7eIQfylFTTQw4un/oSasfYLApqC8e3pXho/0AEPHgzwN4Ns4NjOycLwJcQSalDNI9iZzrCBEpp6eHh9ZYQKbUZgTh/f1/s+sTPe7n0trvQTsbErhWLTYB1DEnfy25vtYQlhzKtSLM9wh2+cFVXy9sCeAhnjgZzLPyJaZH7fJ9wimal1MuYODJvsE3SIe2j2hHyDIQqL412uKsjwIOxU/M2g/sc6rUcbYCNh4d2Y5fNDchQyBuoTnqIHojcDoHv18+b/3IvOczOzgit4XDMAg8heutwi6/34nwX4qpTen1tSM3A7po1iW2WQrfdG7GTBJOQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DY2U6W+n1ubaPGlp8RZxACN0MDJF+DS+DG8VaQ3eSk+8/5CjKQEwjNX3xccctI0qB1wyr9ijPat7dzlWX8daI8KveCS0LkrDL887qfjJp0nmG5qli7hTspPdETDPMME5/iA6WK0zbXWVXCTchbybaGyctRybIHWkAjZPcPH+0RsqoGyc71hRog/vk3Ka+ERw+HREDdXx/6O+90unILVzeYt3ZWJtfQZtGDc+cE8UlKcoFUnnCRGxujwwPuRPVdPvTbtbkEkftn74FZJDGVqZybG0VN7ZEeLxL4gnylFk2PuWJYp43l6kwoM11JDxD3DllVBKjzQ/VZI22zK2AvYQZg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com;
  • Cc: "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 09 Jan 2023 18:28:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=00dc8fc2-24d1-4fce-9fff-420171fb08f5;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2023-01-09T17:47:38Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;
  • Thread-index: AdkkUwD6aRGwmsjgQS+RzXLKsHA1TA==
  • Thread-topic: Problem with pat_enable() and commit 72cbc8f04fe2

I've come across a case with a VM running on Hyper-V that doesn't get
MTRRs, but the PAT is functional.  (This is a Confidential VM using
AMD's SEV-SNP encryption technology with the vTOM option.)  In this
case, the changes in commit 72cbc8f04fe2 ("x86/PAT: Have pat_enabled()
properly reflect state when running on Xen") apply.   pat_enabled() returns
"true", but the MTRRs are not enabled.

But with this commit, there's a problem.  Consider memremap() on a RAM
region, called with MEMREMAP_WB plus MEMREMAP_DEC as the 3rd
argument. Because of the request for a decrypted mapping,
arch_memremap_can_ram_remap() returns false, and a new mapping
must be created, which is appropriate.

The following call stack results:

  memremap()
  arch_memremap_wb()
  ioremap_cache()
  __ioremap_caller()
  memtype_reserve()  <--- pcm is _PAGE_CACHE_MODE_WB
  pat_x_mtrr_type()  <-- only called after commit 72cbc8f04fe2

pat_x_mtrr_type() returns _PAGE_CACHE_MODE_UC_MINUS because
mtrr_type_lookup() fails.  As a result, memremap() erroneously creates the
new mapping as uncached.   This uncached mapping is causing a significant
performance problem in certain Hyper-V Confidential VM configurations.

Any thoughts on resolving this?  Should memtype_reserve() be checking
both pat_enabled() *and* whether MTRRs are enabled before calling
pat_x_mtrr_type()?  Or does that defeat the purpose of commit
72cbc8f04fe2 in the Xen environment?

I'm also looking at how to avoid this combination in a Hyper-V Confidential
VM, but that doesn't address underlying the flaw.

Michael



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.