diff mbox series

[XEN,v3,03/16] x86/p2m: guard altp2m routines

Message ID acb98c1c52613555a59cd27aad853a24caef0e19.1717410850.git.Sergiy_Kibrik@epam.com (mailing list archive)
State New, archived
Headers show
Series x86: make cpu virtualization support configurable | expand

Commit Message

Sergiy Kibrik June 3, 2024, 11:11 a.m. UTC
Initialize and bring down altp2m only when it is supported by the platform,
e.g. VMX. Also guard p2m_altp2m_propagate_change().
The puspose of that is the possiblity to disable altp2m support and exclude its
code from the build completely, when it's not supported by the target platform.

Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
CC: Tamas K Lengyel <tamas@tklengyel.com>
CC: Jan Beulich <jbeulich@suse.com>
---
changes in v3:
 - put hvm_altp2m_supported() first
 - rewrite changes to p2m_init() with less code
 - add tag
---
 xen/arch/x86/mm/p2m-basic.c | 9 +++++----
 xen/arch/x86/mm/p2m-ept.c   | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

Comments

Jan Beulich June 7, 2024, 7:32 a.m. UTC | #1
On 03.06.2024 13:11, Sergiy Kibrik wrote:
> Initialize and bring down altp2m only when it is supported by the platform,
> e.g. VMX. Also guard p2m_altp2m_propagate_change().
> The puspose of that is the possiblity to disable altp2m support and exclude its
> code from the build completely, when it's not supported by the target platform.
> 
> Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

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

I question though whether Stefano's R-b was valid to retain with ...

> ---
> changes in v3:
>  - put hvm_altp2m_supported() first
>  - rewrite changes to p2m_init() with less code

... this.

Jan
Sergiy Kibrik June 10, 2024, 10:33 a.m. UTC | #2
hi Stefano,

07.06.24 10:32, Jan Beulich:
> On 03.06.2024 13:11, Sergiy Kibrik wrote:
>> Initialize and bring down altp2m only when it is supported by the platform,
>> e.g. VMX. Also guard p2m_altp2m_propagate_change().
>> The puspose of that is the possiblity to disable altp2m support and exclude its
>> code from the build completely, when it's not supported by the target platform.
>>
>> Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> I question though whether Stefano's R-b was valid to retain with ...
> 
>> ---
>> changes in v3:
>>   - put hvm_altp2m_supported() first
>>   - rewrite changes to p2m_init() with less code
> 
> ... this.

could you please take a look at this patch once more, after it's been 
through these modifications? Thank you!

    -Sergiy
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c
index 25d27a0a9f..08007a687c 100644
--- a/xen/arch/x86/mm/p2m-basic.c
+++ b/xen/arch/x86/mm/p2m-basic.c
@@ -128,7 +128,7 @@  int p2m_init(struct domain *d)
         return rc;
     }
 
-    rc = p2m_init_altp2m(d);
+    rc = hvm_altp2m_supported() ? p2m_init_altp2m(d) : 0;
     if ( rc )
     {
         p2m_teardown_hostp2m(d);
@@ -197,11 +197,12 @@  void p2m_final_teardown(struct domain *d)
 {
     if ( is_hvm_domain(d) )
     {
+        if ( hvm_altp2m_supported() )
+            p2m_teardown_altp2m(d);
         /*
-         * We must tear down both of them unconditionally because
-         * we initialise them unconditionally.
+         * We must tear down nestedp2m unconditionally because
+         * we initialise it unconditionally.
          */
-        p2m_teardown_altp2m(d);
         p2m_teardown_nestedp2m(d);
     }
 
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index f83610cb8c..c261ba02db 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -986,7 +986,7 @@  out:
     if ( is_epte_present(&old_entry) )
         ept_free_entry(p2m, &old_entry, target);
 
-    if ( entry_written && p2m_is_hostp2m(p2m) )
+    if ( hvm_altp2m_supported() && entry_written && p2m_is_hostp2m(p2m) )
     {
         ret = p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt, p2ma);
         if ( !rc )