linux/include/xen/hvm.h
Jane Malalane b1c3497e60 x86/xen: Add support for HVMOP_set_evtchn_upcall_vector
Implement support for the HVMOP_set_evtchn_upcall_vector hypercall in
order to set the per-vCPU event channel vector callback on Linux and
use it in preference of HVM_PARAM_CALLBACK_IRQ.

If the per-VCPU vector setup is successful on BSP, use this method
for the APs. If not, fallback to the global vector-type callback.

Also register callback_irq at per-vCPU event channel setup to trick
toolstack to think the domain is enlightened.

Suggested-by: "Roger Pau Monné" <roger.pau@citrix.com>
Signed-off-by: Jane Malalane <jane.malalane@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20220729070416.23306-1-jane.malalane@citrix.com
Signed-off-by: Juergen Gross <jgross@suse.com>
2022-08-12 11:28:21 +02:00

66 lines
1.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/* Simple wrappers around HVM functions */
#ifndef XEN_HVM_H__
#define XEN_HVM_H__
#include <xen/interface/hvm/params.h>
#include <asm/xen/hypercall.h>
static const char *param_name(int op)
{
#define PARAM(x) [HVM_PARAM_##x] = #x
static const char *const names[] = {
PARAM(CALLBACK_IRQ),
PARAM(STORE_PFN),
PARAM(STORE_EVTCHN),
PARAM(PAE_ENABLED),
PARAM(IOREQ_PFN),
PARAM(BUFIOREQ_PFN),
PARAM(TIMER_MODE),
PARAM(HPET_ENABLED),
PARAM(IDENT_PT),
PARAM(DM_DOMAIN),
PARAM(ACPI_S_STATE),
PARAM(VM86_TSS),
PARAM(VPT_ALIGN),
PARAM(CONSOLE_PFN),
PARAM(CONSOLE_EVTCHN),
};
#undef PARAM
if (op >= ARRAY_SIZE(names))
return "unknown";
if (!names[op])
return "reserved";
return names[op];
}
static inline int hvm_get_parameter(int idx, uint64_t *value)
{
struct xen_hvm_param xhv;
int r;
xhv.domid = DOMID_SELF;
xhv.index = idx;
r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
if (r < 0) {
pr_err("Cannot get hvm parameter %s (%d): %d!\n",
param_name(idx), idx, r);
return r;
}
*value = xhv.value;
return r;
}
#define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2
#define HVM_CALLBACK_VIA_TYPE_SHIFT 56
#define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\
HVM_CALLBACK_VIA_TYPE_SHIFT | (x))
void xen_setup_callback_vector(void);
int xen_set_upcall_vector(unsigned int cpu);
#endif /* XEN_HVM_H__ */