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

[PATCH] x86/paging: restrict physical address width reported to guests


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 29 Sep 2021 14:47:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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; bh=q8LufTiCUQsqHdGqUe2Z53cyWIXeXkkmydlokoMNKK4=; b=YLnCyRzo0kE/YJrwz2kjctT2hXNrEP3cagd4FtkV86V9kf0D7fTBDpt6dipHjlIT0VukC6NF3ydMJXOOlq+xYu2uuO44/DpTXpYZkP07YSGelNWXKrPdV25Yh3nrNZqSUkT7Is8xkjD+CQk33wASxyHVH+pMx3P5obOFkEBgk0pD2Tfnu1hcs2tUQkfcu6IU9ZlYZiynLOd0btkI56on90bpAnqWo7izrQQsazKgTicY5t0I498YM6LbMD9NnZZ0yYbYWHQ3etU+zjMRimgTqD3DBpyDZw5LGbQuI4bc0UZJz7zn/1ICXqn4fsaayeDdPQDuy/omc/T5hiDZHwRRQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I5Fcwr0jtB+7+qt66ta0uxT9Of0oDiet3IpknjAG0d8ZHMeWV6bFznNReFVNYITq841f9ovvlyMhbqNrhvfmE1dIibPq1UCCejW142TTMWMZUoBLDHF58yyLqMj9GaOxifxvXRzu1/Gnm51AEf6nnHKEg+Y57ejCMqsvrAE9TSt6RTsbaV5V7bdtGCV/TFh9CgtcfUxM8w853YdMYwu08PTPYu57LmUT7BcO+970fNSjT8hp2AtEpqtnLP6rwNNVCtblYADTOSvF2Nyp2ZQAThzsStox2yJRpIpSf5ySyj6LzyKF7SpOAaNcFNtYBj5djHaft646m173nbNBpP3yKQ==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 29 Sep 2021 12:47:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Modern hardware may report more than 48 bits of physical address width.
For paging-external guests our P2M implementation does not cope with
larger values. Telling the guest of more available bits means misleading
it into perhaps trying to actually put some page there (like was e.g.
intermediately done in OVMF for the shared info page).

While there also convert the PV check to a paging-external one (which in
our current code base are synonyms of one another anyway).

Fixes: 5dbd60e16a1f ("x86/shadow: Correct guest behaviour when creating PTEs 
above maxphysaddr")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -401,11 +401,18 @@ static always_inline unsigned int paging
 {
     unsigned int bits = paging_mode_hap(d) ? hap_paddr_bits : paddr_bits;
 
-    if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) &&
-         !is_pv_domain(d) )
+    if ( paging_mode_external(d) )
     {
-        /* Shadowed superpages store GFNs in 32-bit page_info fields. */
-        bits = min(bits, 32U + PAGE_SHIFT);
+        if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) )
+        {
+            /* Shadowed superpages store GFNs in 32-bit page_info fields. */
+            bits = min(bits, 32U + PAGE_SHIFT);
+        }
+        else
+        {
+            /* Both p2m-ept and p2m-pt only support 4-level page tables. */
+            bits = min(bits, 48U);
+        }
     }
 
     return bits;




 


Rackspace

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