mbox series

[0/6] xsm: refactoring xsm hooks

Message ID 20210617233918.10095-1-dpsmith@apertussolutions.com (mailing list archive)
Headers show
Series xsm: refactoring xsm hooks | expand

Message

Daniel P. Smith June 17, 2021, 11:39 p.m. UTC
Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
patch set is being split into two separate patch sets. This is the first
patch set and is focused purely on the clean up and refactoring of the
XSM hooks.

This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
infrastructure. Then proceeds to move and realign the headers to remove the
psuedo is/is not enable implementation. The remainder of the changes are clean up
and removing no longer necessary abstractions.

Daniel P. Smith (6):
  xsm: refactor xsm_ops handling
  xsm: decouple xsm header inclusion selection
  xsm: enabling xsm to always be included
  xsm: remove xen_defualt_t from hook definitions
  xsm: expanding function related macros in dummy.h
  xsm: removing the XSM_ASSERT_ACTION macro

 xen/arch/arm/dm.c                     |   2 +-
 xen/arch/arm/domctl.c                 |   6 +-
 xen/arch/arm/hvm.c                    |   2 +-
 xen/arch/arm/mm.c                     |   2 +-
 xen/arch/arm/platform_hypercall.c     |   2 +-
 xen/arch/x86/cpu/mcheck/mce.c         |   2 +-
 xen/arch/x86/cpu/vpmu.c               |   2 +-
 xen/arch/x86/domctl.c                 |   8 +-
 xen/arch/x86/hvm/dm.c                 |   2 +-
 xen/arch/x86/hvm/hvm.c                |  12 +-
 xen/arch/x86/irq.c                    |   5 +-
 xen/arch/x86/mm.c                     |  20 +-
 xen/arch/x86/mm/mem_paging.c          |   2 +-
 xen/arch/x86/mm/mem_sharing.c         |   9 +-
 xen/arch/x86/mm/p2m.c                 |   2 +-
 xen/arch/x86/mm/paging.c              |   4 +-
 xen/arch/x86/mm/shadow/set.c          |   2 +-
 xen/arch/x86/msi.c                    |   3 +-
 xen/arch/x86/pci.c                    |   2 +-
 xen/arch/x86/physdev.c                |  17 +-
 xen/arch/x86/platform_hypercall.c     |  10 +-
 xen/arch/x86/pv/emul-priv-op.c        |   2 +-
 xen/arch/x86/sysctl.c                 |   4 +-
 xen/common/Kconfig                    |  55 +-
 xen/common/domain.c                   |   4 +-
 xen/common/domctl.c                   |  12 +-
 xen/common/event_channel.c            |  12 +-
 xen/common/grant_table.c              |  16 +-
 xen/common/hypfs.c                    |   2 +-
 xen/common/kernel.c                   |   2 +-
 xen/common/kexec.c                    |   2 +-
 xen/common/mem_access.c               |   2 +-
 xen/common/memory.c                   |  16 +-
 xen/common/monitor.c                  |   2 +-
 xen/common/sched/core.c               |   6 +-
 xen/common/sysctl.c                   |   8 +-
 xen/common/vm_event.c                 |   2 +-
 xen/common/xenoprof.c                 |   2 +-
 xen/drivers/char/console.c            |   2 +-
 xen/drivers/passthrough/device_tree.c |   4 +-
 xen/drivers/passthrough/pci.c         |  12 +-
 xen/include/xen/sched.h               |   2 +-
 xen/include/xsm/dummy.h               | 774 --------------------------
 xen/include/xsm/xsm-core.h            | 236 ++++++++
 xen/include/xsm/xsm.h                 | 626 +++++++--------------
 xen/xsm/Makefile                      |   4 +-
 xen/xsm/dummy.c                       |   7 +-
 xen/xsm/dummy.h                       | 697 +++++++++++++++++++++++
 xen/xsm/flask/flask_op.c              |  21 +-
 xen/xsm/silo.c                        |  18 +-
 xen/xsm/xsm_core.c                    |  54 +-
 51 files changed, 1309 insertions(+), 1413 deletions(-)
 delete mode 100644 xen/include/xsm/dummy.h
 create mode 100644 xen/include/xsm/xsm-core.h
 create mode 100644 xen/xsm/dummy.h

Comments

Andrew Cooper June 18, 2021, 10:14 a.m. UTC | #1
On 18/06/2021 00:39, Daniel P. Smith wrote:
> Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
> patch set is being split into two separate patch sets. This is the first
> patch set and is focused purely on the clean up and refactoring of the
> XSM hooks.
>
> This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
> infrastructure. Then proceeds to move and realign the headers to remove the
> psuedo is/is not enable implementation. The remainder of the changes are clean up
> and removing no longer necessary abstractions.
>
> <snip>
>  51 files changed, 1309 insertions(+), 1413 deletions(-)

The diffstat is great, but sadly CI says no. 
https://gitlab.com/xen-project/patchew/xen/-/pipelines/323044913

The problem is that ARM doesn't have alternative_vcall().  Given how
much of an improvement this ought to be for hypercalls, I don't want to
lose the vcalls.

One option is to implement vcall() support on ARM, but that will leave
new architectures (RISC-V on the way) with a heavy lift to get XSM to
compile.

Instead, what we want to do is make vcall() a common interface, falling
back to a plain function pointer call for architectures which don't
implement the optimisation.  So something like:

1) Introduce CONFIG_HAS_VCALL, which is selected by X86 only right now
2) Introduce xen/vcall.h which uses CONFIG_HAS_VCALL to either include
asm/vcall.h or provide the fallback implementation
3) Switch x86's current use over to this new interface

The iommu_vcall() is a red herring, not adequately documented, and needs
to stay in some form.  Specifically, it needs to not become an
alternative on ARM, even if ARM gains vcalls.  I'd be tempted to rework
it in 4) to use the common vcall() by default, and leave ARM as the
special case overriding the default behaviour, along with an explanation
of why it isn't a vcall().

Obviously, name subject bikeshedding.  alternative_vcall() is a bit of a
mouthful, and I don't think that alt_vcall() loses any salient information.

Thoughts?

~Andrew
Jan Beulich June 18, 2021, 11:48 a.m. UTC | #2
On 18.06.2021 12:14, Andrew Cooper wrote:
> On 18/06/2021 00:39, Daniel P. Smith wrote:
>> Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
>> patch set is being split into two separate patch sets. This is the first
>> patch set and is focused purely on the clean up and refactoring of the
>> XSM hooks.
>>
>> This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
>> infrastructure. Then proceeds to move and realign the headers to remove the
>> psuedo is/is not enable implementation. The remainder of the changes are clean up
>> and removing no longer necessary abstractions.
>>
>> <snip>
>>  51 files changed, 1309 insertions(+), 1413 deletions(-)
> 
> The diffstat is great, but sadly CI says no. 
> https://gitlab.com/xen-project/patchew/xen/-/pipelines/323044913
> 
> The problem is that ARM doesn't have alternative_vcall().  Given how
> much of an improvement this ought to be for hypercalls, I don't want to
> lose the vcalls.
> 
> One option is to implement vcall() support on ARM, but that will leave
> new architectures (RISC-V on the way) with a heavy lift to get XSM to
> compile.
> 
> Instead, what we want to do is make vcall() a common interface, falling
> back to a plain function pointer call for architectures which don't
> implement the optimisation.  So something like:
> 
> 1) Introduce CONFIG_HAS_VCALL, which is selected by X86 only right now
> 2) Introduce xen/vcall.h which uses CONFIG_HAS_VCALL to either include
> asm/vcall.h or provide the fallback implementation

A word on the suggested names: The 'v' in alternative_vcall() stands for
"returning void", as opposed to alternative_call(). It's unclear to me
what you see it stand for in the names you propose.

Jan
Daniel P. Smith June 18, 2021, 3:53 p.m. UTC | #3
On 6/18/21 6:14 AM, Andrew Cooper wrote:
> On 18/06/2021 00:39, Daniel P. Smith wrote:
>> Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
>> patch set is being split into two separate patch sets. This is the first
>> patch set and is focused purely on the clean up and refactoring of the
>> XSM hooks.
>>
>> This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
>> infrastructure. Then proceeds to move and realign the headers to remove the
>> psuedo is/is not enable implementation. The remainder of the changes are clean up
>> and removing no longer necessary abstractions.
>>
>> <snip>
>>  51 files changed, 1309 insertions(+), 1413 deletions(-)
> 
> The diffstat is great, but sadly CI says no. 
> https://gitlab.com/xen-project/patchew/xen/-/pipelines/323044913
> 
> The problem is that ARM doesn't have alternative_vcall().  Given how
> much of an improvement this ought to be for hypercalls, I don't want to
> lose the vcalls.
> 
> One option is to implement vcall() support on ARM, but that will leave
> new architectures (RISC-V on the way) with a heavy lift to get XSM to
> compile.
> 
> Instead, what we want to do is make vcall() a common interface, falling
> back to a plain function pointer call for architectures which don't
> implement the optimisation.  So something like:
> 
> 1) Introduce CONFIG_HAS_VCALL, which is selected by X86 only right now
> 2) Introduce xen/vcall.h which uses CONFIG_HAS_VCALL to either include
> asm/vcall.h or provide the fallback implementation
> 3) Switch x86's current use over to this new interface
> 
> The iommu_vcall() is a red herring, not adequately documented, and needs
> to stay in some form.  Specifically, it needs to not become an
> alternative on ARM, even if ARM gains vcalls.  I'd be tempted to rework
> it in 4) to use the common vcall() by default, and leave ARM as the
> special case overriding the default behaviour, along with an explanation
> of why it isn't a vcall().
> 
> Obviously, name subject bikeshedding.  alternative_vcall() is a bit of a
> mouthful, and I don't think that alt_vcall() loses any salient information.
> 
> Thoughts?

I can look at spinning an attempt at what you are suggesting and submitting.

v/r,
dps
Andrew Cooper June 18, 2021, 9:21 p.m. UTC | #4
On 18/06/2021 12:48, Jan Beulich wrote:
> On 18.06.2021 12:14, Andrew Cooper wrote:
>> On 18/06/2021 00:39, Daniel P. Smith wrote:
>>> Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
>>> patch set is being split into two separate patch sets. This is the first
>>> patch set and is focused purely on the clean up and refactoring of the
>>> XSM hooks.
>>>
>>> This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
>>> infrastructure. Then proceeds to move and realign the headers to remove the
>>> psuedo is/is not enable implementation. The remainder of the changes are clean up
>>> and removing no longer necessary abstractions.
>>>
>>> <snip>
>>>  51 files changed, 1309 insertions(+), 1413 deletions(-)
>> The diffstat is great, but sadly CI says no. 
>> https://gitlab.com/xen-project/patchew/xen/-/pipelines/323044913
>>
>> The problem is that ARM doesn't have alternative_vcall().  Given how
>> much of an improvement this ought to be for hypercalls, I don't want to
>> lose the vcalls.
>>
>> One option is to implement vcall() support on ARM, but that will leave
>> new architectures (RISC-V on the way) with a heavy lift to get XSM to
>> compile.
>>
>> Instead, what we want to do is make vcall() a common interface, falling
>> back to a plain function pointer call for architectures which don't
>> implement the optimisation.  So something like:
>>
>> 1) Introduce CONFIG_HAS_VCALL, which is selected by X86 only right now
>> 2) Introduce xen/vcall.h which uses CONFIG_HAS_VCALL to either include
>> asm/vcall.h or provide the fallback implementation
> A word on the suggested names: The 'v' in alternative_vcall() stands for
> "returning void", as opposed to alternative_call(). It's unclear to me
> what you see it stand for in the names you propose.

Urgh - yet another reason to prefer the Linux static_call() infrastructure.

Would a general alt_call name be acceptable?

~Andrew
Jan Beulich June 21, 2021, 6:45 a.m. UTC | #5
On 18.06.2021 23:21, Andrew Cooper wrote:
> On 18/06/2021 12:48, Jan Beulich wrote:
>> On 18.06.2021 12:14, Andrew Cooper wrote:
>>> On 18/06/2021 00:39, Daniel P. Smith wrote:
>>>> Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC
>>>> patch set is being split into two separate patch sets. This is the first
>>>> patch set and is focused purely on the clean up and refactoring of the
>>>> XSM hooks.
>>>>
>>>> This patch set refactors the xsm_ops wrapper hooks to use the alternative_call
>>>> infrastructure. Then proceeds to move and realign the headers to remove the
>>>> psuedo is/is not enable implementation. The remainder of the changes are clean up
>>>> and removing no longer necessary abstractions.
>>>>
>>>> <snip>
>>>>  51 files changed, 1309 insertions(+), 1413 deletions(-)
>>> The diffstat is great, but sadly CI says no. 
>>> https://gitlab.com/xen-project/patchew/xen/-/pipelines/323044913
>>>
>>> The problem is that ARM doesn't have alternative_vcall().  Given how
>>> much of an improvement this ought to be for hypercalls, I don't want to
>>> lose the vcalls.
>>>
>>> One option is to implement vcall() support on ARM, but that will leave
>>> new architectures (RISC-V on the way) with a heavy lift to get XSM to
>>> compile.
>>>
>>> Instead, what we want to do is make vcall() a common interface, falling
>>> back to a plain function pointer call for architectures which don't
>>> implement the optimisation.  So something like:
>>>
>>> 1) Introduce CONFIG_HAS_VCALL, which is selected by X86 only right now
>>> 2) Introduce xen/vcall.h which uses CONFIG_HAS_VCALL to either include
>>> asm/vcall.h or provide the fallback implementation
>> A word on the suggested names: The 'v' in alternative_vcall() stands for
>> "returning void", as opposed to alternative_call(). It's unclear to me
>> what you see it stand for in the names you propose.
> 
> Urgh - yet another reason to prefer the Linux static_call() infrastructure.

Which iirc wasn't there yet when I wrote ours.

> Would a general alt_call name be acceptable?

Well, it seemed a little terse to me at the time, but I'm not opposed.
There's hardly anything else the "alt" there could stand for, I guess.

Jan