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

[PATCH] x86/hvm: Allow supplying a dynamic start ASID



Currently, Xen always starts the ASID allocation at 1. But
for SEV technologies the ASID space is divided. This is
because it's a security issue if a guest is started as
ES/SNP and is migrated to SEV-only. So, the types are
tracked explicitly.

Thus, in preparation of SEV support in Xen, add min_asid
to allow supplying the dynamic start ASID during the
allocation process.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@xxxxxxxxxx>
---
 xen/arch/x86/hvm/asid.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/asid.c b/xen/arch/x86/hvm/asid.c
index 8d27b7dba1..e14b64f2c8 100644
--- a/xen/arch/x86/hvm/asid.c
+++ b/xen/arch/x86/hvm/asid.c
@@ -41,6 +41,7 @@ boolean_param("asid", opt_asid_enabled);
 /* Per-CPU ASID management. */
 struct hvm_asid_data {
    uint64_t core_asid_generation;
+   uint32_t min_asid;
    uint32_t next_asid;
    uint32_t max_asid;
    bool disabled;
@@ -53,7 +54,8 @@ void hvm_asid_init(int nasids)
     static int8_t g_disabled = -1;
     struct hvm_asid_data *data = &this_cpu(hvm_asid_data);
 
-    data->max_asid = nasids - 1;
+    data->min_asid = 1;
+    data->max_asid = nasids - data->min_asid;
     data->disabled = !opt_asid_enabled || (nasids <= 1);
 
     if ( g_disabled != data->disabled )
@@ -66,8 +68,8 @@ void hvm_asid_init(int nasids)
     /* Zero indicates 'invalid generation', so we start the count at one. */
     data->core_asid_generation = 1;
 
-    /* Zero indicates 'ASIDs disabled', so we start the count at one. */
-    data->next_asid = 1;
+    /* Zero indicates 'ASIDs disabled', so we start the count at min_asid. */
+    data->next_asid = data->min_asid;
 }
 
 void hvm_asid_flush_vcpu_asid(struct hvm_vcpu_asid *asid)
@@ -117,7 +119,7 @@ bool hvm_asid_handle_vmenter(struct hvm_vcpu_asid *asid)
     if ( unlikely(data->next_asid > data->max_asid) )
     {
         hvm_asid_flush_core();
-        data->next_asid = 1;
+        data->next_asid = data->min_asid;
         if ( data->disabled )
             goto disabled;
     }
-- 
2.44.0



 


Rackspace

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