### smap (x86)
> `= <boolean> | hvm`
-> Default: `true`
+> Default: `true` unless running in pv-shim mode on AMD or Hygon hardware
Flag to enable Supervisor Mode Access Prevention
Use `smap=hvm` to allow SMAP use by HVM guests only.
+In PV shim mode on AMD or Hygon hardware due to significant performance impact
+in some cases and generally lower security risk the option defaults to false.
+
### smep (x86)
> `= <boolean> | hvm`
-> Default: `true`
+> Default: `true` unless running in pv-shim mode on AMD or Hygon hardware
Flag to enable Supervisor Mode Execution Protection
Use `smep=hvm` to allow SMEP use by HVM guests only.
+In PV shim mode on AMD or Hygon hardware due to significant performance impact
+in some cases and generally lower security risk the option defaults to false.
+
### smt (x86)
> `= <boolean>`
unsigned long __read_mostly mmu_cr4_features = XEN_MINIMAL_CR4;
-/* smep: Enable/disable Supervisor Mode Execution Protection (default on). */
-#define SMEP_HVM_ONLY (-1)
-static s8 __initdata opt_smep = 1;
+/* smep: Enable/disable Supervisor Mode Execution Protection */
+#define SMEP_HVM_ONLY (-2)
+static s8 __initdata opt_smep = -1;
/*
* Initial domain place holder. Needs to be global so it can be created in
}
custom_param("smep", parse_smep_param);
-/* smap: Enable/disable Supervisor Mode Access Prevention (default on). */
-#define SMAP_HVM_ONLY (-1)
-static s8 __initdata opt_smap = 1;
+/* smap: Enable/disable Supervisor Mode Access Prevention */
+#define SMAP_HVM_ONLY (-2)
+static s8 __initdata opt_smap = -1;
static int __init parse_smap_param(const char *s)
{
set_in_cr4(X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT);
+ /* Do not enable SMEP/SMAP in PV shim on AMD and Hygon by default */
+ if ( opt_smep == -1 )
+ opt_smep = !pv_shim || !(boot_cpu_data.x86_vendor &
+ (X86_VENDOR_AMD | X86_VENDOR_HYGON));
+ if ( opt_smap == -1 )
+ opt_smap = !pv_shim || !(boot_cpu_data.x86_vendor &
+ (X86_VENDOR_AMD | X86_VENDOR_HYGON));
+
if ( !opt_smep )
setup_clear_cpu_cap(X86_FEATURE_SMEP);
if ( cpu_has_smep && opt_smep != SMEP_HVM_ONLY )