mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/hvm: Improve physdev_op hypercall dispatching
hvm_physdev_op() and hvm_physdev_op_compat32() are almost identical, but there
is no need to have two functions instantiated at the end of different function
pointers.
Combine the two into a single hvm_physdev_op() and dispatch to
{do,compat}_physdev_op() based on the hcall_64bit setting.
This also fixes an inconsistency where 64bit PVH hardware domains were
permitted access to extra physdev ops, but 32bit domains weren't.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
a130a41289
commit
909c219944
1 file changed
+9
-24
@@ -73,10 +73,12 @@ static long hvm_grant_table_op(
|
||||
|
||||
static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
{
|
||||
const struct vcpu *curr = current;
|
||||
|
||||
switch ( cmd )
|
||||
{
|
||||
default:
|
||||
if ( !is_pvh_vcpu(current) || !is_hardware_domain(current->domain) )
|
||||
if ( !is_pvh_vcpu(curr) || !is_hardware_domain(curr->domain) )
|
||||
return -ENOSYS;
|
||||
/* fall through */
|
||||
case PHYSDEVOP_map_pirq:
|
||||
@@ -84,26 +86,13 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
case PHYSDEVOP_eoi:
|
||||
case PHYSDEVOP_irq_status_query:
|
||||
case PHYSDEVOP_get_free_pirq:
|
||||
return do_physdev_op(cmd, arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static long hvm_physdev_op_compat32(
|
||||
int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
{
|
||||
switch ( cmd )
|
||||
{
|
||||
case PHYSDEVOP_map_pirq:
|
||||
case PHYSDEVOP_unmap_pirq:
|
||||
case PHYSDEVOP_eoi:
|
||||
case PHYSDEVOP_irq_status_query:
|
||||
case PHYSDEVOP_get_free_pirq:
|
||||
return compat_physdev_op(cmd, arg);
|
||||
break;
|
||||
default:
|
||||
return -ENOSYS;
|
||||
break;
|
||||
}
|
||||
if ( curr->arch.hvm_vcpu.hcall_64bit )
|
||||
return do_physdev_op(cmd, arg);
|
||||
else
|
||||
return compat_physdev_op(cmd, arg);
|
||||
}
|
||||
|
||||
#define HYPERCALL(x) \
|
||||
@@ -118,15 +107,13 @@ static long hvm_physdev_op_compat32(
|
||||
[ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x, \
|
||||
(hypercall_fn_t *) compat_ ## x }
|
||||
|
||||
#define do_physdev_op hvm_physdev_op
|
||||
#define compat_physdev_op hvm_physdev_op_compat32
|
||||
#define do_arch_1 paging_domctl_continuation
|
||||
|
||||
static const hypercall_table_t hvm_hypercall_table[] = {
|
||||
HVM_CALL(memory_op),
|
||||
HVM_CALL(grant_table_op),
|
||||
COMPAT_CALL(vcpu_op),
|
||||
COMPAT_CALL(physdev_op),
|
||||
HVM_CALL(physdev_op),
|
||||
COMPAT_CALL(xen_version),
|
||||
HYPERCALL(console_io),
|
||||
HYPERCALL(event_channel_op),
|
||||
@@ -146,8 +133,6 @@ static const hypercall_table_t hvm_hypercall_table[] = {
|
||||
HYPERCALL(arch_1)
|
||||
};
|
||||
|
||||
#undef do_physdev_op
|
||||
#undef compat_physdev_op
|
||||
#undef do_arch_1
|
||||
|
||||
#undef HYPERCALL
|
||||
|
||||