Skip to contentSkip to conversation

x86/vtx: Improvements to ept= command line handling

PATCH In review Andrew Cooper 3 participants 6 messages Dec 20, 2018 – Dec 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/vtx: Improvements to ept= command line handling

Switch parse_ept_param() to use the parse_boolean() infrastructure for more consistency with related command line parameters. Rename opt_pml_enabled to opt_ept_pml for consistency with opt_ept_ad, and switch it to being bool

Drop the comment leading comment for parse_ept_param(). It is stale, and just repeats the command line documentation.

For the command line documentation, rewrite it largely from scratch, updating to the latest metadata style. Document A/D first, including a note about AVR41, and modify PML to note its dependency on A/D.

No practical changes to behaviour.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>

---
 docs/misc/xen-command-line.markdown | 40 ++++++++++++++++++++++---------------
 xen/arch/x86/hvm/vmx/vmcs.c         | 28 ++++++++------------------
 2 files changed, 32 insertions(+), 36 deletions(-)
docs/misc/xen-command-line.markdown +24 -16
index 44ee51a..78b207c 100644
@@ -841,29 +841,37 @@ effect the inverse meaning.
 >> Allows mapping of RuntimeServices which have no cachability attribute
 >> set as UC.
 
-### ept (Intel)
-> `= List of ( {no-}pml | {no-}ad )`
+### ept
+> `= List of [ ad=<bool>, pml=<bool> ]`
 
-Controls EPT related features.
+> Applicability: Intel
 
-> Sub-options:
-
-> `pml`
+Extended Page Tables are a feature of Intel's VT-x technology, whereby
+hardware manages the virtualisation of HVM guest pagetables.  EPT was
+introduced with the Nehalem architecture.
 
-> Default: `true`
+*   The `ad` boolean controls hardware tracking of Access and Dirty bits in the
+    EPT pagetables, and was first introduced in Broadwell Server.
 
->> PML is a new hardware feature in Intel's Broadwell Server and further
->> platforms which reduces hypervisor overhead of log-dirty mechanism by
->> automatically recording GPAs (guest physical addresses) when guest memory
->> gets dirty, and therefore significantly reducing number of EPT violation
->> caused by write protection of guest memory, which is a necessity to
->> implement log-dirty mechanism before PML.
+    By default, Xen will use A/D tracking when available in hardware, except
+    on Avoton processors affected by erratum AVR41.  Explicitly choosing
+    `ad=0` will disable the use of A/D tracking on capable hardware, whereas
+    choosing `ad=1` will cause tracking to be used even on AVR41-affected
+    hardware.
 
-> `ad`
+*   The `pml` boolean controls the use of Page Modification Logging, which is
+    also introduced in Broadwell Server.
 
-> Default: Hardware dependent
+    PML is a feature whereby the processor generates a list of pages which
+    have been dirtied.  This is necessary information for operations such as
+    live migration, and having the processor maintain the list of dirtied
+    pages is more efficient than traditional software implementations where
+    all guest writes trap into Xen so the dirty bitmap can be maintained.
 
->> Have hardware keep accessed/dirty (A/D) bits updated.
+    By default, Xen will use PML when it is available in hardware.  PML
+    functionally depends on A/D tracking, so choosing `ad=0` will implicitly
+    disable PML.  `pml=0` can be used to prevent the use of PML on otherwise
+    capable hardware.
 
 ### extra\_guest\_irqs
 > `= [<domU number>][,<dom0 number>]`
xen/arch/x86/hvm/vmx/vmcs.c +8 -20
index d6366c2..74f2a08 100644
@@ -65,35 +65,23 @@ integer_param("ple_gap", ple_gap);
 static unsigned int __read_mostly ple_window = 4096;
 integer_param("ple_window", ple_window);
 
-static bool_t __read_mostly opt_pml_enabled = 1;
+static bool __read_mostly opt_ept_pml = true;
 static s8 __read_mostly opt_ept_ad = -1;
 
-/*
- * The 'ept' parameter controls functionalities that depend on, or impact the
- * EPT mechanism. Optional comma separated value may contain:
- *
- *  pml                 Enable PML
- *  ad                  Use A/D bits
- */
 static int __init parse_ept_param(const char *s)
 {
     const char *ss;
-    int rc = 0;
+    int val, rc = 0;
 
     do {
-        bool_t val = !!strncmp(s, "no-", 3);
-
-        if ( !val )
-            s += 3;
-
         ss = strchr(s, ',');
         if ( !ss )
             ss = strchr(s, '\0');
 
-        if ( !strncmp(s, "pml", ss - s) )
-            opt_pml_enabled = val;
-        else if ( !strncmp(s, "ad", ss - s) )
+        if ( (val = parse_boolean("ad", s, ss)) >= 0 )
             opt_ept_ad = val;
+        else if ( (val = parse_boolean("pml", s, ss)) >= 0 )
+            opt_ept_pml = val;
         else
             rc = -EINVAL;
 
@@ -247,7 +235,7 @@ static int vmx_init_vmcs_config(void)
             opt |= SECONDARY_EXEC_ENABLE_VPID;
         if ( opt_unrestricted_guest_enabled )
             opt |= SECONDARY_EXEC_UNRESTRICTED_GUEST;
-        if ( opt_pml_enabled )
+        if ( opt_ept_pml )
             opt |= SECONDARY_EXEC_ENABLE_PML;
 
         /*
@@ -330,9 +318,9 @@ static int vmx_init_vmcs_config(void)
     if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT) )
         _vmx_secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_PML;
 
-    /* Turn off opt_pml_enabled if PML feature is not present */
+    /* Turn off opt_ept_pml if PML feature is not present. */
     if ( !(_vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_PML) )
-        opt_pml_enabled = 0;
+        opt_ept_pml = false;
 
     if ( (_vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) &&
           ple_gap == 0 )
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.12.18 at 18:16, <[email protected]> wrote:

Switch parse_ept_param() to use the parse_boolean() infrastructure for more consistency with related command line parameters. Rename opt_pml_enabled to opt_ept_pml for consistency with opt_ept_ad, and switch it to being bool

Drop the comment leading comment for parse_ept_param(). It is stale, and just

Nit: There's one "comment" to many here.

Quoted 26 lines
docs/misc/xen-command-line.markdown +8 -8
@@ -841,29 +841,37 @@ effect the inverse meaning.
 >> Allows mapping of RuntimeServices which have no cachability attribute
 >> set as UC.
 
-### ept (Intel)
-> `= List of ( {no-}pml | {no-}ad )`
+### ept
+> `= List of [ ad=<bool>, pml=<bool> ]`
 
-Controls EPT related features.
+> Applicability: Intel
 
-> Sub-options:
-
-> `pml`
+Extended Page Tables are a feature of Intel's VT-x technology, whereby
+hardware manages the virtualisation of HVM guest pagetables.  EPT was
+introduced with the Nehalem architecture.
 
-> Default: `true`
+*   The `ad` boolean controls hardware tracking of Access and Dirty bits in the
+    EPT pagetables, and was first introduced in Broadwell Server.
 
->> PML is a new hardware feature in Intel's Broadwell Server and further

docs/misc/xen-command-line.markdown effect the inverse meaning. · line 860

Quoted 10 lines
docs/misc/xen-command-line.markdown +5 -5
->> platforms which reduces hypervisor overhead of log-dirty mechanism by
->> automatically recording GPAs (guest physical addresses) when guest memory
->> gets dirty, and therefore significantly reducing number of EPT violation
->> caused by write protection of guest memory, which is a necessity to
->> implement log-dirty mechanism before PML.
+    By default, Xen will use A/D tracking when available in hardware, except
+    on Avoton processors affected by erratum AVR41.  Explicitly choosing
+    `ad=0` will disable the use of A/D tracking on capable hardware, whereas
+    choosing `ad=1` will cause tracking to be used even on AVR41-affected
+    hardware.

Is there any reason for this special casing of the one erratum? Earlier this week I've gone through some spec updates for other purposes, and I've seen some rather frightening EPT A/D errata.

Anyway, this is a question unrelated to the patch here, so

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 7 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.12.18 at 18:16, <[email protected]> wrote:

Switch parse_ept_param() to use the parse_boolean() infrastructure for more consistency with related command line parameters. Rename opt_pml_enabled to opt_ept_pml for consistency with opt_ept_ad, and switch it to being bool

Drop the comment leading comment for parse_ept_param(). It is stale, and just

Nit: There's one "comment" to many here.

Oops - will fix.

Quoted 26 lines
Quoted 26 lines
docs/misc/xen-command-line.markdown +8 -7
@@ -841,29 +841,37 @@ effect the inverse meaning.
 >> Allows mapping of RuntimeServices which have no cachability attribute
 >> set as UC.
 
-### ept (Intel)
-> `= List of ( {no-}pml | {no-}ad )`
+### ept
+> `= List of [ ad=<bool>, pml=<bool> ]`
 
-Controls EPT related features.
+> Applicability: Intel
 
-> Sub-options:
-
-> `pml`
+Extended Page Tables are a feature of Intel's VT-x technology, whereby
+hardware manages the virtualisation of HVM guest pagetables.  EPT was
+introduced with the Nehalem architecture.
 
-> Default: `true`
+*   The `ad` boolean controls hardware tracking of Access and Dirty bits in the
+    EPT pagetables, and was first introduced in Broadwell Server.
 
Quoted 14 lines

docs/misc/xen-command-line.markdown effect the inverse meaning. · line 860

Quoted 11 lines
docs/misc/xen-command-line.markdown +5 -6
->> PML is a new hardware feature in Intel's Broadwell Server and further
->> platforms which reduces hypervisor overhead of log-dirty mechanism by
->> automatically recording GPAs (guest physical addresses) when guest memory
->> gets dirty, and therefore significantly reducing number of EPT violation
->> caused by write protection of guest memory, which is a necessity to
->> implement log-dirty mechanism before PML.
+    By default, Xen will use A/D tracking when available in hardware, except
+    on Avoton processors affected by erratum AVR41.  Explicitly choosing
+    `ad=0` will disable the use of A/D tracking on capable hardware, whereas
+    choosing `ad=1` will cause tracking to be used even on AVR41-affected
+    hardware.

Is there any reason for this special casing of the one erratum? Earlier this week I've gone through some spec updates for other purposes, and I've seen some rather frightening EPT A/D errata.

Which, out of interest?  There are a few, particularly on Skylake, but all the problematic ones I'm aware of are fixed in microcode.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.12.18 at 12:15, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.12.18 at 18:16, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +5 -0
+    By default, Xen will use A/D tracking when available in hardware, except
+    on Avoton processors affected by erratum AVR41.  Explicitly choosing
+    `ad=0` will disable the use of A/D tracking on capable hardware, whereas
+    choosing `ad=1` will cause tracking to be used even on AVR41-affected
+    hardware.
Quoted 6 lines
Quoted 3 lines

Is there any reason for this special casing of the one erratum? Earlier this week I've gone through some spec updates for other purposes, and I've seen some rather frightening EPT A/D errata.

Which, out of interest? There are a few, particularly on Skylake, but all the problematic ones I'm aware of are fixed in microcode.

I'd have to go through them again, as I didn't pay close attention to what was said about their status. Are we generally putting ourselves on the position then that errata don't need working around if there's a microcode update available? That's a possible position to take, but not spelled out anywhere.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 21.12.18 at 12:15, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

docs/misc/xen-command-line.markdown effect the inverse meaning. · line 860

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.12.18 at 18:16, <[email protected]> wrote:
docs/misc/xen-command-line.markdown +5 -0
+    By default, Xen will use A/D tracking when available in hardware, except
+    on Avoton processors affected by erratum AVR41.  Explicitly choosing
+    `ad=0` will disable the use of A/D tracking on capable hardware, whereas
+    choosing `ad=1` will cause tracking to be used even on AVR41-affected
+    hardware.

Is there any reason for this special casing of the one erratum? Earlier this week I've gone through some spec updates for other purposes, and I've seen some rather frightening EPT A/D errata.

Quoted 7 lines
Quoted 2 lines

Which, out of interest? There are a few, particularly on Skylake, but all the problematic ones I'm aware of are fixed in microcode.

I'd have to go through them again, as I didn't pay close attention to what was said about their status. Are we generally putting ourselves on the position then that errata don't need working around if there's a microcode update available? That's a possible position to take, but not spelled out anywhere.

Intel and AMD are quite clear that you should be running up-to-date microcode.

Its conceptually similar to someone saying "I found an issue in Xen 4.8.0" and our reply being "Thats great, but its already fixed in 4.8.1
- please update".

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#5 lore raw
In reply to Andrew Cooper
Quoted 13 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Friday, December 21, 2018 1:17 AM

Switch parse_ept_param() to use the parse_boolean() infrastructure for more
consistency with related command line parameters. Rename opt_pml_enabled to
opt_ept_pml for consistency with opt_ept_ad, and switch it to being bool

Drop the comment leading comment for parse_ept_param(). It is stale, and just
repeats the command line documentation.

Quoted 8 lines

For the command line documentation, rewrite it largely from scratch, updating
to the latest metadata style. Document A/D first, including a note about AVR41, and modify PML to note its dependency on A/D.

No practical changes to behaviour.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel