xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
@ 2018-05-08 13:03 Andrew Cooper
  2018-05-08 16:05 ` George Dunlap
  2018-05-08 16:10 ` Roger Pau Monné
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Cooper @ 2018-05-08 13:03 UTC (permalink / raw)
  To: Xen-devel
  Cc: Juergen Gross, Wei Liu, Jason Andryuk, Andrew Cooper, Jan Beulich,
	Roger Pau Monné

c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
smap_check logic, it exists only to work around a bug in guest_walk_tables()
was resolved by the aformentioned commit.

Remove the unused variables and associated infrastructure.

Reported-by: Jason Andryuk <jandryuk@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Juergen Gross <jgross@suse.com>
CC: Jason Andryuk <jandryuk@gmail.com>

I'm on the fence as to whether to suggest this for 4.11 at this point.  Its
probably not something to be backported, but it is a nice bit of cleanup, and
removes a particularly gross hack.
---
 xen/arch/x86/domain.c        |  7 +------
 xen/arch/x86/time.c          |  3 +--
 xen/include/asm-x86/domain.h | 13 -------------
 3 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 801ac33..4ff3d2f3 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -217,13 +217,9 @@ void dump_pageframe_info(struct domain *d)
 void update_guest_memory_policy(struct vcpu *v,
                                 struct guest_memory_policy *policy)
 {
-    smap_check_policy_t old_smap_policy = v->arch.smap_check_policy;
     bool old_guest_mode = nestedhvm_is_n2(v);
     bool new_guest_mode = policy->nested_guest_mode;
 
-    v->arch.smap_check_policy = policy->smap_policy;
-    policy->smap_policy = old_smap_policy;
-
     /*
      * When 'v' is in the nested guest mode, all guest copy
      * functions/macros which finally call paging_gva_to_gfn()
@@ -1541,8 +1537,7 @@ void paravirt_ctxt_switch_to(struct vcpu *v)
 bool update_runstate_area(struct vcpu *v)
 {
     bool rc;
-    struct guest_memory_policy policy =
-        { .smap_policy = SMAP_CHECK_ENABLED, .nested_guest_mode = false };
+    struct guest_memory_policy policy = { .nested_guest_mode = false };
     void __user *guest_handle = NULL;
 
     if ( guest_handle_is_null(runstate_guest(v)) )
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 84c1c0c..c342d00 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1106,8 +1106,7 @@ bool update_secondary_system_time(struct vcpu *v,
                                   struct vcpu_time_info *u)
 {
     XEN_GUEST_HANDLE(vcpu_time_info_t) user_u = v->arch.time_info_guest;
-    struct guest_memory_policy policy =
-        { .smap_policy = SMAP_CHECK_ENABLED, .nested_guest_mode = false };
+    struct guest_memory_policy policy = { .nested_guest_mode = false };
 
     if ( guest_handle_is_null(user_u) )
         return true;
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 8b66096..197f8d6 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -508,12 +508,6 @@ struct pv_vcpu
     struct vcpu_time_info pending_system_time;
 };
 
-typedef enum __packed {
-    SMAP_CHECK_HONOR_CPL_AC,    /* honor the guest's CPL and AC */
-    SMAP_CHECK_ENABLED,         /* enable the check */
-    SMAP_CHECK_DISABLED,        /* disable the check */
-} smap_check_policy_t;
-
 struct arch_vcpu
 {
     /*
@@ -569,12 +563,6 @@ struct arch_vcpu
      * and thus should be saved/restored. */
     bool_t nonlazy_xstate_used;
 
-    /*
-     * The SMAP check policy when updating runstate_guest(v) and the
-     * secondary system time.
-     */
-    smap_check_policy_t smap_check_policy;
-
     struct vmce vmce;
 
     struct paging_vcpu paging;
@@ -595,7 +583,6 @@ struct arch_vcpu
 
 struct guest_memory_policy
 {
-    smap_check_policy_t smap_policy;
     bool nested_guest_mode;
 };
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 13:03 [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure Andrew Cooper
@ 2018-05-08 16:05 ` George Dunlap
  2018-05-08 16:08   ` Juergen Gross
  2018-05-08 16:13   ` Andrew Cooper
  2018-05-08 16:10 ` Roger Pau Monné
  1 sibling, 2 replies; 7+ messages in thread
From: George Dunlap @ 2018-05-08 16:05 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, Wei Liu, Jason Andryuk, Xen-devel, Jan Beulich,
	Roger Pau Monné

On Tue, May 8, 2018 at 2:03 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
> smap_check logic, it exists only to work around a bug in guest_walk_tables()
> was resolved by the aformentioned commit.
>
> Remove the unused variables and associated infrastructure.
>
> Reported-by: Jason Andryuk <jandryuk@gmail.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: George Dunlap <george.dunlap@citrix.com>

> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Juergen Gross <jgross@suse.com>
> CC: Jason Andryuk <jandryuk@gmail.com>
>
> I'm on the fence as to whether to suggest this for 4.11 at this point.  Its
> probably not something to be backported, but it is a nice bit of cleanup, and
> removes a particularly gross hack.

It looks like the commit that made this code vestigal was introduced
in March 2017?  So we've already had two releases with this flag not
doing anything, and no ill effects reported.

I'd be in favor of accepting a patch like this for 4.11, and also for
backporting it to 4.10 and 4.9

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 16:05 ` George Dunlap
@ 2018-05-08 16:08   ` Juergen Gross
  2018-05-08 16:13   ` Andrew Cooper
  1 sibling, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2018-05-08 16:08 UTC (permalink / raw)
  To: George Dunlap, Andrew Cooper
  Cc: Jason Andryuk, Wei Liu, Roger Pau Monné, Jan Beulich,
	Xen-devel

On 08/05/18 18:05, George Dunlap wrote:
> On Tue, May 8, 2018 at 2:03 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
>> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
>> smap_check logic, it exists only to work around a bug in guest_walk_tables()
>> was resolved by the aformentioned commit.
>>
>> Remove the unused variables and associated infrastructure.
>>
>> Reported-by: Jason Andryuk <jandryuk@gmail.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Reviewed-by: George Dunlap <george.dunlap@citrix.com>
> 
>> ---
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: Roger Pau Monné <roger.pau@citrix.com>
>> CC: Juergen Gross <jgross@suse.com>
>> CC: Jason Andryuk <jandryuk@gmail.com>
>>
>> I'm on the fence as to whether to suggest this for 4.11 at this point.  Its
>> probably not something to be backported, but it is a nice bit of cleanup, and
>> removes a particularly gross hack.
> 
> It looks like the commit that made this code vestigal was introduced
> in March 2017?  So we've already had two releases with this flag not
> doing anything, and no ill effects reported.
> 
> I'd be in favor of accepting a patch like this for 4.11, and also for
> backporting it to 4.10 and 4.9

Okay, so:

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 13:03 [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure Andrew Cooper
  2018-05-08 16:05 ` George Dunlap
@ 2018-05-08 16:10 ` Roger Pau Monné
  2018-05-08 16:20   ` Andrew Cooper
  1 sibling, 1 reply; 7+ messages in thread
From: Roger Pau Monné @ 2018-05-08 16:10 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, Jason Andryuk, Wei Liu, Jan Beulich, Xen-devel

On Tue, May 08, 2018 at 02:03:04PM +0100, Andrew Cooper wrote:
> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
> smap_check logic, it exists only to work around a bug in guest_walk_tables()
> was resolved by the aformentioned commit.
> 
> Remove the unused variables and associated infrastructure.
> 
> Reported-by: Jason Andryuk <jandryuk@gmail.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
> index 8b66096..197f8d6 100644
> --- a/xen/include/asm-x86/domain.h
> +++ b/xen/include/asm-x86/domain.h
> @@ -595,7 +583,6 @@ struct arch_vcpu
>  
>  struct guest_memory_policy
>  {
> -    smap_check_policy_t smap_policy;
>      bool nested_guest_mode;

Maybe guest_memory_policy could be dropped and
update_guest_memory_policy updated to take a bool nested_mode
parameter? Or the function can be dropped altogether likely.

In any case, this can be done in a followup cleanup patch.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 16:05 ` George Dunlap
  2018-05-08 16:08   ` Juergen Gross
@ 2018-05-08 16:13   ` Andrew Cooper
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Cooper @ 2018-05-08 16:13 UTC (permalink / raw)
  To: George Dunlap
  Cc: Juergen Gross, Wei Liu, Jason Andryuk, Xen-devel, Jan Beulich,
	Roger Pau Monné

On 08/05/18 17:05, George Dunlap wrote:
> On Tue, May 8, 2018 at 2:03 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
>> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
>> smap_check logic, it exists only to work around a bug in guest_walk_tables()
>> was resolved by the aformentioned commit.
>>
>> Remove the unused variables and associated infrastructure.
>>
>> Reported-by: Jason Andryuk <jandryuk@gmail.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: George Dunlap <george.dunlap@citrix.com>
>
>> ---
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: Roger Pau Monné <roger.pau@citrix.com>
>> CC: Juergen Gross <jgross@suse.com>
>> CC: Jason Andryuk <jandryuk@gmail.com>
>>
>> I'm on the fence as to whether to suggest this for 4.11 at this point.  Its
>> probably not something to be backported, but it is a nice bit of cleanup, and
>> removes a particularly gross hack.
> It looks like the commit that made this code vestigal was introduced
> in March 2017?  So we've already had two releases with this flag not
> doing anything, and no ill effects reported.

Well, it is a write-only variable.  I'd be rather concerned if it did
anything.

> I'd be in favor of accepting a patch like this for 4.11, and also for
> backporting it to 4.10 and 4.9

Ok - I'm not fussed either way.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 16:10 ` Roger Pau Monné
@ 2018-05-08 16:20   ` Andrew Cooper
  2018-05-08 16:26     ` Julien Grall
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2018-05-08 16:20 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Juergen Gross, Wei Liu, Jason Andryuk, Xen-devel, Julien Grall,
	Jan Beulich

On 08/05/18 17:10, Roger Pau Monné wrote:
> On Tue, May 08, 2018 at 02:03:04PM +0100, Andrew Cooper wrote:
>> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
>> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
>> smap_check logic, it exists only to work around a bug in guest_walk_tables()
>> was resolved by the aformentioned commit.
>>
>> Remove the unused variables and associated infrastructure.
>>
>> Reported-by: Jason Andryuk <jandryuk@gmail.com>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>
>> diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
>> index 8b66096..197f8d6 100644
>> --- a/xen/include/asm-x86/domain.h
>> +++ b/xen/include/asm-x86/domain.h
>> @@ -595,7 +583,6 @@ struct arch_vcpu
>>  
>>  struct guest_memory_policy
>>  {
>> -    smap_check_policy_t smap_policy;
>>      bool nested_guest_mode;
> Maybe guest_memory_policy could be dropped and
> update_guest_memory_policy updated to take a bool nested_mode
> parameter? 

update_guest_memory_policy() stores the old value in the passed
structure, and would more accurately be toggle_guest_memory_policy()
when it came to guest mode.

> Or the function can be dropped altogether likely.

Sadly not yet.  This exists because of Xen's virtual-address based API
for the shared info and time mappings.  This API is bad and wrong and
wants fixing.  ISTR Juergen and Julien having plans to deal with this?

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure
  2018-05-08 16:20   ` Andrew Cooper
@ 2018-05-08 16:26     ` Julien Grall
  0 siblings, 0 replies; 7+ messages in thread
From: Julien Grall @ 2018-05-08 16:26 UTC (permalink / raw)
  To: Andrew Cooper, Roger Pau Monné
  Cc: Juergen Gross, Jason Andryuk, Wei Liu, Jan Beulich, Xen-devel

Hi,

On 08/05/18 17:20, Andrew Cooper wrote:
> On 08/05/18 17:10, Roger Pau Monné wrote:
>> On Tue, May 08, 2018 at 02:03:04PM +0100, Andrew Cooper wrote:
>>> c/s 4c5d78a10d "x86/pagewalk: Re-implement the pagetable walker" dropped the
>>> consumer of smap_policy.  Looking at c/s 31ae587e6f which introduced the
>>> smap_check logic, it exists only to work around a bug in guest_walk_tables()
>>> was resolved by the aformentioned commit.
>>>
>>> Remove the unused variables and associated infrastructure.
>>>
>>> Reported-by: Jason Andryuk <jandryuk@gmail.com>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>>
>>> diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
>>> index 8b66096..197f8d6 100644
>>> --- a/xen/include/asm-x86/domain.h
>>> +++ b/xen/include/asm-x86/domain.h
>>> @@ -595,7 +583,6 @@ struct arch_vcpu
>>>   
>>>   struct guest_memory_policy
>>>   {
>>> -    smap_check_policy_t smap_policy;
>>>       bool nested_guest_mode;
>> Maybe guest_memory_policy could be dropped and
>> update_guest_memory_policy updated to take a bool nested_mode
>> parameter?
> 
> update_guest_memory_policy() stores the old value in the passed
> structure, and would more accurately be toggle_guest_memory_policy()
> when it came to guest mode.
> 
>> Or the function can be dropped altogether likely.
> 
> Sadly not yet.  This exists because of Xen's virtual-address based API
> for the shared info and time mappings.  This API is bad and wrong and
> wants fixing.  ISTR Juergen and Julien having plans to deal with this?

This should indeed be fixed properly, I was waiting some answer on my 
questions before attempting to go further on a fix (see [1] and [2]). I 
didn't have bandwidth so far to ping on the subject.

Cheers,

[1] 
https://www.mail-archive.com/xen-devel@lists.xenproject.org/msg08836.html
[2] 
https://www.mail-archive.com/xen-devel@lists.xenproject.org/msg08835.html

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-08 16:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-08 13:03 [PATCH] x86/domain: Drop the only-written smap_check_policy infrastructure Andrew Cooper
2018-05-08 16:05 ` George Dunlap
2018-05-08 16:08   ` Juergen Gross
2018-05-08 16:13   ` Andrew Cooper
2018-05-08 16:10 ` Roger Pau Monné
2018-05-08 16:20   ` Andrew Cooper
2018-05-08 16:26     ` Julien Grall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).