All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Tamas K Lengyel" <tamas@tklengyel.com>,
	"Jun Nakajima" <jun.nakajima@intel.com>,
	"Kevin Tian" <kevin.tian@intel.com>
Subject: [PATCH] x86/hvm: Drop .is_singlestep_supported() callback
Date: Thu, 13 Jan 2022 18:48:00 +0000	[thread overview]
Message-ID: <20220113184800.29456-1-andrew.cooper3@citrix.com> (raw)

There is absolutely no need for a function pointer call here.

Drop the hook, introduce a singlestep_supported boolean, and configure it in
start_vmx() like all other optional functionality.

No functional change, but rather more efficient logic.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Tamas K Lengyel <tamas@tklengyel.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>

Based on Jan's "altcall all hvm ops" patch, but not logically related.  This
had escaped my previous attempts to drop inappropriate function pointer use.

The hvm_funcs data fields are a mess.  All the booleans and 'hvm_capabilities'
want merging into a single bitfield, so we're not wasting 8 bytes of space to
hold 6 bits of information.
---
 xen/arch/x86/hvm/vmx/vmx.c         | 8 ++------
 xen/arch/x86/include/asm/hvm/hvm.h | 7 +++----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index a7a0d662342a..1c46669762b0 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2120,11 +2120,6 @@ static void vmx_enable_msr_interception(struct domain *d, uint32_t msr)
         vmx_set_msr_intercept(v, msr, VMX_MSR_W);
 }
 
-static bool_t vmx_is_singlestep_supported(void)
-{
-    return !!cpu_has_monitor_trap_flag;
-}
-
 static void vmx_vcpu_update_eptp(struct vcpu *v)
 {
     struct domain *d = v->domain;
@@ -2454,7 +2449,6 @@ static struct hvm_function_table __initdata vmx_function_table = {
     .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources,
     .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m,
     .enable_msr_interception = vmx_enable_msr_interception,
-    .is_singlestep_supported = vmx_is_singlestep_supported,
     .altp2m_vcpu_update_p2m = vmx_vcpu_update_eptp,
     .altp2m_vcpu_update_vmfunc_ve = vmx_vcpu_update_vmfunc_ve,
     .altp2m_vcpu_emulate_ve = vmx_vcpu_emulate_ve,
@@ -2661,6 +2655,8 @@ const struct hvm_function_table * __init start_vmx(void)
         return NULL;
     }
 
+    vmx_function_table.singlestep_supported = cpu_has_monitor_trap_flag;
+
     if ( cpu_has_vmx_dt_exiting )
         vmx_function_table.set_descriptor_access_exiting =
             vmx_set_descriptor_access_exiting;
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index b26302d9e769..9338cf25a657 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -97,6 +97,7 @@ struct hvm_function_table {
 
     /* Necessary hardware support for alternate p2m's? */
     bool altp2m_supported;
+    bool singlestep_supported;
 
     /* Hardware virtual interrupt delivery enable? */
     bool virtual_intr_delivery_enabled;
@@ -208,7 +209,6 @@ struct hvm_function_table {
                                 uint8_t *p2m_acc, struct npfec npfec);
 
     void (*enable_msr_interception)(struct domain *d, uint32_t msr);
-    bool_t (*is_singlestep_supported)(void);
 
     /* Alternate p2m */
     void (*altp2m_vcpu_update_p2m)(struct vcpu *v);
@@ -644,10 +644,9 @@ static inline void hvm_enable_msr_interception(struct domain *d, uint32_t msr)
     alternative_vcall(hvm_funcs.enable_msr_interception, d, msr);
 }
 
-static inline bool_t hvm_is_singlestep_supported(void)
+static inline bool hvm_is_singlestep_supported(void)
 {
-    return (hvm_funcs.is_singlestep_supported &&
-            alternative_call(hvm_funcs.is_singlestep_supported));
+    return hvm_funcs.singlestep_supported;
 }
 
 static inline bool hvm_hap_supported(void)
-- 
2.11.0



             reply	other threads:[~2022-01-13 18:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 18:48 Andrew Cooper [this message]
2022-01-14  7:41 ` [PATCH] x86/hvm: Drop .is_singlestep_supported() callback Jan Beulich
2022-01-14 14:30 ` Tamas K Lengyel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220113184800.29456-1-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.