summaryrefslogtreecommitdiff
path: root/xen/include/xsm
AgeCommit message (Collapse)Author
2021-09-16xsm: convert xsm_ops hook calls to alternative callDaniel P. Smith
To reduce retpolines convert all the pointer function calls of the xsm_ops hooks over to the alternative_call infrastructure. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2021-09-16xsm: refactor xsm_ops handlingDaniel P. Smith
This renames the `struct xsm_operations` to the shorter `struct xsm_ops` and converts the global xsm_ops from being a pointer to an explicit instance. As part of this conversion, it reworks the XSM modules init function to return their xsm_ops struct which is copied in to the global xsm_ops instance. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2021-09-16xsm: apply coding styleDaniel P. Smith
Instead of intermixing coding style changes with code changes as they are come upon in this patch set, moving all coding style changes into a single commit. The focus of coding style changes here are, - move trailing comments to line above - ensuring line length does not exceed 80 chars - ensuring proper indentation for 80 char wrapping - covert u32 type statements to uint32_t - remove space between closing and opening parens - drop extern on function declarations Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2021-09-10xsm: drop dubious xsm_op_t typeDaniel P. Smith
The type xsm_op_t masks the use of void pointers. This commit drops the xsm_op_t type and replaces it and all its uses with an explicit void. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2021-09-10xsm: remove remnants of xsm_memtype hookDaniel P. Smith
In c/s fcb8baddf00e the xsm_memtype hook was removed but some remnants were left behind. This commit cleans up those remnants. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2021-05-03x86: make mem-paging configurable and default it to offJan Beulich
... for being unsupported. While doing so, make the option dependent upon HVM, which really is the main purpose of the change. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Alexandru Isaila <aisaila@bitdefender.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2021-04-09xen/xsm: Improve alloc/free of evtchn bucketsAndrew Cooper
Currently, flask_alloc_security_evtchn() is called in loops of 64 (EVTCHNS_PER_BUCKET), which for non-dummy implementations is a function pointer call even in the no-op case. The non no-op case only sets a single constant, and doesn't actually fail. Spectre v2 protections has made function pointer calls far more expensive, and 64 back-to-back calls is a waste. Rework the APIs to pass the size of the bucket instead, and call them once. No practical change, but {alloc,free}_evtchn_bucket() should be rather more efficient now. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
2021-01-29xen/ioreq: Make x86's IOREQ related dm-op handling commonJulien Grall
As a lot of x86 code can be re-used on Arm later on, this patch moves the IOREQ related dm-op handling to the common code. The idea is to have the top level dm-op handling arch-specific and call into ioreq_server_dm_op() for otherwise unhandled ops. Pros: - More natural than doing it other way around (top level dm-op handling common). - Leave compat_dm_op() in x86 code. Cons: - Code duplication. Both arches have to duplicate dm_op(), etc. Make the corresponding functions static and rename them according to the new naming scheme (including dropping the "hvm" prefixes). Introduce common dm.c file as a resting place for the do_dm_op() (which is identical for both Arm and x86) to minimize code duplication. The common DM feature is supposed to be built with IOREQ_SERVER option enabled (as well as the IOREQ feature), which is selected for x86's config HVM for now. Also update XSM code a bit to let dm-op be used on Arm. This support is going to be used on Arm to be able run device emulator outside of Xen hypervisor. Signed-off-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Acked-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Paul Durrant <paul@xen.org> [On Arm only] Tested-by: Wei Chen <Wei.Chen@arm.com>
2021-01-07xsm/dummy: harden against speculative abuseJan Beulich
First of all don't open-code is_control_domain(), which is already suitably using evaluate_nospec(). Then also apply this construct to the other paths of xsm_default_action(). Also guard two paths not using this function. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Wei Liu <wl@xen.org>
2020-11-10xen/evtchn: revert 52e1fc47abc3a0123Juergen Gross
With the event channel lock no longer disabling interrupts commit 52e1fc47abc3a0123 ("evtchn/Flask: pre-allocate node on send path") can be reverted again. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2020-10-06xen/xsm: Drop xsm_hvm_param_nested()Andrew Cooper
The sole caller has been removed. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Wei Liu <wl@xen.org>
2020-10-02evtchn/Flask: pre-allocate node on send pathJan Beulich
xmalloc() & Co may not be called with IRQs off, or else check_lock() will have its assertion trigger about locks getting acquired inconsistently. Re-arranging the locking in evtchn_send() doesn't seem very reasonable, especially since the per-channel lock was introduced to avoid acquiring the per-domain event lock on the send paths. Issue a second call to xsm_evtchn_send() instead, before acquiring the lock, to give XSM / Flask a chance to pre-allocate whatever it may need. As these nodes are used merely for caching earlier decisions' results, allocate just one node in AVC code despite two potentially being needed. Things will merely be not as performant if a second allocation was wanted, just like when the pre-allocation fails. Fixes: c0ddc8634845 ("evtchn: convert per-channel lock to be IRQ-safe") Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Jason Andryuk <jandryuk@gmail.com> Acked-by: Julien Grall <jgrall@amazon.com> Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
2020-05-29xen: add basic hypervisor filesystem supportJuergen Gross
Add the infrastructure for the hypervisor filesystem. This includes the hypercall interface and the base functions for entry creation, deletion and modification. In order not to have to repeat the same pattern multiple times in case adding a new node should BUG_ON() failure, the helpers for adding a node (hypfs_add_dir() and hypfs_add_leaf()) get a nofault parameter causing the BUG() in case of a failure. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Julien Grall <jgrall@amazon.com>
2020-03-17x86/HVM: reduce domain.h include dependenciesJan Beulich
Drop #include-s not needed by the header itself. Put the ones needed into whichever other files actually need them. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Paul Durrant <paul@xen.org> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2019-08-23domain: remove the 'is_xenstore' flagPaul Durrant
This patch introduces a convenience macro, is_xenstore_domain(), which tests the domain 'options' directly and then uses that in place of the 'is_xenstore' flag. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: "Roger Pau Monné" <roger.pau@citrix.com> Acked-by: George Dunlap <George.Dunlap@eu.citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2019-07-19x86/mem_sharing: compile mem_sharing subsystem only when kconfig is enabledTamas K Lengyel
Disable it by default as it is only an experimental subsystem. Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2019-06-14xen/arm: Turn on SILO mode by default on ArmJulien Grall
On Arm, exclusive load-store atomics should only be used between trusted thread. As not all the guests are trusted, it may be possible to DoS Xen when updating shared memory with guest atomically. Recent patches introduced new helpers to update shared memory with guest atomically. Those helpers relies on a memory region to be be shared with Xen and a single guest. At the moment, nothing prevent a guest sharing a page with Xen and as well with another guest (e.g via grant table). For the scope of the XSA, the quickest way is to deny communications between unprivileged guest. So this patch is enabling and using SILO mode by default on Arm. Users wanted finer graine policy could wrote their own Flask policy. This is part of XSA-295. Signed-off-by: Julien Grall <julien.grall@arm.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2019-05-13xen: remove tmem from hypervisorWei Liu
This patch removes all tmem related code and CONFIG_TMEM from the hypervisor. Also remove tmem hypercalls from the default XSM policy. It is written as if tmem is disabled and tmem freeable pages is 0. We will need to keep public/tmem.h around forever to avoid breaking guests. Remove the hypervisor only part and put guest visible part under a xen version check. Take the chance to remove trailing whitespaces. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2019-02-07xsm, argo: XSM control for any access to argo by a domainChristopher Clark
Will inhibit initialization of the domain's argo data structure to prevent receiving any messages or notifications and access to any of the argo hypercall operations. Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Tested-by: Chris Patterson <pattersonc@ainfosec.com> Release-acked-by: Juergen Gross <jgross@suse.com>
2019-02-07xsm, argo: XSM control for argo message send operationChristopher Clark
Default policy: allow. Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Tested-by: Chris Patterson <pattersonc@ainfosec.com> Release-acked-by: Juergen Gross <jgross@suse.com>
2019-02-07xsm, argo: XSM control for argo registerChristopher Clark
XSM controls for argo ring registration with two distinct cases, where the ring being registered is: 1) Single source: registering a ring for communication to receive messages from a specified single other domain. Default policy: allow. 2) Any source: registering a ring for communication to receive messages from any, or all, other domains (ie. wildcard). Default policy: deny, with runtime policy configuration via bootparam. This commit modifies the signature of core XSM hook functions in order to apply 'const' to arguments, needed in order for 'const' to be accepted in signature of functions that invoke them. Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Tested-by: Chris Patterson <pattersonc@ainfosec.com> Release-acked-by: Juergen Gross <jgross@suse.com>
2018-11-14xen: allow console_io hypercalls from certain DomUsStefano Stabellini
Introduce an is_console option to allow certain classes of domUs to use the Xen console. Specifically, it will be used to give console access to all domUs started from Xen from information on device tree. Signed-off-by: Stefano Stabellini <stefanos@xilinx.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Jan Beulich <jbeulich@suse.com> CC: andrew.cooper3@citrix.com CC: George.Dunlap@eu.citrix.com CC: ian.jackson@eu.citrix.com CC: jbeulich@suse.com CC: konrad.wilk@oracle.com CC: tim@xen.org CC: wei.liu2@citrix.com CC: dgdegra@tycho.nsa.gov
2018-10-15xen/xsm: Add new SILO mode for XSMXin Li
When SILO is enabled, there would be no page-sharing or event notifications between unprivileged VMs (no grant tables or event channels). Signed-off-by: Xin Li <xin.li@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-08-28xen/xsm: Rename CONFIG_XSM_POLICY to CONFIG_XSM_FLASK_POLICYAndrew Cooper
The embedded policy is specifically a flask policy, so update the infrastructure to reflect this. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Doug Goldstein <cardoe@cardoe.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2018-08-28xen/xsm: Rename CONFIG_FLASK_* to CONFIG_XSM_FLASK_*Andrew Cooper
Flask is one single XSM module, and another is about to be introduced. Properly namespace the symbols for clarity. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Doug Goldstein <cardoe@cardoe.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2018-08-02Make MEM_ACCESS configurableStefano Stabellini
Select MEM_ACCESS_ALWAYS_ON on x86 to mark that MEM_ACCESS is not configurable on x86. Avoid selecting it on ARM. Rename HAS_MEM_ACCESS to MEM_ACCESS everywhere. Add a prompt and a description to MEM_ACCESS in xen/common/Kconfig. The result is that the user-visible option is MEM_ACCESS, and it is configurable only on ARM (disabled by default). At the moment the arch-specific mem_access code remains enabled on ARM, even with MEM_ACCESS=y. The purpose is to reduce code size. The option doesn't depend on EXPERT because it would be nice to ecurity-support configurations without MEM_ACCESS and a non-expert should be able to disable it. Suggested-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Julien Grall <julien.grall@arm.com> CC: dgdegra@tycho.nsa.gov CC: andrew.cooper3@citrix.com CC: George.Dunlap@eu.citrix.com CC: ian.jackson@eu.citrix.com CC: jbeulich@suse.com CC: julien.grall@arm.com CC: konrad.wilk@oracle.com CC: sstabellini@kernel.org CC: tim@xen.org CC: wei.liu2@citrix.com --- Changes in v5: - change MEM_ACCESS_ALWAYS_ON to bool - change default for MEM_ACCESS, default y if MEM_ACCESS_ALWAYS_ON Changes in v4: - remove HAS_MEM_ACCESS - move MEM_ACCESS_ALWAYS_ON to common - combile default and bool to def_bool Changes in v3: - keep HAS_MEM_ACCESS to mark that an arch can do MEM_ACCESS - introduce MEM_ACCESS_ALWAYS_ON - the main MEM_ACCESS option is in xen/common/Kconfig Changes in v2: - patch added
2018-04-03x86/mm: add HYPERVISOR_memory_op to acquire guest resourcesPaul Durrant
Certain memory resources associated with a guest are not necessarily present in the guest P2M. This patch adds the boilerplate for new memory op to allow such a resource to be priv-mapped directly, by either a PV or HVM tools domain. NOTE: Whilst the new op is not intrinsically specific to the x86 architecture, I have no means to test it on an ARM platform and so cannot verify that it functions correctly. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Julien Grall <julien.grall@arm.com>
2018-02-13xsm: add bodge when compiling with llvm coverage supportRoger Pau Monné
llvm coverage support seems to disable some of the optimizations needed in order to compile xsm, and the end result is that references to __xsm_action_mismatch_detected are left in the object files. Since coverage support cannot be used in production, introduce __xsm_action_mismatch_detected for llvm coverage builds. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2018-01-11x86/xsm: Use the exported bootstrap_map() functionAndrew Cooper
... rather than obtaining it via function pointer. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2017-12-05XSM/flask: constification of IRQ mapping interfacesJan Beulich
This clarifies that the involved structures are read-only. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2017-10-12x86: enforce proper privilege when (un)mapping pIRQ-sJan Beulich
(Un)mapping of IRQs, just like other RESOURCE__ADD* / RESOURCE__REMOVE* actions (in FLASK terms) should be XSM_DM_PRIV rather than XSM_TARGET. This in turn requires bypassing the XSM check in physdev_unmap_pirq() for the HVM emuirq case just like is being done in physdev_map_pirq(). The primary goal security wise, however, is to no longer allow HVM guests, by specifying their own domain ID instead of DOMID_SELF, to enter code paths intended for PV guest and the control domains of HVM guests only. This is part of XSA-237. Reported-by: HW42 <hw42@ipsumj.de> Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: George Dunlap <george.dunlap@citrix.com>
2017-08-28passthrough: give XEN_DOMCTL_test_assign_device more sane semanticsJan Beulich
So far callers of the libxc interface passed in a domain ID which was then ignored in the hypervisor. Instead, make the hypervisor honor it (accepting DOMID_INVALID to obtain original behavior), allowing to query whether a device can be assigned to a particular domain. Do this by folding the assign and test-assign paths. Drop XSM's test_assign_{,dt}device hooks as no longer being individually useful. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
2017-04-10xsm: fix clang 3.5 build after c47d1dRoger Pau Monné
The changes introduced on c47d1d broke the clang build due to undefined references to __xsm_action_mismatch_detected, because clang hasn't optimized the code properly. The following patch allows the clang build to work again, while keeping the same functionality. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2017-04-07altp2m: introduce external-only and limited use-casesTamas K Lengyel
Currently setting altp2mhvm=1 in the domain configuration allows access to the altp2m interface for both in-guest and external privileged tools. This poses a problem for use-cases where only external access should be allowed, requiring the user to compile Xen with XSM enabled to be able to appropriately restrict access. In this patch we deprecate the altp2mhvm domain configuration option and introduce the altp2m option, which allows specifying if by default the altp2m interface should be external-only or limited. The information is stored in HVM_PARAM_ALTP2M which we now define with specific XEN_ALTP2M_* modes. If external mode is selected, the XSM check is shifted to use XSM_DM_PRIV type check, thus restricting access to the interface by the guest itself. Note that we keep the default XSM policy untouched. Users of XSM who wish to enforce external mode for altp2m can do so by adjusting their XSM policy directly, as this domain config option does not override an active XSM policy. Also, as part of this patch we adjust the hvmop handler to require HVM_PARAM_ALTP2M to be of a type other then disabled for all ops. This has been previously only required for get/set altp2m domain state, all other options were gated on altp2m_enabled. Since altp2m_enabled only gets set during set altp2m domain state, this change introduces no new requirements to the other ops but makes it more clear that it is required for all ops. Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com> Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Jan Beulich <jbeulich@suse.com>
2017-03-14build/clang: fix XSM dummy policy when using clang 4.0Roger Pau Monné
There seems to be some weird bug in clang 4.0 that prevents xsm_pmu_op from working as expected, and vpmu.o ends up with a reference to __xsm_action_mismatch_detected which makes the build fail: [...] ld -melf_x86_64_fbsd -T xen.lds -N prelink.o \ xen/common/symbols-dummy.o -o xen/.xen-syms.0 prelink.o: In function `xsm_default_action': xen/include/xsm/dummy.h:80: undefined reference to `__xsm_action_mismatch_detected' xen/xen/include/xsm/dummy.h:80: relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__xsm_action_mismatch_detected' ld: xen/xen/.xen-syms.0: hidden symbol `__xsm_action_mismatch_detected' isn't defined Then doing a search in the objects files: # find xen/ -type f -name '*.o' -print0 | xargs -0 bash -c \ 'for filename; do nm "$filename" | \ grep -q __xsm_action_mismatch_detected && echo "$filename"; done' bash xen/arch/x86/prelink.o xen/arch/x86/cpu/vpmu.o xen/arch/x86/cpu/built_in.o xen/arch/x86/built_in.o The current patch is the only way I've found to fix this so far, by simply moving the XSM_PRIV check into the default case in xsm_pmu_op. This also fixes the behavior of do_xenpmu_op, which will now return -EINVAL for unknown XENPMU_* operations, instead of -EPERM when called by a privileged domain. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2017-01-25dm_op: convert HVMOP_inject_trap and HVMOP_inject_msiPaul Durrant
NOTE: This patch also modifies the types of the 'vector', 'type' and 'insn_len' arguments of xc_hvm_inject_trap() from uint32_t to uint8_t. In practice the values passed were always truncated to 8 bits. Suggested-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-01-25dm_op: convert HVMOP_set_pci_intx_level, HVMOP_set_isa_irq_level, and...Paul Durrant
... HVMOP_set_pci_link_route These HVMOPs were exposed to guests so their definitions need to be preserved for compatibility. This patch therefore updates __XEN_LATEST_INTERFACE_VERSION__ to 0x00040900 and makes the HVMOP defintions conditional on __XEN_INTERFACE_VERSION__ less than that value. NOTE: This patch also widens the 'domain' parameter of xc_hvm_set_pci_intx_level() from a uint8_t to a uint16_t. Suggested-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-01-25dm_op: convert HVMOP_*ioreq_server*Paul Durrant
The definitions of HVM_IOREQSRV_BUFIOREQ_* have to persist as they are already in use by callers of the libxc interface. Suggested-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-01-25public / x86: introduce __HYPERCALL_dm_op...Paul Durrant
...as a set of hypercalls to be used by a device model. As stated in the new docs/designs/dm_op.markdown: "The aim of DMOP is to prevent a compromised device model from compromising domains other then the one it is associated with. (And is therefore likely already compromised)." See that file for further information. This patch simply adds the boilerplate for the hypercall. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Suggested-by: Ian Jackson <ian.jackson@citrix.com> Suggested-by: Jennifer Herbert <jennifer.herbert@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
2016-08-17domctl: relax getdomaininfo permissionsJan Beulich
Qemu needs access to this for the domain it controls, both due to it being used by xc_domain_memory_mapping() (which qemu calls) and the explicit use in hw/xenpv/xen_domainbuild.c:xen_domain_poll(). Extend permissions to that of any "ordinary" domctl: A domain controlling the targeted domain can invoke this operation for that target domain (which is being achieved by no longer passing NULL to xsm_domctl()). This at once avoids a for_each_domain() loop when the ID of an existing domain gets passed in. Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2016-07-14xsm: add a default policy to .init.dataDaniel De Graaf
This adds a Kconfig option and support for including the XSM policy from tools/flask/policy in the hypervisor so that the bootloader does not need to provide a policy to get sane behavior from an XSM-enabled hypervisor. The policy provided by the bootloader, if present, will override the built-in policy. The XSM policy is not moved out of tools because that remains the primary location for installing and configuring the policy. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-07-14xsm: rework policy_buffer globalsDaniel De Graaf
This makes the buffers function parameters instead of globals, in preparation for adding alternate locations for the policy. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-06-24xsm: clean up unregistrationDaniel De Graaf
The only possible value of original_ops was &dummy_xsm_ops, and unregister_xsm was never used. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
2016-06-21xen/xsm: remove .xsm_initcall.init sectionDaniel De Graaf
Since FLASK is the only implementation of XSM hooks in Xen, using an iterated initcall dispatch for setup is overly complex. Change this to a direct function call to a globally visible function; if additional XSM hooks are added in the future, a switching mechanism will be needed regardless, and that can be placed in xsm_core.c. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Doug Goldstein <cardoe@cardoe.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Julien Grall <julien.grall@arm.com>
2016-06-08build: convert verbose to KconfigDoug Goldstein
Convert 'verbose', which was enabled by 'debug=y' to Kconfig as CONFIG_VERBOSE_DEBUG which is enabled by default when CONFIG_DEBUG is enabled. Signed-off-by: Doug Goldstein <cardoe@cardoe.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Julien Grall <julien.grall@arm.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2016-04-26Revert "HYPERCALL_version_op. New hypercall mirroring XENVER_ but sane."Konrad Rzeszutek Wilk
This reverts commit 2716d875379d538c1dfccad78a99ca7db2e09f90. As it was decided that the existing XENVER hypercall - while having grown organically over the years can still be expanded. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Requested-and-acked-by: Jan Beulich <jbeulich@suse.com>
2016-04-08xen/arm64: check XSM Magic from the second unknown module.Fu Wei
This patch adds a has_xsm_magic helper function for detecting XSM from the second unknown module. If Xen can't get the kind of module from compatible, we guess the kind of these unknowns respectively: (1) The first unknown must be kernel. (2) Detect the XSM Magic from the 2nd unknown: a. If it's XSM, set the kind as XSM, and that also means we won't load ramdisk; b. if it's not XSM, set the kind as ramdisk. So if user want to load ramdisk, it must be the 2nd unknown. We also detect the XSM Magic for the following unknowns, then set its kind according to the return value of has_xsm_magic. By this way, arm64 behavior can be compatible to x86 and can simplify multi-arch bootloader such as GRUB. Signed-off-by: Fu Wei <fu.wei@linaro.org> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Julien Grall <julien.grall@arm.com>
2016-03-30HYPERCALL_version_op. New hypercall mirroring XENVER_ but sane.Konrad Rzeszutek Wilk
This hypercall mirrors the XENVER_ in that it has similar functionality. However it is designed differently: - No compat layer. The data structures are the same size on 32 as on 64-bit. - The hypercall accepts three arguments - the command, pointer to an buffer, and the length of the buffer. - Each sub-ops can be "probed" for size by returning the size of buffer that will be needed - if the buffer is NULL. - Subops can complete even if the buffer is too small - truncated data will be filled and hypercall will return -ENOBUFS. - VERSION_commandline, VERSION_changeset are privileged. - There is no XENVER_compile_info equivalent. - The hypercall can return -EPERM and toolstack/OSes are expected to deal with. However there are three subops: XEN_VERSION_version, XEN_VERSION_platform_parameters and XEN_VERSION_get_features that will always return an value as guests cannot survive without them. While we combine some of the common code between XENVER_ and VERSION_ take the liberty of moving pae_extended_cr3 in x86 area. Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> [XSM bits] Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
2016-03-25xsm: only define XSM_MAGIC in xsm.hDoug Goldstein
Rather than have XSM_MAGIC set in the global xen/config.h and set in xsm.h if it's unset, just set it once in xsm.h since its only used in files that already include xsm.h Signed-off-by: Doug Goldstein <cardoe@cardoe.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2016-03-22xsm/xen_version: Add XSM for most of xen_version hypercallKonrad Rzeszutek Wilk
Most of XENVER_* have now an XSM check for their sub-ops. The subop for XENVER_commandline is now a priviliged operation. To not break guests we still return an string - but it is just '<denied>\0'. The XENVER_[version|platform_parameters|get_features] - will always return an value to the guest. The rest: XENVER_[extraversion|capabilities|page_size| guest_handle|changeset| compile_info] behave as before - allowed by default for all guests if using the XSM default policy or with the dummy one. And if the system admin wants to curtail access to some of them - they can do that now with a non-default XSM policy. Also we add a local variable block. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> --- Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> v2: Do XSM check for all the XENVER_ ops. - Add empty data conditions. - Return <denied> for priv subops. - Move extraversion from priv to normal. Drop the XSM check for the non-priv subops. v3: - Add +1 for strlen(xen_deny()) to include NULL. Move changeset, compile_info to non-priv subops. - Remove the \0 on xen_deny() - Add new XSM domain for xenver hypercall. Add all subops to it. - Remove the extra line, Add Ack from Daniel v4: - Rename the XSM from xen_version_op to xsm_xen_version. Prefix the types with 'xen' to distinguish it from another hypercall performing similar operation. Removed Ack from Daniel as it was so large. Add local variable block. v5: - Make XENVER_platform_parameters,get_features,version be excluded from the XSM check per Jans' review. Add BUILD_BUG_CHECK and fix odd line removals. Remove stray changes and fix spelling.