[PATCH] x86/guest: finish conversion to altcall

Jan Beulich posted 1 patch 3 months, 1 week ago
Failed in applying to current master (apply log)
[PATCH] x86/guest: finish conversion to altcall
Posted by Jan Beulich 3 months, 1 week ago
While .setup() and .e820_fixup() don't need fiddling with for being run
only very early, both .ap_setup() and .resume() want converting too:
This way both pre-filled struct hypervisor_ops instances can become
__initconst_cf_clobber, thus allowing to eliminate up to 5 more ENDBR
(configuration dependent) during the 2nd phase of alternatives patching.

While fiddling with section annotations here, also move "ops" itself to
.data.ro_after_init.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -207,7 +207,7 @@ static int cf_check flush_tlb(
     return hyperv_flush_tlb(mask, va, flags);
 }
 
-static const struct hypervisor_ops __initconstrel ops = {
+static const struct hypervisor_ops __initconst_cf_clobber ops = {
     .name = "Hyper-V",
     .setup = setup,
     .ap_setup = ap_setup,
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -13,7 +13,7 @@
 #include <asm/cache.h>
 #include <asm/guest.h>
 
-static struct hypervisor_ops __read_mostly ops;
+static struct hypervisor_ops __ro_after_init ops;
 
 const char *__init hypervisor_probe(void)
 {
@@ -49,7 +49,7 @@ void __init hypervisor_setup(void)
 int hypervisor_ap_setup(void)
 {
     if ( ops.ap_setup )
-        return ops.ap_setup();
+        return alternative_call(ops.ap_setup);
 
     return 0;
 }
@@ -57,7 +57,7 @@ int hypervisor_ap_setup(void)
 void hypervisor_resume(void)
 {
     if ( ops.resume )
-        ops.resume();
+        alternative_vcall(ops.resume);
 }
 
 void __init hypervisor_e820_fixup(void)
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -318,7 +318,7 @@ static int cf_check flush_tlb(
     return xen_hypercall_hvm_op(HVMOP_flush_tlbs, NULL);
 }
 
-static const struct hypervisor_ops __initconstrel ops = {
+static const struct hypervisor_ops __initconst_cf_clobber ops = {
     .name = "Xen",
     .setup = setup,
     .ap_setup = ap_setup,
Ping: [PATCH] x86/guest: finish conversion to altcall
Posted by Jan Beulich 2 months, 3 weeks ago
On 17.01.2024 10:31, Jan Beulich wrote:
> While .setup() and .e820_fixup() don't need fiddling with for being run
> only very early, both .ap_setup() and .resume() want converting too:
> This way both pre-filled struct hypervisor_ops instances can become
> __initconst_cf_clobber, thus allowing to eliminate up to 5 more ENDBR
> (configuration dependent) during the 2nd phase of alternatives patching.
> 
> While fiddling with section annotations here, also move "ops" itself to
> .data.ro_after_init.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

May I ask for an ack (or otherwise)?

Thanks, Jan

> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -207,7 +207,7 @@ static int cf_check flush_tlb(
>      return hyperv_flush_tlb(mask, va, flags);
>  }
>  
> -static const struct hypervisor_ops __initconstrel ops = {
> +static const struct hypervisor_ops __initconst_cf_clobber ops = {
>      .name = "Hyper-V",
>      .setup = setup,
>      .ap_setup = ap_setup,
> --- a/xen/arch/x86/guest/hypervisor.c
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -13,7 +13,7 @@
>  #include <asm/cache.h>
>  #include <asm/guest.h>
>  
> -static struct hypervisor_ops __read_mostly ops;
> +static struct hypervisor_ops __ro_after_init ops;
>  
>  const char *__init hypervisor_probe(void)
>  {
> @@ -49,7 +49,7 @@ void __init hypervisor_setup(void)
>  int hypervisor_ap_setup(void)
>  {
>      if ( ops.ap_setup )
> -        return ops.ap_setup();
> +        return alternative_call(ops.ap_setup);
>  
>      return 0;
>  }
> @@ -57,7 +57,7 @@ int hypervisor_ap_setup(void)
>  void hypervisor_resume(void)
>  {
>      if ( ops.resume )
> -        ops.resume();
> +        alternative_vcall(ops.resume);
>  }
>  
>  void __init hypervisor_e820_fixup(void)
> --- a/xen/arch/x86/guest/xen/xen.c
> +++ b/xen/arch/x86/guest/xen/xen.c
> @@ -318,7 +318,7 @@ static int cf_check flush_tlb(
>      return xen_hypercall_hvm_op(HVMOP_flush_tlbs, NULL);
>  }
>  
> -static const struct hypervisor_ops __initconstrel ops = {
> +static const struct hypervisor_ops __initconst_cf_clobber ops = {
>      .name = "Xen",
>      .setup = setup,
>      .ap_setup = ap_setup,
Re: Ping: [PATCH] x86/guest: finish conversion to altcall
Posted by Paul Durrant 2 months, 3 weeks ago
On 02/02/2024 07:08, Jan Beulich wrote:
> On 17.01.2024 10:31, Jan Beulich wrote:
>> While .setup() and .e820_fixup() don't need fiddling with for being run
>> only very early, both .ap_setup() and .resume() want converting too:
>> This way both pre-filled struct hypervisor_ops instances can become
>> __initconst_cf_clobber, thus allowing to eliminate up to 5 more ENDBR
>> (configuration dependent) during the 2nd phase of alternatives patching.
>>
>> While fiddling with section annotations here, also move "ops" itself to
>> .data.ro_after_init.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> May I ask for an ack (or otherwise)?
> 
> Thanks, Jan
> 

Yes, no objections.

Acked-by: Paul Durrant <paul@xen.org>

>> --- a/xen/arch/x86/guest/hyperv/hyperv.c
>> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
>> @@ -207,7 +207,7 @@ static int cf_check flush_tlb(
>>       return hyperv_flush_tlb(mask, va, flags);
>>   }
>>   
>> -static const struct hypervisor_ops __initconstrel ops = {
>> +static const struct hypervisor_ops __initconst_cf_clobber ops = {
>>       .name = "Hyper-V",
>>       .setup = setup,
>>       .ap_setup = ap_setup,
>> --- a/xen/arch/x86/guest/hypervisor.c
>> +++ b/xen/arch/x86/guest/hypervisor.c
>> @@ -13,7 +13,7 @@
>>   #include <asm/cache.h>
>>   #include <asm/guest.h>
>>   
>> -static struct hypervisor_ops __read_mostly ops;
>> +static struct hypervisor_ops __ro_after_init ops;
>>   
>>   const char *__init hypervisor_probe(void)
>>   {
>> @@ -49,7 +49,7 @@ void __init hypervisor_setup(void)
>>   int hypervisor_ap_setup(void)
>>   {
>>       if ( ops.ap_setup )
>> -        return ops.ap_setup();
>> +        return alternative_call(ops.ap_setup);
>>   
>>       return 0;
>>   }
>> @@ -57,7 +57,7 @@ int hypervisor_ap_setup(void)
>>   void hypervisor_resume(void)
>>   {
>>       if ( ops.resume )
>> -        ops.resume();
>> +        alternative_vcall(ops.resume);
>>   }
>>   
>>   void __init hypervisor_e820_fixup(void)
>> --- a/xen/arch/x86/guest/xen/xen.c
>> +++ b/xen/arch/x86/guest/xen/xen.c
>> @@ -318,7 +318,7 @@ static int cf_check flush_tlb(
>>       return xen_hypercall_hvm_op(HVMOP_flush_tlbs, NULL);
>>   }
>>   
>> -static const struct hypervisor_ops __initconstrel ops = {
>> +static const struct hypervisor_ops __initconst_cf_clobber ops = {
>>       .name = "Xen",
>>       .setup = setup,
>>       .ap_setup = ap_setup,
>
Re: [PATCH] x86/guest: finish conversion to altcall
Posted by Andrew Cooper 3 months, 1 week ago
On 17/01/2024 9:31 am, Jan Beulich wrote:
> While .setup() and .e820_fixup() don't need fiddling with for being run
> only very early, both .ap_setup() and .resume() want converting too:
> This way both pre-filled struct hypervisor_ops instances can become
> __initconst_cf_clobber, thus allowing to eliminate up to 5 more ENDBR
> (configuration dependent) during the 2nd phase of alternatives patching.
>
> While fiddling with section annotations here, also move "ops" itself to
> .data.ro_after_init.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>