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

[xen staging] x86/HVM: polish hvm_asid_init() a little



commit b58ebec511beda7559c8209ca13e91187a060f98
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Aug 6 14:49:17 2025 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Aug 6 14:49:17 2025 +0200

    x86/HVM: polish hvm_asid_init() a little
    
    While the logic there covers asymmetric cases, the resulting log
    messages would likely raise more confusion than clarify anything. Split
    the BSP action from the AP one, indicating the odd CPU in the AP log
    message, thus avoiding the impression that global state would have
    changed.
    
    While there also
    - move g_disabled into .data.ro_after_init; only the BSP will ever write
      to it,
    - make the function's parameter unsigned; no negative values may be
      passed in. Also reflect this in svm_asid_init().
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/hvm/asid.c             | 14 ++++++++------
 xen/arch/x86/hvm/svm/asid.c         |  2 +-
 xen/arch/x86/include/asm/hvm/asid.h |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/hvm/asid.c b/xen/arch/x86/hvm/asid.c
index 8d27b7dba1..935cae3901 100644
--- a/xen/arch/x86/hvm/asid.c
+++ b/xen/arch/x86/hvm/asid.c
@@ -48,20 +48,22 @@ struct hvm_asid_data {
 
 static DEFINE_PER_CPU(struct hvm_asid_data, hvm_asid_data);
 
-void hvm_asid_init(int nasids)
+void hvm_asid_init(unsigned int nasids)
 {
-    static int8_t g_disabled = -1;
+    static int8_t __ro_after_init g_disabled = -1;
     struct hvm_asid_data *data = &this_cpu(hvm_asid_data);
 
     data->max_asid = nasids - 1;
     data->disabled = !opt_asid_enabled || (nasids <= 1);
 
-    if ( g_disabled != data->disabled )
+    if ( g_disabled < 0 )
     {
-        printk("HVM: ASIDs %sabled.\n", data->disabled ? "dis" : "en");
-        if ( g_disabled < 0 )
-            g_disabled = data->disabled;
+        g_disabled = data->disabled;
+        printk("HVM: ASIDs %sabled\n", data->disabled ? "dis" : "en");
     }
+    else if ( g_disabled != data->disabled )
+        printk("HVM: CPU%u: ASIDs %sabled\n", smp_processor_id(),
+               data->disabled ? "dis" : "en");
 
     /* Zero indicates 'invalid generation', so we start the count at one. */
     data->core_asid_generation = 1;
diff --git a/xen/arch/x86/hvm/svm/asid.c b/xen/arch/x86/hvm/svm/asid.c
index 0bc1f5aa72..03f98b7a8b 100644
--- a/xen/arch/x86/hvm/svm/asid.c
+++ b/xen/arch/x86/hvm/svm/asid.c
@@ -12,7 +12,7 @@
 
 void svm_asid_init(const struct cpuinfo_x86 *c)
 {
-    int nasids = 0;
+    unsigned int nasids = 0;
 
     /* Check for erratum #170, and leave ASIDs disabled if it's present. */
     if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) )
diff --git a/xen/arch/x86/include/asm/hvm/asid.h 
b/xen/arch/x86/include/asm/hvm/asid.h
index 17c58353d1..25ba57e768 100644
--- a/xen/arch/x86/include/asm/hvm/asid.h
+++ b/xen/arch/x86/include/asm/hvm/asid.h
@@ -13,7 +13,7 @@ struct vcpu;
 struct hvm_vcpu_asid;
 
 /* Initialise ASID management for the current physical CPU. */
-void hvm_asid_init(int nasids);
+void hvm_asid_init(unsigned int nasids);
 
 /* Invalidate a particular ASID allocation: forces re-allocation. */
 void hvm_asid_flush_vcpu_asid(struct hvm_vcpu_asid *asid);
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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