xen: support enabling SMEP/SMAP for HVM only
PATCH v2 1/1 xen: support enabling SMEP/SMAP for HVM only
Enhance "smep" and "smap" command line options to support enabling SMEP or SMAP for HVM only with allowing "hvm" as a value.
Signed-off-by He Chen <[email protected]>
---
Changes in V2:
* Allow "hvm" as a value to "smep" and "smap" command line options.
* Clear SMEP/SMAP CPUID bits for pv guests if they are set to hvm only.
* Refine docs.
* Rewrite commit message.
--- docs/misc/xen-command-line.markdown | 14 +++++---- xen/arch/x86/cpuid.c | 5 ++++ xen/arch/x86/setup.c | 58 ++++++++++++++++++++++++++++++++----- xen/include/asm-x86/setup.h | 3 ++ 4 files changed, 66 insertions(+), 14 deletions(-)
docs/misc/xen-command-line.markdown +8 -6
@@ -1427,19 +1427,21 @@ enabling more sockets and cores to go into deeper sleep states. Set the serial transmit buffer size. -### smep -> `= <boolean>` +### smap +> `= <boolean> | hvm` > Default: `true` -Flag to enable Supervisor Mode Execution Protection +Flag to enable Supervisor Mode Access Prevention +Using `smap=hvm` to enable SMAP for HVM guests only. -### smap -> `= <boolean>` +### smep +> `= <boolean> | hvm` > Default: `true` -Flag to enable Supervisor Mode Access Prevention +Flag to enable Supervisor Mode Execution Protection +Using `smep=hvm` to enable SMEP for HVM guests only. ### snb\_igd\_quirk > `= <boolean> | cap | <integer>`
xen/arch/x86/cpuid.c +5 -0
@@ -4,6 +4,7 @@#include <asm/hvm/hvm.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/processor.h> +#include <asm/setup.h> const uint32_t known_features[] =INIT_KNOWN_FEATURES ;const uint32_t special_features[] =INIT_SPECIAL_FEATURES ;
@@ -118,6 +119,10 @@ static void __init calculate_pv_featureset(void)__set_bit (X86_FEATURE_HTT , pv_featureset);__set_bit (X86_FEATURE_X2APIC , pv_featureset);__set_bit (X86_FEATURE_CMP_LEGACY , pv_featureset); +if ( smep_hvm_only ) +__clear_bit (X86_FEATURE_SMEP , pv_featureset); +if ( smap_hvm_only ) +__clear_bit (X86_FEATURE_SMAP , pv_featureset);sanitise_featureset (pv_featureset); }
xen/arch/x86/setup.c +50 -8
88 lines not on this page · raw message
xen/include/asm-x86/setup.h +3 -0
@@ -51,6 +51,9 @@ void microcode_grab_module(extern uint8_t kbd_shift_flags; +extern bool_t smep_hvm_only; +extern bool_t smap_hvm_only; +#ifdef NDEBUG # define highmem_start 0#else
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel